Skip to content
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

Lack of com.kohlschutter:compiler-annotations dependency leads to compiler warnings #129

Closed
norrisjeremy opened this issue Feb 16, 2023 · 3 comments
Labels
dependencies Pull requests that update a dependency file has workaround There is a workaround available to prevent the issue or reduce its impact information needed More information is required

Comments

@norrisjeremy
Copy link

norrisjeremy commented Feb 16, 2023

Describe the bug
The com.kohlschutter:compiler-annotations needs to be declared as a full dependency, not just a provided scope dependency, else it leads to compiler warnings when -Xlint:all is enabled, like this in downstream projects that use junixsocket:

[WARNING] COMPILATION WARNING : 
[INFO] -------------------------------------------------------------
[WARNING] Cannot find annotation method 'value()' in type 'com.kohlschutter.annotations.compiletime.SuppressFBWarnings': class file for com.kohlschutter.annotations.compiletime.SuppressFBWarnings not found
[WARNING] Cannot find annotation method 'value()' in type 'com.kohlschutter.annotations.compiletime.SuppressFBWarnings'
[WARNING] Cannot find annotation method 'value()' in type 'com.kohlschutter.annotations.compiletime.SuppressFBWarnings'
[WARNING] Cannot find annotation method 'value()' in type 'com.kohlschutter.annotations.compiletime.SuppressFBWarnings'
[INFO] 4 warnings 
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /.../jsch/src/main/java/com/jcraft/jsch/JUnixSocketFactory.java: warnings found and -Werror specified
[INFO] 1 error

Guava faced a similar issue several years ago, see google/guava#2721.

This happens because maven does not pull in a transient dependency for com.kohlschutter:compiler-annotations (since it is marked with as a provided scope dependency of com.kohlschutter.junixsocket:junixsocket-common).

This has forced us to explicitly declare a direct dependency on com.kohlschutter:compiler-annotations over at https://github.com/mwiede/jsch, since we enable -Xlint:all -Werror in our javac flags.

We would rather not have to declare an explicit dependency on com.kohlschutter:compiler-annotations since we aren't actually directly utilizing any of these annotations in the JSch code.

To Reproduce

$ cat Foo.java
public class Foo {
  public void foo() throws Exception {
    var foo = org.newsclub.net.unix.AFUNIXSocketChannel.open();
  }
}
$ javac -Xlint:all -Werror -cp junixsocket-common-2.6.2.jar Foo.java
junixsocket-common-2.6.2.jar(/org/newsclub/net/unix/AFSocketChannel.class): warning: Cannot find annotation method 'value()' in type 'SuppressFBWarnings': class file for com.kohlschutter.annotations.compiletime.SuppressFBWarnings not found
junixsocket-common-2.6.2.jar(/org/newsclub/net/unix/AFSocketChannel.class): warning: Cannot find annotation method 'value()' in type 'SuppressFBWarnings'
error: warnings found and -Werror specified
1 error
2 warnings

Expected behavior
Project to compile successfully.

Output/Screenshots

[WARNING] COMPILATION WARNING : 
[INFO] -------------------------------------------------------------
[WARNING] Cannot find annotation method 'value()' in type 'com.kohlschutter.annotations.compiletime.SuppressFBWarnings': class file for com.kohlschutter.annotations.compiletime.SuppressFBWarnings not found
[WARNING] Cannot find annotation method 'value()' in type 'com.kohlschutter.annotations.compiletime.SuppressFBWarnings'
[WARNING] Cannot find annotation method 'value()' in type 'com.kohlschutter.annotations.compiletime.SuppressFBWarnings'
[WARNING] Cannot find annotation method 'value()' in type 'com.kohlschutter.annotations.compiletime.SuppressFBWarnings'
[INFO] 4 warnings 
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /.../jsch/src/main/java/com/jcraft/jsch/JUnixSocketFactory.java: warnings found and -Werror specified
[INFO] 1 error

Environment (please complete the following information):

  • OS: n/a
  • Distribution: n/a
  • Version: n/a

Notes
https://github.com/mwiede/jsch/blob/master/pom.xml#L96
https://github.com/mwiede/jsch/blob/master/pom.xml#L101
google/guava#2721

Lastly, please make sure to test the problem still occurs on the latest version of junixsocket
Yes, this occurs with current 2.6.2 release.

@norrisjeremy
Copy link
Author

FYI, it appears that using disabling classfile type warnings (-Xlint:all,-classfile) seems to workaround this issue.

@kohlschuetter
Copy link
Member

Thanks for bringing this up, @norrisjeremy !

I'm reluctant to add compiler-annotations as a full dependency, mostly because these annotations are supposed to be specific to compiling the class files/building the project. The fact that they get exported to users of the junixsocket library is actually undesired, but deemed acceptable.

How much of a problem is this to you, now that you have a workaround?
I'm asking because a proper fix is actually far from being straightforward (with including compiler-annotations as a dependency not being an option at all).

@kohlschuetter kohlschuetter added information needed More information is required has workaround There is a workaround available to prevent the issue or reduce its impact dependencies Pull requests that update a dependency file labels Feb 18, 2023
@norrisjeremy
Copy link
Author

Hi @kohlschuetter,

I think disabling the classfile warnings will suffice for us, thanks!

Thanks,
Jeremy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file has workaround There is a workaround available to prevent the issue or reduce its impact information needed More information is required
Projects
None yet
Development

No branches or pull requests

2 participants