Skip to content

Commit

Permalink
Merge pull request #3224 from JasonFengJ9/jdk11condyfix
Browse files Browse the repository at this point in the history
Add Java11 JPP tag to ConstantDynamic methods
  • Loading branch information
pshipton authored Oct 11, 2018
2 parents 70408e2 + d4bc38a commit d443732
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions jcl/src/java.base/share/classes/java/lang/invoke/MethodHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -812,11 +812,6 @@ private static final Class<?> fromFieldDescriptorString(String fieldDescriptor,
*/
private static final native MethodHandle getCPMethodHandleAt(Object internalRamClass, int index);

/*
* sun.reflect.ConstantPool doesn't have a getConstantDynamicAt method. This is the
* equivalent for ConstantDynamic.
*/
private static final native Object getCPConstantDynamicAt(Object internalRamClass, int index);

/**
* Get the class name from a constant pool class element, which is located
Expand All @@ -840,6 +835,13 @@ private static final Class<?> fromFieldDescriptorString(String fieldDescriptor,
private static final int BSM_NAME_ARGUMENT_INDEX = 1;
private static final int BSM_TYPE_ARGUMENT_INDEX = 2;
private static final int BSM_OPTIONAL_ARGUMENTS_START_INDEX = 3;

/*[IF Java11]*/
/*
* sun.reflect.ConstantPool doesn't have a getConstantDynamicAt method. This is the
* equivalent for ConstantDynamic.
*/
private static final native Object getCPConstantDynamicAt(Object internalRamClass, int index);

@SuppressWarnings("unused")
private static final Object resolveConstantDynamic(long j9class, String name, String fieldDescriptor, long bsmData) throws Throwable {
Expand Down Expand Up @@ -1000,6 +1002,7 @@ private static final Object resolveConstantDynamic(long j9class, String name, St

return result;
}
/*[ENDIF] Java11*/

@SuppressWarnings("unused")
private static final MethodHandle resolveInvokeDynamic(long j9class, String name, String methodDescriptor, long bsmData) throws Throwable {
Expand Down Expand Up @@ -1108,9 +1111,11 @@ private static final MethodHandle resolveInvokeDynamic(long j9class, String name
case 14:
cpEntry = getCPMethodHandleAt(internalRamClass, index);
break;
/*[IF Java11]*/
case 17:
cpEntry = getCPConstantDynamicAt(internalRamClass, index);
break;
/*[ENDIF] Java11*/
default:
// Do nothing. The null check below will throw the appropriate exception.
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/oti/vmconstantpool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
<staticmethodref class="java/lang/invoke/MethodType" name="vmResolveFromMethodDescriptorString" signature="(Ljava/lang/String;Ljava/lang/ClassLoader;Ljava/lang/Class;)Ljava/lang/invoke/MethodType;" flags="opt_methodHandle"/>
<staticmethodref class="java/lang/invoke/MethodHandle" name="sendResolveMethodHandle" signature="(ILjava/lang/Class;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/invoke/MethodHandle;" flags="opt_methodHandle"/>
<staticmethodref class="java/lang/invoke/MethodHandle" name="resolveInvokeDynamic" signature="(JLjava/lang/String;Ljava/lang/String;J)Ljava/lang/invoke/MethodHandle;" flags="opt_methodHandle"/>
<staticmethodref class="java/lang/invoke/MethodHandle" name="resolveConstantDynamic" signature="(JLjava/lang/String;Ljava/lang/String;J)Ljava/lang/Object;" flag="opt_methodHandle"/>
<staticmethodref class="java/lang/invoke/MethodHandle" name="resolveConstantDynamic" signature="(JLjava/lang/String;Ljava/lang/String;J)Ljava/lang/Object;" jcl="se11" flag="opt_methodHandle"/>
<staticmethodref class="java/lang/invoke/MethodHandle" name="invokeWithArgumentsHelper" signature="(Ljava/lang/invoke/MethodHandle;[Ljava/lang/Object;)Ljava/lang/Object;" flags="opt_methodHandle"/>
<staticmethodref class="java/lang/invoke/MethodHandle" name="constructorPlaceHolder" signature="(Ljava/lang/Object;)Ljava/lang/Object;" flags="opt_methodHandle"/>
<specialmethodref class="java/lang/invoke/MethodHandle" name="forGenericInvoke" signature="(Ljava/lang/invoke/MethodType;Z)Ljava/lang/invoke/MethodHandle;" flags="opt_methodHandle"/>
Expand Down

0 comments on commit d443732

Please sign in to comment.