Community
Participate
Working Groups
Created attachment 282736 [details] Minimal example to demonstrate issue. The following example raises an IllegalArgumentException when compiled under Eclipse and NonVisibleLambda is run. No IllegalArgumentException is raised when compiled with javac and run. stack trace: Exception in thread "main" java.lang.BootstrapMethodError: java.lang.IllegalAccessError: tried to access class some.other.pkg.AbstractFoo$AbstractFooBuilder from class some.pkg.NonVisibleLambda at some.pkg.NonVisibleLambda.main(NonVisibleLambda.java:13) Caused by: java.lang.IllegalAccessError: tried to access class some.other.pkg.AbstractFoo$AbstractFooBuilder from class some.pkg.NonVisibleLambda ... 1 more ------------------------------- some/pkg/NonVisibleLambda.java ------------------------------- package some.pkg; import java.util.stream.Stream; import some.other.pkg.ShinyFoo; import some.other.pkg.ShinyFoo.ShinyFooBuilder; public class NonVisibleLambda { public static void main( final String[] args ) { final ShinyFooBuilder builder = ShinyFoo.builder(); Stream.of( "hello", "hola", "hallo", "bonjour" ).forEach( builder::bar ); builder.baz( "world" ).build().foo(); } } ------------------------------- some/other/pkg/AbstractFoo.java ------------------------------- package some.other.pkg; import java.util.ArrayList; import java.util.List; abstract class AbstractFoo { protected final List<String> bars; protected AbstractFoo( final AbstractFooBuilder<?, ?> builder ) { bars = builder.bars; } abstract void foo(); static abstract class AbstractFooBuilder<T extends AbstractFoo, B extends AbstractFooBuilder<T, B>> { private final List<String> bars = new ArrayList<>();; public B bar( final String bar ) { bars.add( bar ); return getThis(); } protected B getThis() { return (B)this; } protected abstract T build(); } } ------------------------------- some/other/pkg/ShinyFoo.java ------------------------------- package some.other.pkg; import static java.util.stream.Collectors.joining; public class ShinyFoo extends AbstractFoo { public static ShinyFooBuilder builder() { return new ShinyFooBuilder(); } private final String baz; private ShinyFoo( final ShinyFooBuilder builder ) { super( builder ); baz = builder.baz; } @Override public void foo() { System.out.println( bars.stream().collect( joining( ", ") ) + ", " + baz + "!" ); } public static class ShinyFooBuilder extends AbstractFooBuilder<ShinyFoo, ShinyFooBuilder> { private String baz; public ShinyFooBuilder baz( final String baz ) { this.baz = baz; return getThis(); } @Override public ShinyFoo build() { return new ShinyFoo( this ); } } } If the method being referenced by method refernce (i.e. some/other/pkg/AbstractFoo.AbstractFooBuilder.bar(...)): public B bar( final String bar ) { bars.add( bar ); return getThis(); } is changed to public void bar( final String bar ) { bars.add( bar ); } i.e. no return type, then no exception is raised. Changing the method reference to an expression i.e. builder::foo to s -> builder.foo( s ) is the workaround at present. Version information: Eclipse IDE for Java Developers Version: 2020-03 (4.15.0) Build id: 20200313-1211 Eclipse Java Development Tools Version: 3.18.300.v20200305-0155 Build id: I20200305-0155 openjdk version "1.8.0_252" OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_252-b09) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.252-b09, mixed mode) javac 1.8.0_252 Windows 10 64-bit Microsoft Windows Verion 1909 (OS Build 18363.657) n.b. this it NOT a duplicate of https://bugs.eclipse.org/bugs/show_bug.cgi?id=480930 but looks very similar. Bug 480930 had no return type on the method reference - this one does.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
I could reproduce the problem with the latest build. Note: Can not move to "Core", due to Github migration.