RFR 8183938: [MVT] Add test for mock vector API

Paul Sandoz paul.sandoz at oracle.com
Thu Jul 6 15:03:49 UTC 2017


Yes, i will take a look, don’t let this block pushing what you have.

Paul.

> On 6 Jul 2017, at 08:00, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
> 
> unreflectWithers fails with NPE:
> 
> n error occurred while instantiating class VectorTest: java.lang.NullPointerException
>    at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:393)
>    at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:295)
>    at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:117)
>    at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:183)
>    at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:128)
>    at org.testng.TestRunner.initMethods(TestRunner.java:415)
>    at org.testng.TestRunner.init(TestRunner.java:241)
>    at org.testng.TestRunner.init(TestRunner.java:211)
>    at org.testng.TestRunner.<init>(TestRunner.java:158)
>    at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:545)
>    at org.testng.SuiteRunner.init(SuiteRunner.java:159)
>    at org.testng.SuiteRunner.<init>(SuiteRunner.java:114)
>    at org.testng.TestNG.createSuiteRunner(TestNG.java:1260)
>    at org.testng.TestNG.createSuiteRunners(TestNG.java:1247)
>    at org.testng.TestNG.runSuitesLocally(TestNG.java:1101)
>    at org.testng.TestNG.run(TestNG.java:1018)
>    at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:94)
>    at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:54)
>    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>    at java.base/java.lang.reflect.Method.invoke(Method.java:563)
>    at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:115)
>    at java.base/java.lang.Thread.run(Thread.java:844)
> Caused by: java.lang.Error: java.lang.NullPointerException
>    at VectorUtils.valueFactory(VectorUtils.java:111)
>    at Long2.<clinit>(Long2.java:16)
>    at VectorLibrary$L2.<clinit>(VectorLibrary.java:17)
>    at VectorTest.<clinit>(VectorTest.java:33)
>    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:487)
>    at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
>    at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:382)
>    ... 23 more
> Caused by: java.lang.NullPointerException
>    at java.base/jdk.experimental.bytecode.BasicClassBuilder$BasicTypeHelper.tag(BasicClassBuilder.java:582)
>    at java.base/jdk.experimental.value.MethodHandleBuilder$IsolatedMethodBuilder$IsolatedMethodTypeHelper.tag(MethodHandleBuilder.java:183)
>    at java.base/jdk.experimental.value.MethodHandleBuilder$IsolatedMethodBuilder$IsolatedMethodTypeHelper.tag(MethodHandleBuilder.java:123)
>    at java.base/jdk.experimental.bytecode.TypedCodeBuilder.load(TypedCodeBuilder.java:984)
>    at java.base/jdk.experimental.value.ValueType.lambda$unreflectWithers$4(ValueType.java:326)
>    at java.base/jdk.experimental.bytecode.MethodBuilder.withCode(MethodBuilder.java:50)
>    at java.base/jdk.experimental.value.MethodHandleBuilder.lambda$loadCode$1(MethodHandleBuilder.java:94)
>    at java.base/jdk.experimental.bytecode.ClassBuilder.withMethod(ClassBuilder.java:103)
>    at java.base/jdk.experimental.value.MethodHandleBuilder.loadCode(MethodHandleBuilder.java:92)
>    at java.base/jdk.experimental.value.MethodHandleBuilder.loadCode(MethodHandleBuilder.java:70)
>    at java.base/jdk.experimental.value.MethodHandleBuilder.loadCode(MethodHandleBuilder.java:66)
>    at java.base/jdk.experimental.value.ValueType.unreflectWithers(ValueType.java:314)
>    at VectorUtils.valueFactory(VectorUtils.java:109)
>    ... 32 more
> 
> 
> I think the cause is that unreflect wither is failing to handle double slots ('i' is always incremented by one).
> 
> Can you please take a look?
> 
> Thanks
> Maurizio
> 
> 
> On 06/07/17 15:41, Paul Sandoz wrote:
>>> On 6 Jul 2017, at 06:28, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
>>> 
>>> Hi,
>>> this changeset adds the mock vector API test that Vlad has worked on. I cleaned it up a bit and converted to a working testng test.
>>> 
>>> http://cr.openjdk.java.net/~mcimadamore/8183938/
>>> 
>> Looks good. Minor stuff:
>> 
>> Utils
>> --
>> 
>>   33     // Copied from jdk.experimental.value.ValueType
>>   34     public static Field[] valueFields(ValueType vt) {
>>   35         int valFieldMask = Modifier.FINAL;
>>   36         return Stream.of(vt.sourceClass().getDeclaredFields())
>>   37                 .filter(f -> (f.getModifiers() & (valFieldMask | Modifier.STATIC)) == valFieldMask)
>>   38                 .toArray(Field[]::new);
>>   39     }
>> 
>> There is now a public method on ValueType to obtain the value fields, but also see the following.
>> 
>> 
>> VectorUtils
>>>> 
>>  106     static MethodHandle valueFactory(Class<?> vcc, MethodHandles.Lookup lookup) {
>> 
>> This method could be removed and calls replaced with the unreflectWithers, or probably better is to replace the implementation with unreflectWithers.
>> 
>> Since your Point test already has a combo constructor i think we have this case covered.
>> 
>> Paul.
> 



More information about the valhalla-dev mailing list