package sandbox; /** * Demonstrates how to replicate issue 235620 * https://netbeans.org/bugzilla/show_bug.cgi?id=235620 * * Steps: * * 1) in the testSomething() method, highlight the code between the two comments * 2) Copy the highlighted code using ctrl+c * 3) Place cursor in the testSomethingElse() method between the two comments * 4) Paste the copied code using ctrl+v * * This will trigger first the NPE from bug 236155, then the AssertionError from bug 235620 * * 5) then click inside the pasted method. This will trigger the IllegalArgumentException from bug 236152 * * * @author Jacob Dilles */ public class Issue235620 { static void run(Runnable r) { r.run(); } static abstract class RunnableImpl implements Runnable { public void run() { doSomething("abc"); } abstract void doSomething(String str); } public void testSomething() { // (1) start highlight here V run(new RunnableImpl() { @Override void doSomething(String str) { StringBuilder sb = new StringBuilder(); sb.append("my string =").append(str); System.out.println(sb); } }); // ^ end highlight here (1) } public void testSomethingElse() { // (3) Place cursor below this line and CTRL+V to paste //Plase cursor above this line when pasting (3) // (5) then click in the pasted code } }