New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

val inside Java7 try-with-resources does not work with Javac #555

Closed
lombokissues opened this Issue Jul 14, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@lombokissues
Collaborator

lombokissues commented Jul 14, 2015

Migrated from Google Code (issue 520)

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

👤 andrii.rubtsov   🕗 May 20, 2013 at 11:32 UTC

What steps will reproduce the problem?
import java.io.ByteArrayInputStream;
import java.io.IOException;
import lombok.val;

public class ValInsideTryWithResources {
public static void main(String[] args) throws IOException {
try (val is = new ByteArrayInputStream("test".getBytes())) {
}
}
}

What is the expected output? What do you see instead?
Compilation fails under "javac" (maven). Code works when compiled/executed from Eclipse.
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ lombok-test ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1251, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\workspace\lombok-test\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/workspace/lombok-test/src/main/java/ValInsideTryWithResources.java:[10,23] incompatible types
required: lombok.val
found: java.io.ByteArrayInputStream
[ERROR] /D:/workspace/lombok-test/src/main/java/ValInsideTryWithResources.java:[10,18] try-with-resources not applicable to variable type
required: java.lang.AutoCloseable
found: lombok.val
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.271s
[INFO] Finished at: Mon May 20 13:37:28 EEST 2013
[INFO] Final Memory: 11M/154M

What version of the product are you using? On what operating system?
0.11.8
Win7 x 64
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

Collaborator

lombokissues commented Jul 14, 2015

👤 andrii.rubtsov   🕗 May 20, 2013 at 11:32 UTC

What steps will reproduce the problem?
import java.io.ByteArrayInputStream;
import java.io.IOException;
import lombok.val;

public class ValInsideTryWithResources {
public static void main(String[] args) throws IOException {
try (val is = new ByteArrayInputStream("test".getBytes())) {
}
}
}

What is the expected output? What do you see instead?
Compilation fails under "javac" (maven). Code works when compiled/executed from Eclipse.
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ lombok-test ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1251, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\workspace\lombok-test\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/workspace/lombok-test/src/main/java/ValInsideTryWithResources.java:[10,23] incompatible types
required: lombok.val
found: java.io.ByteArrayInputStream
[ERROR] /D:/workspace/lombok-test/src/main/java/ValInsideTryWithResources.java:[10,18] try-with-resources not applicable to variable type
required: java.lang.AutoCloseable
found: lombok.val
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.271s
[INFO] Finished at: Mon May 20 13:37:28 EEST 2013
[INFO] Final Memory: 11M/154M

What version of the product are you using? On what operating system?
0.11.8
Win7 x 64
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

👤 askoning   🕗 May 20, 2013 at 15:06 UTC

Confirmed in 0.11.7 with commandline javac (OpenJDK 1.7.0_15).

Collaborator

lombokissues commented Jul 14, 2015

👤 askoning   🕗 May 20, 2013 at 15:06 UTC

Confirmed in 0.11.7 with commandline javac (OpenJDK 1.7.0_15).

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

👤 reinierz   🕗 May 23, 2013 at 23:04 UTC

Good catch (heh). We fixed it and it'll be in the next major lombok release. If you can't wait, there's an edge release that has the bug fixed: https://projectlombok.org/download-edge.html

Collaborator

lombokissues commented Jul 14, 2015

👤 reinierz   🕗 May 23, 2013 at 23:04 UTC

Good catch (heh). We fixed it and it'll be in the next major lombok release. If you can't wait, there's an edge release that has the bug fixed: https://projectlombok.org/download-edge.html

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

👤 andrii.rubtsov   🕗 May 28, 2013 at 11:31 UTC

Thanks for prompt reaction

Collaborator

lombokissues commented Jul 14, 2015

👤 andrii.rubtsov   🕗 May 28, 2013 at 11:31 UTC

Thanks for prompt reaction

@lombokissues

This comment has been minimized.

Show comment
Hide comment
@lombokissues

lombokissues Jul 14, 2015

Collaborator

End of migration

Collaborator

lombokissues commented Jul 14, 2015

End of migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment