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 269895 - VarHandle compareAndSet compiles and runs on commandline Java 9 fails at runtime under NetBeans 8.2
Summary: VarHandle compareAndSet compiles and runs on commandline Java 9 fails at runt...
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Platform (show other bugs)
Version: 8.2
Hardware: PC Mac OS X
: P3 normal (vote)
Assignee: Tomas Zezula
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-22 08:55 UTC by KnobbyClarke
Modified: 2017-02-22 08:55 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 KnobbyClarke 2017-02-22 08:55:17 UTC
public class Foo {
   int i;
   
   public void body(){
       System.out.println("i=" + i);
       Bar.VH_FOO_FIELD_I.compareAndSet(this, 0, 1);
       System.out.println("i=" + i);
   }
   
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Foo f = new Foo();
        f.body();     
    }   
}
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;

/**
 *
 * @author davidclarke
 */
public class Bar {
     public static final VarHandle VH_FOO_FIELD_I;

    static {
        try {
            VH_FOO_FIELD_I = MethodHandles.lookup().
                in(Foo.class).
                findVarHandle(Foo.class, "i", int.class);
        } catch (Exception e) {
            throw new Error(e);
        }
    }   
}
Compiles and runs OK from command line gives
Exception in thread "main" java.lang.invoke.WrongMethodTypeException: cannot convert MethodHandle(VarHandle,Foo,int,int)boolean to (VarHandle,Object[])boolean
	at java.base/java.lang.invoke.MethodHandle.asTypeUncached(MethodHandle.java:785)
	at java.base/java.lang.invoke.MethodHandle.asType(MethodHandle.java:771)
	at java.base/java.lang.invoke.Invokers.checkVarHandleGenericType(Invokers.java:450)
	at au.com.wcc.vectors.Foo.body(Foo.java:19)
	at au.com.wcc.vectors.Foo.main(Foo.java:28)
under NetBeans

NetBeans etc/netbeans.conf edited to use Java 8 to load (else it just quits).