Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 201781 - Unable to run method handles code in NetBeans IDE 7.1 nightly build
Unable to run method handles code in NetBeans IDE 7.1 nightly build
Status: RESOLVED FIXED
Product: java
Classification: Unclassified
Component: Editor
7.1
PC Windows 7
: P2 (vote)
: 7.1
Assigned To: Dusan Balek
issues@java
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-09-07 21:40 UTC by aruld
Modified: 2011-09-22 14:51 UTC (History)
0 users

See Also:
Issue Type: DEFECT
:


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.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo