changeset 55890:256be3515a30 intrinsics-project

adapting to the new constant pool API
author vromero
date Mon, 22 Apr 2019 15:35:22 -0400
parents 18b81ba7105e
children 8958d42ac38e
files src/java.base/share/classes/java/util/Formatter.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/IntrinsicsVisitor.java
diffstat 2 files changed, 30 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/util/Formatter.java	Wed Apr 17 19:31:12 2019 +0200
+++ b/src/java.base/share/classes/java/util/Formatter.java	Mon Apr 22 15:35:22 2019 -0400
@@ -2765,7 +2765,7 @@
         if (arg == null)
             print(spec, "null", l);
         else if (arg instanceof Float)
-            print(spec, ((Double) arg).floatValue(), l);
+            print(spec, ((Float) arg).floatValue(), l);
         else if (arg instanceof Double)
             print(spec, ((Double) arg).doubleValue(), l);
         else if (arg instanceof BigDecimal)
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/IntrinsicsVisitor.java	Wed Apr 17 19:31:12 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/IntrinsicsVisitor.java	Mon Apr 22 15:35:22 2019 -0400
@@ -37,6 +37,7 @@
 import com.sun.tools.javac.intrinsics.Intrinsics;
 import com.sun.tools.javac.intrinsics.IntrinsicProcessor.Result;
 import com.sun.tools.javac.jvm.ClassFile;
+import com.sun.tools.javac.jvm.PoolConstant;
 import com.sun.tools.javac.tree.JCTree.JCExpression;
 import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
 import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
@@ -305,13 +306,13 @@
                     syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs));
             Symbol bsm = rs.resolveQualifiedMethod(pos, attrEnv, site,
                     bsmName, bsm_staticArgs, List.nil());
+            PoolConstant.LoadableConstant[] loadableConstantsArr = objToLoadableConstantArr(staticArgs);
             DynamicMethodSymbol dynSym =
                     new DynamicMethodSymbol(methName,
                             syms.noSymbol,
-                            ClassFile.REF_invokeStatic,
-                            (MethodSymbol)bsm,
+                            ((MethodSymbol)bsm).asHandle(),
                             indyType,
-                            staticArgs.toArray());
+                            loadableConstantsArr);
 
             JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName);
             qualifier.sym = dynSym;
@@ -354,6 +355,31 @@
         }
     }
 
+    private PoolConstant.LoadableConstant[] objToLoadableConstantArr(List<Object> args) {
+        PoolConstant.LoadableConstant[] loadableConstants = new PoolConstant.LoadableConstant[args.size()];
+        int index = 0;
+        for (Object arg : args) {
+            loadableConstants[index++] = objToLoadableConstant(arg);
+        }
+        return loadableConstants;
+    }
+
+    PoolConstant.LoadableConstant objToLoadableConstant(Object o) {
+        if (o instanceof Integer) {
+            return PoolConstant.LoadableConstant.Int((int)o);
+        } else if (o instanceof Float) {
+            return PoolConstant.LoadableConstant.Float((float)o);
+        } else if (o instanceof Long) {
+            return PoolConstant.LoadableConstant.Long((long)o);
+        } else if (o instanceof Double) {
+            return PoolConstant.LoadableConstant.Double((double)o);
+        } else if (o instanceof String) {
+            return PoolConstant.LoadableConstant.String((String)o);
+        } else {
+            throw new AssertionError("unexpected constant: " + o);
+        }
+    }
+
     private String signature(Type type) {
         SignatureGenerator generator = new SignatureGenerator();
         generator.assembleSig(type.getTag() == BOT ? syms.objectType : type);