This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 201781 - Unable to run method handles code in NetBeans IDE 7.1 nightly build
Summary: Unable to run method handles code in NetBeans IDE 7.1 nightly build
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.1
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-07 21:40 UTC by aruld
Modified: 2011-09-22 14:51 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description aruld 2011-09-07 21:40:33 UTC
[ BUILD # : 201109070600 ]
[ JDK VERSION : 1.7 ]

The following Method handle test fails to run in NetBeans IDE 7.1 9/7 build:

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles.Lookup;
import static java.lang.invoke.MethodHandles.lookup;
import static java.lang.invoke.MethodType.methodType;

public class MethodHandleTest {
  public static void main(String... args) throws Throwable {
    methodHandleTest();
  }

  private static void methodHandleTest() throws Throwable {
    final Lookup lookup = lookup();
    MethodHandle multiply = lookup.findStatic(MethodHandleTest.class, "add",
methodType(int.class, int.class, int.class));
    System.out.println(multiply.invoke(3, 2)); // should print 5
  }

  public static int add(int i, int j) {
    return i + j;
  }

}

The exception I get is:

Exception in thread "main" java.lang.invoke.WrongMethodTypeException: cannot
convert MethodHandle(int,int)int to (Object[])Object
	at java.lang.invoke.MethodHandle.asType(MethodHandle.java:691)
	at java.lang.invoke.InvokeGeneric.dispatch(InvokeGeneric.java:103)
	at
java.lang.invoke.InvokeGeneric.dispatchWithConversion(InvokeGeneric.java:117)
	at perf.MethodHandleTest.methodHandleTest(MethodHandleTest.java:32)
	at perf.MethodHandleTest.main(MethodHandleTest.java:26)
Java Result: 1


This is a valid code and runs outside NetBeans IDE just fine.
Comment 1 Jan Lahoda 2011-09-18 19:40:49 UTC
Actually, I think the IDE can compile the code fine. The problem is that the code is OK with source level >= 1.7, but fails with that exception with source level <= 1.6 (in both cases this happens both inside and outside the IDE). The problem seems to be that when a source level changes, the project is not automatically reindexed - it is reindexed after a change in the given source root (or at the next IDE start/project reopening). As it is possible to listen on source level changes now, JavaCustomIndex (APTUtils?) should probably listen on them.
Comment 2 Dusan Balek 2011-09-20 12:35:25 UTC
Fixed in jet-main.

http://hg.netbeans.org/jet-main/rev/cf04f68bdb8c
Comment 3 Quality Engineering 2011-09-22 14:51:26 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/cf04f68bdb8c
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #201781: Unable to run method handles code in NetBeans IDE 7.1 nightly build - fixed.