Framework: ReflectTools depends on unaccessible class

Created on 21 Mar 2018  路  9Comments  路  Source: vaadin/framework

Attempting to compile the Vaadin Framework project on JDK9 or JDK10 I run into following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project vaadin-server: Compilation failure
[ERROR] server/src/main/java/com/vaadin/util/ReflectTools.java:[90,18] cannot access com.sun.beans.introspect.PropertyInfo
[ERROR] class file for com.sun.beans.introspect.PropertyInfo not found

The use of com.sun.beans.introspect should be replaced with something compatible with JDK 8, 9 and 10.

enhancement

Most helpful comment

@tsuoanttila See JDK-8212636 I think it can be fixed by doing the following change in server/src/main/java/com/vaadin/util/ReflectTools.java.
Before:

Line 90: pd = new PropertyDescriptor(field.getName(), object.getClass());

After:

pd = new PropertyDescriptor((String)field.getName(), object.getClass());

All 9 comments

There were also some talks about using a separate bean introspection library instead of the one that is part of the JRE because of the way it requires using lots of extra parts from the Java 9+ modular JRE.

Also, I don't see any direct reference to e.g. com.sun.beans.introspect.PropertyInfo in the source file.

@tsuoanttila See JDK-8212636 I think it can be fixed by doing the following change in server/src/main/java/com/vaadin/util/ReflectTools.java.
Before:

Line 90: pd = new PropertyDescriptor(field.getName(), object.getClass());

After:

pd = new PropertyDescriptor((String)field.getName(), object.getClass());

yes, it's very weird, why add one more step to convert to string forcely works, can you explain it? difference between null and (String) null??

It actually solves the problem. Would you please explain, why this works?

not working

I think another workaround is to use "--release 8" command line parameter in compilation.

I had this problem on JDK 11 (Maven build fails):
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project flow-server: Compilation failure
[ERROR] (...)/flow/flow-server/src/main/java/com/vaadin/flow/internal/ReflectTools.java:[115,18] cannot access com.sun.beans.introspect.PropertyInfo
[ERROR] class file for com.sun.beans.introspect.PropertyInfo not found

@tsuoanttila See JDK-8212636 I think it can be fixed by doing the following change in server/src/main/java/com/vaadin/util/ReflectTools.java.
Before:

Line 90: pd = new PropertyDescriptor(field.getName(), object.getClass());

After:

pd = new PropertyDescriptor((String)field.getName(), object.getClass());

It definitely works, but I want to know why, really irrational!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lanmaster picture lanmaster  路  3Comments

FSchliephacke picture FSchliephacke  路  4Comments

RobertZenz picture RobertZenz  路  6Comments

SomeoneToIgnore picture SomeoneToIgnore  路  7Comments

vaadin-bot picture vaadin-bot  路  7Comments