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(tests): issue #1200, added testing compatibility for jdk9+ #1245

Merged
merged 1 commit into from
Jul 30, 2018
Merged

fix(tests): issue #1200, added testing compatibility for jdk9+ #1245

merged 1 commit into from
Jul 30, 2018

Conversation

devsomelife
Copy link

This solves the "await/Continuations error" when trying to run tests in if you're using jdk9+

@tomparle
Copy link
Contributor

Hi SomelifeDev,

I confirm this solves the Cannot use await/continuations when not all application classes on the callstack are properly enhanced. The following class is not enhanced: jdk.internal.reflect.NativeMethodAccessorImpl error when using jdk9.
I also confirmed that it worked with jdk10.

There is an additional warning that I'm not qualified enough to say if it's important or not :
WARNING: Illegal reflective access by javassist.util.proxy.SecurityActions (file:.../play-1.x/framework/lib/javassist-3.21.0-GA.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)

So, thanks a lot ! I am looking forward this fix to be merged since it would finally allows us to use Play 1.x with more recent versions of JDK.

@tazmaniax
Copy link
Collaborator

I would say that I'm equally unqualified to resolve :) but looking at the javassist release notes, v3.22 introduced support for JDK 9 and the latest GA release is v3.23.1. If it's possible to upgrade javassist then that's probably worth doing. If that's not possible or doesn't resolve it then it's possible to open up the required modules for javaasist which can be found in this migration guide - see slide 16 and 31.

@tomparle
Copy link
Contributor

Hi Chris,

thank you for the quick reply !
Indeed, upgrading to the latest version of javassist did the trick !
I created the corresponding pull request which only required a small change : #1247

Please tell me if the pull request is ok or if I should have done something differently, I'm not that much used to contribute, yet !
Tom

Copy link
Contributor

@asolntsev asolntsev left a comment

Choose a reason for hiding this comment

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

@SomelifeDev is there a unit-test for class Controller? It would be a good practice to add one more test-case to that unit-test.

@tazmaniax
Copy link
Collaborator

Connecting this to #1200

@devsomelife
Copy link
Author

Hey, glad it works and great one for the update on the javassist: quite obvious but nobody bothered apparently, until now.

@asolntsev hmm, not sure to be honest. This is just to fix the inability to use the built-in play test system on jdk 9+

@tomparle
Copy link
Contributor

@SomelifeDev it's not that we did not bother, but personally I had no idea of how to fix this initially ! So thank you for having unblocked the situation.
Regarding to the corresponding test case, while it seems that there is no test class for Controller specifically, among all tests in error, there is the test ContinuationTest that explicitely failed with jdk9+, but passed with SomelifeDev's fix.
So maybe I guess we may not need to add another test specifically, what do you think ?

@asolntsev
Copy link
Contributor

@tomparle @SomelifeDev Regarding a unit-test. I mean, in normal situation I would

  1. extract className.startsWith("sun.") || className.startsWith("play.") to a separate method in Controller class. Say,
static boolean shouldNotBeEnhanced(String className) {
  return className.startsWith("sun.") || className.startsWith("play.");
}
  1. I would create a unit-test ControllerTest.java with couple of asserts:
@Test
public void jdkAndPlayClassesShouldNeverBeenEnhanced() {
  assertTrue(shouldNotBeEnhanced("sun.blah"));
  assertTrue(shouldNotBeEnhanced("play.foo"));
  assertFalse(shouldNotBeEnhanced("com.bar"));
}

But in this case I guess we can omit this step because there is so much code that is not covered by unit-tests at all.

@tomparle
Copy link
Contributor

@asolntsev thanks for your test suggestion, sounds right to me, especially because it enlightens the "ignore for enhancement" mechanism, which is otherwise kind of hidden in Play internals.
@SomelifeDev what do you think ? it should be quick to add this test.
Otherwise I will add it next week (not sure if I can contribute to the pull request of another user ?)

@devsomelife
Copy link
Author

@asolntsev and @tomparle
Done (after a couple massive monday morning brain farts).
Was a good idea and even if lot of tests are missing, it's the occasion to start on the ControllerTest class anyway. Plus allowed me to finally take the time to properly set things up on my side...

@asolntsev
Copy link
Contributor

@SomelifeDev Great work, thank you!
I have two more wishes:

  1. Method shouldBeCheckedForEnhancement could be simplified:
static boolean shouldBeCheckedForEnhancement(String className) {
  return className.startsWith("jdk.") || className.startsWith("sun.") || className.startsWith("play.");
}
  1. Could you squach your N commits into one commit? It would simplify git history tree.

refactor(tests): issue #1200, adds Controller.test class and unit test for modification on this issue

fix(tests): issue #1200, fixes missing imports

fix(tests): issue #1200, fixes encapsulation

fix(tests): issue #1200 sorted import errors

style(tests): issue #1200 beautification
@devsomelife
Copy link
Author

@asolntsev done and done.

@asolntsev asolntsev merged commit 50b1864 into playframework:master Jul 30, 2018
@asolntsev
Copy link
Contributor

@SomelifeDev Thank you! Merged.

@tomparle
Copy link
Contributor

@SomelifeDev thank you for the fix and having taken into account @asolntsev 's suggestions !

@@ -1252,6 +1252,17 @@ private static void verifyContinuationsEnhancement() {
}
}


/**
* Checks if the classname is from the jdk, sun or play package and therefore should not be checked for enhancement
Copy link
Collaborator

@tazmaniax tazmaniax Jul 31, 2018

Choose a reason for hiding this comment

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

Sorry for being late to the party but this comment feels counter intuitive. It states that if the class name package is jdk, sun or play then it should NOT be checked for enhancement. As the method returns true if any of those packages match then shouldn't the method be shouldNotBeCheckedForEnhancement() ? Or am I having a brain fart here :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, good point. I already fixed it in master branch.

@devsomelife
Copy link
Author

@tazmaniax
You're 100% correct

@xael-fry xael-fry added this to the 1.5.2 milestone Aug 22, 2018
xael-fry pushed a commit to xael-fry/play that referenced this pull request Aug 23, 2018
…removing the workaround that was fixed in latest version of javassist

* upgraded javassist to 3.23.1-GA to suppress warning with JDK9+
xael-fry added a commit that referenced this pull request Aug 23, 2018
[#1245] Fix public/protected testing with Javassist, by removing the workaround that was fixed in latest version of javassist
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.

None yet

5 participants