SciJava OPS and Java 6 compiler bug

13 views
Skip to first unread message

Curtis Rueden

unread,
Jan 13, 2014, 3:57:41 PM1/13/14
to SciJava, Johannes Schindelin, Christian Dietz
Hi all,

There is a bug in the Java 6 compiler [1] which prevents the current master of SciJava-OPS [2] from compiling successfully [3]. The bug was fixed in Java 7, but will not be fixed for Java 6.

The problem essentially stems from having a copy() method declared in an interface hierarchy that uses multiple inheritance, and narrows the return type of the copy() method appropriate to each interface.

I know of no good workarounds. The solution is either:

A) Change the design to eliminate need for this copy() method
B) Require Java 7 for compilation (but maybe still build Java 6-compatible classes)

Preferences?

Regards,
Curtis


[2] https://github.com/scijava/scijava-ops

[3] http://jenkins.imagej.net/job/SciJava-OPS


On Sun, Nov 17, 2013 at 9:24 AM, <jen...@imagej.net> wrote:
See <http://jenkins.imagej.net/job/SciJava-OPS/4/changes>

Changes:

[Curtis Rueden] Move Condition interface into core scijava-ops

[Curtis Rueden] Add abstract superclass for Conditions

[Curtis Rueden] Fix Condition type hierarchy

------------------------------------------
Started by an SCM change
Building on master
Checkout:workspace / <http://jenkins.imagej.net/job/SciJava-OPS/ws/> - hudson.remoting.LocalChannel@2924d60
Using strategy: Default
Last Built Revision: Revision 989366870f8b13f15d9ec3d394433ceaf9a31235 (origin/master)
Fetching changes from 1 remote Git repository
Fetching upstream changes from git://github.com/scijava/scijava-ops
Commencing build of Revision 54811ff1bda6a9331707725ba73272ae57a34ecf (origin/master)
Checking out Revision 54811ff1bda6a9331707725ba73272ae57a34ecf (origin/master)
[workspace] $ /bin/sh -xe /tmp/hudson1582769724563638714.sh
+ git clean -dfx
Removing core/target/
[workspace] $ mvn -U clean package
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO]   SciJava OPS Projects
[INFO]   SciJava OPS Core Library
[INFO]   SciJava OPS: Functions
[INFO]   SciJava OPS: Descriptors
[INFO]   SciJava OPS: Trackers
[INFO] ------------------------------------------------------------------------
[INFO] Building SciJava OPS Projects
[INFO]    task-segment: [clean, package]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] [imagej:set-rootdir {execution: set-rootdir}]
[INFO] Setting rootdir: /data/devel/jenkins/jobs/SciJava-OPS/workspace
[INFO] [buildnumber:create {execution: default}]
[INFO] Checking for local modifications: skipped.
[INFO] Updating project files from SCM: skipped.
[INFO] Executing: /bin/sh -c cd /data/devel/jenkins/jobs/SciJava-OPS/workspace && git rev-parse --verify HEAD
[INFO] Working directory: /data/devel/jenkins/jobs/SciJava-OPS/workspace
[INFO] Storing buildNumber: 54811ff1bda6a9331707725ba73272ae57a34ecf at timestamp: 1384701872242
[INFO] Executing: /bin/sh -c cd /data/devel/jenkins/jobs/SciJava-OPS/workspace && git rev-parse --verify HEAD
[INFO] Working directory: /data/devel/jenkins/jobs/SciJava-OPS/workspace
[INFO] Storing buildScmBranch: UNKNOWN
[INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO] Preparing source:jar
[WARNING] Removing: jar from forked lifecycle, to prevent recursive invocation.
[INFO] [imagej:set-rootdir {execution: set-rootdir}]
[INFO] [buildnumber:create {execution: default}]
[INFO] [source:jar {execution: default}]
[INFO] ------------------------------------------------------------------------
[INFO] Building SciJava OPS Core Library
[INFO]    task-segment: [clean, package]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] [imagej:set-rootdir {execution: set-rootdir}]
[INFO] [buildnumber:create {execution: default}]
[debug] execute contextualize
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /data/devel/jenkins/jobs/SciJava-OPS/workspace/core/src/main/resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 30 source files to /data/devel/jenkins/jobs/SciJava-OPS/workspace/core/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /data/devel/jenkins/jobs/SciJava-OPS/workspace/core/src/main/java/org/scijava/ops/AbstractAgnosticUnaryOutputFunction.java:[42,16] types org.scijava.ops.AgnosticUnaryOutputFunction<I,O> and org.scijava.ops.AgnosticUnaryOutputFunction<I,O> are incompatible; both define copy(), but with unrelated return types
[ERROR] /data/devel/jenkins/jobs/SciJava-OPS/workspace/core/src/main/java/org/scijava/ops/AbstractCondition.java:[42,16] types org.scijava.ops.AbstractAgnosticUnaryOutputFunction<I,boolean[]> and org.scijava.ops.AbstractAgnosticUnaryOutputFunction<I,boolean[]> are incompatible; both define copy(), but with unrelated return types
[ERROR] /data/devel/jenkins/jobs/SciJava-OPS/workspace/core/src/main/java/org/scijava/ops/AgnosticUnaryOutputFunction.java:[42,7] types org.scijava.ops.UnaryOutputFunction<I,O> and org.scijava.ops.AgnosticOutputFunction<O> are incompatible; both define copy(), but with unrelated return types
[ERROR] /data/devel/jenkins/jobs/SciJava-OPS/workspace/core/src/main/java/org/scijava/ops/Condition.java:[45,7] types org.scijava.ops.AgnosticUnaryOutputFunction<I,boolean[]> and org.scijava.ops.AgnosticUnaryOutputFunction<I,boolean[]> are incompatible; both define copy(), but with unrelated return types
[INFO] 4 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure

