--- a/dyncast.patch Mon Apr 06 03:31:44 2009 -0700
+++ b/dyncast.patch Wed Apr 29 21:04:27 2009 -0700
@@ -8,22 +8,20 @@ diff --git a/src/share/classes/com/sun/t
public final Type stringBuilderType;
public final Type cloneableType;
public final Type serializableType;
-+ public final Type voidWrapperType;
++ public final Type dynamicType;
public final Type methodHandleType;
- public final Type dynamicType;
+ public final Type invokeDynamicType;
public final Type throwableType;
-@@ -425,8 +426,11 @@
+@@ -425,6 +426,9 @@
cloneableType = enterClass("java.lang.Cloneable");
throwableType = enterClass("java.lang.Throwable");
serializableType = enterClass("java.io.Serializable");
-+ voidWrapperType = enterClass("java.lang.Void");
- methodHandleType = enterClass("java.dyn.MethodHandle");
- dynamicType = enterClass("java.dyn.Dynamic");
++ dynamicType = enterClass("java.dyn.Dynamic");
+ // interface Dynamic does *not* inherit members from Object:
+ ((ClassType)dynamicType).supertype_field = Type.noType;
+ methodHandleType = enterClass("java.dyn.MethodHandle");
+ invokeDynamicType = enterClass("java.dyn.InvokeDynamic");
errorType = enterClass("java.lang.Error");
- illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
- exceptionType = enterClass("java.lang.Exception");
diff --git a/src/share/classes/com/sun/tools/javac/code/Types.java b/src/share/classes/com/sun/tools/javac/code/Types.java
--- a/src/share/classes/com/sun/tools/javac/code/Types.java
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java
@@ -81,37 +79,39 @@ diff --git a/src/share/classes/com/sun/t
diff --git a/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/share/classes/com/sun/tools/javac/comp/Resolve.java
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java
-@@ -884,7 +884,7 @@
+@@ -884,7 +884,12 @@
}
Type restype;
if (typeargtypes.isEmpty()) {
- restype = syms.objectType;
-+ restype = syms.dynamicType;
++ if (site == syms.dynamicType)
++ // foo.bar() defaults to (Dynamic) -> Dynamic
++ restype = syms.dynamicType;
++ else
++ // InvokeDynamic.bar(foo) defaults to (typeof foo) -> Object
++ restype = syms.objectType;
} else {
restype = typeargtypes.head;
if (!typeargtypes.tail.isEmpty())
-@@ -924,9 +924,18 @@
- };
- Type implicitArgType(Type argType) {
- argType = types.erasure(argType);
-- if (argType.tag == BOT)
-- // nulls type as Object
-- argType = syms.objectType;
-+ if (argType.tag == BOT) {
-+ // Null arguments type as java.lang.Void, which is a
-+ // reference that only takes a null value.
-+ // The signature for this dynamic call will mention Void,
-+ // and bootstrap methods will have to recognize this
-+ // specially as a signal for ambiguous nulls (if they care).
-+ // Even beyond the odd name, this is imperfect, since the
-+ // conversion rules for real null (to any reference type T)
-+ // do not match the reference conversion rules for Void
-+ // (which of course only converts to Object).
-+ argType = syms.voidWrapperType;
-+ }
- return argType;
+@@ -876,7 +876,8 @@
+ List<Type> argtypes,
+ List<Type> typeargtypes) {
+ assert allowInvokedynamic;
+- assert site == syms.invokeDynamicType || (site == syms.methodHandleType && name == names.invoke);
++ assert site == syms.invokeDynamicType || site == syms.dynamicType
++ || (site == syms.methodHandleType && name == names.invoke);
+ ClassSymbol c = (ClassSymbol) site.tsym;
+ Scope implicit = c.members().next;
+ if (implicit == null) {
+@@ -1317,7 +1317,7 @@
}
-
+ if (sym.kind >= AMBIGUOUS &&
+ allowInvokedynamic &&
+- (site == syms.invokeDynamicType ||
++ (site == syms.invokeDynamicType || site == syms.dynamicType ||
+ site == syms.methodHandleType && name == names.invoke)) {
+ // lookup failed; supply an exactly-typed implicit method
+ sym = findImplicitMethod(env, site, name, argtypes, typeargtypes);
diff --git a/src/share/classes/com/sun/tools/javac/jvm/Gen.java b/src/share/classes/com/sun/tools/javac/jvm/Gen.java
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java
@@ -123,15 +123,16 @@ diff --git a/src/share/classes/com/sun/t
types.asSuper(tree.expr.type, tree.clazz.type.tsym) == null) {
code.emitop2(checkcast, makeRef(tree.pos(), tree.clazz.type));
}
-@@ -2142,9 +2143,21 @@
+@@ -2142,9 +2143,22 @@
}
result = items.
makeImmediateItem(sym.type, ((VarSymbol) sym).getConstValue());
-- } else if (allowInvokedynamic && sym.kind == MTH && ssym == syms.dynamicType.tsym) {
+- } else if (allowInvokedynamic && sym.kind == MTH && ssym == syms.invokeDynamicType.tsym) {
- base.drop();
- result = items.makeDynamicItem(sym);
-+ } else if (allowInvokedynamic && sym.kind == MTH && sym.owner == syms.dynamicType.tsym) {
-+ if (ssym == syms.dynamicType.tsym) {
++ } else if (allowInvokedynamic && sym.kind == MTH &&
++ (sym.owner == syms.invokeDynamicType.tsym || sym.owner == syms.dynamicType.tsym)) {
++ if (ssym == syms.dynamicType.tsym || ssym == syms.invokeDynamicType.tsym) {
+ base.drop();
+ result = items.makeDynamicItem(sym);
+ } else {
@@ -148,22 +149,19 @@ diff --git a/src/share/classes/com/sun/t
} else {
if (!accessSuper)
sym = binaryQualifier(sym, tree.selected.type);
-diff --git a/src/share/classes/com/sun/tools/javac/util/Names.java b/src/share/classes/com/sun/tools/javac/util/Names.java
---- a/src/share/classes/com/sun/tools/javac/util/Names.java
-+++ b/src/share/classes/com/sun/tools/javac/util/Names.java
-@@ -73,6 +73,7 @@
- public final Name java_io_Serializable;
- public final Name serialVersionUID;
- public final Name java_lang_Enum;
-+ public final Name java_lang_Void;
- public final Name java_dyn_MethodHandle;
- public final Name java_dyn_Dynamic;
- public final Name package_info;
-@@ -178,6 +179,7 @@
- java_lang_Cloneable = fromString("java.lang.Cloneable");
- java_io_Serializable = fromString("java.io.Serializable");
- java_lang_Enum = fromString("java.lang.Enum");
-+ java_lang_Void = fromString("java.lang.Void");
- java_dyn_MethodHandle = fromString("java.dyn.MethodHandle");
- java_dyn_Dynamic = fromString("java.dyn.Dynamic");
- package_info = fromString("package-info");
+diff --git a/src/share/classes/com/sun/tools/javac/comp/Attr.java b/src/share/classes/com/sun/tools/javac/comp/Attr.java
+--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java
++++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java
+@@ -1318,9 +1332,10 @@
+ }
+
+ // as a special case, MethodHandle.<T>invoke(abc) and InvokeDynamic.<T>foo(abc)
+- // has type <T>, and T can be a primitive type.
++ // and ((Dynamic)a).<T>foo(bc) has type <T>, and T can be a primitive type.
+ if (tree.meth.getTag() == JCTree.SELECT && !typeargtypes.isEmpty()) {
+ Type selt = ((JCFieldAccess) tree.meth).selected.type;
+- if ((selt == syms.methodHandleType && methName == names.invoke) || selt == syms.invokeDynamicType) {
++ if ((selt == syms.methodHandleType && methName == names.invoke) ||
++ selt == syms.invokeDynamicType || selt == syms.dynamicType) {
+ assert types.isSameType(restype, typeargtypes.head) : mtype;
+ typeargtypesNonRefOK = true;
--- a/meth.patch Mon Apr 06 03:31:44 2009 -0700
+++ b/meth.patch Wed Apr 29 21:04:27 2009 -0700
@@ -1,4 +1,5 @@ 6754038: writing libraries in Java for n
6754038: writing libraries in Java for non-Java languages requires method handle invocation
+Summary: Language changes documented in http://wikis.sun.com/display/mlvm/ProjectCoinProposal
MQ base = 80586310cc78 in http://hg.openjdk.java.net/bsd-port/bsd-port/langtools [2009-03-12]
diff --git a/src/share/classes/com/sun/tools/classfile/OpCodes.java b/src/share/classes/com/sun/tools/classfile/OpCodes.java
@@ -30,7 +31,7 @@ diff --git a/src/share/classes/com/sun/t
public final Type cloneableType;
public final Type serializableType;
+ public final Type methodHandleType;
-+ public final Type dynamicType;
++ public final Type invokeDynamicType;
public final Type throwableType;
public final Type errorType;
public final Type illegalArgumentExceptionType;
@@ -46,7 +47,7 @@ diff --git a/src/share/classes/com/sun/t
+ try {
+ completer.complete(sym);
+ } catch (CompletionFailure e) {
-+ sym.flags_field |= PUBLIC;
++ sym.flags_field |= (PUBLIC | ABSTRACT);
+ ((ClassType) sym.type).supertype_field = objectType;
+ // do not bother to create MH.type if not visibly declared
+ // this sym just accumulates invoke(...) methods
@@ -64,7 +65,7 @@ diff --git a/src/share/classes/com/sun/t
throwableType = enterClass("java.lang.Throwable");
serializableType = enterClass("java.io.Serializable");
+ methodHandleType = enterClass("java.dyn.MethodHandle");
-+ dynamicType = enterClass("java.dyn.Dynamic");
++ invokeDynamicType = enterClass("java.dyn.InvokeDynamic");
errorType = enterClass("java.lang.Error");
illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
exceptionType = enterClass("java.lang.Exception");
@@ -73,7 +74,7 @@ diff --git a/src/share/classes/com/sun/t
synthesizeEmptyInterfaceIfMissing(cloneableType);
synthesizeEmptyInterfaceIfMissing(serializableType);
+ synthesizeMHTypeIfMissing(methodHandleType);
-+ synthesizeEmptyInterfaceIfMissing(dynamicType);
++ synthesizeMHTypeIfMissing(invokeDynamicType);
synthesizeBoxTypeIfMissing(doubleType);
synthesizeBoxTypeIfMissing(floatType);
@@ -145,11 +146,11 @@ diff --git a/src/share/classes/com/sun/t
restype.tsym);
}
-+ // as a special case, MethodHandle.<T>invoke(abc) and Dynamic.<T>foo(abc)
++ // as a special case, MethodHandle.<T>invoke(abc) and InvokeDynamic.<T>foo(abc)
+ // has type <T>, and T can be a primitive type.
+ if (tree.meth.getTag() == JCTree.SELECT && !typeargtypes.isEmpty()) {
+ Type selt = ((JCFieldAccess) tree.meth).selected.type;
-+ if ((selt == syms.methodHandleType && methName == names.invoke) || selt == syms.dynamicType) {
++ if ((selt == syms.methodHandleType && methName == names.invoke) || selt == syms.invokeDynamicType) {
+ assert types.isSameType(restype, typeargtypes.head) : mtype;
+ typeargtypesNonRefOK = true;
+ }
@@ -162,16 +163,6 @@ diff --git a/src/share/classes/com/sun/t
// Check that value of resulting type is admissible in the
// current context. Also, capture the return type
result = check(tree, capture(restype), VAL, pkind, pt);
-@@ -1928,7 +1956,8 @@
- // Check if type-qualified fields or methods are static (JLS)
- if ((sym.flags() & STATIC) == 0 &&
- sym.name != names._super &&
-- (sym.kind == VAR || sym.kind == MTH)) {
-+ (sym.kind == VAR || sym.kind == MTH) &&
-+ !(allowInvokedynamic && sym.owner == syms.dynamicType.tsym)) {
- rs.access(rs.new StaticError(sym),
- tree.pos(), site, sym.name, true);
- }
diff --git a/src/share/classes/com/sun/tools/javac/comp/Check.java b/src/share/classes/com/sun/tools/javac/comp/Check.java
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java
@@ -228,7 +219,7 @@ diff --git a/src/share/classes/com/sun/t
}
/** error symbols, which are returned when resolution fails
-@@ -858,6 +860,76 @@
+@@ -858,6 +860,77 @@
return bestSoFar;
}
@@ -248,7 +239,7 @@ diff --git a/src/share/classes/com/sun/t
+ List<Type> argtypes,
+ List<Type> typeargtypes) {
+ assert allowInvokedynamic;
-+ assert site == syms.dynamicType || (site == syms.methodHandleType && name == names.invoke);
++ assert site == syms.invokeDynamicType || (site == syms.methodHandleType && name == names.invoke);
+ ClassSymbol c = (ClassSymbol) site.tsym;
+ Scope implicit = c.members().next;
+ if (implicit == null) {
@@ -268,6 +259,7 @@ diff --git a/src/share/classes/com/sun/t
+ List.<Type>nil(),
+ syms.methodClass);
+ int flags = PUBLIC | ABSTRACT;
++ if (site == syms.invokeDynamicType) flags |= STATIC;
+ Symbol m = null;
+ for (Scope.Entry e = implicit.lookup(name);
+ e.scope != null;
@@ -297,21 +289,21 @@ diff --git a/src/share/classes/com/sun/t
+ Type implicitArgType(Type argType) {
+ argType = types.erasure(argType);
+ if (argType.tag == BOT)
-+ // nulls type as Object
-+ argType = syms.objectType;
++ // nulls type as the marker type Void (which has no instances)
++ argType = types.boxedClass(syms.voidType).type;
+ return argType;
+ }
+
/** Load toplevel or member class with given fully qualified name and
* verify that it is accessible.
* @param env The current environment.
-@@ -1242,6 +1314,14 @@
+@@ -1242,6 +1315,14 @@
methodResolutionCache.put(steps.head, sym);
steps = steps.tail;
}
+ if (sym.kind >= AMBIGUOUS &&
+ allowInvokedynamic &&
-+ (site == syms.dynamicType ||
++ (site == syms.invokeDynamicType ||
+ site == syms.methodHandleType && name == names.invoke)) {
+ // lookup failed; supply an exactly-typed implicit method
+ sym = findImplicitMethod(env, site, name, argtypes, typeargtypes);
@@ -332,17 +324,6 @@ diff --git a/src/share/classes/com/sun/t
new_ = 187,
newarray = 188,
anewarray = 189,
-diff --git a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
---- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
-+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
-@@ -471,6 +471,7 @@
- if (value instanceof MethodSymbol) {
- MethodSymbol m = (MethodSymbol)value;
- poolbuf.appendByte((m.owner.flags() & INTERFACE) != 0
-+ && (m.flags() & STATIC) == 0 // JSR 292, transitional
- ? CONSTANT_InterfaceMethodref
- : CONSTANT_Methodref);
- poolbuf.appendChar(pool.put(m.owner));
diff --git a/src/share/classes/com/sun/tools/javac/jvm/Code.java b/src/share/classes/com/sun/tools/javac/jvm/Code.java
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java
@@ -389,7 +370,7 @@ diff --git a/src/share/classes/com/sun/t
}
result = items.
makeImmediateItem(sym.type, ((VarSymbol) sym).getConstValue());
-+ } else if (allowInvokedynamic && sym.kind == MTH && ssym == syms.dynamicType.tsym) {
++ } else if (allowInvokedynamic && sym.kind == MTH && ssym == syms.invokeDynamicType.tsym) {
+ base.drop();
+ result = items.makeDynamicItem(sym);
} else {
@@ -421,7 +402,7 @@ diff --git a/src/share/classes/com/sun/t
+ class DynamicItem extends StaticItem {
+ DynamicItem(Symbol member) {
+ super(member);
-+ assert member.owner == syms.dynamicType.tsym;
++ assert member.owner == syms.invokeDynamicType.tsym;
+ }
+
+ Item load() {
@@ -518,7 +499,7 @@ diff --git a/src/share/classes/com/sun/t
public final Name serialVersionUID;
public final Name java_lang_Enum;
+ public final Name java_dyn_MethodHandle;
-+ public final Name java_dyn_Dynamic;
++ public final Name java_dyn_InvokeDynamic;
public final Name package_info;
public final Name ConstantValue;
public final Name LineNumberTable;
@@ -535,7 +516,7 @@ diff --git a/src/share/classes/com/sun/t
java_io_Serializable = fromString("java.io.Serializable");
java_lang_Enum = fromString("java.lang.Enum");
+ java_dyn_MethodHandle = fromString("java.dyn.MethodHandle");
-+ java_dyn_Dynamic = fromString("java.dyn.Dynamic");
++ java_dyn_InvokeDynamic = fromString("java.dyn.InvokeDynamic");
package_info = fromString("package-info");
serialVersionUID = fromString("serialVersionUID");
ConstantValue = fromString("ConstantValue");
@@ -568,7 +549,7 @@ new file mode 100644
new file mode 100644
--- /dev/null
+++ b/test/tools/javac/meth/InvokeDyn.java
-@@ -0,0 +1,55 @@
+@@ -0,0 +1,59 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -598,6 +579,12 @@ new file mode 100644
+ * @summary Generate call sites for method handle
+ * @author jrose
+ *
++ * @library ..
++ * @compile -source 7 -target 7 InvokeDyn.java
++ */
++//No: @run main/othervm -XX:+EnableInvokeDynamic meth.InvokeDyn
++
++/*
+ * Standalone testing:
+ * <code>
+ * $ cd $MY_REPO_DIR/langtools
@@ -605,30 +592,28 @@ new file mode 100644
+ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeDyn.java
+ * $ javap -c -classpath dist meth.InvokeDyn
+ * </code>
-+ *
-+ * @compile InvokeDyn.java
+ */
+
+package meth;
+
-+import java.dyn.Dynamic;
++import java.dyn.InvokeDynamic;
+
+public class InvokeDyn {
+ void test() {
+ Object x = "hello";
-+ Dynamic.greet(x, "world", 123);
-+ Dynamic.greet(x, "mundus", 456);
-+ Dynamic.greet(x, "kosmos", 789);
-+ Dynamic.<String>cogitate(10.11121, 3.14);
-+ Dynamic.<void>#"yow: what I mean to say is, please treat this one specially"(null);
-+ Dynamic.<int>invoke("goodbye");
++ InvokeDynamic.greet(x, "world", 123);
++ InvokeDynamic.greet(x, "mundus", 456);
++ InvokeDynamic.greet(x, "kosmos", 789);
++ InvokeDynamic.<String>cogitate(10.11121, 3.14);
++ InvokeDynamic.<void>#"yow: what I mean to say is, please treat this one specially"(null);
++ InvokeDynamic.<int>invoke("goodbye");
+ }
+}
diff --git a/test/tools/javac/meth/InvokeMH.java b/test/tools/javac/meth/InvokeMH.java
new file mode 100644
--- /dev/null
+++ b/test/tools/javac/meth/InvokeMH.java
-@@ -0,0 +1,73 @@
+@@ -0,0 +1,75 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -658,6 +643,10 @@ new file mode 100644
+ * @summary Generate call sites for method handle
+ * @author jrose
+ *
++ * @compile -source 7 -target 7 InvokeMH.java
++ */
++
++/*
+ * Standalone testing:
+ * <code>
+ * $ cd $MY_REPO_DIR/langtools
@@ -665,8 +654,6 @@ new file mode 100644
+ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH.java
+ * $ javap -c -classpath dist meth.InvokeMH
+ * </code>
-+ *
-+ * @compile InvokeMH.java
+ */
+
+package meth;
@@ -706,7 +693,7 @@ new file mode 100644
new file mode 100644
--- /dev/null
+++ b/test/tools/javac/meth/MakeNegTests.sh
-@@ -0,0 +1,96 @@
+@@ -0,0 +1,98 @@
+#!/bin/sh
+
+#
@@ -738,7 +725,7 @@ new file mode 100644
+# @run shell MakeNegTests.sh
+
+default_template=InvokeMH.java
-+javacflags='-target 7'
++javacflags='-source 7 -target 7'
+# the rest of this file is a generic "//BAD"-line tester
+
+: ${TESTSRC=.} ${TESTCLASSES=.}
@@ -777,6 +764,8 @@ new file mode 100644
+ casefile="$casestem"${badnum}.java
+ cclassname=` basename "$casefile" .java `
+ sed < "$template" > "$casefile" "
++ s|@compile|@compile/fail|
++ / @[a-z]/s|@|##|
+ ${badnum}s:^ *[/*]*: :
+ s/${tclassname}/${cclassname}/g
+ "
--- a/nb-javac/dyncast.patch Mon Apr 06 03:31:44 2009 -0700
+++ b/nb-javac/dyncast.patch Wed Apr 29 21:04:27 2009 -0700
@@ -1,5 +1,6 @@ 0000000: writing libraries in Java for n
0000000: writing libraries in Java for non-Java languages requires permissive Dynamic type
MQ base = 4d206181439a in http://hg.netbeans.org/main/nb-javac [release65_base] + meth.patch
+NOTE: This needs to be refreshed after ../dyncast.patch is debugged.
diff --git a/src/share/classes/com/sun/tools/javac/code/Symtab.java b/src/share/classes/com/sun/tools/javac/code/Symtab.java
--- a/src/share/classes/com/sun/tools/javac/code/Symtab.java
--- a/nb-javac/meth.patch Mon Apr 06 03:31:44 2009 -0700
+++ b/nb-javac/meth.patch Wed Apr 29 21:04:27 2009 -0700
@@ -9,7 +9,7 @@ diff --git a/src/share/classes/com/sun/t
public final Type cloneableType;
public final Type serializableType;
+ public final Type methodHandleType;
-+ public final Type dynamicType;
++ public final Type invokeDynamicType;
public final Type throwableType;
public final Type errorType;
public final Type illegalArgumentExceptionType;
@@ -18,7 +18,7 @@ diff --git a/src/share/classes/com/sun/t
throwableType = enterClass("java.lang.Throwable");
serializableType = enterClass("java.io.Serializable");
+ methodHandleType = enterClass("java.dyn.MethodHandle");
-+ dynamicType = enterClass("java.dyn.Dynamic");
++ invokeDynamicType = enterClass("java.dyn.InvokeDynamic");
errorType = enterClass("java.lang.Error");
illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
exceptionType = enterClass("java.lang.Exception");
@@ -91,11 +91,11 @@ diff --git a/src/share/classes/com/sun/t
restype.tsym);
}
-+ // as a special case, MethodHandle.<T>invoke(abc) and Dynamic.<T>foo(abc)
++ // as a special case, MethodHandle.<T>invoke(abc) and InvokeDynamic.<T>foo(abc)
+ // has type <T>, and T can be a primitive type.
+ if (tree.meth.getTag() == JCTree.SELECT && !typeargtypes.isEmpty()) {
+ Type selt = ((JCFieldAccess) tree.meth).selected.type;
-+ if ((selt == syms.methodHandleType && methName == names.invoke) || selt == syms.dynamicType) {
++ if ((selt == syms.methodHandleType && methName == names.invoke) || selt == syms.invokeDynamicType) {
+ assert types.isSameType(restype, typeargtypes.head) : mtype;
+ typeargtypesNonRefOK = true;
+ }
@@ -108,16 +108,6 @@ diff --git a/src/share/classes/com/sun/t
// Check that value of resulting type is admissible in the
// current context. Also, capture the return type
result = check(tree, capture(restype), VAL, pkind, pt);
-@@ -1968,7 +1997,8 @@
- // Check if type-qualified fields or methods are static (JLS)
- if ((sym.flags() & STATIC) == 0 &&
- sym.name != names._super &&
-- (sym.kind == VAR || sym.kind == MTH)) {
-+ (sym.kind == VAR || sym.kind == MTH) &&
-+ !(allowInvokedynamic && sym.owner == syms.dynamicType.tsym)) {
- rs.access(rs.new StaticError(sym),
- tree.pos(), site, sym.name, true);
- }
diff --git a/src/share/classes/com/sun/tools/javac/comp/Check.java b/src/share/classes/com/sun/tools/javac/comp/Check.java
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java
@@ -174,7 +164,7 @@ diff --git a/src/share/classes/com/sun/t
}
/** error symbols, which are returned when resolution fails
-@@ -848,6 +850,76 @@
+@@ -848,6 +850,77 @@
return bestSoFar;
}
@@ -194,7 +184,7 @@ diff --git a/src/share/classes/com/sun/t
+ List<Type> argtypes,
+ List<Type> typeargtypes) {
+ assert allowInvokedynamic;
-+ assert site == syms.dynamicType || (site == syms.methodHandleType && name == names.invoke);
++ assert site == syms.invokeDynamicType || (site == syms.methodHandleType && name == names.invoke);
+ ClassSymbol c = (ClassSymbol) site.tsym;
+ Scope implicit = c.members().next;
+ if (implicit == null) {
@@ -214,6 +204,7 @@ diff --git a/src/share/classes/com/sun/t
+ List.<Type>nil(),
+ syms.methodClass);
+ int flags = PUBLIC | ABSTRACT;
++ if (site == syms.invokeDynamicType) flags |= STATIC;
+ Symbol m = null;
+ for (Scope.Entry e = implicit.lookup(name);
+ e.scope != null;
@@ -243,8 +234,8 @@ diff --git a/src/share/classes/com/sun/t
+ Type implicitArgType(Type argType) {
+ argType = types.erasure(argType);
+ if (argType.tag == BOT)
-+ // nulls type as Object
-+ argType = syms.objectType;
++ // nulls type as the marker type Void (which has no instances)
++ argType = types.boxedClass(syms.voidType).type;
+ return argType;
+ }
+
@@ -257,7 +248,7 @@ diff --git a/src/share/classes/com/sun/t
}
+ if (sym.kind >= AMBIGUOUS &&
+ allowInvokedynamic &&
-+ (site == syms.dynamicType ||
++ (site == syms.invokeDynamicType ||
+ (site == syms.methodHandleType && name == names.invoke))) {
+ // lookup failed; supply an exactly-typed implicit method
+ sym = findImplicitMethod(env, site, name, argtypes, typeargtypes);
@@ -278,17 +269,6 @@ diff --git a/src/share/classes/com/sun/t
new_ = 187,
newarray = 188,
anewarray = 189,
-diff --git a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
---- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
-+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
-@@ -494,6 +494,7 @@
- if (value instanceof MethodSymbol) {
- MethodSymbol m = (MethodSymbol)value;
- poolbuf.appendByte((m.owner.flags() & INTERFACE) != 0
-+ && (m.flags() & STATIC) == 0 // JSR 292, transitional
- ? CONSTANT_InterfaceMethodref
- : CONSTANT_Methodref);
- poolbuf.appendChar(pool.put(m.owner));
diff --git a/src/share/classes/com/sun/tools/javac/jvm/Code.java b/src/share/classes/com/sun/tools/javac/jvm/Code.java
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java
@@ -335,7 +315,7 @@ diff --git a/src/share/classes/com/sun/t
}
result = items.
makeImmediateItem(sym.type, ((VarSymbol) sym).getConstValue());
-+ } else if (allowInvokedynamic && sym.kind == MTH && ssym == syms.dynamicType.tsym) {
++ } else if (allowInvokedynamic && sym.kind == MTH && ssym == syms.invokeDynamicType.tsym) {
+ base.drop();
+ result = items.makeDynamicItem(sym);
} else {
@@ -367,7 +347,7 @@ diff --git a/src/share/classes/com/sun/t
+ class DynamicItem extends StaticItem {
+ DynamicItem(Symbol member) {
+ super(member);
-+ assert member.owner == syms.dynamicType.tsym;
++ assert member.owner == syms.invokeDynamicType.tsym;
+ }
+
+ Item load() {
@@ -464,7 +444,7 @@ diff --git a/src/share/classes/com/sun/t
java_io_Serializable = fromString("java.io.Serializable");
java_lang_Enum = fromString("java.lang.Enum");
+ java_dyn_MethodHandle = fromString("java.dyn.MethodHandle");
-+ java_dyn_Dynamic = fromString("java.dyn.Dynamic");
++ java_dyn_InvokeDynamic = fromString("java.dyn.InvokeDynamic");
package_info = fromString("package-info");
serialVersionUID = fromString("serialVersionUID");
ConstantValue = fromString("ConstantValue");
@@ -481,7 +461,7 @@ diff --git a/src/share/classes/com/sun/t
public final Name serialVersionUID;
public final Name java_lang_Enum;
+ public final Name java_dyn_MethodHandle;
-+ public final Name java_dyn_Dynamic;
++ public final Name java_dyn_InvokeDynamic;
public final Name package_info;
public final Name ConstantValue;
public final Name LineNumberTable;
@@ -497,7 +477,7 @@ new file mode 100644
new file mode 100644
--- /dev/null
+++ b/test/tools/javac/meth/InvokeDyn.java
-@@ -0,0 +1,55 @@
+@@ -0,0 +1,60 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -527,6 +507,12 @@ new file mode 100644
+ * @summary Generate call sites for method handle
+ * @author jrose
+ *
++ * @library ..
++ * @compile -source 7 -target 7 InvokeDyn.java
++ */
++//No: @run main/othervm -XX:+EnableInvokeDynamic meth.InvokeDyn
++
++/*
+ * Standalone testing:
+ * <code>
+ * $ cd $MY_REPO_DIR/langtools
@@ -534,30 +520,29 @@ new file mode 100644
+ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeDyn.java
+ * $ javap -c -classpath dist meth.InvokeDyn
+ * </code>
-+ *
+ * @compile InvokeDyn.java
+ */
+
+package meth;
+
-+import java.dyn.Dynamic;
++import java.dyn.InvokeDynamic;
+
+public class InvokeDyn {
+ void test() {
+ Object x = "hello";
-+ Dynamic.greet(x, "world", 123);
-+ Dynamic.greet(x, "mundus", 456);
-+ Dynamic.greet(x, "kosmos", 789);
-+ Dynamic.<String>cogitate(10.11121, 3.14);
-+ Dynamic.<void>#"yow: what I mean to say is, please treat this one specially"(null);
-+ Dynamic.<int>invoke("goodbye");
++ InvokeDynamic.greet(x, "world", 123);
++ InvokeDynamic.greet(x, "mundus", 456);
++ InvokeDynamic.greet(x, "kosmos", 789);
++ InvokeDynamic.<String>cogitate(10.11121, 3.14);
++ InvokeDynamic.<void>#"yow: what I mean to say is, please treat this one specially"(null);
++ InvokeDynamic.<int>invoke("goodbye");
+ }
+}
diff --git a/test/tools/javac/meth/InvokeMH.java b/test/tools/javac/meth/InvokeMH.java
new file mode 100644
--- /dev/null
+++ b/test/tools/javac/meth/InvokeMH.java
-@@ -0,0 +1,73 @@
+@@ -0,0 +1,76 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -587,6 +572,10 @@ new file mode 100644
+ * @summary Generate call sites for method handle
+ * @author jrose
+ *
++ * @compile -source 7 -target 7 InvokeMH.java
++ */
++
++/*
+ * Standalone testing:
+ * <code>
+ * $ cd $MY_REPO_DIR/langtools
@@ -594,7 +583,6 @@ new file mode 100644
+ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH.java
+ * $ javap -c -classpath dist meth.InvokeMH
+ * </code>
-+ *
+ * @compile InvokeMH.java
+ */
+
@@ -635,7 +623,7 @@ new file mode 100644
new file mode 100644
--- /dev/null
+++ b/test/tools/javac/meth/MakeNegTests.sh
-@@ -0,0 +1,96 @@
+@@ -0,0 +1,98 @@
+#!/bin/sh
+
+#
@@ -667,7 +655,7 @@ new file mode 100644
+# @run shell MakeNegTests.sh
+
+default_template=InvokeMH.java
-+javacflags='-target 7'
++javacflags='-source 7 -target 7'
+# the rest of this file is a generic "//BAD"-line tester
+
+: ${TESTSRC=.} ${TESTCLASSES=.}
@@ -706,6 +694,8 @@ new file mode 100644
+ casefile="$casestem"${badnum}.java
+ cclassname=` basename "$casefile" .java `
+ sed < "$template" > "$casefile" "
++ s|@compile|@compile/fail|
++ / @[a-z]/s|@|##|
+ ${badnum}s:^ *[/*]*: :
+ s/${tclassname}/${cclassname}/g
+ "
--- a/quid.patch Mon Apr 06 03:31:44 2009 -0700
+++ b/quid.patch Wed Apr 29 21:04:27 2009 -0700
@@ -175,7 +175,7 @@ new file mode 100644
new file mode 100644
--- /dev/null
+++ b/test/tools/javac/quid/MakeNegTests.sh
-@@ -0,0 +1,95 @@
+@@ -0,0 +1,97 @@
+#!/bin/sh
+
+#
@@ -245,6 +245,8 @@ new file mode 100644
+ casefile="$casestem"${badnum}.java
+ cclassname=` basename "$casefile" .java `
+ sed < "$template" > "$casefile" "
++ s|@compile|@compile/fail|
++ / @[a-z]/s|@|##|
+ ${badnum}s:^ *[/*]*: :
+ s/${tclassname}/${cclassname}/g
+ "
@@ -275,7 +277,7 @@ new file mode 100644
new file mode 100644
--- /dev/null
+++ b/test/tools/javac/quid/QuotedIdent.java
-@@ -0,0 +1,129 @@
+@@ -0,0 +1,132 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -305,6 +307,11 @@ new file mode 100644
+ * @summary Verify correct lexing of quoted identifiers.
+ * @author jrose
+ *
++ * @library ..
++ * @run main quid.QuotedIdent
++ */
++
++/*
+ * Standalone testing:
+ * <code>
+ * $ cd $MY_REPO_DIR/langtools
@@ -313,8 +320,6 @@ new file mode 100644
+ * $ java -version # should print 1.6 or later
+ * $ java -cp dist quid.QuotedIdent
+ * </code>
-+ *
-+ * @run main QuotedIdent
+ */
+
+package quid;
@@ -409,7 +414,7 @@ new file mode 100644
new file mode 100644
--- /dev/null
+++ b/test/tools/javac/quid/QuotedIdent2.java
-@@ -0,0 +1,79 @@
+@@ -0,0 +1,81 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -439,6 +444,10 @@ new file mode 100644
+ * @summary Verify correct separate compilation of classes with extended identifiers.
+ * @author jrose
+ *
++ * @library ..
++ * @run main quid.QuotedIdent2
++ */
++/*
+ * Standalone testing:
+ * <code>
+ * $ cd $MY_REPO_DIR/langtools
@@ -448,8 +457,6 @@ new file mode 100644
+ * $ java -version # should print 1.6 or later
+ * $ java -cp dist QuotedIdent2
+ * </code>
-+ *
-+ * @run main QuotedIdent2
+ */
+
+package quid;
--- a/series Mon Apr 06 03:31:44 2009 -0700
+++ b/series Wed Apr 29 21:04:27 2009 -0700
@@ -1,4 +1,6 @@
# base = 80586310cc78 in http://hg.openjdk.java.net/bsd-port/bsd-port/langtools [2009-03-12]
quid.patch #-/quid #+80586310cc78 #+jdk7-b50
meth.patch #-/meth #+80586310cc78 #+jdk7-b50
-dyncast.patch #-/dyncast #+80586310cc78 #+jdk7-b50
+
+# Keep this separate, for debugging and review:
+dyncast.patch #-/dyncast #+dyncast