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

Fix various unit test failures related to powermock running in JDK 11 #1400

Merged
merged 1 commit into from
Jun 22, 2020

Conversation

HenryCaiHaiying
Copy link
Contributor

Errors like:
[ERROR] initializationError(com.pinterest.secor.io.FileReaderWriterFactoryTest) Time elapsed: 0 s <<< ERROR!
java.lang.IllegalAccessError: class jdk.internal.reflect.ConstructorAccessorImpl loaded by org.powermock.core.classloader.MockClassLoader @5c448ef cannot access jdk/internal/reflect superclass jdk.internal.reflect.MagicAccessorImpl

The errors only occur in JDK 9 and above, powermock (and its dependent jboss.javassist) has issues on JDK 9 and above, see https://stackoverflow.com/questions/50456726/mockclassloader-cannot-access-jdk-internal-reflect-superclass-jdk-internal-refle

Upgraded the powermock to latest version and used techniques like @PowerMockIgnore to defer un-related class's classloading to the system default classloader (instead of the powermock's classloader).

The other issue is mock's anyString() seems not matching argument Null, changed some unit tests to pass in a non-null argument.

Errors like:
[ERROR] initializationError(com.pinterest.secor.io.FileReaderWriterFactoryTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessError: class jdk.internal.reflect.ConstructorAccessorImpl loaded by org.powermock.core.classloader.MockClassLoader @5c448ef cannot access jdk/internal/reflect superclass jdk.internal.reflect.MagicAccessorImpl

The errors only occur in JDK 9 and above, powermock (and its dependent jboss.javassist) has issues on JDK 9 and above, see https://stackoverflow.com/questions/50456726/mockclassloader-cannot-access-jdk-internal-reflect-superclass-jdk-internal-refle

Upgraded the powermock to latest version and used techniques like @PowerMockIgnore to defer un-related class's classloading to the system default classloader (instead of the powermock's classloader).

The other issue is mock's anyString() seems not matching argument Null, changed some unit tests to pass in a non-null argument.
@HenryCaiHaiying HenryCaiHaiying merged commit 08d521f into pinterest:master Jun 22, 2020
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

Successfully merging this pull request may close these issues.

1 participant