/data/devel/jenkins/jobs/SciJava-OPS/workspace/core/src/main/java/org/scijava/ops/AbstractAgnosticUnaryOutputFunction.java:[42,16] types org.scijava.ops.AgnosticUnaryOutputFunction<I,O> and org.scijava.ops.AgnosticUnaryOutputFunction<I,O> are incompatible; both define copy(), but with unrelated return types
/data/devel/jenkins/jobs/SciJava-OPS/workspace/core/src/main/java/org/scijava/ops/AbstractCondition.java:[42,16] types org.scijava.ops.AbstractAgnosticUnaryOutputFunction<I,boolean[]> and org.scijava.ops.AbstractAgnosticUnaryOutputFunction<I,boolean[]> are incompatible; both define copy(), but with unrelated return types
/data/devel/jenkins/jobs/SciJava-OPS/workspace/core/src/main/java/org/scijava/ops/AgnosticUnaryOutputFunction.java:[42,7] types org.scijava.ops.UnaryOutputFunction<I,O> and org.scijava.ops.AgnosticOutputFunction<O> are incompatible; both define copy(), but with unrelated return types
/data/devel/jenkins/jobs/SciJava-OPS/workspace/core/src/main/java/org/scijava/ops/Condition.java:[45,7] types org.scijava.ops.AgnosticUnaryOutputFunction<I,boolean[]> and org.scijava.ops.AgnosticUnaryOutputFunction<I,boolean[]> are incompatible; both define copy(), but with unrelated return types

[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15 seconds
[INFO] Finished at: Sun Nov 17 09:24:37 CST 2013
[INFO] Final Memory: 63M/1026M
[INFO] ------------------------------------------------------------------------
Build step 'Invoke top-level Maven targets' marked build as failure
Archiving artifacts
Recording test results

Johannes Schindelin

unread,
Jan 13, 2014, 4:14:47 PM1/13/14
to Curtis Rueden, SciJava, Christian Dietz
Hi Curtis,

On Mon, 13 Jan 2014, Curtis Rueden wrote:

> There is a bug in the Java 6 compiler [1] which prevents the current
> master of SciJava-OPS [2] from compiling successfully [3]. The bug was
> fixed in Java 7, but will not be fixed for Java 6.

Just for kicks, I tried it with

java -jar $JARS/javac-1.6.0.24-ubuntu-fiji1.jar \
-d target/classes/ \
-classpath $JARS/scijava-common-2.7.0.jar:$JARS/imglib2-2.0.0-beta-22.jar \
$(git ls-files \*.java)

i.e. with Fiji's javac and it also has a problem there.

We could fix Fiji's javac, but it would still be a major hassle to compile
with Maven.

> A) Change the design to eliminate need for this copy() method
> B) Require Java 7 for compilation (but maybe still build Java
> 6-compatible classes)

I tend to prefer A) and to put my money where my mouth is, I offer to do
the bulk of the work if you describe how you want it done.

Ciao,
Dscho

Curtis Rueden

unread,
Jan 13, 2014, 5:49:00 PM1/13/14
to SciJava, Christian Dietz, Johannes Schindelin
Hi Johannes,

> I tend to prefer A) and to put my money where my mouth is, I offer to
> do the bulk of the work if you describe how you want it done.

Thanks. But the problem is: I don't know. I did not yet dive into the code deeply enough to understand why descriptors and functions need to be able to copy themselves that way. I'm sure there is a good reason though.

We could simplify the interface hierarchy somehow to get rid of the problem (it is caused by certain forms of multiple inheritance) but it might do long-term harm to the design.

Best bet is probably to try and solve it in conjunction with completing the interface hierarchy in the first place, as I promised to do. Unfortunately, I will almost certainly not have time to work on it before the Konstanz trip.

Regards,
Curtis



--
You received this message because you are subscribed to the Google Groups "scijava" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scijava+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages