[Geoserver-devel] JDK11: run build with illegal reflective access checks, here is a report

Hi,
I’ve enabled emitting warning for all illegal access (committed and pushed) and then grepped in the sources.
Here is what I have. (sidenote, I did the same in GWC, but got no warnings)

1) Protobuf

WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/home/aaime/.m2/repository/com/google/protobuf/protobuf-java/3.5.0/protobuf-java-3.5.0.jar) to field java.nio.Buffer.address
WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/home/aaime/.m2/repository/com/google/protobuf/protobuf-java/3.6.1/protobuf-java-3.6.1.jar) to field java.lang.String.value
WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/home/aaime/.m2/repository/com/google/protobuf/protobuf-java/3.6.1/protobuf-java-3.6.1.jar) to field java.nio.Buffer.address

We need to align the protobuf version for sure, for the reset same diagnosis as in GeoTools. Task created to at least align the various protobuf versions.

2) iText

WARNING: Illegal reflective access by com.lowagie.text.pdf.MappedRandomAccessFile$1 (file:/home/aaime/.m2/repository/com/lowagie/itext/2.1.5/itext-2.1.5.jar) to method java.nio.DirectByteBuffer.cleaner()

And again our cleaner friend (third time it pops up).
This one is a problem that we might just have to put up with, the iText version we’re using is the latest open source available (there is a 2.1.7 one, but was released in 2009),
after it iText switched to AGPL, which is incompatible with GeoServer GPL (would make everything AGPL, we cannot have that).
We can look at alternatives (PDFBox, but I did not find a Graphics2D implementation that emits PDF), or given it’s just one case, if
there is a replacement for the cleaner available (have to check) we migth as well fork itext and change that one bit in its code…
Task created to look into it.

3) JAXB

WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/home/aaime/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.0/jaxb-runtime-2.3.0.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte,int,int)
WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/home/aaime/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.0/jaxb-runtime-2.3.0.jar) to method java.lang.ClassLoader.findLoadedClass(java.lang.String)
WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/home/aaime/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.0/jaxb-runtime-2.3.0.jar) to method java.lang.ClassLoader.resolveClass(java.lang.Class)

Same as in GeoTools, did not open a new task, this needs upgrade to a version of the library that is not released yet.

4) XStream

WARNING: Illegal reflective access by com.thoughtworks.xstream.converters.collections.TreeMapConverter (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.3/xstream-1.4.3.jar) to field java.util.TreeMap.comparator
WARNING: Illegal reflective access by com.thoughtworks.xstream.converters.reflection.AbstractAttributedCharacterIteratorAttributeConverter (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to method java.text.AttributedCharacterIterator$Attribute.getName()
WARNING: Illegal reflective access by com.thoughtworks.xstream.converters.reflection.FieldDictionary (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.lang.reflect.Proxy.constructorParams
WARNING: Illegal reflective access by com.thoughtworks.xstream.converters.reflection.FieldDictionary (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.lang.reflect.Proxy.EMPTY_CLASS_ARRAY
WARNING: Illegal reflective access by com.thoughtworks.xstream.converters.reflection.FieldDictionary (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.lang.reflect.Proxy.h
WARNING: Illegal reflective access by com.thoughtworks.xstream.converters.reflection.FieldDictionary (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.lang.reflect.Proxy.proxyCache
WARNING: Illegal reflective access by com.thoughtworks.xstream.converters.reflection.FieldDictionary (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.lang.reflect.Proxy.PROXY_PACKAGE_PREFIX
WARNING: Illegal reflective access by com.thoughtworks.xstream.converters.reflection.FieldDictionary (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.lang.reflect.Proxy.serialVersionUID
WARNING: Illegal reflective access by com.thoughtworks.xstream.converters.reflection.FieldDictionary (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.util.AbstractCollection.MAX_ARRAY_SIZE
WARNING: Illegal reflective access by com.thoughtworks.xstream.converters.reflection.FieldDictionary (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.util.AbstractList.modCount
WARNING: Illegal reflective access by com.thoughtworks.xstream.converters.reflection.FieldDictionary (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.util.Arrays$ArrayList.a
WARNING: Illegal reflective access by com.thoughtworks.xstream.converters.reflection.FieldDictionary (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.util.Arrays$ArrayList.serialVersionUID
WARNING: Illegal reflective access by com.thoughtworks.xstream.converters.reflection.FieldDictionary (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.util.Collections$UnmodifiableCollection.c
WARNING: Illegal reflective access by com.thoughtworks.xstream.converters.reflection.FieldDictionary (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.util.Collections$UnmodifiableCollection.serialVersionUID
WARNING: Illegal reflective access by com.thoughtworks.xstream.converters.reflection.FieldDictionary (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.util.Collections$UnmodifiableSet.serialVersionUID
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.awt.font.TextAttribute.instanceMap
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.lang.reflect.Proxy.h
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.util.EnumMap.keyType
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.util.EnumSet.elementType
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.util.Properties.defaults
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.util.TreeMap.comparator
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/home/aaime/.m2/repository/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.util.TreeSet.m

Euh… these need some looking into, but as far as I can see, XStream here is just doing its job, we are asking
it to build XML and JSON by reflecting on Java objects structures, and well, it does :-p
Checking case by case, we might roll custom converters that know what they are converting at compile time, and avoid the reflective lookups.
We can also try not to pass proxies down to XStream, thought not sure it’s always a good idea (e.g. REST config).

5) javaassist in hibernate/geofence

WARNING: Illegal reflective access by javassist.util.proxy.SecurityActions (file:/home/aaime/.m2/repository/javassist/javassist/3.12.0.GA/javassist-3.12.0.GA.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte,int,int,java.security.ProtectionDomain)

This comes from as hibernate dependency in geofence-server… upgrading hibernate does not seem trivial though, not sure if doing so will resolve the issue (the latest hibernate is still using javaassist,
some might have been solved, only only very recently, not sure it made into a release used by Hibernate, see:
https://github.com/jboss-javassist/javassist/issues/214

https://github.com/jboss-javassist/javassist/issues/145

Task created for investigation

6) cglib-nodeps
WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$2 (file:/home/aaime/.m2/repository/cglib/cglib-nodep/2.2/cglib-nodep-2.2.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte,int,int,java.security.ProtectionDomain)

Have to check, but believe this is coming from a bytecode engineering bit I added in WFS. Not sure there is a workaround honestly, will check.
Task created.

7) POI

WARNING: Illegal reflective access by org.apache.poi.openxml4j.util.ZipSecureFile$1 (file:/home/aaime/.m2/repository/org/apache/poi/poi-ooxml/3.17/poi-ooxml-3.17.jar) to field java.io.FilterInputStream.in
WARNING: Illegal reflective access by org.apache.poi.util.DocumentHelper (file:/home/aaime/.m2/repository/org/apache/poi/poi-ooxml/3.17/poi-ooxml-3.17.jar) to method com.sun.org.apache.xerces.internal.util.SecurityManager.setEntityExpansionLimit(int)

There is a new version, 4.0, that we might try, checking the source code quickly it seems issues have been solved.
Task created.

8) EMF

WARNING: Illegal reflective access by org.eclipse.emf.ecore.xmi.impl.XMLHandler (file:/home/aaime/.m2/repository/org/eclipse/emf/org.eclipse.emf.ecore.xmi/2.12.0/org.eclipse.emf.ecore.xmi-2.12.0.jar) to method com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser$LocatorProxy.getEncoding()
WARNING: Illegal reflective access by org.eclipse.emf.ecore.xmi.impl.XMLHandler (file:/home/aaime/.m2/repository/org/eclipse/emf/org.eclipse.emf.ecore.xmi/2.12.0/org.eclipse.emf.ecore.xmi-2.12.0.jar) to method com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser$LocatorProxy.getXMLVersion()

Same as in GeoTools, did not create a new task for it, EMF usage in GeoServer depends on GeoTools

9) ModificationProxyCloner

WARNING: Illegal reflective access by org.geoserver.catalog.impl.ModificationProxyCloner (file:/home/aaime/devel/git-gs/src/main/target/gs-main-2.15-SNAPSHOT.jar) to method sun.util.calendar.ZoneInfo.clone()

The class tries hard to clone objects returned by ModificationProxy, so that changing them won’t alter the state of the underlying in memory CatalogInfo.
Guess we can simply add a special case for Calendar to avoid the specific issue, but don’t have a general solution.
Task created.

10) Spring

WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/home/aaime/.m2/repository/org/springframework/spring-core/4.3.18.RELEASE/spring-core-4.3.18.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte,int,int,java.security.ProtectionDomain)

We already have a task to upgrade Spring

11) Assorted test issues

WARNING: Illegal reflective access by org.geoserver.filters.GZipFilterTest$1 (file:/home/aaime/devel/git-gs/src/main/target/test-classes/) to field java.io.FilterOutputStream.out
WARNING: Illegal reflective access by org.mockito.cglib.core.ReflectUtils$2 (file:/home/aaime/.m2/repository/org/mockito/mockito-core/1.8.5/mockito-core-1.8.5.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte,int,int,java.security.ProtectionDomain)

Same as in GeoTools, we might want, or not, fix these… since they are so few, I guess we could, depends on how hard it is to do,
for example, the current Mockito is 2.0, and in the codebase we have a mix of mockito and easymock, and so on.
Ideally we should standardize on one, but both we are using (mockito, easymock) are on outdated versions, upgrading has no
guarantee of fixing the above either, both are using reflection heavily, both have had updates to make them compatible to JDK9+
very recently (e.g., we’d have to make the large version jump).

Anyhow, task created

That’s all folks :slight_smile:

···

Regards, Andrea Aime == GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

Save as with GeoTools, I’ve uploaded here a log of a full sequential (-T1) build with “–illlegal-access=debug” turned on,
meaning each illegal access warning also has a stack trace of where it came from, useful for locating
sources of a particular violation without running a full build locally:

https://drive.google.com/open?id=121bylTJnBCqGDB1D4q9asY-knA6-P_ZI

Cheers
Andrea

···

Regards, Andrea Aime == GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

Ah hem, wrong link,right one here:

https://drive.google.com/open?id=1ZU7gJbbTRSNwiccQfzsDsjFQmG5ytoLu

Cheers
Andrea

···

Regards, Andrea Aime == GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.