-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix compilation errors with Eclipse compiler #13532
Conversation
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
@@ -296,10 +296,10 @@ public static <T> TupleDomain<T> intersect(List<? extends TupleDomain<? extends | |||
} | |||
|
|||
@SuppressWarnings("unchecked") | |||
private static <U, T extends U> TupleDomain<U> upcast(TupleDomain<T> domain) | |||
private static <T> TupleDomain<T> upcast(TupleDomain<? extends T> domain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a correct simplification.
Was the original code an incorrect Java, according to JLS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compiler complained about the usage:
The method upcast(TupleDomain<T>) in the type TupleDomain<T> is not applicable for the arguments (capture#20-of ? extends TupleDomain<? extends T>)
so it couldn't infer the U type, I'm not sure, if ECJ is too limited, or Javac is more lazy in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with this particular change. In the past, I've seen ECJ having problems where it shouldn't. I don't have any recent experience with this compiler.
Is there any reason you want to use ECJ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because this is what Eclipse is using,and a bit annoying that I can't start the app, without fixing the errors 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it possible to configure Eclipse to use javac as a compiler?
Re package names -- airlift/airbase#321 (it looks like it's valid Java to have |
@@ -402,7 +402,7 @@ public static boolean dynamicFilter(@SqlType("T") double input, @SqlType(VARCHAR | |||
{ | |||
private NullableFunction() {} | |||
|
|||
private static final String NAME = "$internal$dynamic_filter_nullable_function"; | |||
protected static final String NAME = "$internal$dynamic_filter_nullable_function"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
The class has no subclasses. Did you mean to make it package private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, package private would work as well.
154e062
to
d3d771b
Compare
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
Let's structure this in the following commits
I am not sure what to do about Also, when using Eclipse, do you have a choice which compiler to build with? E.g. can you delegate the build to maven / javac? (BTW we recommend IntelliJ for development) |
I think, there are a couple of issues around the visibility rules in ECJ and Javac, and in this case, ECJ has the less problem.
But, this is only a compilation error in ECJ - Javac is inconsistent
Interestingly, this works in both :
however, if we write this:
this fails in ECJ - which definitely looks bad. |
d3d771b
to
a4bc00a
Compare
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
a4bc00a
to
6d02453
Compare
6d02453
to
6c5e83f
Compare
For me, it's unclear why these tests are failing, I suspect this is independent from the changes. |
It indeed looks unrelated and is a flaky test.
Click to see full stack trace
|
Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In "Fix package declaration for TestingRedirectHandlerInjector":
TestingRedirectHandlerInjector
is placed in correct folder - just the package declaration is wrong. So instead of changing the path to the file the first commit should just change package io.trino.jdbc
to package io.trino.tests.product.jdbc
.
Looks good other than that.
26e866e
to
48b2f43
Compare
@gzsombor In case you're still pushing can you also do following:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the changes in this PR are ok and stand on their own, but I don't think we should make changes solely for the purpose of appeasing the Eclipse compiler. It is not a goal of Trino to support compilers that don't follow the JLS closely, and we can't guarantee that certain changes won't inadvertently be rolled back or new incompatibilities introduced in the future.
@@ -402,7 +402,7 @@ public static boolean dynamicFilter(@SqlType("T") double input, @SqlType(VARCHAR | |||
{ | |||
private NullableFunction() {} | |||
|
|||
private static final String NAME = "$internal$dynamic_filter_nullable_function"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading the JLS correctly, this seems to be a bug in the Eclipse compiler:
A member (class, interface, field, or method) of a class, interface, type parameter,
or reference type, or a constructor of a class, is accessible only if (i) the class, interface, type parameter, or reference type is accessible, and (ii) the member or
constructor is declared to permit access:
[...]
– Otherwise, the member or constructor is declared private. Access is
permitted only when the access occurs from within the body of the top level
class or interface that encloses the declaration of the member or constructor.
and
The body of a class declares members (fields, methods, classes, and interfaces),
instance and static initializers, and constructors (§8.1.7).
@@ -296,10 +296,10 @@ public static <T> TupleDomain<T> intersect(List<? extends TupleDomain<? extends | |||
} | |||
|
|||
@SuppressWarnings("unchecked") | |||
private static <U, T extends U> TupleDomain<U> upcast(TupleDomain<T> domain) | |||
private static <T> TupleDomain<T> upcast(TupleDomain<? extends T> domain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it possible to configure Eclipse to use javac as a compiler?
48b2f43
to
8707da9
Compare
Yes, you are right, the constant visibility problem is more of an eclipse bug - it seems that in the Java 6 era, Javac had a similar bug, and this is when this logic was introduced, to be compatible with that old Javac. |
This is equivalent and shorter. This also fixes compilation problem when compiling with ECJ.
8707da9
to
fe2676d
Compare
Description
The Eclipse compiler seems to be more picky about things, like the package declaration and the places of the file, etc.
This patch tries to address these issues.
Related issues, pull requests, and links
Documentation
( ) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
( ) No release notes entries required.
( ) Release notes entries required with the following suggested text: