Skip to content

Conversation

@astubbs
Copy link

@astubbs astubbs commented Aug 13, 2020

Fixes #9 --enable-preview through Jabel?
First cut, works for me so far...

Branched from logging PR, can rebase on master if you like instead: #37

@astubbs astubbs force-pushed the enable-previe-features branch from 2e299a1 to 4b29f6b Compare August 13, 2020 12:02
@astubbs astubbs changed the title Enable previe features Enable preview features Aug 13, 2020
@astubbs astubbs force-pushed the enable-previe-features branch from 712f8ed to 1ba2d7a Compare August 13, 2020 12:42
import com.sun.tools.javac.code.Source;
import net.bytebuddy.asm.Advice;

public class PreviewFeatureCheckOverride {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's follow the convention of ${ClassBeingVisited}Advice:

Suggested change
public class PreviewFeatureCheckOverride {
public class PreviewAdvice {

@bsideup
Copy link
Owner

bsideup commented Aug 16, 2020

Hey @astubbs,

Since the logging one may take longer, could you please rebase this PR on top of master? Thanks!

@astubbs
Copy link
Author

astubbs commented Aug 17, 2020

Will do @bsideup , what do you think otherwise?

@astubbs astubbs force-pushed the enable-previe-features branch from 1ba2d7a to f149620 Compare August 17, 2020 19:01
I don’t understand why, but must be something to do with the way ByteBuddy works, the Advice class seems to be required to be a normal class, not an inner static class.
@astubbs astubbs force-pushed the enable-previe-features branch from 4a6d826 to 5bec5e6 Compare August 17, 2020 19:04
@astubbs astubbs requested a review from bsideup August 17, 2020 19:15
…or is (very) disabled. Passes locally, but fails on github CI.

Local:

↪ ./gradlew -version

------------------------------------------------------------
Gradle 6.2.1
------------------------------------------------------------

Build time:   2020-02-24 20:24:10 UTC
Revision:     aacbcb7e587faa6a8e7851751a76183b6187b164

Kotlin:       1.3.61
Groovy:       2.5.8
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          13.0.2 (Oracle Corporation 13.0.2+8)
OS:           Mac OS X 10.15.6 x86_64
@astubbs astubbs force-pushed the enable-previe-features branch from 78911e4 to 57a42dc Compare August 18, 2020 10:20
@astubbs
Copy link
Author

astubbs commented Aug 18, 2020

Wow ok have been pulling my hair out about this. Turns out the difference of fail vs not failing (it passes locally no matter what I do, and fails on CI), was Gradle wrapper vs not. I /had/ java 14 installed on my machine and removing that made no difference.

I had a quick look through the release notes between 6.2 and 6.6 and couldn't find anything obvious...


↪ gradle -version

------------------------------------------------------------
Gradle 6.6
------------------------------------------------------------

Build time:   2020-08-10 22:06:19 UTC
Revision:     d119144684a0c301aea027b79857815659e431b9

Kotlin:       1.3.72
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM:          13.0.2 (Oracle Corporation 13.0.2+8)
OS:           Mac OS X 10.15.6 x86_64

11:55:48 18/08/20 in /Users/antony/repos/projects/jabel
↪ gradle clean test

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 1s
7 actionable tasks: 6 executed, 1 up-to-date
11:55:53 18/08/20 in /Users/antony/repos/projects/jabel
↪ ./gradlew -version

------------------------------------------------------------
Gradle 6.2.1
------------------------------------------------------------

Build time:   2020-02-24 20:24:10 UTC
Revision:     aacbcb7e587faa6a8e7851751a76183b6187b164

Kotlin:       1.3.61
Groovy:       2.5.8
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          13.0.2 (Oracle Corporation 13.0.2+8)
OS:           Mac OS X 10.15.6 x86_64

11:56:01 18/08/20 in /Users/antony/repos/projects/jabel
↪ ./gradlew clean test

> Task :example:compileJava FAILED
/Users/antony/repos/projects/jabel/example/src/main/java/com/example/JabelExample.java:16: error: switch expressions are a preview feature and are disabled by default.
        var result = switch (args.length) {
                     ^
  (use --enable-preview to enable switch expressions)
/Users/antony/repos/projects/jabel/example/src/main/java/com/example/JabelExample.java:17: error: switch rules are a preview feature and are disabled by default.
            case 1 -> {
                   ^
  (use --enable-preview to enable switch rules)
/Users/antony/repos/projects/jabel/example/src/main/java/com/example/JabelExample.java:20: error: multiple case labels are a preview feature and are disabled by default.
            case 2, 3 -> "two or three";
                  ^
  (use --enable-preview to enable multiple case labels)
/Users/antony/repos/projects/jabel/example/src/main/java/com/example/JabelExample.java:16: warning: as of release 10, 'var' is a restricted type name and cannot be used for type declarations or as the element type of an array
        var result = switch (args.length) {
            ^
/Users/antony/repos/projects/jabel/example/src/main/java/com/example/JabelExample.java:36: warning: as of release 10, 'var' is a restricted type name and cannot be used for type declarations or as the element type of an array
                Function<String, String> function = (var prefix) -> {
                                                     ^
/Users/antony/repos/projects/jabel/example/src/main/java/com/example/JabelExample.java:31: warning: as of release 10, 'var' is a restricted type name and cannot be used for type declarations or as the element type of an array
        var callable = new Callable<>() {
            ^
/Users/antony/repos/projects/jabel/example/src/main/java/com/example/JabelExample.java:44: warning: as of release 10, 'var' is a restricted type name and cannot be used for type declarations or as the element type of an array
        var closeable = new AutoCloseable() {
            ^
/Users/antony/repos/projects/jabel/example/src/main/java/com/example/JabelExample.java:54: error: variables in try-with-resources are not supported in -source 8
        try (closeable) {
                      ^
  (use -source 9 or higher to enable variables in try-with-resources)
/Users/antony/repos/projects/jabel/example/src/main/java/com/example/JabelExample.java:69: warning: as of release 10, 'var' is a restricted type name and cannot be used for type declarations or as the element type of an array
        var me = 4;
            ^
/Users/antony/repos/projects/jabel/example/src/main/java/com/example/JabelExample.java:70: warning: as of release 10, 'var' is a restricted type name and cannot be used for type declarations or as the element type of an array
        var operation = "squareMe";
            ^
/Users/antony/repos/projects/jabel/example/src/main/java/com/example/JabelExample.java:71: warning: as of release 10, 'var' is a restricted type name and cannot be used for type declarations or as the element type of an array
        var result = switch (operation) {
            ^
4 errors
7 warnings

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':example:compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 532ms
3 actionable tasks: 3 executed
11:56:07 18/08/20 in /Users/antony/repos/projects/jabel
↪

@astubbs astubbs force-pushed the enable-previe-features branch from 60845a6 to 03da78c Compare August 18, 2020 11:35
@astubbs
Copy link
Author

astubbs commented Aug 18, 2020

Ok, I'm not actually sure this is needed to access preview features. I assumed from the existence of the issue, that it didn't so I dove straight in. Now I'm not so sure. I can't get it to test reliably...

@bsideup
Copy link
Owner

bsideup commented Sep 17, 2020

Hi @astubbs,

Please see my answer here:
#9 (comment)

@astubbs
Copy link
Author

astubbs commented Sep 21, 2020

Haha ok so this definitely isn't needed - let's close it :) Was a fun learning experience though!

@bsideup bsideup closed this Sep 29, 2020
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.

--enable-preview through Jabel?

2 participants