JDK7 support

204 views
Skip to first unread message

bernie

unread,
Nov 18, 2011, 3:27:00 PM11/18/11
to bindgen
Hi,

I recently started using bindgen with Wicket which works great on Java
1.6. I decided to give Java 1.7 a try for a project but I am unable to
run the bindgen annotation processor successfully with Maven. For some
reason, the processor works when building the project in Eclipse.

The following 3 messages seem to indicate that something is wrong with
the bindgen pom.
[WARNING] The POM for org.bindgen:bindgen:jar:2.23 is invalid,
transitive dependencies (if any) will not be available: 2 problems
were encountered while building the effective model for
org.bindgen:bindgen:2.23
[ERROR] 'dependencies.dependency.systemPath' for joist:joist-util:jar
is missing. @
[ERROR] 'dependencies.dependency.systemPath' for
com.tonicsystems:jarjar:jar is missing. @

This message is caused by using JDK7:
[INFO] diagnostic warning: Supported source version 'RELEASE_6' from
annotation processor 'org.bindgen.processor.Processor' less than -
source '1.7'

Here is the actual annotation processor error that halts the build:
[INFO] diagnostic error: org.bindgen/BindKeyword.txt
[ERROR] error on execute: error during compilation

I wanted to build bindgen from source with JDK7 in Eclipse to try to
fix the problem, but was unable to. I followed the build instructions
on the bindgen site but am still missing 'bin/lib/build/jars/joist-
util.jar' and 'bin/lib/tests/jars/junit.jar'. Is there a step missing
in the instructions or have I done something wrong?

Also, was JDK7 support planned in the near future for bindgen?

Thanks!

Stephen Haberman

unread,
Nov 18, 2011, 3:48:06 PM11/18/11
to bin...@googlegroups.com

> I recently started using bindgen with Wicket which works great on Java
> 1.6.

Awesome!

> This message is caused by using JDK7:
> [INFO] diagnostic warning: Supported source version 'RELEASE_6' from
> annotation processor 'org.bindgen.processor.Processor' less than -
> source '1.7'

Oh, huh. Didn't think of that. I haven't switched to JDK7 myself yet.

> Is there a step missing in the instructions or have I done something wrong?

It should work. Those jars are downloaded by ivy, specifically by running "ant
ivy.retrieve".

> Also, was JDK7 support planned in the near future for bindgen?

Now that you brought it to my attention, sure! I'll try getting a JDK7 install
going and seeing what happens; might be a day or so before I get to it. Let me
know if you beat me to it.

- Stephen

Bertrand Guay-Paquet

unread,
Nov 18, 2011, 4:11:17 PM11/18/11
to bin...@googlegroups.com
By the way, I asked a question on StackOverflow regarding forward
compatibility of annotation processors:
http://stackoverflow.com/questions/8185331/forward-compatible-java-6-annotation-processor-and-supportedsourceversion

Maybe it will turn up good advice!

>> Is there a step missing in the instructions or have I done something wrong?
> It should work. Those jars are downloaded by ivy, specifically by running "ant
> ivy.retrieve".

That's probably what I was missing. I didn't understand this command had
to be run. I'll install ant and give it a try.

>> Also, was JDK7 support planned in the near future for bindgen?
> Now that you brought it to my attention, sure! I'll try getting a JDK7 install
> going and seeing what happens; might be a day or so before I get to it. Let me
> know if you beat me to it.

Great! Since it works in Eclipse and not Maven, I started migrating to
Gradle to see if it works there. I'll reply with any progress.

Regards,
Bertrand

Stephen Haberman

unread,
Nov 18, 2011, 4:19:33 PM11/18/11
to bin...@googlegroups.com, bern...@gmail.com

> Great! Since it works in Eclipse and not Maven, I started migrating
> to Gradle to see if it works there. I'll reply with any progress.

If I can save you any time, it'll probably not work with gradle because
I think the issue is in javac itself, which both maven and gradle use.

- Stephen


Bertrand Guay-Paquet

unread,
Nov 18, 2011, 8:25:47 PM11/18/11
to bin...@googlegroups.com
Installing ant and running "ant ivy.retrieve" did the trick. Perhaps
this should be added to the build instructions? For my part, I didn't
understand this had to be done (I had no experience with ant).

Some findings:
I first modified the Bindable.java annotation to:
@Target(value = { ElementType.TYPE, ElementType.PACKAGE })
since it is used in the examples in
/bindgen-examples/src/main/java/org/bindgen/example/subpackage/package-info.java.
Isn't this an error also for jdk 6?.

My tests were done with a jdk6 compiled version of the annotation
processor while using jdk7 for compiling the examples. Here are the
problems I found:

===================
bindgen.properties:
I put skipGeneratedTimestamps=true in bindgen.properties to facilitate
directory comparison between the jdk6 and jdk7 versions of the example
generated sources. The property was only honored for jdk6.

There are differences in the generated BindKeyword.java and
BindKeyword.txt files. Classes in the org.bindgen.outofscope package are
in the jdk7 version.

===================
In RawTypesExampleTest.java:
b.fieldGiven().set(this.e);
Assert.assertSame(this.e, b.fieldGiven().get());

b.fieldFixed().set(this.e); // <<< error!
// changing to b.fieldFixed().set((Enumeration<?>) this.e);
also doesn't work
Assert.assertSame(this.e, b.fieldFixed().get());

The same error is present in testMethod(). Here it is:
The method set(Enumeration<capture#1-of ?>) in the type
AbstractBinding<RawTypesExample,Enumeration<capture#1-of ?>> is not
applicable for the arguments (Enumeration<String>)
RawTypesExampleTest.java
/bindgen-examples/src/test/java/org/bindgen/example/fixRawTypes line
21 Java Problem

Could this be caused by different versions of the Enumeration class in
jdk6 and jdk7?

Also, some differences between the jdk6 and jdk7 versions of
RawTypesExampleBindingPath.java:
<<< private EnumerationBindingPath<R, String> methodFixed;
>>> private EnumerationBindingPath<R, ?> methodFixed;
<<< private EnumerationBindingPath<R, String> fieldFixed;
>>> private EnumerationBindingPath<R, ?> fieldFixed;

<<< public class MyMethodFixedBinding extends
EnumerationBindingPath<R, String> {
>>> public class MyMethodFixedBinding<E> extends
EnumerationBindingPath<R, E> {
same for MyFieldFixedBinding

===================
In TransactionExampleTest.java, the following statements fail because of
an undefined symbol:
TransactionBlock block = teb.businessLogic();
TransactionBlock block = teb.businessLogicThatCanFail();

Looking at the generated TransactionExampleBindingPath, we can see that
the 2 method bindings are indeed not created.

After much tinkering, I finally found out how to attach a debugger to
the ant compilation of the examples project:
set
ANT_OPTS="-agentlib:jdwp=transport=dt_socket,address=localhost:9009,server=y,suspend=y"
In Eclipse, create a remote debug configuration using port 9009. Run
"ant compile". Run the debug configuration in Eclipse with proper
breakpoints set. This will allow further investigation.

Cheers,
Bertrand

bernie

unread,
Nov 18, 2011, 8:58:43 PM11/18/11
to bindgen
bindgen.properties is not found because of:
Bindgen/src/main/java/org/bindgen/processor/util/ConfUtil.java line 66
FileObject dummyFileObject = env.getFiler().getResource(location, "",
"dummy.txt");
which throws FileNotFoundException in JDK7 but not in JDK6

I don't know what else is available to locate bindgen.properties...
However, artificually injecting the properties via
BindgenConfig#loadDefaultOptions() made sure all the java files and
BindKeyword.txt were identical. The output still did not compile, but
it eliminates many of the "problems" I identified in my previous
message.

Here is the javac error output:
[javac] annotations: [java.lang.SuppressWarnings,
java.lang.Override]
[javac] last round: false
[javac] error: org.bindgen/BindKeyword.txt
[javac] Round 3:
[javac] input files: {}
[javac] annotations: []
[javac] last round: true
[javac] 1 error
Reply all
Reply to author
Forward
0 new messages