Skip to content

Issue 939: Error with setInternalState and JDK12 "java.lang.NoSuchFieldException: modifiers #955

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

Merged
merged 1 commit into from
Nov 17, 2018

Conversation

eolivelli
Copy link
Contributor

Add a catch clause in order to workaround a problem with PowerMockRunner and JDK12

Signed-off-by: Enrico Olivelli - Diennea enrico.olivelli@diennea.com

Fixes #939

…ldException: modifiers"

Signed-off-by: Enrico Olivelli - Diennea <enrico.olivelli@diennea.com>
@eolivelli
Copy link
Contributor Author

eolivelli commented Nov 13, 2018

@thekingnothing can you please take a look ? this is quite blocker for testing of projects of JDK12.

@eolivelli
Copy link
Contributor Author

@ijuma do you think this change will be useful in your case ?

@@ -58,7 +58,16 @@ public void run(RunNotifier notifier) {
try {
super.run(notifier);
} finally {
Whitebox.setInternalState(description, "fAnnotations", new Annotation[]{});
try {
Whitebox.setInternalState(description, "fAnnotations", new Annotation[]{});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the old code made such a drastic operation?
@thekingnothing Is it really needed because it looks like a workaround of something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tibor17 it's a "dirty hack" to fix out memory issue. However, I don't see a lot of benefits as annotation does not consume a lot of memory and does not store any state or link to a heavy object.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thekingnothing
The performance issues are understandable, but I was asking for the purpose why annotations had to be removed from Description after Runners execution. Nobody reads them anyway after the runner has finished.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I cannot help, as this code was introduced 7 years ago and I'm supporting PowerMock only for 3 years. I cannot say the real reason why it was done in such a way.

@thekingn0thing thekingn0thing merged commit 314dae8 into powermock:release/2.x Nov 17, 2018
@eolivelli
Copy link
Contributor Author

Great!

I thank you.
Hoping to see soon a new release in Maven central

@thekingn0thing
Copy link
Member

Thank you. In theory, the release should be in Maven central in next few minutes, however, sync between bintray and maven central usually fails. So the release will be in next few hours.

@Tibor17
Copy link

Tibor17 commented Nov 17, 2018

@thekingnothing
I have a question to Javasist version. The Maven Enforcer Plugin found that Javasist is compiled with Java 1.8. Is this required in PowerMock? Can we use older version compliant with Java 1.7?

@thekingn0thing
Copy link
Member

@Tibor17 a Javasist version was upgraded as part of the #952 pull request to add supporting JDK 11. PowerMock does not depend directly on any new feature of the latest Javasist, so it works fine with previous versions except that previous Javasist's versions could not work with JDK 10/11.

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.

3 participants