-
Bug
-
Resolution: Unresolved
-
P4
-
11, 15, 16
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
Windows 10
AdoptOpenJDK (version 15+36) from https://adoptopenjdk.net/.
A DESCRIPTION OF THE PROBLEM :
I have a project structure as below
lib
************+
contains module-info.java as below
module lib{
exports pkg;
}
and java files as below
src -> time
-> Time.java
public final class Time extends AbstractTime {
}
time.internal
-> AbstractTime.java
public abstract class AbstractTime<T extends AbstractTime> {
public int compareTo(AbstractTime time) {
return 0;
}
}
while trying to access the method compareTo(AbstractTime time) from a different lib called test,
which contains module-info.java as below
module module {
requires lib;
}
public final class Main {
public static void main(String[] args) {
consumeComparator(LocalTime::compareTo); // works as expected
consumeComparator(LocalTime::compareTo); // throws IllegalAccessError
}
static void consumeComparator(Comparator<LocalTime> comparator) {}
}
Method reference is throwing an IllegalAccessError
Exception in thread "main" java.lang.IllegalAccessError: class root.Main (in module test) cannot access class time.internal.AbstractLocalTime because module time does not export time._internal to module test
at test/root.Main.main
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I have a project structure as below
lib
************+
contains module-info.java as below
module lib{
exports pkg;
}
and java files as below
src -> time
-> Time.java
public final class Time extends AbstractTime {
}
time.internal
-> AbstractTime.java
public abstract class AbstractTime<T extends AbstractTime> {
public int compareTo(AbstractTime time) {
return 0;
}
}
while trying to access the method compareTo(AbstractTime time) from a different lib called test,
which contains module-info.java as below
module module {
requires lib;
}
public final class Main {
public static void main(String[] args) {
consumeComparator(LocalTime::compareTo); // works as expected
consumeComparator(LocalTime::compareTo); // throws IllegalAccessError
}
static void consumeComparator(Comparator<LocalTime> comparator) {}
}
Method reference is throwing an IllegalAccessError
Exception in thread "main" java.lang.IllegalAccessError: class root.Main (in module test) cannot access class time.internal.AbstractLocalTime because module time does not export time._internal to module test
at test/root.Main.main
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both lamda and method reference should be able to call compateTo method
ACTUAL -
Method reference failed with IllegalAccessError
FREQUENCY : always
Windows 10
AdoptOpenJDK (version 15+36) from https://adoptopenjdk.net/.
A DESCRIPTION OF THE PROBLEM :
I have a project structure as below
lib
************+
contains module-info.java as below
module lib{
exports pkg;
}
and java files as below
src -> time
-> Time.java
public final class Time extends AbstractTime {
}
time.internal
-> AbstractTime.java
public abstract class AbstractTime<T extends AbstractTime> {
public int compareTo(AbstractTime time) {
return 0;
}
}
while trying to access the method compareTo(AbstractTime time) from a different lib called test,
which contains module-info.java as below
module module {
requires lib;
}
public final class Main {
public static void main(String[] args) {
consumeComparator(LocalTime::compareTo); // works as expected
consumeComparator(LocalTime::compareTo); // throws IllegalAccessError
}
static void consumeComparator(Comparator<LocalTime> comparator) {}
}
Method reference is throwing an IllegalAccessError
Exception in thread "main" java.lang.IllegalAccessError: class root.Main (in module test) cannot access class time.internal.AbstractLocalTime because module time does not export time._internal to module test
at test/root.Main.main
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I have a project structure as below
lib
************+
contains module-info.java as below
module lib{
exports pkg;
}
and java files as below
src -> time
-> Time.java
public final class Time extends AbstractTime {
}
time.internal
-> AbstractTime.java
public abstract class AbstractTime<T extends AbstractTime> {
public int compareTo(AbstractTime time) {
return 0;
}
}
while trying to access the method compareTo(AbstractTime time) from a different lib called test,
which contains module-info.java as below
module module {
requires lib;
}
public final class Main {
public static void main(String[] args) {
consumeComparator(LocalTime::compareTo); // works as expected
consumeComparator(LocalTime::compareTo); // throws IllegalAccessError
}
static void consumeComparator(Comparator<LocalTime> comparator) {}
}
Method reference is throwing an IllegalAccessError
Exception in thread "main" java.lang.IllegalAccessError: class root.Main (in module test) cannot access class time.internal.AbstractLocalTime because module time does not export time._internal to module test
at test/root.Main.main
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both lamda and method reference should be able to call compateTo method
ACTUAL -
Method reference failed with IllegalAccessError
FREQUENCY : always