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

[BUG] Bug in Eclipse when passing a ternary operator with method references to an extension method #3153

Closed
javier-godoy opened this issue Mar 28, 2022 · 0 comments · Fixed by #3155
Assignees
Labels
accepted The issue/enhancement is valid, sensible, and explained in sufficient detail bug eclipse

Comments

@javier-godoy
Copy link

Describe the bug
Trying to use a ternary operator with arguments that are method references, as parameter to an @ExtensionMethod did not work.

foobar.setPredicate(value?Bar::isBaz:null);

To Reproduce

public class FooExtensions<T> {}
	public static <T> void setPredicate(Foo<T> foo, SerializablePredicate<T> predicate) {}
}

public class Foo<T> {}

@Getter
@Setter
public class Bar {
  boolean baz;
}

@ExtensionMethod(FooExtensions.class)
public class Test {

  void setPredicate(Foo<Bar> foobar, boolean value) {
	foobar.setPredicate(value?Bar::isBaz:null);		
  }

}

Compiling with javac succeeds.

As a workaround for Eclipse, replacing the ternary expression with separate calls foobar.setPredicate(Bar::isBaz); and foobar.setPredicate(null); compiles fine (per #2741).

If you have stack traces or error messages please include all of them

!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ui".
Java Model Exception: java.lang.NullPointerException

!ENTRY org.eclipse.jdt.ui 4 0 2022-03-28 16:50:09.417
!MESSAGE Error in JDT Core during reconcile
!STACK 1
Java Model Exception: java.lang.NullPointerException
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:326)
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:348)
	at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:193)
	at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:94)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:740)
	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:806)
	at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1319)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:131)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:93)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:90)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:157)
	at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:94)
	at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:107)
	at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:76)
	at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:210)
Caused by: java.lang.NullPointerException
Caused by: java.lang.NullPointerException
!SUBENTRY 1 org.eclipse.jdt.core 4 1005 2022-03-28 16:50:09.417
!MESSAGE java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException

Expected behavior

I expect foobar.setPredicate(value?Bar::isBaz:null); to compile when using Eclipse 2021-09.

Version info (please complete the following information):

  • Lombok version: 1.18.22
  • Platform: Eclipse 2021-09 (4.21.0)
@Rawi01 Rawi01 self-assigned this Mar 29, 2022
@Rawi01 Rawi01 added bug eclipse accepted The issue/enhancement is valid, sensible, and explained in sufficient detail labels Mar 29, 2022
Rawi01 added a commit to Rawi01/lombok that referenced this issue Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted The issue/enhancement is valid, sensible, and explained in sufficient detail bug eclipse
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants