Mercurial > hg > release > icedtea6-1.13
changeset 2973:241d297ff5e3
Add langtools backports suggested by Joe Darcy and backport for bundled HotSpot suggested by Xerxes.
2013-03-26 Andrew John Hughes <gnu.andrew@redhat.com>
* Makefile.am:
(ICEDTEA_PATCHES): Add new backports (HotSpot
one only to bundled HotSpot build).
* patches/hotspot/original/6840152-jvm_crashes_with_heavyweight_monitors.patch:
Backport suggested by Xerxes for hs20.
* patches/openjdk/6500343-bad_code_from_conditionals.patch,
* patches/openjdk/6682380-foreach_crash.patch,
* patches/openjdk/6718364-inference_failure.patch,
* patches/openjdk/7003595-incompatibleclasschangeerror.patch,
* patches/openjdk/7024568-long_method_resolution_oom_error.patch,
* patches/openjdk/7046929-fix_t6397104_test_failure.patch:
Langtools backports present in the proprietary JDK 6 tree,
as listed by Joe Darcy.
author | Andrew John Hughes <gnu.andrew@redhat.com> |
---|---|
date | Wed, 27 Mar 2013 21:14:08 +0000 |
parents | 02a65b9914d5 |
children | 3584aac9d62d |
files | ChangeLog Makefile.am patches/hotspot/original/6840152-jvm_crashes_with_heavyweight_monitors.patch patches/openjdk/6500343-bad_code_from_conditionals.patch patches/openjdk/6682380-foreach_crash.patch patches/openjdk/6718364-inference_failure.patch patches/openjdk/7003595-incompatibleclasschangeerror.patch patches/openjdk/7024568-long_method_resolution_oom_error.patch patches/openjdk/7046929-fix_t6397104_test_failure.patch |
diffstat | 9 files changed, 868 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Mar 22 14:18:47 2013 +0000 +++ b/ChangeLog Wed Mar 27 21:14:08 2013 +0000 @@ -1,3 +1,19 @@ +2013-03-26 Andrew John Hughes <gnu.andrew@redhat.com> + + * Makefile.am: + (ICEDTEA_PATCHES): Add new backports (HotSpot + one only to bundled HotSpot build). + * patches/hotspot/original/6840152-jvm_crashes_with_heavyweight_monitors.patch: + Backport suggested by Xerxes for hs20. + * patches/openjdk/6500343-bad_code_from_conditionals.patch, + * patches/openjdk/6682380-foreach_crash.patch, + * patches/openjdk/6718364-inference_failure.patch, + * patches/openjdk/7003595-incompatibleclasschangeerror.patch, + * patches/openjdk/7024568-long_method_resolution_oom_error.patch, + * patches/openjdk/7046929-fix_t6397104_test_failure.patch: + Langtools backports present in the proprietary JDK 6 tree, + as listed by Joe Darcy. + 2013-03-22 Andrew John Hughes <gnu.andrew@redhat.com> * Makefile.am: @@ -9,7 +25,7 @@ add sun.misc.Unsafe.copyMemory method from 7. * patches/jvmtiEnv.patch: Moved to... * patches/hotspot/original/jvmtiEnv.patch: here. - + 2013-03-18 Andrew John Hughes <gnu.andrew@redhat.com> * Makefile.am:
--- a/Makefile.am Fri Mar 22 14:18:47 2013 +0000 +++ b/Makefile.am Wed Mar 27 21:14:08 2013 +0000 @@ -478,7 +478,13 @@ patches/pr1319-support_giflib_5.patch \ patches/openjdk/8007393.patch \ patches/openjdk/8007611.patch \ - patches/copy_memory.patch + patches/copy_memory.patch \ + patches/openjdk/6718364-inference_failure.patch \ + patches/openjdk/6682380-foreach_crash.patch \ + patches/openjdk/7046929-fix_t6397104_test_failure.patch + patches/openjdk/7024568-long_method_resolution_oom_error.patch \ + patches/openjdk/7003595-incompatibleclasschangeerror.patch \ + patches/openjdk/6500343-bad_code_from_conditionals.patch if WITH_ALT_HSBUILD ICEDTEA_PATCHES += \ @@ -528,7 +534,8 @@ patches/openjdk/7010849-modernise_sa.patch \ patches/hotspot/original/7197906-handle_32_bit_shifts.patch \ patches/hotspot/original/fix_get_stack_bounds_leak.patch \ - patches/hotspot/original/jvmtiEnv.patch + patches/hotspot/original/jvmtiEnv.patch \ + patches/hotspot/original/6840152-jvm_crashes_with_heavyweight_monitors.patch endif if WITH_RHINO
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/hotspot/original/6840152-jvm_crashes_with_heavyweight_monitors.patch Wed Mar 27 21:14:08 2013 +0000 @@ -0,0 +1,32 @@ +# HG changeset patch +# User coleenp +# Date 1297874084 18000 +# Node ID c08677f982895c7e89d370768ec261c00b0d6e2d +# Parent 5415131bc5ab69d30d14636e414d1fa400800408 +6840152: JVM crashes when heavyweight monitors are used +Summary: Turn off biased locking if !UseFastLocking or UseHeavyMonitors options are requested. +Reviewed-by: phh, never, dcubed, dholmes + +diff --git a/src/share/vm/runtime/arguments.cpp b/src/share/vm/runtime/arguments.cpp +--- openjdk/hotspot/src/share/vm/runtime/arguments.cpp ++++ openjdk/hotspot/src/share/vm/runtime/arguments.cpp +@@ -3103,6 +3103,19 @@ + // Set flags if Aggressive optimization flags (-XX:+AggressiveOpts) enabled. + set_aggressive_opts_flags(); + ++ // Turn off biased locking for locking debug mode flags, ++ // which are subtlely different from each other but neither works with ++ // biased locking. ++ if (!UseFastLocking || UseHeavyMonitors) { ++ if (!FLAG_IS_DEFAULT(UseBiasedLocking) && UseBiasedLocking) { ++ // flag set to true on command line; warn the user that they ++ // can't enable biased locking here ++ warning("Biased Locking is not supported with locking debug flags" ++ "; ignoring UseBiasedLocking flag." ); ++ } ++ UseBiasedLocking = false; ++ } ++ + #ifdef CC_INTERP + // Clear flags not supported by the C++ interpreter + FLAG_SET_DEFAULT(ProfileInterpreter, false);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/openjdk/6500343-bad_code_from_conditionals.patch Wed Mar 27 21:14:08 2013 +0000 @@ -0,0 +1,129 @@ +# HG changeset patch +# User mcimadamore +# Date 1222684483 -3600 +# Node ID ddd110646d215c6f504b1908d501ab964bf75574 +# Parent 1e83972f53fb28e27ea3ec762b8c33d0684443c1 +6500343: compiler generates bad code when translating conditional expressions +Summary: TransTypes needs to deal with intersection types coming from conditional expressions +Reviewed-by: jjg + +diff --git a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java +--- openjdk/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java ++++ openjdk/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java +@@ -534,7 +534,7 @@ + tree.truepart = translate(tree.truepart, erasure(tree.type)); + tree.falsepart = translate(tree.falsepart, erasure(tree.type)); + tree.type = erasure(tree.type); +- result = tree; ++ result = retype(tree, tree.type, pt); + } + + public void visitIf(JCIf tree) { +diff --git a/test/tools/javac/conditional/6500343/T6500343a.java b/test/tools/javac/conditional/6500343/T6500343a.java +new file mode 100644 +--- /dev/null ++++ openjdk/langtools/test/tools/javac/conditional/6500343/T6500343a.java +@@ -0,0 +1,50 @@ ++/* ++ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, ++ * CA 95054 USA or visit www.sun.com if you need additional information or ++ * have any questions. ++ */ ++ ++/* ++ * @test ++ * @bug 6500343 ++ * @summary compiler generates bad code when translating conditional expressions ++ * @author Maurizio Cimadamore ++ * ++ */ ++ ++public class T6500343a { ++ static class Base {} ++ static interface I {} ++ static class A1 extends Base implements I {} ++ static class A2 extends Base implements I {} ++ ++ static Object crash(I i, A1 a1, A2 a2, boolean b1, boolean b2) { ++ return b1 ? i : b2 ? a2 : a1; ++ // lub(I, lub(A1, A2)) ==> lub(I, Base&I) ==> I (doesn't compile on 1.4 ok >1.5) ++ } ++ ++ public static void main(String[] args) { ++ T6500343a.crash(new A1(), new A1(), new A2(), true, false); ++ T6500343a.crash(new A1(), new A1(), new A2(), false, true); ++ T6500343a.crash(new A1(), new A1(), new A2(), false, false); ++ T6500343a.crash(new A1(), new A1(), new A2(), true, true); ++ } ++} ++ +diff --git a/test/tools/javac/conditional/6500343/T6500343b.java b/test/tools/javac/conditional/6500343/T6500343b.java +new file mode 100644 +--- /dev/null ++++ openjdk/langtools/test/tools/javac/conditional/6500343/T6500343b.java +@@ -0,0 +1,48 @@ ++/* ++ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, ++ * CA 95054 USA or visit www.sun.com if you need additional information or ++ * have any questions. ++ */ ++ ++/* ++ * @test ++ * @bug 6500343 ++ * @summary compiler generates bad code when translating conditional expressions ++ * @author Maurizio Cimadamore ++ * ++ */ ++ ++public class T6500343b { ++ ++ final static int i1 = 0; ++ final static int i2 = 1; ++ ++ static void crash(int i) { ++ switch (i) { ++ case (true ? 0 : 1): ++ case (i1 == 5 ? 1 : 2): ++ case (i1 == i2 ? 2 : 3): ++ } ++ } ++ ++ public static void main(String[] args) { ++ T6500343b.crash(0); ++ } ++}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/openjdk/6682380-foreach_crash.patch Wed Mar 27 21:14:08 2013 +0000 @@ -0,0 +1,97 @@ +# HG changeset patch +# User mcimadamore +# Date 1208967003 -3600 +# Node ID ec29a1a284ca0b0be1b3b44b1643e7eb6acefb69 +# Parent 627deea1ea4fba84a0e9182fbdc24110d4f5448c +6682380: Foreach loop with generics inside finally block crashes javac with -target 1.5 +Summary: A missing type-erasure in Lower.java causes the compiler to crash since JDK6 +Reviewed-by: jjg + +diff --git a/src/share/classes/com/sun/tools/javac/comp/Lower.java b/src/share/classes/com/sun/tools/javac/comp/Lower.java +--- openjdk/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java ++++ openjdk/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java +@@ -2863,13 +2863,15 @@ + JCExpressionStatement step = make.Exec(makeUnary(JCTree.PREINC, make.Ident(index))); + + Type elemtype = types.elemtype(tree.expr.type); +- JCStatement loopvarinit = make. +- VarDef(tree.var.sym, +- make. +- Indexed(make.Ident(arraycache), make.Ident(index)). +- setType(elemtype)); ++ JCExpression loopvarinit = make.Indexed(make.Ident(arraycache), ++ make.Ident(index)).setType(elemtype); ++ JCVariableDecl loopvardef = (JCVariableDecl)make.VarDef(tree.var.mods, ++ tree.var.name, ++ tree.var.vartype, ++ loopvarinit).setType(tree.var.type); ++ loopvardef.sym = tree.var.sym; + JCBlock body = make. +- Block(0, List.of(loopvarinit, tree.body)); ++ Block(0, List.of(loopvardef, tree.body)); + + result = translate(make. + ForLoop(loopinit, +@@ -2944,7 +2946,11 @@ + JCExpression vardefinit = make.App(make.Select(make.Ident(itvar), next)); + if (iteratorTarget != syms.objectType) + vardefinit = make.TypeCast(iteratorTarget, vardefinit); +- JCVariableDecl indexDef = make.VarDef(tree.var.sym, vardefinit); ++ JCVariableDecl indexDef = (JCVariableDecl)make.VarDef(tree.var.mods, ++ tree.var.name, ++ tree.var.vartype, ++ vardefinit).setType(tree.var.type); ++ indexDef.sym = tree.var.sym; + JCBlock body = make.Block(0, List.of(indexDef, tree.body)); + result = translate(make. + ForLoop(List.of(init), +diff --git a/test/tools/javac/foreach/T6682380.java b/test/tools/javac/foreach/T6682380.java +new file mode 100644 +--- /dev/null ++++ openjdk/langtools/test/tools/javac/foreach/T6682380.java +@@ -0,0 +1,45 @@ ++/* ++ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, ++ * CA 95054 USA or visit www.sun.com if you need additional information or ++ * have any questions. ++ */ ++ ++/* ++ * @test ++ * @bug 6682380 6679509 ++ * @summary Foreach loop with generics inside finally block crashes javac with -target 1.5 ++ * @author Jan Lahoda, Maurizio Cimadamore ++ * @compile -target 1.5 T6682380.java ++ */ ++ ++import java.util.List; ++ ++public class T6682380<X> { ++ ++ public static void main(String[] args) { ++ try { ++ } finally { ++ List<T6682380<?>> l = null; ++ T6682380<?>[] a = null; ++ for (T6682380<?> e1 : l); ++ for (T6682380<?> e2 : a); ++ } ++ } ++}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/openjdk/6718364-inference_failure.patch Wed Mar 27 21:14:08 2013 +0000 @@ -0,0 +1,76 @@ +# HG changeset patch +# User mcimadamore +# Date 1218213500 -3600 +# Node ID 30a415f8667f66f38aa33ad8d289048cb8d3f614 +# Parent d635feaf3747d1c3111fc84cbff603ccaa75577d +6718364: inference fails when a generic method is invoked with raw arguments +Summary: Bug in the implementation of Types.isSubtypeUnchecked +Reviewed-by: jjg + +diff --git a/src/share/classes/com/sun/tools/javac/code/Types.java b/src/share/classes/com/sun/tools/javac/code/Types.java +--- openjdk/langtools/src/share/classes/com/sun/tools/javac/code/Types.java ++++ openjdk/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +@@ -305,6 +305,11 @@ + else if (t.tag == TYPEVAR) { + return isSubtypeUnchecked(t.getUpperBound(), s, warn); + } ++ else if (s.tag == UNDETVAR) { ++ UndetVar uv = (UndetVar)s; ++ if (uv.inst != null) ++ return isSubtypeUnchecked(t, uv.inst, warn); ++ } + else if (!s.isRaw()) { + Type t2 = asSuper(t, s.tsym); + if (t2 != null && t2.isRaw()) { +diff --git a/test/tools/javac/generics/inference/6718364/T6718364.java b/test/tools/javac/generics/inference/6718364/T6718364.java +new file mode 100644 +--- /dev/null ++++ openjdk/langtools/test/tools/javac/generics/inference/6718364/T6718364.java +@@ -0,0 +1,38 @@ ++/* ++ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, ++ * CA 95054 USA or visit www.sun.com if you need additional information or ++ * have any questions. ++ */ ++ ++/** ++ * @test ++ * @bug 6718364 ++ * @summary inference fails when a generic method is invoked with raw arguments ++ * @compile/ref=T6718364.out -XDstdout -XDrawDiagnostics -Xlint:unchecked T6718364.java ++ */ ++class T6718364 { ++ class X<T> {} ++ ++ public <T> void m(X<T> x, T t) {} ++ ++ public void test() { ++ m(new X<X<Integer>>(), new X()); ++ } ++} +diff --git a/test/tools/javac/generics/inference/6718364/T6718364.out b/test/tools/javac/generics/inference/6718364/T6718364.out +new file mode 100644 +--- /dev/null ++++ openjdk/langtools/test/tools/javac/generics/inference/6718364/T6718364.out +@@ -0,0 +1,3 @@ ++T6718364.java:36:32: compiler.warn.prob.found.req: (- compiler.misc.unchecked.assign), T6718364.X, T6718364.X<java.lang.Integer> ++T6718364.java:36:10: compiler.warn.unchecked.meth.invocation.applied: <T>m(T6718364.X<T>,T), T6718364, , T6718364.X<T6718364.X<java.lang.Integer>>,T6718364.X ++2 warnings +\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/openjdk/7003595-incompatibleclasschangeerror.patch Wed Mar 27 21:14:08 2013 +0000 @@ -0,0 +1,351 @@ +# HG changeset patch +# User dmeetry +# Date 1325086840 -14400 +# Node ID 41a303cb946ebfadabb94e0625448bfbfe4dccc0 +# Parent 3ff13f513bc2478e05ff229fd5139989596d1850 +7003595: IncompatibleClassChangeError with unreferenced local class with subclass +Summary: Compiler omits unreferenced local inner classes from the InnerClasses attribute +Reviewed-by: mcimadamore + +diff --git a/src/share/classes/com/sun/tools/javac/code/Symbol.java b/src/share/classes/com/sun/tools/javac/code/Symbol.java +--- openjdk/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java ++++ openjdk/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java +@@ -726,6 +726,11 @@ + */ + public JavaFileObject classfile; + ++ /** the list of translated local classes (used for generating ++ * InnerClasses attribute) ++ */ ++ public List<ClassSymbol> trans_local; ++ + /** the constant pool of the class + */ + public Pool pool; +diff --git a/src/share/classes/com/sun/tools/javac/comp/Lower.java b/src/share/classes/com/sun/tools/javac/comp/Lower.java +--- openjdk/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java ++++ openjdk/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java +@@ -2271,6 +2271,14 @@ + tree.extending = translate(tree.extending); + tree.implementing = translate(tree.implementing); + ++ if (currentClass.isLocal()) { ++ ClassSymbol encl = currentClass.owner.enclClass(); ++ if (encl.trans_local == null) { ++ encl.trans_local = List.nil(); ++ } ++ encl.trans_local = encl.trans_local.prepend(currentClass); ++ } ++ + // Recursively translate members, taking into account that new members + // might be created during the translation and prepended to the member + // list `tree.defs'. +diff --git a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java +--- openjdk/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java ++++ openjdk/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java +@@ -863,10 +863,10 @@ + } + if (c.type.tag != CLASS) return; // arrays + if (pool != null && // pool might be null if called from xClassName +- c.owner.kind != PCK && ++ c.owner.enclClass() != null && + (innerClasses == null || !innerClasses.contains(c))) { + // log.errWriter.println("enter inner " + c);//DEBUG +- if (c.owner.kind == TYP) enterInner((ClassSymbol)c.owner); ++ enterInner(c.owner.enclClass()); + pool.put(c); + pool.put(c.name); + if (innerClasses == null) { +@@ -1505,6 +1505,13 @@ + default : Assert.error(); + } + } ++ ++ if (c.trans_local != null) { ++ for (ClassSymbol local : c.trans_local) { ++ enterInner(local); ++ } ++ } ++ + databuf.appendChar(fieldsCount); + writeFields(c.members().elems); + databuf.appendChar(methodsCount); +diff --git a/test/tools/javac/7003595/T7003595.java b/test/tools/javac/7003595/T7003595.java +new file mode 100644 +--- /dev/null ++++ openjdk/langtools/test/tools/javac/7003595/T7003595.java +@@ -0,0 +1,233 @@ ++/* ++ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ */ ++ ++/* ++ * @test ++ * @bug 7003595 ++ * @summary IncompatibleClassChangeError with unreferenced local class with subclass ++ */ ++ ++import com.sun.source.util.JavacTask; ++import com.sun.tools.classfile.Attribute; ++import com.sun.tools.classfile.ClassFile; ++import com.sun.tools.classfile.InnerClasses_attribute; ++import com.sun.tools.classfile.ConstantPool.*; ++import com.sun.tools.javac.api.JavacTool; ++ ++import java.io.File; ++import java.net.URI; ++import java.util.Arrays; ++import java.util.ArrayList; ++import javax.tools.JavaCompiler; ++import javax.tools.JavaFileObject; ++import javax.tools.SimpleJavaFileObject; ++import javax.tools.StandardJavaFileManager; ++import javax.tools.ToolProvider; ++ ++ ++public class T7003595 { ++ ++ /** global decls ***/ ++ ++ // Create a single file manager and reuse it for each compile to save time. ++ static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null); ++ ++ //statistics ++ static int checkCount = 0; ++ ++ enum ClassKind { ++ NESTED("static class #N { #B }", "$", true), ++ INNER("class #N { #B }", "$", false), ++ LOCAL_REF("void test() { class #N { #B }; new #N(); }", "$1", false), ++ LOCAL_NOREF("void test() { class #N { #B }; }", "$1", false), ++ ANON("void test() { new Object() { #B }; }", "$1", false), ++ NONE("", "", false); ++ ++ String memberInnerStr; ++ String sep; ++ boolean staticAllowed; ++ ++ private ClassKind(String memberInnerStr, String sep, boolean staticAllowed) { ++ this.memberInnerStr = memberInnerStr; ++ this.sep = sep; ++ this.staticAllowed = staticAllowed; ++ } ++ ++ String getSource(String className, String outerName, String nested) { ++ return memberInnerStr.replaceAll("#O", outerName). ++ replaceAll("#N", className).replaceAll("#B", nested); ++ } ++ ++ static String getClassfileName(String[] names, ClassKind[] outerKinds, int pos) { ++ System.out.println(" pos = " + pos + " kind = " + outerKinds[pos] + " sep = " + outerKinds[pos].sep); ++ String name = outerKinds[pos] != ANON ? ++ names[pos] : ""; ++ if (pos == 0) { ++ return "Test" + outerKinds[pos].sep + name; ++ } else { ++ String outerStr = getClassfileName(names, outerKinds, pos - 1); ++ return outerStr + outerKinds[pos].sep + name; ++ } ++ } ++ ++ boolean isAllowed(ClassKind nestedKind) { ++ return nestedKind != NESTED || ++ staticAllowed; ++ } ++ } ++ ++ enum LocalInnerClass { ++ LOCAL_REF("class L {}; new L();", "Test$1L"), ++ LOCAL_NOREF("class L {};", "Test$1L"), ++ ANON("new Object() {};", "Test$1"), ++ NONE("", ""); ++ ++ String localInnerStr; ++ String canonicalInnerStr; ++ ++ private LocalInnerClass(String localInnerStr, String canonicalInnerStr) { ++ this.localInnerStr = localInnerStr; ++ this.canonicalInnerStr = canonicalInnerStr; ++ } ++ } ++ ++ public static void main(String... args) throws Exception { ++ for (ClassKind ck1 : ClassKind.values()) { ++ String cname1 = "C1"; ++ for (ClassKind ck2 : ClassKind.values()) { ++ if (!ck1.isAllowed(ck2)) continue; ++ String cname2 = "C2"; ++ for (ClassKind ck3 : ClassKind.values()) { ++ if (!ck2.isAllowed(ck3)) continue; ++ String cname3 = "C3"; ++ new T7003595(new ClassKind[] {ck1, ck2, ck3}, new String[] { cname1, cname2, cname3 }).compileAndCheck(); ++ } ++ } ++ } ++ ++ System.out.println("Total checks made: " + checkCount); ++ } ++ ++ /** instance decls **/ ++ ++ ClassKind[] cks; ++ String[] cnames; ++ ++ T7003595(ClassKind[] cks, String[] cnames) { ++ this.cks = cks; ++ this.cnames = cnames; ++ } ++ ++ void compileAndCheck() throws Exception { ++ final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); ++ JavaSource source = new JavaSource(); ++ JavacTask ct = (JavacTask)tool.getTask(null, fm, null, ++ null, null, Arrays.asList(source)); ++ ct.call(); ++ verifyBytecode(source); ++ } ++ ++ void verifyBytecode(JavaSource source) { ++ for (int i = 0; i < 3 ; i ++) { ++ if (cks[i] == ClassKind.NONE) break; ++ checkCount++; ++ String filename = cks[i].getClassfileName(cnames, cks, i); ++ File compiledTest = new File(filename + ".class"); ++ try { ++ ClassFile cf = ClassFile.read(compiledTest); ++ if (cf == null) { ++ throw new Error("Classfile not found: " + filename); ++ } ++ ++ InnerClasses_attribute innerClasses = (InnerClasses_attribute)cf.getAttribute(Attribute.InnerClasses); ++ ++ ArrayList<String> foundInnerSig = new ArrayList<>(); ++ if (innerClasses != null) { ++ for (InnerClasses_attribute.Info info : innerClasses.classes) { ++ String foundSig = info.getInnerClassInfo(cf.constant_pool).getName(); ++ foundInnerSig.add(foundSig); ++ } ++ } ++ ++ ArrayList<String> expectedInnerSig = new ArrayList<>(); ++ //add inner class (if any) ++ if (i < 2 && cks[i + 1] != ClassKind.NONE) { ++ expectedInnerSig.add(cks[i + 1].getClassfileName(cnames, cks, i + 1)); ++ } ++ //add inner classes ++ for (int j = 0 ; j != i + 1 && j < 3; j++) { ++ expectedInnerSig.add(cks[j].getClassfileName(cnames, cks, j)); ++ } ++ ++ if (expectedInnerSig.size() != foundInnerSig.size()) { ++ throw new Error("InnerClasses attribute for " + cnames[i] + " has wrong size\n" + ++ "expected " + expectedInnerSig.size() + "\n" + ++ "found " + innerClasses.number_of_classes + "\n" + ++ source); ++ } ++ ++ for (String foundSig : foundInnerSig) { ++ if (!expectedInnerSig.contains(foundSig)) { ++ throw new Error("InnerClasses attribute for " + cnames[i] + " has unexpected signature: " + ++ foundSig + "\n" + source + "\n" + expectedInnerSig); ++ } ++ } ++ ++ for (String expectedSig : expectedInnerSig) { ++ if (!foundInnerSig.contains(expectedSig)) { ++ throw new Error("InnerClasses attribute for " + cnames[i] + " does not contain expected signature: " + ++ expectedSig + "\n" + source); ++ } ++ } ++ } catch (Exception e) { ++ e.printStackTrace(); ++ throw new Error("error reading " + compiledTest +": " + e); ++ } ++ } ++ } ++ ++ class JavaSource extends SimpleJavaFileObject { ++ ++ static final String source_template = "class Test { #C }"; ++ ++ String source; ++ ++ public JavaSource() { ++ super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); ++ String c3 = cks[2].getSource(cnames[2], cnames[1], ""); ++ String c2 = cks[1].getSource(cnames[1], cnames[0], c3); ++ String c1 = cks[0].getSource(cnames[0], "Test", c2); ++ source = source_template.replace("#C", c1); ++ } ++ ++ @Override ++ public String toString() { ++ return source; ++ } ++ ++ @Override ++ public CharSequence getCharContent(boolean ignoreEncodingErrors) { ++ return source; ++ } ++ } ++} +diff --git a/test/tools/javac/7003595/T7003595b.java b/test/tools/javac/7003595/T7003595b.java +new file mode 100644 +--- /dev/null ++++ openjdk/langtools/test/tools/javac/7003595/T7003595b.java +@@ -0,0 +1,36 @@ ++/* ++ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ */ ++ ++/* ++ * @test ++ * @bug 7003595 ++ * @summary IncompatibleClassChangeError with unreferenced local class with subclass ++ */ ++ ++public class T7003595b { ++ public static void main(String... args) throws Exception { ++ class A {} ++ class B extends A {} ++ B.class.getSuperclass().getDeclaringClass(); ++ } ++}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/openjdk/7024568-long_method_resolution_oom_error.patch Wed Mar 27 21:14:08 2013 +0000 @@ -0,0 +1,115 @@ +# HG changeset patch +# User mcimadamore +# Date 1299507108 0 +# Node ID 74f0c05c51eb8e4ce08cdf8a3b8a33e36b09b5b2 +# Parent 5e6c661891da3dfbf371c1186df6cc0a77224951 +7024568: Very long method resolution causing OOM error +Summary: Resolve.findMethod scans same receiver type more than once in certain inheritance graphs +Reviewed-by: jjg +Contributed-by: jan.lahoda@oracle.com + +diff --git a/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/share/classes/com/sun/tools/javac/comp/Resolve.java +--- openjdk/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java ++++ openjdk/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java +@@ -45,7 +45,9 @@ + import javax.lang.model.element.ElementVisitor; + + import java.util.Map; ++import java.util.Set; + import java.util.HashMap; ++import java.util.HashSet; + + /** Helper class for name resolution, used mostly by the attribution phase. + * +@@ -896,7 +898,8 @@ + bestSoFar, + allowBoxing, + useVarargs, +- operator); ++ operator, ++ new HashSet<TypeSymbol>()); + } + // where + private Symbol findMethod(Env<AttrContext> env, +@@ -909,11 +912,13 @@ + Symbol bestSoFar, + boolean allowBoxing, + boolean useVarargs, +- boolean operator) { ++ boolean operator, ++ Set<TypeSymbol> seen) { + for (Type ct = intype; ct.tag == CLASS || ct.tag == TYPEVAR; ct = types.supertype(ct)) { + while (ct.tag == TYPEVAR) + ct = ct.getUpperBound(); + ClassSymbol c = (ClassSymbol)ct.tsym; ++ if (!seen.add(c)) return bestSoFar; + if ((c.flags() & (ABSTRACT | INTERFACE | ENUM)) == 0) + abstractok = false; + for (Scope.Entry e = c.members().lookup(name); +@@ -942,7 +947,7 @@ + bestSoFar = findMethod(env, site, name, argtypes, + typeargtypes, + l.head, abstractok, bestSoFar, +- allowBoxing, useVarargs, operator); ++ allowBoxing, useVarargs, operator, seen); + } + if (concrete != bestSoFar && + concrete.kind < ERR && bestSoFar.kind < ERR && +diff --git a/test/tools/javac/7024568/T7024568.java b/test/tools/javac/7024568/T7024568.java +new file mode 100644 +--- /dev/null ++++ openjdk/langtools/test/tools/javac/7024568/T7024568.java +@@ -0,0 +1,46 @@ ++/* ++ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ */ ++ ++/* @test ++ * @bug 7024568 ++ * @summary Very long method resolution causing OOM error ++ * @compile/fail/ref=T7024568.out -XDrawDiagnostics T7024568.java ++ */ ++ ++class Main { ++ void test(Obj o) { ++ o.test(0, 0, 0, 0, 0, 0, 0, 0, undefined); ++ } ++} ++ ++interface Test { ++ public void test(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, String str); ++ public void test(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, long l); ++} ++ ++interface Obj extends Test, A, B, C, D, E {} ++interface A extends Test {} ++interface B extends A, Test {} ++interface C extends A, B, Test {} ++interface D extends A, B, C, Test {} ++interface E extends A, B, C, D, Test {} +diff --git a/test/tools/javac/7024568/T7024568.out b/test/tools/javac/7024568/T7024568.out +new file mode 100644 +--- /dev/null ++++ openjdk/langtools/test/tools/javac/7024568/T7024568.out +@@ -0,0 +1,2 @@ ++T7024568.java:32:40: compiler.err.cant.resolve.location: kindname.variable, undefined, , , (compiler.misc.location: kindname.class, Main, null) ++1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/openjdk/7046929-fix_t6397104_test_failure.patch Wed Mar 27 21:14:08 2013 +0000 @@ -0,0 +1,42 @@ +# HG changeset patch +# User dmeetry +# Date 1326293347 -14400 +# Node ID 592c30109bbeb42a654b249f70f9feae1a24f377 +# Parent c66bb51b9aa74550f8719c5292fe09cda800f800 +7046929: tools/javac/api/T6397104.java fails +Reviewed-by: jjh + +diff --git a/test/tools/javac/api/T6397104.java b/test/tools/javac/api/T6397104.java +--- openjdk/langtools/test/tools/javac/api/T6397104.java ++++ openjdk/langtools/test/tools/javac/api/T6397104.java +@@ -26,10 +26,10 @@ + * @bug 6397104 + * @summary JSR 199: JavaFileManager.getFileForOutput should have sibling argument + * @author Peter von der Ah\u00e9 +- * @ignore this test should be rewritten when fixing 6473901 + */ + + import java.io.File; ++import java.net.URI; + import java.util.Arrays; + import javax.tools.*; + import javax.tools.JavaFileManager.Location; +@@ -52,10 +52,14 @@ + : fm.getJavaFileObjectsFromFiles(Arrays.asList(siblingFile)).iterator().next(); + FileObject fileObject = + fm.getFileForOutput(location, "java.lang", relName, sibling); +- if (!fileObject.toUri().getPath().equals(expectedPath)) +- throw new AssertionError("Expected " + expectedPath + +- ", got " + fileObject.toUri().getPath()); +- System.out.format("OK: (%s, %s) => %s%n", siblingFile, relName, fileObject.toUri()); ++ ++ File expectedFile = new File(expectedPath).getCanonicalFile(); ++ File fileObjectFile = new File(fileObject.toUri()).getCanonicalFile(); ++ ++ if (!fileObjectFile.equals(expectedFile)) ++ throw new AssertionError("Expected " + expectedFile + ++ ", got " + fileObjectFile); ++ System.out.format("OK: (%s, %s) => %s%n", siblingFile, relName, fileObjectFile); + } + + void test(boolean hasLocation, File siblingFile, String relName, String expectedPath)