[
https://issues.apache.org/jira/browse/WW-5101?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Greg Huber updated WW-5101:
---------------------------
Description:
Testing on java 11 AbstractLocalizedTextProvider outputs
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by
com.opensymphony.xwork2.util.AbstractLocalizedTextProvider
(
[file:struts2-core-2.5.26.jar|file:///struts2-core-2.5.26.jar]
) to field java.util.ResourceBundle.cacheList
WARNING: Please consider reporting this to the maintainers of
com.opensymphony.xwork2.util.AbstractLocalizedTextProvider
WARNING: Use --illegal-access=warn to enable warnings of further illegal
reflective access operations
WARNING: All illegal access operations will be denied in a future release
{code:java}
clearMap(ResourceBundle.class, null, "cacheList");
private void clearMap(Class cl, Object obj, String name) throws
NoSuchFieldException, IllegalAccessException,
NoSuchMethodException, InvocationTargetException{
Field field = cl.getDeclaredField(name);
field.setAccessible(true);
Object cache = field.get(obj);
synchronized (cache) {
Class ccl = cache.getClass();
Method clearMethod = ccl.getMethod("clear");
clearMethod.invoke(cache);
}
}
{code}
When it executes the linefield.setAccessible(true); produces the warning.
Seems we might be able to replace
{code:java}
try{
clearMap(ResourceBundle.class, null, "cacheList"); }
catch (NoSuchFieldException e) {
// happens in IBM JVM, that has a different ResourceBundle impl it has a
'cache' member
clearMap(ResourceBundle.class, null, "cache");
}{code}
ResourceBundle.clearCache();
Tomcat also uses the same method to flush
{color:#000000}resourceEntries{color}. Tomcat checks
org.apache.catalina.loader.WebappClassLoader but for version #9 is loading
org.apache.catalina.loader.ParallelWebappClassLoader, so defaults
clearMap(cl.getSuperclass(), loader, TOMCAT_RESOURCE_ENTRIES_FIELD);
Commenting out the tocat reload, the bundles seem to reload ok. Maybe drop
this going forward
was:
Testing on java 11 AbstractLocalizedTextProvider outputs
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by
com.opensymphony.xwork2.util.AbstractLocalizedTextProvider
(
[file:struts2-core-2.5.26.jar|file:///struts2-core-2.5.26.jar]
) to field java.util.ResourceBundle.cacheList
WARNING: Please consider reporting this to the maintainers of
com.opensymphony.xwork2.util.AbstractLocalizedTextProvider
WARNING: Use --illegal-access=warn to enable warnings of further illegal
reflective access operations
WARNING: All illegal access operations will be denied in a future release
{code:java}
clearMap(ResourceBundle.class, null, "cacheList");
private void clearMap(Class cl, Object obj, String name)
throws NoSuchFieldException, IllegalAccessException,
NoSuchMethodException, InvocationTargetException
{ Field field = cl.getDeclaredField(name); field.setAccessible(true); Object
cache = field.get(obj); synchronized (cache) \\{ Class ccl = cache.getClass();
Method clearMethod = ccl.getMethod("clear"); clearMethod.invoke(cache); }
}
{code}
When it executes the linefield.setAccessible(true); produces the warning.
Seems we might be able to replace
{code:java}
try{
clearMap(ResourceBundle.class, null, "cacheList"); }
catch (NoSuchFieldException e) {
// happens in IBM JVM, that has a different ResourceBundle impl it has a
'cache' member
clearMap(ResourceBundle.class, null, "cache");
}{code}
ResourceBundle.clearCache();
Tomcat also uses the same method to flush
{color:#000000}resourceEntries{color}. Tomcat checks
org.apache.catalina.loader.WebappClassLoader but for version #9 is loading
org.apache.catalina.loader.ParallelWebappClassLoader, so defaults
clearMap(cl.getSuperclass(), loader, TOMCAT_RESOURCE_ENTRIES_FIELD);
Commenting out the tocat reload, the bundles seem to reload ok. Maybe drop
this going forward
> AbstractLocalizedTextProvider illegal reflective access operation has occurred
> ------------------------------------------------------------------------------
>
> Key: WW-5101
> URL: https://issues.apache.org/jira/browse/WW-5101
> Project: Struts 2
> Issue Type: New Feature
> Components: Core
> Affects Versions: 2.5.26
> Reporter: Greg Huber
> Priority: Minor
>
> Testing on java 11 AbstractLocalizedTextProvider outputs
> WARNING: An illegal reflective access operation has occurred
> WARNING: Illegal reflective access by
> com.opensymphony.xwork2.util.AbstractLocalizedTextProvider
> (
> [file:struts2-core-2.5.26.jar|file:///struts2-core-2.5.26.jar]
> ) to field java.util.ResourceBundle.cacheList
> WARNING: Please consider reporting this to the maintainers of
> com.opensymphony.xwork2.util.AbstractLocalizedTextProvider
> WARNING: Use --illegal-access=warn to enable warnings of further illegal
> reflective access operations
> WARNING: All illegal access operations will be denied in a future release
> {code:java}
> clearMap(ResourceBundle.class, null, "cacheList");
> private void clearMap(Class cl, Object obj, String name) throws
> NoSuchFieldException, IllegalAccessException,
> NoSuchMethodException, InvocationTargetException{
> Field field = cl.getDeclaredField(name);
> field.setAccessible(true);
> Object cache = field.get(obj);
> synchronized (cache) {
> Class ccl = cache.getClass();
> Method clearMethod = ccl.getMethod("clear");
> clearMethod.invoke(cache);
> }
> }
> {code}
> When it executes the linefield.setAccessible(true); produces the warning.
> Seems we might be able to replace
> {code:java}
> try{
> clearMap(ResourceBundle.class, null, "cacheList"); }
> catch (NoSuchFieldException e) {
> // happens in IBM JVM, that has a different ResourceBundle impl it has a
> 'cache' member
> clearMap(ResourceBundle.class, null, "cache");
> }{code}
>
> ResourceBundle.clearCache();
> Tomcat also uses the same method to flush
> {color:#000000}resourceEntries{color}. Tomcat checks
> org.apache.catalina.loader.WebappClassLoader but for version #9 is loading
> org.apache.catalina.loader.ParallelWebappClassLoader, so defaults
> clearMap(cl.getSuperclass(), loader, TOMCAT_RESOURCE_ENTRIES_FIELD);
> Commenting out the tocat reload, the bundles seem to reload ok. Maybe drop
> this going forward
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)