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

Prevent Java 9 on Travis CI from failing #598

Merged
merged 1 commit into from
Dec 12, 2016
Merged

Prevent Java 9 on Travis CI from failing #598

merged 1 commit into from
Dec 12, 2016

Conversation

sormuras
Copy link
Member

@sormuras sormuras commented Dec 11, 2016

Overview

Assume that two tests using Class::getPackage::getXyz() are not executed on Java 9 -- until the reason why those methods return null is understood and fixed. Create new ticket to track this issue?


I hereby agree to the terms of the JUnit Contributor License Agreement.

@@ -49,12 +50,14 @@ void getAttributeWithFunctionReturningNullIsEmpty() {

@Test
void vendorFromObjectClassIsPresent() {
assumeFalse(System.getProperty("java.version").equals("9-ea"), "Java 9 not supported, yet");
Copy link
Member

Choose a reason for hiding this comment

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

Let's not check that it is equal to 9-ea but rather that it starts with 9.

assertTrue(PackageUtils.getAttribute(Object.class, Package::getSpecificationVendor).isPresent());
assertTrue(PackageUtils.getAttribute(Object.class, Package::getImplementationVendor).isPresent());
}

@Test
void versionSystemPropertyEqualsRuntimeClassImplementationVersion() {
assumeFalse(System.getProperty("java.version").equals("9-ea"), "Java 9 not supported, yet");
Copy link
Member

Choose a reason for hiding this comment

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

ditto

@sormuras
Copy link
Member Author

Changes force pushed.

@sormuras
Copy link
Member Author

Back to three green CI lights.

@sbrannen
Copy link
Member

sbrannen commented Dec 11, 2016

FYI: getPackage() is deprecated on JDK 9 in favor of getDefinedPackage().

So perhaps that's the reason.

But... getDefinedPackage() is not available until JDK 9.

@sbrannen
Copy link
Member

Here's an excerpt from the JDK 9 mailing list:

I considered deprecating ClassLoader::getPackage(s). These methods are not doing anything inherently wrong or causing any risk although the spec and impl version, title, vendor, annotation might not be the expected value. The Package design and implementation has been flawed since 1.2. This patch leaves it with @apiNote to make it clear.

@sbrannen
Copy link
Member

Oops... I linked to documentation about ClassLoader instead of Class. So Class::getPackage() is not deprecated in JDK 9; however, based on the linked discussion, it appears that package metadata still might suffer from the same issues as with ClassLoader.

@sbrannen
Copy link
Member

sbrannen commented Dec 11, 2016

And the Javadoc for Package states the following:

A Package can be obtained with the Package.getPackage(String) and ClassLoader.getDefinedPackage(String) methods. Every Package defined by a class loader can be obtained with the Package.getPackages() and ClassLoader.getDefinedPackages() methods.

@sbrannen
Copy link
Member

And the following from the Javadoc for Package in JDK 9 seems to hit the nail on the head:

A Package automatically defined for classes in a named module has the following properties: ... The specification and implementation titles, versions, and vendors are unspecified.

So, since your test works with Object which is in the java.base module, I'm assuming the above applies, which means that the implementation titles, versions, and vendors are unspecified.

@sbrannen
Copy link
Member

Create new ticket to track this issue?

Yes, we should create a new ticket to address the issue with package versioning metadata on JDK 9.

@sbrannen sbrannen self-assigned this Dec 12, 2016
@sbrannen sbrannen added this to the 5.0 M4 milestone Dec 12, 2016
@sbrannen sbrannen merged commit 68537d0 into junit-team:master Dec 12, 2016
@sbrannen
Copy link
Member

Merged into master.

Thanks

@sbrannen
Copy link
Member

Created separate issue to address versioning metadata from JARs on Java 9 in #600.

@sormuras sormuras deleted the java_9_fix branch December 12, 2016 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants