CodeFX-org/java-9-wtf

Package return values changed

sormuras opened this issue · 5 comments

Having a class like DefaultPackageTestCase defined in the default package, the result of DefaultPackageTestCase.class.getPackage() differ. See following code:

System.out.println("Java version = " + Runtime.class.getPackage().getImplementationVersion());
System.out.println("  class = |" + DefaultPackageTestCase.class + "|");
System.out.println("package = |" + DefaultPackageTestCase.class.getPackage() + "|");
System.out.println("   name = |" + DefaultPackageTestCase.class.getPackage().getName() + "|");

Java 8

Java version = 1.8.0_121

  class = |class DefaultPackageTestCase|
package = |null|
java.lang.NullPointerException

Java 9

Java version = null

  class = |class DefaultPackageTestCase|
package = |package |
   name = ||

The java.lang.Package API has been overhauled for Java SE 9 so that it works with modules. See the javadoc for more on this.

Sooo, @sormuras, up for a PR? 😃

I'm with Mikhail here: I inlined "the test case right here because I believe you have better idea how to integrate it into your compiler module"

@sormuras: Lazy bum, happy now? 😃

Done via 0a3ac95