java 11 compatibility: handle a new exception if a field is inaccessible#59
java 11 compatibility: handle a new exception if a field is inaccessible#59sda399 wants to merge 5 commits intoehcache:masterfrom
Conversation
sda399
commented
Sep 20, 2019
- setAccessible function now throws a new exception
- catch the new exception class that appeared in java9+ only
- setAccessible function now throws a new exception - catch the new exception class that appeared in java9+ only
|
Hi all, |
|
@chrisdennis would it be possible to merge this please? The library doesn't really work well with java 11 without this change and as far as i can tell all the issues have been fixed. I'd be more than happy to assist if any more changes are required |
| } catch (RuntimeException e) { | ||
| // new class (jdk9+ only) can be thrown | ||
| if ("java.lang.reflect.InaccessibleObjectException".equals(e.getClass().getName())) { | ||
| LOG.error("JPMS blocks field access. This prevents Ehcache from accessing " |
There was a problem hiding this comment.
This should probably be just a warning. Because it might occur a lot and there's nothing we can do about it.
| LOG.error("Security settings prevent Ehcache from accessing the subgraph beneath '{}'" + | ||
| " - cache sizes may be underestimated as a result", field, e); | ||
| continue; | ||
| } catch (RuntimeException e) { |
There was a problem hiding this comment.
Right now this is swallowing thrown RuntimeException instances without logging anything and then adding an inaccessible field to the collection. I think it's going to be simpler (and cleaner) to just:
} catch (RuntimeException e) {
LOG.warn("The JVM is preventing Ehcache from accessing the subgraph beneath '{}'" +
" - cache sizes may be underestimated as a result", field, e);
}|
Unfortunately i do not have access to the original for had to re-fork and re-raise the pr, available here #61 |
|
Replaced with #61 |