changeset 50936:0001cbfdf09b jep-334

minor changes to j.l.Wrapper, j.l.c.ConstantClassDesc
author vromero
date Thu, 07 Jun 2018 12:21:54 -0700
parents 3d99fff7aea5
children a2438bc09010
files src/java.base/share/classes/java/lang/Class.java src/java.base/share/classes/java/lang/constant/ConstantClassDesc.java src/java.base/share/classes/sun/invoke/util/Wrapper.java
diffstat 3 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/Class.java	Tue Jun 05 17:31:57 2018 -0700
+++ b/src/java.base/share/classes/java/lang/Class.java	Thu Jun 07 12:21:54 2018 -0700
@@ -3868,7 +3868,7 @@
     @Override
     public String descriptorString() {
         if (isPrimitive())
-            return new String(new char[] {Wrapper.forPrimitiveType(this).basicTypeChar()});
+            return Wrapper.forPrimitiveType(this).basicTypeString();
         else if (isArray()) {
             return "[" + componentType.descriptorString();
         }
--- a/src/java.base/share/classes/java/lang/constant/ConstantClassDesc.java	Tue Jun 05 17:31:57 2018 -0700
+++ b/src/java.base/share/classes/java/lang/constant/ConstantClassDesc.java	Thu Jun 07 12:21:54 2018 -0700
@@ -112,12 +112,12 @@
         if (o == null || getClass() != o.getClass()) return false;
 
         ClassDesc constant = (ClassDesc) o;
-        return Objects.equals(descriptor, constant.descriptorString());
+        return descriptor.equals(constant.descriptorString());
     }
 
     @Override
     public int hashCode() {
-        return descriptor != null ? descriptor.hashCode() : 0;
+        return descriptor.hashCode();
     }
 
     @Override
--- a/src/java.base/share/classes/sun/invoke/util/Wrapper.java	Tue Jun 05 17:31:57 2018 -0700
+++ b/src/java.base/share/classes/sun/invoke/util/Wrapper.java	Thu Jun 07 12:21:54 2018 -0700
@@ -47,6 +47,7 @@
     private final Class<?> wrapperType;
     private final Class<?> primitiveType;
     private final char     basicTypeChar;
+    private final String   basicTypeString;
     private final Object   emptyArray;
     private final int      format;
     private final String   wrapperSimpleName;
@@ -56,6 +57,7 @@
         this.wrapperType = wtype;
         this.primitiveType = ptype;
         this.basicTypeChar = tchar;
+        this.basicTypeString = new String(new char[] {this.basicTypeChar});
         this.emptyArray = emptyArray;
         this.format = format;
         this.wrapperSimpleName = wtypeName;
@@ -459,6 +461,11 @@
      */
     public char basicTypeChar() { return basicTypeChar; }
 
+    /** What is the bytecode signature string for this wrapper's
+     *  primitive type?
+     */
+    public String basicTypeString() { return basicTypeString; }
+
     /** What is the simple name of the wrapper type?
      */
     public String wrapperSimpleName() { return wrapperSimpleName; }
@@ -581,9 +588,8 @@
      * Returns null for {@code VOID}.
      */
     public Object wrap(int x) {
-        if (basicTypeChar == 'L')  return (Integer)x;
         switch (basicTypeChar) {
-            case 'L': throw newIllegalArgumentException("cannot wrap to object type");
+            case 'L': return (Integer)x;
             case 'V': return null;
             case 'I': return Integer.valueOf(x);
             case 'J': return Long.valueOf(x);