Closed samrocketman closed 1 year ago
Correction on verification. I avoided maven just to be sure and this is what I determined. I will close this as a result.
cat > Hello.groovy <<'EOF'
class Hello {
}
EOF
./groovy-2.4.21/bin/groovyc -Jtarget=11 -Jsource=11 Hello.groovy
javap -verbose Hello.class | grep 'major\|minor'
javap
results in
minor version: 0
major version: 49
According to stack overflow:
major | minor | Java platform version |
---|---|---|
45 | 3 | 1.0 |
45 | 3 | 1.1 |
46 | 0 | 1.2 |
47 | 0 | 1.3 |
48 | 0 | 1.4 |
49 | 0 | 1.5 |
50 | 0 | 1.6 |
51 | 0 | 1.7 |
52 | 0 | 1.8 |
53 | 0 | 9 |
54 | 0 | 10 |
55 | 0 | 11 |
56 | 0 | 12 |
57 | 0 | 13 |
58 | 0 | 14 |
59 | 0 | 15 |
60 | 0 | 16 |
61 | 0 | 17 |
62 | 0 | 18 |
63 | 0 | 19 |
Looks like allowed JDKs is up to bytecode 1.8 but I can't get groovyc
to output anything other than bytecode 1.5.
./groovy-2.4.21/bin/groovyc -J groovy.target.indy=1 -J groovy.target.bytecode=1.8 Hello.groovy
javap
still returns major 49
.
I'll leave this open for a short period in case someone else more experienced in Groovy can correct me.
Okay, never mind. I was able to target newer bytecodes in maven and it actually works.
<properties>
<groovy.target.bytecode>1.8</groovy.target.bytecode>
</properties>
$ javap -verbose target/classes/net/gleske/scmfilter/credential/GraphQLTokenCredential.class | grep 'major\|minor'
minor version: 0
major version: 52
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
Results in a compile error for Groovy 2.4.21. This makes sense because Groovy 2.4.21 only handles bytecode up to 8.
Switching to Java 8 or 1.8 works for gmavenplus.
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
At first I misunderstood what I was doing versus what I wanted. I was able to verify there is no bug and how to check my assumptions.
I documented my process in case anybody else finds it useful.
targetBytecode is what controls this. It defaults to maven.compiler.target
as you have noticed. Using that default ensures the bytecode version GMavenPlus output matches classes output by the Maven Compiler plugin (e.g. any Java files you have).
I'm glad you were able to get it working!
Thanks for the info; and yeah I was a bit verbose but I figured details would help someone else in my position so I tried to be clear about my method (for verifying and not just assuming the setting worked or didn't).
This is a bug report for gmaven plus.
Groovy 2.4.18 release notes https://groovy-lang.org/changelogs/changelog-2.4.18.html
I have verified with other Groovy compiler plugins that targeting OpenJDK 11 bytecode works.