Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 9 compatibility #108

Closed
JohnZavyn opened this issue Nov 2, 2017 · 3 comments
Closed

Java 9 compatibility #108

JohnZavyn opened this issue Nov 2, 2017 · 3 comments
Assignees

Comments

@JohnZavyn
Copy link

com.openpojo.reflection.java.packageloader.boot.JavaBootClassLoader is hard coded to pull the class path from System.getProperty("sun.boot.class.path"). However, this system property has been removed in Java 9, resulting in a null pointer exception.

In debug mode, I was able to manually replace this with "java.class.path", which appeared to work correctly.

See https://docs.oracle.com/javase/8/docs/technotes/tools/windows/findingclasses.html

I see this property is also available in Java 1.7 and 1.8, but I have not checked earlier versions.

For backwards compatibility, it might be useful to check "java.class.path" first, and then "sun.boot.class.path" if the former returns a null.

Love your product, and want to keep using it in Java 9! 😄

@JohnZavyn
Copy link
Author

Also note that after getting the path, I get the following warnings:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.openpojo.reflection.impl.PojoFieldImpl (file:/Users/johnmarsh/.m2/repository/com/openpojo/openpojo/0.8.6/openpojo-0.8.6.jar) to field java.lang.Exception.serialVersionUID
WARNING: Please consider reporting this to the maintainers of com.openpojo.reflection.impl.PojoFieldImpl
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

I seem to remember reading that Oracle will be better protecting in the future, but I can't find my reference at the moment, and I don't recall if there will be other, preferred ways of doing reflection in the future...

Thanks again!

@JohnZavyn
Copy link
Author

To work around this problem, I added the following to my JUnit test:

/**
 * <p>Workaround to allow OpenPojo version 0.8.6 to work with Java 9.</p> 
 * <p>TODO: Remove when OpenPojo is updated</p>
 */
@BeforeClass
public static void setSystemProperty()
{
    System.setProperty("sun.boot.class.path", System.getProperty("java.class.path"));
}

@oshoukry oshoukry self-assigned this Dec 21, 2017
oshoukry added a commit that referenced this issue Jan 6, 2018
Refactored and cleaned up the classpath loading to be more robust, no longer needing sun.boot.classpath.  Also made more robust failures to detect values in environment variables.
@oshoukry
Copy link
Member

oshoukry commented Jan 7, 2018

So the main issue that this was opened on is now resolved which is the exception being thrown.
I'll open another issue for supporting Java 9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants