Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8156453 | 8u111 | David Buck | P3 | Resolved | Fixed | b01 |
JDK-8152643 | 8u102 | Abhijit Roy | P3 | Resolved | Fixed | b02 |
JDK-8162329 | emb-8u111 | David Buck | P3 | Resolved | Fixed | b01 |
A DESCRIPTION OF THE PROBLEM :
Javac shouldn't allow referencing a method that is out of scope. Either it should produce a compile-time error or it should desugar as in the lambda equivalent.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create default-scoped abstract class with concrete method
2) Create a concrete public class extending the above class in the same package
3) Use a method reference to this inherited method in a class outside of the package
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Either
A) compiles the same as map(y -> y.getX())
B) compile-time error
ACTUAL -
IllegalAccessError at runtime
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package x;
abstract class X {
public String getX() { return "x";}
package x;
public class Y extends X {}
package z;
public class Z {
public static void main (String[] args) {
Arrays.asList(new Y()).stream().map(Y::getX).forEach(System.out::println);
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use lambda form
- backported by
-
JDK-8152643 Javac compiles method reference that allows results in an IllegalAccessError
-
- Resolved
-
-
JDK-8156453 Javac compiles method reference that allows results in an IllegalAccessError
-
- Resolved
-
-
JDK-8162329 Javac compiles method reference that allows results in an IllegalAccessError
-
- Resolved
-
- duplicates
-
JDK-8152410 IllegalAccessError when using a public method reference of a package-private class through a public subclass from another package
-
- Closed
-
-
JDK-8155803 Method reference can emit bytecode pointing at non-visible base types
-
- Closed
-
- relates to
-
JDK-8059632 Method reference compilation uses incorrect qualifying type
-
- Resolved
-