broadinstitute / barclay

Command line argument parser and online documentation generation utilities for java command line programs.
BSD 3-Clause "New" or "Revised" License
8 stars 6 forks source link

Java 9 deprecation #137

Open osallou opened 6 years ago

osallou commented 6 years ago

While compiling with JDK 9, I got some deprecation warning that turned to errors.

Here is patch to fix issue

--- a/src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java
+++ b/src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java
@@ -1066,7 +1066,7 @@
     private void createCollection(final Field field, final Object callerArguments, final String annotationType)
             throws IllegalAccessException {
         try {
-            field.set(callerArguments, field.getType().newInstance());
+            field.set(callerArguments, field.getType().getConstructor().newInstance());
         } catch (final Exception ex) {
             try {
                 field.set(callerArguments, new ArrayList<>());
--- a/src/main/java/org/broadinstitute/barclay/argparser/LegacyCommandLineArgumentParser.java
+++ b/src/main/java/org/broadinstitute/barclay/argparser/LegacyCommandLineArgumentParser.java
@@ -879,7 +879,7 @@
      private void createCollection(final Field field, final Object callerOptions, final String annotationType)
             throws IllegalAccessException {
         try {
-            field.set(callerOptions, field.getType().newInstance());
+            field.set(callerOptions, field.getType().getConstructor().newInstance());
         } catch (final Exception ex) {
             try {
                 field.set(callerOptions, new ArrayList<>());
magicDGS commented 6 years ago

Does your fix compiles with Java8? If I am correct, the target compatibility is 1.8

magicDGS commented 6 years ago

In addition, java9 is a short-term release and java10 is released. Oracle recommends to transition to java10: http://www.oracle.com/technetwork/java/eol-135779.html

osallou commented 6 years ago

I have not tested compatibility with java 8.

Default in debian is java 9, 10 should cause same issue as it is a deprecation.

Builing with jdk >=9 will create issue. At runtime, it should be a problem if you take directly the jar, but if you want to build yourself...

Olivier

Le jeu. 3 mai 2018 12:05, Daniel Gómez-Sánchez notifications@github.com a écrit :

In addition, java9 is a short-term release and java10 is released. Oracle recommends to transition to java10: http://www.oracle.com/technetwork/java/eol-135779.html

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/broadinstitute/barclay/issues/137#issuecomment-386247351, or mute the thread https://github.com/notifications/unsubscribe-auth/AA-gYocjlX1AM4acoudWqXL4dYPWpV8Uks5tutZegaJpZM4TwyBj .

mr-c commented 5 years ago

Barclay is now failing to build in Debian as Java 11 is now the default version: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=906973

mr-c commented 5 years ago

Without Java 11 support in barclay then barclay, picard-tools, IGV, paleomix, and Artemis will be removed from the upcoming stable release of Debian "buster" :-(

cmnbroad commented 5 years ago

@osallou @mr-c I'm trying to untangle what/how many issues there here are. Is the original issue reported in this ticket (which looks like a runtime issue, presumably from running a test) the only issue you're aware of, or is there a build-time issue as well ? Also, I see how this affects Picard, but am unclear on how it impacts, say, IGV, which AFAIK doesn't have any Barclay dependency.

osallou commented 5 years ago

those are build issues. I talked about are warnings going to errors with "newer" JDKs. The patch fixed the issue in Debian with JDK 11 (current JDK in Debian)