Skip to content

GUACAMOLE-635: Require Java 1.8 for all Java components except guacamole-common.#324

Merged
asfgit merged 2 commits intoapache:staging/1.0.0from
mike-jumper:java-version
Sep 29, 2018
Merged

GUACAMOLE-635: Require Java 1.8 for all Java components except guacamole-common.#324
asfgit merged 2 commits intoapache:staging/1.0.0from
mike-jumper:java-version

Conversation

@mike-jumper
Copy link
Contributor

As discussed on #319 and on the dev@ mailing list, this change bumps the Java requirement for all Java components to 1.8, with the exception of guacamole-common which remains at 1.6.

There is one change here that isn't simply bumping "1.6" to "1.8": the addition of the @SafeVarargs annotation to the SimpleDirectory<ObjectType> constructor that accepts a varargs array of ObjectType. This is due to a new warning regarding "heap pollution" introduced in newer Java compilers.

From Oracle's documentation on heap pollution:

...

Heap Pollution

Heap pollution occurs when a variable of a parameterized type refers to an object that is not of that parameterized type. ...

...

Prevent Warnings from Varargs Methods with Non-Reifiable Formal Parameters

If you declare a varargs method that has parameters of a parameterized type, and you ensure that the body of the method does not throw a ClassCastException or other similar exception due to improper handling of the varargs formal parameter, you can prevent the warning that the compiler generates for these kinds of varargs methods by adding the following annotation to static and non-constructor method declarations:

@SafeVarargs

...

…ObjectType... objects).

From https://docs.oracle.com/javase/tutorial/java/generics/nonReifiableVarargsType.html#vulnerabilities:

"Heap pollution occurs when a variable of a parameterized type refers
to an object that is not of that parameterized type."

In this case, the parameterized type (ObjectType) and the array of that
type within this constructor are always used as their formal types.
@asfgit asfgit merged commit 182f204 into apache:staging/1.0.0 Sep 29, 2018
@mike-jumper mike-jumper deleted the java-version branch September 30, 2018 17:24
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