From d4d5f60edc5a7be014d23a71eecd282b590d5bd2 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Thu, 4 Nov 2010 12:57:48 +0000 Subject: [PATCH 01/89] 6993963: Project Coin: Use precise exception analysis for effectively final catch parameters More precise rethrow analysis should be extended to effectively-final exception parameters. Multicatch parameters should be made implicitly final. Reviewed-by: jjg, darcy --- .../com/sun/tools/javac/code/Flags.java | 5 + .../com/sun/tools/javac/comp/Attr.java | 10 +- .../com/sun/tools/javac/comp/Flow.java | 16 ++-- .../tools/javac/resources/compiler.properties | 2 - .../javac/multicatch/Neg01eff_final.java | 28 ++++++ .../tools/javac/multicatch/Neg01eff_final.out | 2 + .../test/tools/javac/multicatch/Neg02.java | 4 +- .../test/tools/javac/multicatch/Neg02.out | 2 +- .../javac/multicatch/Neg02eff_final.java | 27 ++++++ .../tools/javac/multicatch/Neg02eff_final.out | 2 + .../test/tools/javac/multicatch/Neg03.java | 17 ++-- .../test/tools/javac/multicatch/Neg03.out | 2 +- .../javac/multicatch/Neg04eff_final.java | 31 ++++++ .../tools/javac/multicatch/Neg04eff_final.out | 2 + .../test/tools/javac/multicatch/Neg05.java | 33 +++++++ .../test/tools/javac/multicatch/Neg05.out | 2 + .../test/tools/javac/multicatch/Pos06.java | 27 ++++++ .../test/tools/javac/multicatch/Pos07.java | 49 ++++++++++ .../tools/javac/multicatch/model/Check.java | 27 ++++++ .../model/Member.java} | 19 ++-- .../tools/javac/multicatch/model/Model01.java | 48 ++++++++++ .../javac/multicatch/model/ModelChecker.java | 95 +++++++++++++++++++ 22 files changed, 412 insertions(+), 38 deletions(-) create mode 100644 langtools/test/tools/javac/multicatch/Neg01eff_final.java create mode 100644 langtools/test/tools/javac/multicatch/Neg01eff_final.out create mode 100644 langtools/test/tools/javac/multicatch/Neg02eff_final.java create mode 100644 langtools/test/tools/javac/multicatch/Neg02eff_final.out create mode 100644 langtools/test/tools/javac/multicatch/Neg04eff_final.java create mode 100644 langtools/test/tools/javac/multicatch/Neg04eff_final.out create mode 100644 langtools/test/tools/javac/multicatch/Neg05.java create mode 100644 langtools/test/tools/javac/multicatch/Neg05.out create mode 100644 langtools/test/tools/javac/multicatch/Pos06.java create mode 100644 langtools/test/tools/javac/multicatch/Pos07.java create mode 100644 langtools/test/tools/javac/multicatch/model/Check.java rename langtools/test/tools/javac/{diags/examples/MulticatchMustBeFinal.java => multicatch/model/Member.java} (74%) create mode 100644 langtools/test/tools/javac/multicatch/model/Model01.java create mode 100644 langtools/test/tools/javac/multicatch/model/ModelChecker.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java index 5b0b8bad260..a7abe98a5f0 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java @@ -247,6 +247,11 @@ public class Flags { */ public static final long OVERRIDE_BRIDGE = 1L<<41; + /** + * Flag that marks an 'effectively final' local variable + */ + public static final long EFFECTIVELY_FINAL = 1L<<42; + /** Modifier masks. */ public static final int diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index 610698b8fb4..d3bbf3da5ca 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -256,6 +256,8 @@ public class Attr extends JCTree.Visitor { } else { log.error(pos, "cant.assign.val.to.final.var", v); } + } else if ((v.flags() & EFFECTIVELY_FINAL) != 0) { + v.flags_field &= ~EFFECTIVELY_FINAL; } } @@ -799,6 +801,7 @@ public class Attr extends JCTree.Visitor { memberEnter.memberEnter(tree, env); annotate.flush(); } + tree.sym.flags_field |= EFFECTIVELY_FINAL; } VarSymbol v = tree.sym; @@ -1061,11 +1064,8 @@ public class Attr extends JCTree.Visitor { localEnv.dup(c, localEnv.info.dup(localEnv.info.scope.dup())); Type ctype = attribStat(c.param, catchEnv); if (TreeInfo.isMultiCatch(c)) { - //check that multi-catch parameter is marked as final - if ((c.param.sym.flags() & FINAL) == 0) { - log.error(c.param.pos(), "multicatch.param.must.be.final", c.param.sym); - } - c.param.sym.flags_field = c.param.sym.flags() | DISJUNCTION; + //multi-catch parameter is implicitly marked as final + c.param.sym.flags_field |= FINAL | DISJUNCTION; } if (c.param.sym.kind == Kinds.VAR) { c.param.sym.setData(ElementKind.EXCEPTION_PARAMETER); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java index fad6dad34af..93e2b9f4886 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java @@ -226,7 +226,7 @@ public class Flow extends TreeScanner { */ Bits uninits; - HashMap> multicatchTypes; + HashMap> preciseRethrowTypes; /** The set of variables that are definitely unassigned everywhere * in current try block. This variable is maintained lazily; it is @@ -332,7 +332,7 @@ public class Flow extends TreeScanner { if (!chk.isUnchecked(tree.pos(), exc)) { if (!chk.isHandled(exc, caught)) pendingExits.append(new PendingExit(tree, exc)); - thrown = chk.incl(exc, thrown); + thrown = chk.incl(exc, thrown); } } @@ -1077,12 +1077,12 @@ public class Flow extends TreeScanner { scan(param); inits.incl(param.sym.adr); uninits.excl(param.sym.adr); - multicatchTypes.put(param.sym, chk.intersect(ctypes, rethrownTypes)); + preciseRethrowTypes.put(param.sym, chk.intersect(ctypes, rethrownTypes)); scanStat(l.head.body); initsEnd.andSet(inits); uninitsEnd.andSet(uninits); nextadr = nextadrCatch; - multicatchTypes.remove(param.sym); + preciseRethrowTypes.remove(param.sym); aliveEnd |= alive; } if (tree.finalizer != null) { @@ -1215,10 +1215,10 @@ public class Flow extends TreeScanner { Symbol sym = TreeInfo.symbol(tree.expr); if (sym != null && sym.kind == VAR && - (sym.flags() & FINAL) != 0 && - multicatchTypes.get(sym) != null && + (sym.flags() & (FINAL | EFFECTIVELY_FINAL)) != 0 && + preciseRethrowTypes.get(sym) != null && allowRethrowAnalysis) { - for (Type t : multicatchTypes.get(sym)) { + for (Type t : preciseRethrowTypes.get(sym)) { markThrown(tree, t); } } @@ -1422,7 +1422,7 @@ public class Flow extends TreeScanner { firstadr = 0; nextadr = 0; pendingExits = new ListBuffer(); - multicatchTypes = new HashMap>(); + preciseRethrowTypes = new HashMap>(); alive = true; this.thrown = this.caught = null; this.classDef = null; diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties index 175c69a9c7c..ba7b98c609c 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -187,8 +187,6 @@ compiler.err.twr.resource.may.not.be.assigned=\ automatic resource {0} may not be assigned compiler.err.multicatch.parameter.may.not.be.assigned=\ multi-catch parameter {0} may not be assigned -compiler.err.multicatch.param.must.be.final=\ - multi-catch parameter {0} must be final compiler.err.finally.without.try=\ ''finally'' without ''try'' compiler.err.foreach.not.applicable.to.type=\ diff --git a/langtools/test/tools/javac/multicatch/Neg01eff_final.java b/langtools/test/tools/javac/multicatch/Neg01eff_final.java new file mode 100644 index 00000000000..46a23b20fd5 --- /dev/null +++ b/langtools/test/tools/javac/multicatch/Neg01eff_final.java @@ -0,0 +1,28 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6943289 + * + * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') + * @author darcy + * @compile/fail/ref=Neg01eff_final.out -XDrawDiagnostics Neg01eff_final.java + * @compile -source 6 -XDrawDiagnostics Neg01eff_final.java + * + */ + +class Neg01eff_final { + static class A extends Exception {} + static class B1 extends A {} + static class B2 extends A {} + + class Test { + void m() throws A { + try { + throw new B1(); + } catch (A ex1) { + try { + throw ex1; // used to throw A, now throws B1! + } catch (B2 ex2) { }//unreachable + } + } + } +} diff --git a/langtools/test/tools/javac/multicatch/Neg01eff_final.out b/langtools/test/tools/javac/multicatch/Neg01eff_final.out new file mode 100644 index 00000000000..6b6ab613949 --- /dev/null +++ b/langtools/test/tools/javac/multicatch/Neg01eff_final.out @@ -0,0 +1,2 @@ +Neg01eff_final.java:24:19: compiler.err.except.never.thrown.in.try: Neg01eff_final.B2 +1 error diff --git a/langtools/test/tools/javac/multicatch/Neg02.java b/langtools/test/tools/javac/multicatch/Neg02.java index 6312447eb53..d4bd4070cb6 100644 --- a/langtools/test/tools/javac/multicatch/Neg02.java +++ b/langtools/test/tools/javac/multicatch/Neg02.java @@ -20,6 +20,8 @@ class Neg02 { else { throw new B(); } - } catch (A | B ex) { } + } catch (final A | B ex) { + ex = new B(); + } } } diff --git a/langtools/test/tools/javac/multicatch/Neg02.out b/langtools/test/tools/javac/multicatch/Neg02.out index f1404578442..5033a5fa62f 100644 --- a/langtools/test/tools/javac/multicatch/Neg02.out +++ b/langtools/test/tools/javac/multicatch/Neg02.out @@ -1,2 +1,2 @@ -Neg02.java:23:24: compiler.err.multicatch.param.must.be.final: ex +Neg02.java:24:13: compiler.err.multicatch.parameter.may.not.be.assigned: ex 1 error diff --git a/langtools/test/tools/javac/multicatch/Neg02eff_final.java b/langtools/test/tools/javac/multicatch/Neg02eff_final.java new file mode 100644 index 00000000000..6430b541bf6 --- /dev/null +++ b/langtools/test/tools/javac/multicatch/Neg02eff_final.java @@ -0,0 +1,27 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6943289 6993963 + * + * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') + * @author mcimadamore + * @compile/fail/ref=Neg02eff_final.out -XDrawDiagnostics Neg02eff_final.java + * + */ + +class Neg02eff_final { + static class A extends Exception {} + static class B extends Exception {} + + void m() { + try { + if (true) { + throw new A(); + } + else { + throw new B(); + } + } catch (A | B ex) { + ex = new B(); + } + } +} diff --git a/langtools/test/tools/javac/multicatch/Neg02eff_final.out b/langtools/test/tools/javac/multicatch/Neg02eff_final.out new file mode 100644 index 00000000000..2d735a4cd6c --- /dev/null +++ b/langtools/test/tools/javac/multicatch/Neg02eff_final.out @@ -0,0 +1,2 @@ +Neg02eff_final.java:24:13: compiler.err.multicatch.parameter.may.not.be.assigned: ex +1 error diff --git a/langtools/test/tools/javac/multicatch/Neg03.java b/langtools/test/tools/javac/multicatch/Neg03.java index c9e0b202c54..cf13a6372ee 100644 --- a/langtools/test/tools/javac/multicatch/Neg03.java +++ b/langtools/test/tools/javac/multicatch/Neg03.java @@ -9,19 +9,22 @@ */ class Neg03 { - static class A extends Exception {} - static class B extends Exception {} - void m() { + static class A extends Exception { public void m() {}; public Object f;} + static class B1 extends A {} + static class B2 extends A {} + + void m() throws B1, B2 { try { if (true) { - throw new A(); + throw new B1(); } else { - throw new B(); + throw new B2(); } - } catch (final A | B ex) { - ex = new B(); + } catch (Exception ex) { + ex = new B2(); //effectively final analysis disabled! + throw ex; } } } diff --git a/langtools/test/tools/javac/multicatch/Neg03.out b/langtools/test/tools/javac/multicatch/Neg03.out index c854ee991ff..f3487a5ac93 100644 --- a/langtools/test/tools/javac/multicatch/Neg03.out +++ b/langtools/test/tools/javac/multicatch/Neg03.out @@ -1,2 +1,2 @@ -Neg03.java:24:13: compiler.err.multicatch.parameter.may.not.be.assigned: ex +Neg03.java:27:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception 1 error diff --git a/langtools/test/tools/javac/multicatch/Neg04eff_final.java b/langtools/test/tools/javac/multicatch/Neg04eff_final.java new file mode 100644 index 00000000000..ea2548df51d --- /dev/null +++ b/langtools/test/tools/javac/multicatch/Neg04eff_final.java @@ -0,0 +1,31 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6943289 + * + * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') + * @author mcimadamore + * @compile/fail/ref=Neg04eff_final.out -XDrawDiagnostics Neg04eff_final.java + * + */ + +class Neg04eff_final { + static class A extends Exception {} + static class B extends Exception {} + + void test() throws B { + try { + if (true) { + throw new A(); + } else if (false) { + throw new B(); + } else { + throw (Throwable)new Exception(); + } + } + catch (A e) {} + catch (Exception e) { + throw e; + } + catch (Throwable t) {} + } +} diff --git a/langtools/test/tools/javac/multicatch/Neg04eff_final.out b/langtools/test/tools/javac/multicatch/Neg04eff_final.out new file mode 100644 index 00000000000..e5b2e3d31de --- /dev/null +++ b/langtools/test/tools/javac/multicatch/Neg04eff_final.out @@ -0,0 +1,2 @@ +Neg04eff_final.java:27:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception +1 error diff --git a/langtools/test/tools/javac/multicatch/Neg05.java b/langtools/test/tools/javac/multicatch/Neg05.java new file mode 100644 index 00000000000..0dcb7db353d --- /dev/null +++ b/langtools/test/tools/javac/multicatch/Neg05.java @@ -0,0 +1,33 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6943289 + * + * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') + * @author mcimadamore + * @compile/fail/ref=Neg05.out -XDrawDiagnostics Neg05.java + * + */ + +class Neg02 { + + static class Foo { + Foo(X x) {} + } + + static interface Base {} + static class A extends Exception implements Base {} + static class B extends Exception implements Base {} + + void m() { + try { + if (true) { + throw new A(); + } + else { + throw new B(); + } + } catch (A | B ex) { + Foo f = new Foo<>(ex); + } + } +} diff --git a/langtools/test/tools/javac/multicatch/Neg05.out b/langtools/test/tools/javac/multicatch/Neg05.out new file mode 100644 index 00000000000..fbd05511adc --- /dev/null +++ b/langtools/test/tools/javac/multicatch/Neg05.out @@ -0,0 +1,2 @@ +Neg05.java:30:31: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg02.Foo), (compiler.misc.diamond.invalid.arg: java.lang.Exception&Neg02.Base>>, (compiler.misc.diamond: Neg02.Foo)) +1 error diff --git a/langtools/test/tools/javac/multicatch/Pos06.java b/langtools/test/tools/javac/multicatch/Pos06.java new file mode 100644 index 00000000000..4819b0afcce --- /dev/null +++ b/langtools/test/tools/javac/multicatch/Pos06.java @@ -0,0 +1,27 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6993963 + * + * @summary Project Coin: Use precise exception analysis for effectively final catch parameters + * @author mcimadamore + * @compile Pos06.java + * + */ + +class Pos06 { + static class A extends Exception {} + static class B extends Exception {} + + void m() { + try { + if (true) { + throw new A(); + } + else { + throw new B(); + } + } catch (A | B ex) { + System.out.println(ex); + } + } +} diff --git a/langtools/test/tools/javac/multicatch/Pos07.java b/langtools/test/tools/javac/multicatch/Pos07.java new file mode 100644 index 00000000000..3136ad25c43 --- /dev/null +++ b/langtools/test/tools/javac/multicatch/Pos07.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2010, 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 6993963 + * @summary Project Coin: Use precise exception analysis for effectively final catch parameters + * @compile Pos07.java + */ + +class Pos07 { + + static class A extends Exception { public void m() {}; public Object f;} + static class B1 extends A {} + static class B2 extends A {} + + void m() throws B1, B2 { + try { + if (true) { + throw new B1(); + } + else { + throw new B2(); + } + } catch (Exception ex) { //effectively final analysis + throw ex; + } + } +} diff --git a/langtools/test/tools/javac/multicatch/model/Check.java b/langtools/test/tools/javac/multicatch/model/Check.java new file mode 100644 index 00000000000..0f633e8436a --- /dev/null +++ b/langtools/test/tools/javac/multicatch/model/Check.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * Annotation used by ModelChecker to mark the class whose model is to be checked + */ +@interface Check {} diff --git a/langtools/test/tools/javac/diags/examples/MulticatchMustBeFinal.java b/langtools/test/tools/javac/multicatch/model/Member.java similarity index 74% rename from langtools/test/tools/javac/diags/examples/MulticatchMustBeFinal.java rename to langtools/test/tools/javac/multicatch/model/Member.java index 219f22add64..bf19ab1e2df 100644 --- a/langtools/test/tools/javac/diags/examples/MulticatchMustBeFinal.java +++ b/langtools/test/tools/javac/multicatch/model/Member.java @@ -21,18 +21,11 @@ * questions. */ -// key: compiler.err.multicatch.param.must.be.final +import javax.lang.model.element.ElementKind; -class MulticatchMustBeFinal { - void e1() throws NullPointerException { } - void e2() throws IllegalArgumentException { } - - void m() { - try { - e1(); - e2(); - } catch (NullPointerException | IllegalArgumentException e) { - e.printStackTrace(); - } - } +/** + * Annotation used by ModelChecker to mark a member that is to be checked + */ +@interface Member { + ElementKind value(); } diff --git a/langtools/test/tools/javac/multicatch/model/Model01.java b/langtools/test/tools/javac/multicatch/model/Model01.java new file mode 100644 index 00000000000..4a734ef9355 --- /dev/null +++ b/langtools/test/tools/javac/multicatch/model/Model01.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2010, 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. + */ + +import javax.lang.model.element.ElementKind; + +@Check +class Test { + + class A extends Exception { + @Member(ElementKind.METHOD) + public void m() {}; + @Member(ElementKind.FIELD) + public Object f; + } + + class B1 extends A {} + class B2 extends A {} + + void test(){ + try { + if (true) + throw new B1(); + else + throw new B2(); + } + catch(B1 | B2 ex) { } + } +} diff --git a/langtools/test/tools/javac/multicatch/model/ModelChecker.java b/langtools/test/tools/javac/multicatch/model/ModelChecker.java new file mode 100644 index 00000000000..2d1423c9437 --- /dev/null +++ b/langtools/test/tools/javac/multicatch/model/ModelChecker.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2010, 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 6993963 + * @summary Project Coin: Use precise exception analysis for effectively final catch parameters + * @library ../../lib + * @build JavacTestingAbstractProcessor ModelChecker + * @compile -processor ModelChecker Model01.java + */ + +import com.sun.source.tree.VariableTree; +import com.sun.source.util.TreePathScanner; +import com.sun.source.util.Trees; +import com.sun.source.util.TreePath; + +import java.util.Set; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.TypeElement; + +@SupportedAnnotationTypes("Check") +public class ModelChecker extends JavacTestingAbstractProcessor { + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + if (roundEnv.processingOver()) + return true; + + Trees trees = Trees.instance(processingEnv); + + TypeElement testAnno = elements.getTypeElement("Check"); + for (Element elem: roundEnv.getElementsAnnotatedWith(testAnno)) { + TreePath p = trees.getPath(elem); + new MulticatchParamTester(trees).scan(p, null); + } + return true; + } + + class MulticatchParamTester extends TreePathScanner { + Trees trees; + + public MulticatchParamTester(Trees trees) { + super(); + this.trees = trees; + } + + @Override + public Void visitVariable(VariableTree node, Void p) { + Element ex = trees.getElement(getCurrentPath()); + if (ex.getSimpleName().contentEquals("ex")) { + assertTrue(ex.getKind() == ElementKind.EXCEPTION_PARAMETER, "Expected EXCEPTION_PARAMETER - found " + ex.getKind()); + for (Element e : types.asElement(ex.asType()).getEnclosedElements()) { + Member m = e.getAnnotation(Member.class); + if (m != null) { + assertTrue(e.getKind() == m.value(), "Expected " + m.value() + " - found " + e.getKind()); + } + } + assertTrue(assertionCount == 3, "Expected 3 assertions - found " + assertionCount); + } + return super.visitVariable(node, p); + } + } + + private static void assertTrue(boolean cond, String msg) { + assertionCount++; + if (!cond) + throw new AssertionError(msg); + } + + static int assertionCount = 0; +} From e202a05c38e7d4a70cd25d3f8a8bdd9f7e902916 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Thu, 4 Nov 2010 12:58:29 +0000 Subject: [PATCH 02/89] 6714835: Safe cast is rejected (with warning) by javac Rules for unchecked cast conversion do not take into account type-containment Reviewed-by: jjg --- .../com/sun/tools/javac/code/Types.java | 2 +- .../tools/javac/cast/6467183/T6467183a.out | 4 +--- .../tools/javac/cast/6714835/T6714835.java | 21 +++++++++++++++++++ .../tools/javac/cast/6714835/T6714835.out | 5 +++++ 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 langtools/test/tools/javac/cast/6714835/T6714835.java create mode 100644 langtools/test/tools/javac/cast/6714835/T6714835.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index f6fd8fd721e..d9bd17efd92 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -3151,7 +3151,7 @@ public class Types { return to.isParameterized() && (!(isUnbounded(to) || isSubtype(from, to) || - ((subFrom != null) && isSameType(subFrom, to)))); + ((subFrom != null) && containsType(to.allparams(), subFrom.allparams())))); } private List superClosure(Type t, Type s) { diff --git a/langtools/test/tools/javac/cast/6467183/T6467183a.out b/langtools/test/tools/javac/cast/6467183/T6467183a.out index 972d54de989..562a48a09b1 100644 --- a/langtools/test/tools/javac/cast/6467183/T6467183a.out +++ b/langtools/test/tools/javac/cast/6467183/T6467183a.out @@ -1,6 +1,4 @@ T6467183a.java:16:26: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), T6467183a.B, T6467183a.A -T6467183a.java:24:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), T6467183a.A, T6467183a.C -T6467183a.java:28:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), T6467183a.A, T6467183a.C - compiler.err.warnings.and.werror 1 error -3 warnings +1 warning diff --git a/langtools/test/tools/javac/cast/6714835/T6714835.java b/langtools/test/tools/javac/cast/6714835/T6714835.java new file mode 100644 index 00000000000..6c31596ae14 --- /dev/null +++ b/langtools/test/tools/javac/cast/6714835/T6714835.java @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @author mcimadamore + * @bug 6714835 + * @summary Safe cast is rejected (with warning) by javac + * @compile/fail/ref=T6714835.out -Xlint:unchecked -Werror -XDrawDiagnostics T6714835.java + */ + +import java.util.*; + +class T6714835 { + void cast1(Iterable x) { + Collection x1 = (Collection)x; //ok + Collection x2 = (Collection)x; //warn + } + + void cast2(Iterable x) { + Collection x1 = (Collection)x; //ok + Collection x2 = (Collection)x; //warn + } +} diff --git a/langtools/test/tools/javac/cast/6714835/T6714835.out b/langtools/test/tools/javac/cast/6714835/T6714835.out new file mode 100644 index 00000000000..dc4a86b02ed --- /dev/null +++ b/langtools/test/tools/javac/cast/6714835/T6714835.out @@ -0,0 +1,5 @@ +T6714835.java:14:71: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.lang.Iterable, java.util.Collection +T6714835.java:19:73: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.lang.Iterable, java.util.Collection +- compiler.err.warnings.and.werror +1 error +2 warnings From aa4bee613c598bfae4ebe07ad029c6211540accc Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Sat, 6 Nov 2010 13:53:48 -0700 Subject: [PATCH 03/89] 6998063: new Scope impl to fix Scope performance issues Reviewed-by: jjg --- .../com/sun/tools/javac/code/Scope.java | 169 +++++++++++------- langtools/test/tools/javac/6996626/Main.java | 45 +++++ .../tools/javac/6996626/pack1/Symbol.java | 31 ++++ 3 files changed, 184 insertions(+), 61 deletions(-) create mode 100644 langtools/test/tools/javac/6996626/Main.java create mode 100644 langtools/test/tools/javac/6996626/pack1/Symbol.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java index 8bbc73d84d8..b491a49e69a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2010, 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 @@ -31,7 +31,8 @@ import java.util.Iterator; /** A scope represents an area of visibility in a Java program. The * Scope class is a container for symbols which provides * efficient access to symbols given their names. Scopes are implemented - * as hash tables. Scopes can be nested; the next field of a scope points + * as hash tables with "open addressing" and "double hashing". + * Scopes can be nested; the next field of a scope points * to its next outer scope. Nested scopes can share their hash tables. * *

This is NOT part of any supported API. @@ -55,7 +56,7 @@ public class Scope { /** A hash table for the scope's entries. */ - public Entry[] table; + Entry[] table; /** Mask for hash codes, always equal to (table.length - 1). */ @@ -67,8 +68,9 @@ public class Scope { public Entry elems; /** The number of elements in this scope. + * This includes deleted elements, whose value is the sentinel. */ - public int nelems = 0; + int nelems = 0; /** A timestamp - useful to quickly check whether a scope has changed or not */ @@ -109,7 +111,8 @@ public class Scope { } } - /** Every hash bucket is a list of Entry's which ends in sentinel. + /** Use as a "not-found" result for lookup. + * Also used to mark deleted entries in the table. */ private static final Entry sentinel = new Entry(null, null, null, null); @@ -130,12 +133,15 @@ public class Scope { this.owner = owner; this.table = table; this.hashMask = table.length - 1; - this.elems = null; - this.nelems = 0; - this.shared = 0; this.scopeCounter = scopeCounter; } + /** Convenience constructor used for dup and dupUnshared. */ + private Scope(Scope next, Symbol owner, Entry[] table) { + this(next, owner, table, next.scopeCounter); + this.nelems = next.nelems; + } + /** Construct a new scope, within scope next, with given owner, * using a fresh table of length INITIAL_SIZE. */ @@ -145,7 +151,6 @@ public class Scope { protected Scope(Symbol owner, ScopeCounter scopeCounter) { this(null, owner, new Entry[INITIAL_SIZE], scopeCounter); - for (int i = 0; i < INITIAL_SIZE; i++) table[i] = sentinel; } /** Construct a fresh scope within this scope, with same owner, @@ -154,11 +159,7 @@ public class Scope { * of fresh tables. */ public Scope dup() { - Scope result = new Scope(this, this.owner, this.table, scopeCounter); - shared++; - // System.out.println("====> duping scope " + this.hashCode() + " owned by " + this.owner + " to " + result.hashCode()); - // new Error().printStackTrace(System.out); - return result; + return dup(this.owner); } /** Construct a fresh scope within this scope, with new owner, @@ -167,7 +168,7 @@ public class Scope { * of fresh tables. */ public Scope dup(Symbol newOwner) { - Scope result = new Scope(this, newOwner, this.table, scopeCounter); + Scope result = new Scope(this, newOwner, this.table); shared++; // System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode()); // new Error().printStackTrace(System.out); @@ -179,7 +180,7 @@ public class Scope { * the table of its outer scope. */ public Scope dupUnshared() { - return new Scope(this, this.owner, this.table.clone(), scopeCounter); + return new Scope(this, this.owner, this.table.clone()); } /** Remove all entries of this scope from its table, if shared @@ -189,7 +190,7 @@ public class Scope { assert shared == 0; if (table != next.table) return next; while (elems != null) { - int hash = elems.sym.name.hashCode() & hashMask; + int hash = getIndex(elems.sym.name); Entry e = table[hash]; assert e == elems : elems.sym; table[hash] = elems.shadowed; @@ -197,6 +198,7 @@ public class Scope { } assert next.shared > 0; next.shared--; + next.nelems = nelems; // System.out.println("====> leaving scope " + this.hashCode() + " owned by " + this.owner + " to " + next.hashCode()); // new Error().printStackTrace(System.out); return next; @@ -215,19 +217,17 @@ public class Scope { s.hashMask = newtable.length - 1; } } - for (int i = 0; i < newtable.length; i++) newtable[i] = sentinel; - for (int i = 0; i < oldtable.length; i++) copy(oldtable[i]); - } - - /** Copy the given entry and all entries shadowed by it to table - */ - private void copy(Entry e) { - if (e.sym != null) { - copy(e.shadowed); - int hash = e.sym.name.hashCode() & hashMask; - e.shadowed = table[hash]; - table[hash] = e; + int n = 0; + for (int i = oldtable.length; --i >= 0; ) { + Entry e = oldtable[i]; + if (e != null && e != sentinel && ! e.isBogus()) { + table[getIndex(e.sym.name)] = e; + n++; + } } + // We don't need to update nelems for shared inherited scopes, + // since that gets handled by leave(). + nelems = n; } /** Enter symbol sym in this scope. @@ -248,13 +248,17 @@ public class Scope { */ public void enter(Symbol sym, Scope s, Scope origin) { assert shared == 0; - // Temporarily disabled (bug 6460352): - // if (nelems * 3 >= hashMask * 2) dble(); - int hash = sym.name.hashCode() & hashMask; - Entry e = makeEntry(sym, table[hash], elems, s, origin); + if (nelems * 3 >= hashMask * 2) + dble(); + int hash = getIndex(sym.name); + Entry old = table[hash]; + if (old == null) { + old = sentinel; + nelems++; + } + Entry e = makeEntry(sym, old, elems, s, origin); table[hash] = e; elems = e; - nelems++; scopeCounter.inc(); } @@ -268,15 +272,15 @@ public class Scope { public void remove(Symbol sym) { assert shared == 0; Entry e = lookup(sym.name); - while (e.scope == this && e.sym != sym) e = e.next(); if (e.scope == null) return; scopeCounter.inc(); // remove e from table and shadowed list; - Entry te = table[sym.name.hashCode() & hashMask]; + int i = getIndex(sym.name); + Entry te = table[i]; if (te == e) - table[sym.name.hashCode() & hashMask] = e.shadowed; + table[i] = e.shadowed; else while (true) { if (te.shadowed == e) { te.shadowed = e.shadowed; @@ -335,12 +339,50 @@ public class Scope { return lookup(name, noFilter); } public Entry lookup(Name name, Filter sf) { - Entry e = table[name.hashCode() & hashMask]; + Entry e = table[getIndex(name)]; + if (e == null || e == sentinel) + return sentinel; while (e.scope != null && (e.sym.name != name || !sf.accepts(e.sym))) e = e.shadowed; return e; } + /*void dump (java.io.PrintStream out) { + out.println(this); + for (int l=0; l < table.length; l++) { + Entry le = table[l]; + out.print("#"+l+": "); + if (le==sentinel) out.println("sentinel"); + else if(le == null) out.println("null"); + else out.println(""+le+" s:"+le.sym); + } + }*/ + + /** Look for slot in the table. + * We use open addressing with double hashing. + */ + int getIndex (Name name) { + int h = name.hashCode(); + int i = h & hashMask; + // The expression below is always odd, so it is guaranteed + // be be mutually prime with table.length, a power of 2. + int x = hashMask - ((h + (h >> 16)) << 1); + int d = -1; // Index of a deleted item. + for (;;) { + Entry e = table[i]; + if (e == null) + return d >= 0 ? d : i; + if (e == sentinel) { + // We have to keep searching even if we see a deleted item. + // However, remember the index in case we fail to find the name. + if (d < 0) + d = i; + } else if (e.sym.name == name) + return i; + i = (i + x) & hashMask; + } + } + public Iterable getElements() { return getElements(noFilter); } @@ -441,10 +483,7 @@ public class Scope { * outwards if not found in this scope. */ public Entry next() { - Entry e = shadowed; - while (e.scope != null && e.sym.name != sym.name) - e = e.shadowed; - return e; + return shadowed; } public Scope getOrigin() { @@ -456,6 +495,8 @@ public class Scope { // in many cases. return scope; } + + protected boolean isBogus () { return false; } } public static class ImportScope extends Scope { @@ -470,22 +511,10 @@ public class Scope { } public Entry lookup(Name name) { - Entry e = table[name.hashCode() & hashMask]; - while (e.scope != null && - (e.sym.name != name || - /* Since an inner class will show up in package and - * import scopes until its inner class attribute has - * been processed, we have to weed it out here. This - * is done by comparing the owners of the entry's - * scope and symbol fields. The scope field's owner - * points to where the class originally was imported - * from. The symbol field's owner points to where the - * class is situated now. This can change when an - * inner class is read (see ClassReader.enterClass). - * By comparing the two fields we make sure that we do - * not accidentally import an inner class that started - * life as a flat class in a package. */ - e.sym.owner != e.scope.owner)) + Entry e = table[getIndex(name)]; + if (e == null) + return sentinel; + while (e.isBogus()) e = e.shadowed; return e; } @@ -499,15 +528,33 @@ public class Scope { } public Entry next() { Entry e = super.shadowed; - while (e.scope != null && - (e.sym.name != sym.name || - e.sym.owner != e.scope.owner)) // see lookup() + while (isBogus()) e = e.shadowed; return e; } @Override public Scope getOrigin() { return origin; } + + /** + * Is this a bogus inner-class import? + * An inner class {@code Outer$Inner.class} read from a class file + * starts out in a package scope under the name {@code Outer$Inner}, + * which (if star-imported) gets copied to the import scope. + * When the InnerClasses attribute is processed, the ClassSymbol + * is renamed in place (to {@code Inner}), and the owner changed + * to the {@code Outer} class. The ImportScope still has the old + * Entry that was created and hashed as {@code "Outer$Inner"}, + * but whose name was changed to {@code "Inner"}. This violates + * the invariants for the Scope hash table, and so is pretty bogus. + * When the symbol was renamed, it should have been removed from + * the import scope (and not just the package scope); however, + * doing so is difficult. A better fix would be to change + * import scopes to indirectly reference package symbols, rather + * than copy from them. + * Until then, we detect and skip the bogus entries using this test. + */ + protected boolean isBogus () { return sym.owner != scope.owner; } } } diff --git a/langtools/test/tools/javac/6996626/Main.java b/langtools/test/tools/javac/6996626/Main.java new file mode 100644 index 00000000000..6c3848050a1 --- /dev/null +++ b/langtools/test/tools/javac/6996626/Main.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2010, 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 6996626 + * @summary Scope fix issues for ImportScope + * @compile pack1/Symbol.java + * @compile Main.java + */ + +import pack1.*; +import pack1.Symbol.*; + +// The following imports are just to trigger re-hashing (in +// com.sun.tools.javac.code.Scope.dble()) of the star-import scope. +import java.io.*; +import java.net.*; +import java.util.*; + +public class Main { + public void main (String[] args) { + throw new CompletionFailure(); + } +} + diff --git a/langtools/test/tools/javac/6996626/pack1/Symbol.java b/langtools/test/tools/javac/6996626/pack1/Symbol.java new file mode 100644 index 00000000000..583cd647240 --- /dev/null +++ b/langtools/test/tools/javac/6996626/pack1/Symbol.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2010, 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. + */ + +package pack1; + +public class Symbol { + public static class CompletionFailure extends RuntimeException { } +} + + + From 1546b42862dd3a9ba0f183ca4a11333615270f76 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 9 Nov 2010 17:49:24 -0800 Subject: [PATCH 04/89] 6997958: test tools/javac/api/T6412669.java fails in PIT Reviewed-by: darcy --- langtools/test/tools/javac/api/T6412669.java | 54 ++++++++++++++++---- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/langtools/test/tools/javac/api/T6412669.java b/langtools/test/tools/javac/api/T6412669.java index 465ee25422d..ef4eeefe50f 100644 --- a/langtools/test/tools/javac/api/T6412669.java +++ b/langtools/test/tools/javac/api/T6412669.java @@ -23,11 +23,12 @@ /* * @test - * @bug 6412669 + * @bug 6412669 6997958 * @summary Should be able to get SourcePositions from 269 world */ import java.io.*; +import java.net.*; import java.util.*; import javax.annotation.*; import javax.annotation.processing.*; @@ -39,28 +40,59 @@ import com.sun.tools.javac.api.*; @SupportedAnnotationTypes("*") public class T6412669 extends AbstractProcessor { - public static void main(String... args) throws IOException { - String testSrc = System.getProperty("test.src", "."); - String testClasses = System.getProperty("test.classes", "."); + public static void main(String... args) throws Exception { + File testSrc = new File(System.getProperty("test.src", ".")); + File testClasses = new File(System.getProperty("test.classes", ".")); + + // Determine location of necessary tools classes. Assume all in one place. + // Likely candidates are typically tools.jar (when testing JDK build) + // or build/classes or dist/javac.jar (when testing langtools, using -Xbootclasspath/p:) + File toolsClasses; + URL u = T6412669.class.getClassLoader().getResource("com/sun/source/util/JavacTask.class"); + switch (u.getProtocol()) { + case "file": + toolsClasses = new File(u.toURI()); + break; + case "jar": + String s = u.getFile(); // will be file:path!/entry + int sep = s.indexOf("!"); + toolsClasses = new File(new URI(s.substring(0, sep))); + break; + default: + throw new AssertionError("Cannot locate tools classes"); + } + //System.err.println("toolsClasses: " + toolsClasses); JavacTool tool = JavacTool.create(); StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); - fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File(testClasses))); + fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(testClasses, toolsClasses)); Iterable files = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6412669.class.getName()+".java"))); - String[] opts = { "-proc:only", "-processor", T6412669.class.getName(), - "-classpath", new File(testClasses).getPath() }; - JavacTask task = tool.getTask(null, fm, null, Arrays.asList(opts), null, files); - if (!task.call()) - throw new AssertionError("test failed"); + String[] opts = { "-proc:only", "-processor", T6412669.class.getName()}; + StringWriter sw = new StringWriter(); + JavacTask task = tool.getTask(sw, fm, null, Arrays.asList(opts), null, files); + boolean ok = task.call(); + String out = sw.toString(); + if (!out.isEmpty()) + System.err.println(out); + if (!ok) + throw new AssertionError("compilation of test program failed"); + // verify we found an annotated element to exercise the SourcePositions API + if (!out.contains("processing element")) + throw new AssertionError("expected text not found in compilation output"); } public boolean process(Set annotations, RoundEnvironment roundEnv) { Trees trees = Trees.instance(processingEnv); SourcePositions sp = trees.getSourcePositions(); Messager m = processingEnv.getMessager(); + m.printMessage(Diagnostic.Kind.NOTE, "processing annotations"); + int count = 0; for (TypeElement anno: annotations) { + count++; + m.printMessage(Diagnostic.Kind.NOTE, " processing annotation " + anno); for (Element e: roundEnv.getElementsAnnotatedWith(anno)) { + m.printMessage(Diagnostic.Kind.NOTE, " processing element " + e); TreePath p = trees.getPath(e); long start = sp.getStartPosition(p.getCompilationUnit(), p.getLeaf()); long end = sp.getEndPosition(p.getCompilationUnit(), p.getLeaf()); @@ -69,6 +101,8 @@ public class T6412669 extends AbstractProcessor { m.printMessage(k, "test [" + start + "," + end + "]", e); } } + if (count == 0) + m.printMessage(Diagnostic.Kind.NOTE, "no annotations found"); return true; } From 4fd5dcc367ecf54b4ef2e2ca7358b6e44b7c5e23 Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Tue, 9 Nov 2010 23:05:33 -0800 Subject: [PATCH 05/89] 6992226: Missing windows COMPANY file property settings Reviewed-by: ohair --- jdk/make/common/Defs.gmk | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/jdk/make/common/Defs.gmk b/jdk/make/common/Defs.gmk index 31e3a4a8f65..71ab366ab61 100644 --- a/jdk/make/common/Defs.gmk +++ b/jdk/make/common/Defs.gmk @@ -83,14 +83,19 @@ ifndef CLOSED_SRC CLOSED_SRC = $(BUILDDIR)/../src/closed endif -# If we have no closed directory, force it to an openjdk build -CLOSED_SRC_DIR_EXISTS := $(shell \ - if [ -d $(CLOSED_SRC) ] ; then \ - echo true; \ - else \ - echo false; \ - fi) -ifeq ($(CLOSED_SRC_DIR_EXISTS), false) +# If CLOSE_SRC_INCLUDED isn't set to true, check if there's any +# closed directory. +ifneq ($(CLOSED_SRC_INCLUDED), true) + CLOSED_SRC_INCLUDED := $(shell \ + if [ -d $(CLOSED_SRC) ] ; then \ + echo true; \ + else \ + echo false; \ + fi) +endif + +# Set OPENJDK based on CLOSED_SRC_INCLUDED +ifeq ($(CLOSED_SRC_INCLUDED), false) OPENJDK = true endif From 83fb083bfa14c049b118e053d31a7f64abb4dde1 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Wed, 10 Nov 2010 12:37:25 +0000 Subject: [PATCH 06/89] 6996914: Diamond inference: problem when accessing protected constructor Special resolution scheme for diamond inference needs to open up protected constructors in anon inner class creation Reviewed-by: jjg --- .../com/sun/tools/javac/comp/Attr.java | 10 +- .../generics/diamond/6996914/T6996914a.java | 171 ++++++++++++++++++ .../generics/diamond/6996914/T6996914b.java | 39 ++++ 3 files changed, 218 insertions(+), 2 deletions(-) create mode 100644 langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java create mode 100644 langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index d3bbf3da5ca..966713bffa6 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -1552,7 +1552,7 @@ public class Attr extends JCTree.Visitor { // Attribute clazz expression and store // symbol + type back into the attributed tree. Type clazztype = attribType(clazz, env); - Pair mapping = getSyntheticScopeMapping(clazztype); + Pair mapping = getSyntheticScopeMapping(clazztype, cdef != null); if (!TreeInfo.isDiamond(tree)) { clazztype = chk.checkClassType( tree.clazz.pos(), clazztype, true); @@ -1849,7 +1849,7 @@ public class Attr extends JCTree.Visitor { * inference. The inferred return type of the synthetic constructor IS * the inferred type for the diamond operator. */ - private Pair getSyntheticScopeMapping(Type ctype) { + private Pair getSyntheticScopeMapping(Type ctype, boolean overrideProtectedAccess) { if (ctype.tag != CLASS) { return erroneousMapping; } @@ -1860,6 +1860,12 @@ public class Attr extends JCTree.Visitor { e.scope != null; e = e.next()) { MethodSymbol newConstr = (MethodSymbol) e.sym.clone(ctype.tsym); + if (overrideProtectedAccess && (newConstr.flags() & PROTECTED) != 0) { + //make protected constructor public (this is required for + //anonymous inner class creation expressions using diamond) + newConstr.flags_field |= PUBLIC; + newConstr.flags_field &= ~PROTECTED; + } newConstr.name = names.init; List oldTypeargs = List.nil(); if (newConstr.type.tag == FORALL) { diff --git a/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java b/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java new file mode 100644 index 00000000000..b0bc084570a --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2010, 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 6996914 + * @summary Diamond inference: problem when accessing protected constructor + * @run main T6996914a + */ + +import com.sun.source.util.JavacTask; +import java.net.URI; +import java.util.Arrays; +import javax.tools.Diagnostic; +import javax.tools.DiagnosticListener; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +public class T6996914a { + + enum PackageKind { + DEFAULT("", ""), + A("package a;", "import a.*;"); + + String pkgDecl; + String importDecl; + + PackageKind(String pkgDecl, String importDecl) { + this.pkgDecl = pkgDecl; + this.importDecl = importDecl; + } + } + + enum DiamondKind { + STANDARD("new Foo<>();"), + ANON("new Foo<>() {};"); + + String expr; + + DiamondKind(String expr) { + this.expr = expr; + } + } + + enum ConstructorKind { + PACKAGE(""), + PROTECTED("protected"), + PRIVATE("private"), + PUBLIC("public"); + + String mod; + + ConstructorKind(String mod) { + this.mod = mod; + } + } + + static class FooClass extends SimpleJavaFileObject { + + final static String sourceStub = + "#P\n" + + "public class Foo {\n" + + " #M Foo() {}\n" + + "}\n"; + + String source; + + public FooClass(PackageKind pk, ConstructorKind ck) { + super(URI.create("myfo:/" + (pk != PackageKind.DEFAULT ? "a/Foo.java" : "Foo.java")), + JavaFileObject.Kind.SOURCE); + source = sourceStub.replace("#P", pk.pkgDecl).replace("#M", ck.mod); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + static class ClientClass extends SimpleJavaFileObject { + + final static String sourceStub = + "#I\n" + + "class Test {\n" + + " Foo fs = #D\n" + + "}\n"; + + String source; + + public ClientClass(PackageKind pk, DiamondKind dk) { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = sourceStub.replace("#I", pk.importDecl).replace("#D", dk.expr); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + public static void main(String... args) throws Exception { + for (PackageKind pk : PackageKind.values()) { + for (ConstructorKind ck : ConstructorKind.values()) { + for (DiamondKind dk : DiamondKind.values()) { + compileAndCheck(pk, ck, dk); + } + } + } + } + + static void compileAndCheck(PackageKind pk, ConstructorKind ck, DiamondKind dk) throws Exception { + FooClass foo = new FooClass(pk, ck); + ClientClass client = new ClientClass(pk, dk); + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); + ErrorListener el = new ErrorListener(); + JavacTask ct = (JavacTask)tool.getTask(null, null, el, + null, null, Arrays.asList(foo, client)); + ct.analyze(); + if (el.errors > 0 == check(pk, ck, dk)) { + String msg = el.errors > 0 ? + "Error compiling files" : + "No error when compiling files"; + throw new AssertionError(msg + ": \n" + foo.source + "\n" + client.source); + } + } + + static boolean check(PackageKind pk, ConstructorKind ck, DiamondKind dk) { + switch (pk) { + case A: return ck == ConstructorKind.PUBLIC || + (ck == ConstructorKind.PROTECTED && dk == DiamondKind.ANON); + case DEFAULT: return ck != ConstructorKind.PRIVATE; + default: throw new AssertionError("Unknown package kind"); + } + } + + /** + * DiagnosticListener to count any errors that occur + */ + private static class ErrorListener implements DiagnosticListener { + + public void report(Diagnostic diagnostic) { + switch (diagnostic.getKind()) { + case ERROR: + errors++; + } + } + int errors; + } +} diff --git a/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java b/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java new file mode 100644 index 00000000000..d82e7998c13 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2010, 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 6996914 + * @summary Diamond inference: problem when accessing protected constructor + * @compile T6996914b.java + */ + +class Super { + private Super(Integer i, Y y, X x) {} + public Super(Number n, X x, Y y) {} +} + +class Test { + Super ssi1 = new Super<>(1, "", 2); + Super ssi2 = new Super<>(1, "", 2) {}; +} From 8f61f3fcff8890befd7d07395ab0b8e1e58be696 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Fri, 12 Nov 2010 12:32:43 +0000 Subject: [PATCH 07/89] 6598108: com.sun.source.util.Trees.isAccessible incorrect JavacTrees' version of isAccessible should take into account enclosing class accessibility Reviewed-by: jjg --- .../com/sun/tools/javac/api/JavacTrees.java | 5 +- .../com/sun/tools/javac/comp/Resolve.java | 77 ++++++++++++------- .../tools/javac/api/6598108/T6598108.java | 71 +++++++++++++++++ 3 files changed, 122 insertions(+), 31 deletions(-) create mode 100644 langtools/test/tools/javac/api/6598108/T6598108.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java index a61630bf9cc..9eeff6908d7 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java @@ -49,6 +49,7 @@ import com.sun.tools.javac.code.Flags; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.TypeSymbol; import com.sun.tools.javac.code.Symbol; +import com.sun.tools.javac.code.Type; import com.sun.tools.javac.comp.Attr; import com.sun.tools.javac.comp.AttrContext; import com.sun.tools.javac.comp.Enter; @@ -230,7 +231,7 @@ public class JavacTrees extends Trees { public boolean isAccessible(Scope scope, TypeElement type) { if (scope instanceof JavacScope && type instanceof ClassSymbol) { Env env = ((JavacScope) scope).env; - return resolve.isAccessible(env, (ClassSymbol)type); + return resolve.isAccessible(env, (ClassSymbol)type, true); } else return false; } @@ -240,7 +241,7 @@ public class JavacTrees extends Trees { && member instanceof Symbol && type instanceof com.sun.tools.javac.code.Type) { Env env = ((JavacScope) scope).env; - return resolve.isAccessible(env, (com.sun.tools.javac.code.Type)type, (Symbol)member); + return resolve.isAccessible(env, (com.sun.tools.javac.code.Type)type, (Symbol)member, true); } else return false; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java index 85d8161dac6..c8b83de4535 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -159,33 +159,45 @@ public class Resolve { * @param c The class whose accessibility is checked. */ public boolean isAccessible(Env env, TypeSymbol c) { + return isAccessible(env, c, false); + } + + public boolean isAccessible(Env env, TypeSymbol c, boolean checkInner) { + boolean isAccessible = false; switch ((short)(c.flags() & AccessFlags)) { - case PRIVATE: - return - env.enclClass.sym.outermostClass() == - c.owner.outermostClass(); - case 0: - return - env.toplevel.packge == c.owner // fast special case - || - env.toplevel.packge == c.packge() - || - // Hack: this case is added since synthesized default constructors - // of anonymous classes should be allowed to access - // classes which would be inaccessible otherwise. - env.enclMethod != null && - (env.enclMethod.mods.flags & ANONCONSTR) != 0; - default: // error recovery - case PUBLIC: - return true; - case PROTECTED: - return - env.toplevel.packge == c.owner // fast special case - || - env.toplevel.packge == c.packge() - || - isInnerSubClass(env.enclClass.sym, c.owner); + case PRIVATE: + isAccessible = + env.enclClass.sym.outermostClass() == + c.owner.outermostClass(); + break; + case 0: + isAccessible = + env.toplevel.packge == c.owner // fast special case + || + env.toplevel.packge == c.packge() + || + // Hack: this case is added since synthesized default constructors + // of anonymous classes should be allowed to access + // classes which would be inaccessible otherwise. + env.enclMethod != null && + (env.enclMethod.mods.flags & ANONCONSTR) != 0; + break; + default: // error recovery + case PUBLIC: + isAccessible = true; + break; + case PROTECTED: + isAccessible = + env.toplevel.packge == c.owner // fast special case + || + env.toplevel.packge == c.packge() + || + isInnerSubClass(env.enclClass.sym, c.owner); + break; } + return (checkInner == false || c.type.getEnclosingType() == Type.noType) ? + isAccessible : + isAccessible & isAccessible(env, c.type.getEnclosingType(), checkInner); } //where /** Is given class a subclass of given base class, or an inner class @@ -202,9 +214,13 @@ public class Resolve { } boolean isAccessible(Env env, Type t) { + return isAccessible(env, t, false); + } + + boolean isAccessible(Env env, Type t, boolean checkInner) { return (t.tag == ARRAY) ? isAccessible(env, types.elemtype(t)) - : isAccessible(env, t.tsym); + : isAccessible(env, t.tsym, checkInner); } /** Is symbol accessible as a member of given type in given evironment? @@ -214,6 +230,9 @@ public class Resolve { * @param sym The symbol. */ public boolean isAccessible(Env env, Type site, Symbol sym) { + return isAccessible(env, site, sym, false); + } + public boolean isAccessible(Env env, Type site, Symbol sym, boolean checkInner) { if (sym.name == names.init && sym.owner != site.tsym) return false; ClassSymbol sub; switch ((short)(sym.flags() & AccessFlags)) { @@ -231,7 +250,7 @@ public class Resolve { || env.toplevel.packge == sym.packge()) && - isAccessible(env, site) + isAccessible(env, site, checkInner) && sym.isInheritedIn(site.tsym, types) && @@ -248,11 +267,11 @@ public class Resolve { // (but type names should be disallowed elsewhere!) env.info.selectSuper && (sym.flags() & STATIC) == 0 && sym.kind != TYP) && - isAccessible(env, site) + isAccessible(env, site, checkInner) && notOverriddenIn(site, sym); default: // this case includes erroneous combinations as well - return isAccessible(env, site) && notOverriddenIn(site, sym); + return isAccessible(env, site, checkInner) && notOverriddenIn(site, sym); } } //where diff --git a/langtools/test/tools/javac/api/6598108/T6598108.java b/langtools/test/tools/javac/api/6598108/T6598108.java new file mode 100644 index 00000000000..a7ca25971aa --- /dev/null +++ b/langtools/test/tools/javac/api/6598108/T6598108.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2010, 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 6598108 + * @summary com.sun.source.util.Trees.isAccessible incorrect + * @author Jan Lahoda + */ + +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.Scope; +import com.sun.source.util.JavacTask; +import com.sun.source.util.TreePath; +import com.sun.source.util.Trees; +import java.net.URI; +import java.util.Arrays; +import javax.lang.model.element.TypeElement; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +public class T6598108 { + public static void main(String[] args) throws Exception { + final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); + assert tool != null; + final JavacTask ct = (JavacTask)tool.getTask(null, null, null, Arrays.asList("-bootclasspath", bootPath), null, Arrays.asList(new MyFileObject())); + + CompilationUnitTree cut = ct.parse().iterator().next(); + TreePath tp = new TreePath(new TreePath(cut), cut.getTypeDecls().get(0)); + Scope s = Trees.instance(ct).getScope(tp); + TypeElement type = ct.getElements().getTypeElement("com.sun.java.util.jar.pack.Package.File"); + + if (Trees.instance(ct).isAccessible(s, type)) { + //com.sun.java.util.jar.pack.Package.File is a public innerclass inside a non-accessible class, so + //"false" would be expected here. + throw new IllegalStateException(""); + } + } + + static class MyFileObject extends SimpleJavaFileObject { + public MyFileObject() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + } + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return "public class Test { public void test() {TTT ttt;}}"; + } + } +} From bb03754fd1f515481d578319d9d4bd77d2ac693a Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Fri, 12 Nov 2010 12:33:52 +0000 Subject: [PATCH 08/89] 6999067: cast for invokeExact call gets redundant cast to warnings Xlint:cast should not report cast used in order to specify target type in polymorphic signature calls Reviewed-by: jjg --- .../com/sun/tools/javac/comp/Flow.java | 15 ++++++- .../test/tools/javac/meth/XlintWarn.java | 42 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 langtools/test/tools/javac/meth/XlintWarn.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java index 93e2b9f4886..e0bb79fe760 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java @@ -1371,11 +1371,24 @@ public class Flow extends TreeScanner { if (!tree.type.isErroneous() && lint.isEnabled(Lint.LintCategory.CAST) && types.isSameType(tree.expr.type, tree.clazz.type) - && !(ignoreAnnotatedCasts && containsTypeAnnotation(tree.clazz))) { + && !(ignoreAnnotatedCasts && containsTypeAnnotation(tree.clazz)) + && !is292targetTypeCast(tree)) { log.warning(Lint.LintCategory.CAST, tree.pos(), "redundant.cast", tree.expr.type); } } + //where + private boolean is292targetTypeCast(JCTypeCast tree) { + boolean is292targetTypeCast = false; + if (tree.expr.getTag() == JCTree.APPLY) { + JCMethodInvocation apply = (JCMethodInvocation)tree.expr; + Symbol sym = TreeInfo.symbol(apply.meth); + is292targetTypeCast = sym != null && + sym.kind == MTH && + (sym.flags() & POLYMORPHIC_SIGNATURE) != 0; + } + return is292targetTypeCast; + } public void visitTopLevel(JCCompilationUnit tree) { // Do nothing for TopLevel since each class is visited individually diff --git a/langtools/test/tools/javac/meth/XlintWarn.java b/langtools/test/tools/javac/meth/XlintWarn.java new file mode 100644 index 00000000000..294cd34f106 --- /dev/null +++ b/langtools/test/tools/javac/meth/XlintWarn.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2008, 2010, 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 6999067 + * @summary cast for invokeExact call gets redundant cast to warnings + * @author mcimadamore + * + * @compile -Werror -Xlint:cast XlintWarn.java + */ + +import java.dyn.*; + +class XlintWarn { + void test(MethodHandle mh) throws Throwable { + int i1 = (int)mh.invoke(); + int i2 = (int)mh.invokeExact(); + int i3 = (int)mh.invokeVarargs(); + int i4 = (int)InvokeDynamic.test(); + } +} From 64789c249195482a2804e12bda7888e172921ce0 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Fri, 12 Nov 2010 12:34:18 +0000 Subject: [PATCH 09/89] 6970016: Clean up ARM/try-with-resources implementation Changed Xlint option name from -Xlint:arm to -Xlint:try Reviewed-by: jjg --- .../com/sun/tools/javac/code/Lint.java | 4 ++-- .../com/sun/tools/javac/comp/Attr.java | 10 ++++---- .../com/sun/tools/javac/comp/Flow.java | 6 ++--- .../sun/tools/javac/parser/JavacParser.java | 6 ++--- .../tools/javac/resources/compiler.properties | 23 ++++++++++--------- .../tools/javac/TryWithResources/ArmLint.out | 3 --- .../javac/TryWithResources/ImplicitFinal.out | 2 +- .../{ArmLint.java => TwrLint.java} | 16 ++++++------- .../tools/javac/TryWithResources/TwrLint.out | 3 +++ .../TryWithResources/TwrOnNonResource.out | 12 +++++----- .../javac/diags/examples/ResourceClosed.java | 4 ++-- .../examples/ResourceMayNotBeAssigned.java | 2 +- .../examples/ResourceNotApplicableToType.java | 2 +- .../diags/examples/ResourceNotReferenced.java | 4 ++-- .../examples/TryResourceNotSupported.java | 2 +- 15 files changed, 50 insertions(+), 49 deletions(-) delete mode 100644 langtools/test/tools/javac/TryWithResources/ArmLint.out rename langtools/test/tools/javac/TryWithResources/{ArmLint.java => TwrLint.java} (68%) create mode 100644 langtools/test/tools/javac/TryWithResources/TwrLint.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java b/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java index 3b9ca6f4c51..5145ca2a4c4 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java @@ -212,9 +212,9 @@ public class Lint VARARGS("varargs"), /** - * Warn about arm resources + * Warn about issues relating to use of try blocks (i.e. try-with-resources) */ - ARM("arm"); + TRY("try"); LintCategory(String option) { this(option, false); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index 966713bffa6..54b2c84b96e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -252,7 +252,7 @@ public class Attr extends JCTree.Visitor { (base.getTag() == JCTree.IDENT && TreeInfo.name(base) == names._this)) && isAssignableAsBlankFinal(v, env)))) { if (v.isResourceVariable()) { //TWR resource - log.error(pos, "twr.resource.may.not.be.assigned", v); + log.error(pos, "try.resource.may.not.be.assigned", v); } else { log.error(pos, "cant.assign.val.to.final.var", v); } @@ -1045,11 +1045,11 @@ public class Attr extends JCTree.Visitor { for (JCTree resource : tree.resources) { if (resource.getTag() == JCTree.VARDEF) { attribStat(resource, tryEnv); - chk.checkType(resource, resource.type, syms.autoCloseableType, "twr.not.applicable.to.type"); + chk.checkType(resource, resource.type, syms.autoCloseableType, "try.not.applicable.to.type"); VarSymbol var = (VarSymbol)TreeInfo.symbolFor(resource); var.setData(ElementKind.RESOURCE_VARIABLE); } else { - attribExpr(resource, tryEnv, syms.autoCloseableType, "twr.not.applicable.to.type"); + attribExpr(resource, tryEnv, syms.autoCloseableType, "try.not.applicable.to.type"); } } // Attribute body @@ -2258,8 +2258,8 @@ public class Attr extends JCTree.Visitor { ((VarSymbol)sitesym).isResourceVariable() && sym.kind == MTH && sym.overrides(syms.autoCloseableClose, sitesym.type.tsym, types, true) && - env.info.lint.isEnabled(Lint.LintCategory.ARM)) { - log.warning(tree, "twr.explicit.close.call"); + env.info.lint.isEnabled(Lint.LintCategory.TRY)) { + log.warning(Lint.LintCategory.TRY, tree, "try.explicit.close.call"); } // Disallow selecting a type from an expression diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java index e0bb79fe760..c6e04e12ff1 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java @@ -1037,10 +1037,10 @@ public class Flow extends TreeScanner { int nextadrCatch = nextadr; if (!unrefdResources.isEmpty() && - lint.isEnabled(Lint.LintCategory.ARM)) { + lint.isEnabled(Lint.LintCategory.TRY)) { for (Map.Entry e : unrefdResources.entrySet()) { - log.warning(e.getValue().pos(), - "automatic.resource.not.referenced", e.getKey()); + log.warning(Lint.LintCategory.TRY, e.getValue().pos(), + "try.resource.not.referenced", e.getKey()); } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java index 214ee9757bf..8df853e2d2c 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -1712,7 +1712,7 @@ public class JavacParser implements Parser { S.nextToken(); List resources = List.nil(); if (S.token() == LPAREN) { - checkAutomaticResourceManagement(); + checkTryWithResources(); S.nextToken(); resources = resources(); accept(RPAREN); @@ -2970,9 +2970,9 @@ public class JavacParser implements Parser { allowMulticatch = true; } } - void checkAutomaticResourceManagement() { + void checkTryWithResources() { if (!allowTWR) { - error(S.pos(), "automatic.resource.management.not.supported.in.source", source.name); + error(S.pos(), "try.with.resources.not.supported.in.source", source.name); allowTWR = true; } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties index ba7b98c609c..7fb2e66a574 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -63,8 +63,6 @@ compiler.err.anon.class.impl.intf.no.typeargs=\ anonymous class implements interface; cannot have type arguments compiler.err.anon.class.impl.intf.no.qual.for.new=\ anonymous class implements interface; cannot have qualifier for new -compiler.misc.twr.not.applicable.to.type=\ - automatic resource management not applicable to variable type compiler.err.array.and.varargs=\ cannot declare both {0} and {1} in {2} compiler.err.array.dimension.missing=\ @@ -183,8 +181,8 @@ compiler.err.except.never.thrown.in.try=\ compiler.err.final.parameter.may.not.be.assigned=\ final parameter {0} may not be assigned -compiler.err.twr.resource.may.not.be.assigned=\ - automatic resource {0} may not be assigned +compiler.err.try.resource.may.not.be.assigned=\ + auto-closeable resource {0} may not be assigned compiler.err.multicatch.parameter.may.not.be.assigned=\ multi-catch parameter {0} may not be assigned compiler.err.finally.without.try=\ @@ -823,10 +821,10 @@ compiler.warn.proc.unclosed.type.files=\ compiler.warn.proc.unmatched.processor.options=\ The following options were not recognized by any processor: ''{0}'' -compiler.warn.twr.explicit.close.call=\ - [arm] explicit call to close() on an automatic resource -compiler.warn.automatic.resource.not.referenced=\ - [arm] automatic resource {0} is never referenced in body of corresponding try statement +compiler.warn.try.explicit.close.call=\ + explicit call to close() on an auto-closeable resource +compiler.warn.try.resource.not.referenced=\ + auto-closeable resource {0} is never referenced in body of corresponding try statement compiler.warn.unchecked.assign=\ unchecked assignment: {0} to {1} compiler.warn.unchecked.assign.to.var=\ @@ -1050,6 +1048,9 @@ compiler.misc.assignment.to.extends-bound=\ # compiler.err.no.elem.type=\ # \[\*\] cannot have a type +compiler.misc.try.not.applicable.to.type=\ + try-with-resources not applicable to variable type + ##### compiler.err.type.found.req=\ @@ -1272,9 +1273,9 @@ compiler.err.unsupported.exotic.id=\ exotic identifiers #"___" are not supported in -source {0}\n\ (use -source 7 or higher to enable exotic identifiers) -compiler.err.automatic.resource.management.not.supported.in.source=\ - automatic resource management is not supported in -source {0}\n\ -(use -source 7 or higher to enable automatic resource management) +compiler.err.try.with.resources.not.supported.in.source=\ + try-with-resources is not supported in -source {0}\n\ +(use -source 7 or higher to enable try-with-resources) compiler.warn.enum.as.identifier=\ as of release 5, ''enum'' is a keyword, and may not be used as an identifier\n\ diff --git a/langtools/test/tools/javac/TryWithResources/ArmLint.out b/langtools/test/tools/javac/TryWithResources/ArmLint.out deleted file mode 100644 index f60161a5257..00000000000 --- a/langtools/test/tools/javac/TryWithResources/ArmLint.out +++ /dev/null @@ -1,3 +0,0 @@ -ArmLint.java:14:15: compiler.warn.twr.explicit.close.call -ArmLint.java:13:13: compiler.warn.automatic.resource.not.referenced: r3 -2 warnings diff --git a/langtools/test/tools/javac/TryWithResources/ImplicitFinal.out b/langtools/test/tools/javac/TryWithResources/ImplicitFinal.out index 0e33814b83f..062fd46b668 100644 --- a/langtools/test/tools/javac/TryWithResources/ImplicitFinal.out +++ b/langtools/test/tools/javac/TryWithResources/ImplicitFinal.out @@ -1,2 +1,2 @@ -ImplicitFinal.java:14:13: compiler.err.twr.resource.may.not.be.assigned: r +ImplicitFinal.java:14:13: compiler.err.try.resource.may.not.be.assigned: r 1 error diff --git a/langtools/test/tools/javac/TryWithResources/ArmLint.java b/langtools/test/tools/javac/TryWithResources/TwrLint.java similarity index 68% rename from langtools/test/tools/javac/TryWithResources/ArmLint.java rename to langtools/test/tools/javac/TryWithResources/TwrLint.java index 2a5a22392ba..39c5ed67f8f 100644 --- a/langtools/test/tools/javac/TryWithResources/ArmLint.java +++ b/langtools/test/tools/javac/TryWithResources/TwrLint.java @@ -2,15 +2,15 @@ * @test /nodynamiccopyright/ * @bug 6911256 6964740 6965277 6967065 * @author Joseph D. Darcy - * @summary Check that -Xlint:arm warnings are generated as expected - * @compile/ref=ArmLint.out -Xlint:arm,deprecation -XDrawDiagnostics ArmLint.java + * @summary Check that -Xlint:twr warnings are generated as expected + * @compile/ref=TwrLint.out -Xlint:try,deprecation -XDrawDiagnostics TwrLint.java */ -class ArmLint implements AutoCloseable { +class TwrLint implements AutoCloseable { private static void test1() { - try(ArmLint r1 = new ArmLint(); - ArmLint r2 = new ArmLint(); - ArmLint r3 = new ArmLint()) { + try(TwrLint r1 = new TwrLint(); + TwrLint r2 = new TwrLint(); + TwrLint r3 = new TwrLint()) { r1.close(); // The resource's close r2.close(42); // *Not* the resource's close // r3 not referenced @@ -18,11 +18,11 @@ class ArmLint implements AutoCloseable { } - @SuppressWarnings("arm") + @SuppressWarnings("try") private static void test2() { try(@SuppressWarnings("deprecation") AutoCloseable r4 = new DeprecatedAutoCloseable()) { - // r4 not referenced + // r4 not referenced - but no warning is generated because of @SuppressWarnings } catch(Exception e) { ; } diff --git a/langtools/test/tools/javac/TryWithResources/TwrLint.out b/langtools/test/tools/javac/TryWithResources/TwrLint.out new file mode 100644 index 00000000000..9b3f6188b14 --- /dev/null +++ b/langtools/test/tools/javac/TryWithResources/TwrLint.out @@ -0,0 +1,3 @@ +TwrLint.java:14:15: compiler.warn.try.explicit.close.call +TwrLint.java:13:13: compiler.warn.try.resource.not.referenced: r3 +2 warnings diff --git a/langtools/test/tools/javac/TryWithResources/TwrOnNonResource.out b/langtools/test/tools/javac/TryWithResources/TwrOnNonResource.out index a894aff7ffb..eafdbfbf632 100644 --- a/langtools/test/tools/javac/TryWithResources/TwrOnNonResource.out +++ b/langtools/test/tools/javac/TryWithResources/TwrOnNonResource.out @@ -1,7 +1,7 @@ -TwrOnNonResource.java:12:13: compiler.err.prob.found.req: (compiler.misc.twr.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable -TwrOnNonResource.java:15:13: compiler.err.prob.found.req: (compiler.misc.twr.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable -TwrOnNonResource.java:18:13: compiler.err.prob.found.req: (compiler.misc.twr.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable -TwrOnNonResource.java:24:13: compiler.err.prob.found.req: (compiler.misc.twr.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable -TwrOnNonResource.java:27:13: compiler.err.prob.found.req: (compiler.misc.twr.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable -TwrOnNonResource.java:30:13: compiler.err.prob.found.req: (compiler.misc.twr.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable +TwrOnNonResource.java:12:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable +TwrOnNonResource.java:15:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable +TwrOnNonResource.java:18:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable +TwrOnNonResource.java:24:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable +TwrOnNonResource.java:27:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable +TwrOnNonResource.java:30:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable 6 errors diff --git a/langtools/test/tools/javac/diags/examples/ResourceClosed.java b/langtools/test/tools/javac/diags/examples/ResourceClosed.java index 6f08187d820..08b2391c71c 100644 --- a/langtools/test/tools/javac/diags/examples/ResourceClosed.java +++ b/langtools/test/tools/javac/diags/examples/ResourceClosed.java @@ -21,8 +21,8 @@ * questions. */ -// key: compiler.warn.twr.explicit.close.call -// options: -Xlint:arm +// key: compiler.warn.try.explicit.close.call +// options: -Xlint:try import java.io.*; diff --git a/langtools/test/tools/javac/diags/examples/ResourceMayNotBeAssigned.java b/langtools/test/tools/javac/diags/examples/ResourceMayNotBeAssigned.java index e8d5edf5ff5..b66245fc8e9 100644 --- a/langtools/test/tools/javac/diags/examples/ResourceMayNotBeAssigned.java +++ b/langtools/test/tools/javac/diags/examples/ResourceMayNotBeAssigned.java @@ -21,7 +21,7 @@ * questions. */ -// key: compiler.err.twr.resource.may.not.be.assigned +// key: compiler.err.try.resource.may.not.be.assigned import java.io.*; diff --git a/langtools/test/tools/javac/diags/examples/ResourceNotApplicableToType.java b/langtools/test/tools/javac/diags/examples/ResourceNotApplicableToType.java index 95890cff5bd..f34477ef237 100644 --- a/langtools/test/tools/javac/diags/examples/ResourceNotApplicableToType.java +++ b/langtools/test/tools/javac/diags/examples/ResourceNotApplicableToType.java @@ -21,7 +21,7 @@ * questions. */ -// key: compiler.misc.twr.not.applicable.to.type +// key: compiler.misc.try.not.applicable.to.type // key: compiler.err.prob.found.req class ResourceNotApplicableToType { diff --git a/langtools/test/tools/javac/diags/examples/ResourceNotReferenced.java b/langtools/test/tools/javac/diags/examples/ResourceNotReferenced.java index e4d9d9f5bfd..8f6cfb2e2e6 100644 --- a/langtools/test/tools/javac/diags/examples/ResourceNotReferenced.java +++ b/langtools/test/tools/javac/diags/examples/ResourceNotReferenced.java @@ -21,8 +21,8 @@ * questions. */ -// key: compiler.warn.automatic.resource.not.referenced -// options: -Xlint:arm +// key: compiler.warn.try.resource.not.referenced +// options: -Xlint:try import java.io.*; diff --git a/langtools/test/tools/javac/diags/examples/TryResourceNotSupported.java b/langtools/test/tools/javac/diags/examples/TryResourceNotSupported.java index 4f2ca7c3714..9063dc9651e 100644 --- a/langtools/test/tools/javac/diags/examples/TryResourceNotSupported.java +++ b/langtools/test/tools/javac/diags/examples/TryResourceNotSupported.java @@ -21,7 +21,7 @@ * questions. */ -// key: compiler.err.automatic.resource.management.not.supported.in.source +// key: compiler.err.try.with.resources.not.supported.in.source // options: -source 1.6 import java.io.*; From f9f932a9f3886d76447bbc21591bdef4f63b4edc Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Sun, 14 Nov 2010 07:16:46 -0800 Subject: [PATCH 10/89] 6991528: Support making Throwable.suppressedExceptions immutable Reviewed-by: mcimadamore --- .../com/sun/tools/javac/comp/Lower.java | 8 +-- .../com/sun/tools/javac/util/Names.java | 4 +- .../TryWithResources/TwrSuppression.java | 2 +- .../javac/TryWithResources/TwrTests.java | 54 +++++++++---------- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java index 9498781064e..f7fdf8ef611 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2010, 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 @@ -1509,17 +1509,17 @@ public class Lower extends TreeTranslator { } private JCBlock makeArmFinallyClause(Symbol primaryException, JCExpression resource) { - // primaryException.addSuppressedException(catchException); + // primaryException.addSuppressed(catchException); VarSymbol catchException = new VarSymbol(0, make.paramName(2), syms.throwableType, currentMethodSym); JCStatement addSuppressionStatement = make.Exec(makeCall(make.Ident(primaryException), - names.fromString("addSuppressedException"), + names.addSuppressed, List.of(make.Ident(catchException)))); - // try { resource.close(); } catch (e) { primaryException.addSuppressedException(e); } + // try { resource.close(); } catch (e) { primaryException.addSuppressed(e); } JCBlock tryBlock = make.Block(0L, List.of(makeResourceCloseInvocation(resource))); JCVariableDecl catchExceptionDecl = make.VarDef(catchException, null); diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/Names.java b/langtools/src/share/classes/com/sun/tools/javac/util/Names.java index 9b939ea7341..08a56daf640 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/Names.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/Names.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2010, 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 @@ -150,6 +150,7 @@ public class Names { public final Name finalize; public final Name java_lang_AutoCloseable; public final Name close; + public final Name addSuppressed; public final Name.Table table; @@ -268,6 +269,7 @@ public class Names { java_lang_AutoCloseable = fromString("java.lang.AutoCloseable"); close = fromString("close"); + addSuppressed = fromString("addSuppressed"); } protected Name.Table createTable(Options options) { diff --git a/langtools/test/tools/javac/TryWithResources/TwrSuppression.java b/langtools/test/tools/javac/TryWithResources/TwrSuppression.java index 2b06b0f51d3..9834d5a17b2 100644 --- a/langtools/test/tools/javac/TryWithResources/TwrSuppression.java +++ b/langtools/test/tools/javac/TryWithResources/TwrSuppression.java @@ -36,7 +36,7 @@ public class TwrSuppression implements AutoCloseable { throw new RuntimeException(); } } catch(RuntimeException e) { - Throwable[] suppressedExceptions = e.getSuppressedExceptions(); + Throwable[] suppressedExceptions = e.getSuppressed(); int length = suppressedExceptions.length; if (length != 2) throw new RuntimeException("Unexpected length " + length); diff --git a/langtools/test/tools/javac/TryWithResources/TwrTests.java b/langtools/test/tools/javac/TryWithResources/TwrTests.java index c3ca6176573..124227989aa 100644 --- a/langtools/test/tools/javac/TryWithResources/TwrTests.java +++ b/langtools/test/tools/javac/TryWithResources/TwrTests.java @@ -90,7 +90,7 @@ public class TwrTests { } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed"); } @@ -112,7 +112,7 @@ public class TwrTests { } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed"); } @@ -134,7 +134,7 @@ public class TwrTests { } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } @@ -158,7 +158,7 @@ public class TwrTests { } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } @@ -181,7 +181,7 @@ public class TwrTests { } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } @@ -207,7 +207,7 @@ public class TwrTests { } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } @@ -231,7 +231,7 @@ public class TwrTests { } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } @@ -259,7 +259,7 @@ public class TwrTests { } catch (Resource.CreateFailException e) { creationFailuresDetected++; checkCreateFailureId(e.resourceId(), createFailureId); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { throw new AssertionError("Secondary exception suppression failed:" + e); } @@ -310,7 +310,7 @@ public class TwrTests { * Check for proper suppressed exceptions in proper order. * * @param suppressedExceptions the suppressed exceptions array returned by - * getSuppressedExceptions() + * getSuppressed() * @bitmap a bitmap indicating which suppressed exceptions are expected. * Bit i is set iff id should throw a CloseFailException. */ @@ -376,7 +376,7 @@ public class TwrTests { } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); @@ -388,7 +388,7 @@ public class TwrTests { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); + checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 1); } @@ -409,7 +409,7 @@ public class TwrTests { } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); @@ -421,7 +421,7 @@ public class TwrTests { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); + checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 2); } @@ -443,7 +443,7 @@ public class TwrTests { } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); @@ -455,7 +455,7 @@ public class TwrTests { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); + checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 2); } @@ -477,7 +477,7 @@ public class TwrTests { } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); @@ -489,7 +489,7 @@ public class TwrTests { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); + checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 3); } @@ -513,7 +513,7 @@ public class TwrTests { } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); @@ -525,7 +525,7 @@ public class TwrTests { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); + checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 3); } @@ -548,7 +548,7 @@ public class TwrTests { } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); @@ -560,7 +560,7 @@ public class TwrTests { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); + checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 4); } @@ -586,7 +586,7 @@ public class TwrTests { } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); @@ -598,7 +598,7 @@ public class TwrTests { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); + checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 4); } @@ -621,7 +621,7 @@ public class TwrTests { } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); @@ -633,7 +633,7 @@ public class TwrTests { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); + checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 5); } @@ -660,7 +660,7 @@ public class TwrTests { } catch (MyKindOfException e) { if (failure == 0) throw new AssertionError("Unexpected MyKindOfException"); - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap); + checkSuppressedExceptions(e.getSuppressed(), bitMap); } catch (Resource.CloseFailException e) { if (failure == 1) throw new AssertionError("Secondary exception suppression failed"); @@ -672,7 +672,7 @@ public class TwrTests { throw new AssertionError("CloseFailException: got id " + id + ", expected lg(" + highestCloseFailBit +")"); } - checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit); + checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit); } checkClosedList(closedList, 5); } From 3a681162e48bd984ef4e210d1a52e0482a8a7679 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Mon, 15 Nov 2010 13:50:53 +0000 Subject: [PATCH 11/89] 6985719: Alike methods in interfaces (Inheritance and Overriding) Javac should report error when interface inherits unrelated method with same erasure Reviewed-by: jjg --- .../com/sun/tools/javac/comp/Check.java | 90 ++++++++++++------- .../javac/generics/6985719/T6985719a.java | 15 ++++ .../javac/generics/6985719/T6985719a.out | 2 + .../javac/generics/6985719/T6985719b.java | 15 ++++ .../javac/generics/6985719/T6985719b.out | 2 + .../javac/generics/6985719/T6985719c.java | 15 ++++ .../javac/generics/6985719/T6985719c.out | 2 + .../javac/generics/6985719/T6985719d.java | 15 ++++ .../javac/generics/6985719/T6985719d.out | 2 + .../javac/generics/6985719/T6985719e.java | 14 +++ .../javac/generics/6985719/T6985719e.out | 2 + .../javac/generics/6985719/T6985719f.java | 14 +++ .../javac/generics/6985719/T6985719f.out | 2 + .../javac/generics/6985719/T6985719g.java | 14 +++ .../javac/generics/6985719/T6985719g.out | 2 + .../javac/generics/6985719/T6985719h.java | 14 +++ .../javac/generics/6985719/T6985719h.out | 2 + 17 files changed, 189 insertions(+), 33 deletions(-) create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719a.java create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719a.out create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719b.java create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719b.out create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719c.java create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719c.out create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719d.java create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719d.out create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719e.java create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719e.out create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719f.java create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719f.out create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719g.java create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719g.out create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719h.java create mode 100644 langtools/test/tools/javac/generics/6985719/T6985719h.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java index 07d95cc5c1e..af05ee9f6c2 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -1510,14 +1510,7 @@ public class Check { Type t1, Type t2, Type site) { - Symbol sym = firstIncompatibility(t1, t2, site); - if (sym != null) { - log.error(pos, "types.incompatible.diff.ret", - t1, t2, sym.name + - "(" + types.memberType(t2, sym).getParameterTypes() + ")"); - return false; - } - return true; + return firstIncompatibility(pos, t1, t2, site) == null; } /** Return the first method which is defined with same args @@ -1528,7 +1521,7 @@ public class Check { * @param site The most derived type. * @returns symbol from t2 that conflicts with one in t1. */ - private Symbol firstIncompatibility(Type t1, Type t2, Type site) { + private Symbol firstIncompatibility(DiagnosticPosition pos, Type t1, Type t2, Type site) { Map interfaces1 = new HashMap(); closure(t1, interfaces1); Map interfaces2; @@ -1539,7 +1532,7 @@ public class Check { for (Type t3 : interfaces1.values()) { for (Type t4 : interfaces2.values()) { - Symbol s = firstDirectIncompatibility(t3, t4, site); + Symbol s = firstDirectIncompatibility(pos, t3, t4, site); if (s != null) return s; } } @@ -1568,7 +1561,7 @@ public class Check { } /** Return the first method in t2 that conflicts with a method from t1. */ - private Symbol firstDirectIncompatibility(Type t1, Type t2, Type site) { + private Symbol firstDirectIncompatibility(DiagnosticPosition pos, Type t1, Type t2, Type site) { for (Scope.Entry e1 = t1.tsym.members().elems; e1 != null; e1 = e1.sibling) { Symbol s1 = e1.sym; Type st1 = null; @@ -1592,7 +1585,18 @@ public class Check { (types.covariantReturnType(rt1, rt2, Warner.noWarnings) || types.covariantReturnType(rt2, rt1, Warner.noWarnings)) || checkCommonOverriderIn(s1,s2,site); - if (!compat) return s2; + if (!compat) { + log.error(pos, "types.incompatible.diff.ret", + t1, t2, s2.name + + "(" + types.memberType(t2, s2).getParameterTypes() + ")"); + return s2; + } + } else if (!checkNameClash((ClassSymbol)site.tsym, s1, s2)) { + log.error(pos, + "name.clash.same.erasure.no.override", + s1, s1.location(), + s2, s2.location()); + return s2; } } } @@ -1644,32 +1648,52 @@ public class Check { log.error(tree.pos(), "enum.no.finalize"); return; } - for (Type t = types.supertype(origin.type); t.tag == CLASS; + for (Type t = origin.type; t.tag == CLASS; t = types.supertype(t)) { - TypeSymbol c = t.tsym; - Scope.Entry e = c.members().lookup(m.name); - while (e.scope != null) { - if (m.overrides(e.sym, origin, types, false)) - checkOverride(tree, m, (MethodSymbol)e.sym, origin); - else if (e.sym.kind == MTH && - e.sym.isInheritedIn(origin, types) && - (e.sym.flags() & SYNTHETIC) == 0 && - !m.isConstructor()) { - Type er1 = m.erasure(types); - Type er2 = e.sym.erasure(types); - if (types.isSameTypes(er1.getParameterTypes(), - er2.getParameterTypes())) { - log.error(TreeInfo.diagnosticPositionFor(m, tree), - "name.clash.same.erasure.no.override", - m, m.location(), - e.sym, e.sym.location()); - } - } - e = e.next(); + if (t != origin.type) { + checkOverride(tree, t, origin, m); + } + for (Type t2 : types.interfaces(t)) { + checkOverride(tree, t2, origin, m); } } } + void checkOverride(JCTree tree, Type site, ClassSymbol origin, MethodSymbol m) { + TypeSymbol c = site.tsym; + Scope.Entry e = c.members().lookup(m.name); + while (e.scope != null) { + if (m.overrides(e.sym, origin, types, false)) { + if ((e.sym.flags() & ABSTRACT) == 0) { + checkOverride(tree, m, (MethodSymbol)e.sym, origin); + } + } + else if (!checkNameClash(origin, e.sym, m)) { + log.error(tree, + "name.clash.same.erasure.no.override", + m, m.location(), + e.sym, e.sym.location()); + } + e = e.next(); + } + } + + private boolean checkNameClash(ClassSymbol origin, Symbol s1, Symbol s2) { + if (s1.kind == MTH && + s1.isInheritedIn(origin, types) && + (s1.flags() & SYNTHETIC) == 0 && + !s2.isConstructor()) { + Type er1 = s2.erasure(types); + Type er2 = s1.erasure(types); + if (types.isSameTypes(er1.getParameterTypes(), + er2.getParameterTypes())) { + return false; + } + } + return true; + } + + /** Check that all abstract members of given class have definitions. * @param pos Position to be used for error reporting. * @param c The class. diff --git a/langtools/test/tools/javac/generics/6985719/T6985719a.java b/langtools/test/tools/javac/generics/6985719/T6985719a.java new file mode 100644 index 00000000000..aef4ba2f698 --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719a.java @@ -0,0 +1,15 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6985719 + * @summary Alike methods in interfaces (Inheritance and Overriding) + * @author mcimadamore + * @compile/fail/ref=T6985719a.out -XDrawDiagnostics T6985719a.java + */ + +import java.util.List; + +class T6985719a { + interface A { void f(List ls); } + interface B { void f(List ls); } + interface C extends A,B {} +} diff --git a/langtools/test/tools/javac/generics/6985719/T6985719a.out b/langtools/test/tools/javac/generics/6985719/T6985719a.out new file mode 100644 index 00000000000..9948d6cf393 --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719a.out @@ -0,0 +1,2 @@ +T6985719a.java:14:5: compiler.err.name.clash.same.erasure.no.override: f(java.util.List), T6985719a.B, f(java.util.List), T6985719a.A +1 error diff --git a/langtools/test/tools/javac/generics/6985719/T6985719b.java b/langtools/test/tools/javac/generics/6985719/T6985719b.java new file mode 100644 index 00000000000..7e4e928b67d --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719b.java @@ -0,0 +1,15 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6985719 + * @summary Alike methods in interfaces (Inheritance and Overriding) + * @author mcimadamore + * @compile/fail/ref=T6985719b.out -XDrawDiagnostics T6985719b.java + */ + +import java.util.List; + +class T6985719b { + abstract class A { abstract void f(List ls); } + interface B { void f(List ls); } + abstract class C extends A implements B {} +} diff --git a/langtools/test/tools/javac/generics/6985719/T6985719b.out b/langtools/test/tools/javac/generics/6985719/T6985719b.out new file mode 100644 index 00000000000..ef2ab842aea --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719b.out @@ -0,0 +1,2 @@ +T6985719b.java:14:14: compiler.err.name.clash.same.erasure.no.override: f(java.util.List), T6985719b.B, f(java.util.List), T6985719b.A +1 error diff --git a/langtools/test/tools/javac/generics/6985719/T6985719c.java b/langtools/test/tools/javac/generics/6985719/T6985719c.java new file mode 100644 index 00000000000..51e52c014d7 --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719c.java @@ -0,0 +1,15 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6985719 + * @summary Alike methods in interfaces (Inheritance and Overriding) + * @author mcimadamore + * @compile/fail/ref=T6985719c.out -XDrawDiagnostics T6985719c.java + */ + +import java.util.List; + +class T6985719c { + interface A { void f(List ls); } + interface B { void f(List ls); } + interface C extends A,B {} +} diff --git a/langtools/test/tools/javac/generics/6985719/T6985719c.out b/langtools/test/tools/javac/generics/6985719/T6985719c.out new file mode 100644 index 00000000000..23d2ba7687c --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719c.out @@ -0,0 +1,2 @@ +T6985719c.java:14:5: compiler.err.name.clash.same.erasure.no.override: f(java.util.List), T6985719c.B, f(java.util.List), T6985719c.A +1 error diff --git a/langtools/test/tools/javac/generics/6985719/T6985719d.java b/langtools/test/tools/javac/generics/6985719/T6985719d.java new file mode 100644 index 00000000000..df2d9409170 --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719d.java @@ -0,0 +1,15 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6985719 + * @summary Alike methods in interfaces (Inheritance and Overriding) + * @author mcimadamore + * @compile/fail/ref=T6985719d.out -XDrawDiagnostics T6985719d.java + */ + +import java.util.List; + +class T6985719d { + abstract class A { abstract void f(List ls); } + interface B { void f(List ls); } + abstract class C extends A implements B {} +} diff --git a/langtools/test/tools/javac/generics/6985719/T6985719d.out b/langtools/test/tools/javac/generics/6985719/T6985719d.out new file mode 100644 index 00000000000..c46439c4921 --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719d.out @@ -0,0 +1,2 @@ +T6985719d.java:14:14: compiler.err.name.clash.same.erasure.no.override: f(java.util.List), T6985719d.B, f(java.util.List), T6985719d.A +1 error diff --git a/langtools/test/tools/javac/generics/6985719/T6985719e.java b/langtools/test/tools/javac/generics/6985719/T6985719e.java new file mode 100644 index 00000000000..1b3e6a5e165 --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719e.java @@ -0,0 +1,14 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6985719 + * @summary Alike methods in interfaces (Inheritance and Overriding) + * @author mcimadamore + * @compile/fail/ref=T6985719e.out -XDrawDiagnostics T6985719e.java + */ + +import java.util.List; + +class T6985719e { + interface A { void f(List ls); } + interface B extends A { void f(List ls); } +} diff --git a/langtools/test/tools/javac/generics/6985719/T6985719e.out b/langtools/test/tools/javac/generics/6985719/T6985719e.out new file mode 100644 index 00000000000..82fd2cd3c36 --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719e.out @@ -0,0 +1,2 @@ +T6985719e.java:13:34: compiler.err.name.clash.same.erasure.no.override: f(java.util.List), T6985719e.B, f(java.util.List), T6985719e.A +1 error diff --git a/langtools/test/tools/javac/generics/6985719/T6985719f.java b/langtools/test/tools/javac/generics/6985719/T6985719f.java new file mode 100644 index 00000000000..54b5c3001e2 --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719f.java @@ -0,0 +1,14 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6985719 + * @summary Alike methods in interfaces (Inheritance and Overriding) + * @author mcimadamore + * @compile/fail/ref=T6985719f.out -XDrawDiagnostics T6985719f.java + */ + +import java.util.List; + +class T6985719f { + abstract class A { abstract void f(List ls); } + abstract class B extends A { void f(List ls); } +} diff --git a/langtools/test/tools/javac/generics/6985719/T6985719f.out b/langtools/test/tools/javac/generics/6985719/T6985719f.out new file mode 100644 index 00000000000..12a07a279ac --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719f.out @@ -0,0 +1,2 @@ +T6985719f.java:13:39: compiler.err.name.clash.same.erasure.no.override: f(java.util.List), T6985719f.B, f(java.util.List), T6985719f.A +1 error diff --git a/langtools/test/tools/javac/generics/6985719/T6985719g.java b/langtools/test/tools/javac/generics/6985719/T6985719g.java new file mode 100644 index 00000000000..df8afa01259 --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719g.java @@ -0,0 +1,14 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6985719 + * @summary Alike methods in interfaces (Inheritance and Overriding) + * @author mcimadamore + * @compile/fail/ref=T6985719g.out -XDrawDiagnostics T6985719g.java + */ + +import java.util.List; + +class T6985719g { + interface A { void f(List ls); } + interface B extends A { void f(List ls); } +} diff --git a/langtools/test/tools/javac/generics/6985719/T6985719g.out b/langtools/test/tools/javac/generics/6985719/T6985719g.out new file mode 100644 index 00000000000..1d37a78937c --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719g.out @@ -0,0 +1,2 @@ +T6985719g.java:13:42: compiler.err.name.clash.same.erasure.no.override: f(java.util.List), T6985719g.B, f(java.util.List), T6985719g.A +1 error diff --git a/langtools/test/tools/javac/generics/6985719/T6985719h.java b/langtools/test/tools/javac/generics/6985719/T6985719h.java new file mode 100644 index 00000000000..9bcc1431197 --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719h.java @@ -0,0 +1,14 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6985719 + * @summary Alike methods in interfaces (Inheritance and Overriding) + * @author mcimadamore + * @compile/fail/ref=T6985719h.out -XDrawDiagnostics T6985719h.java + */ + +import java.util.List; + +class T6985719h { + abstract class A { abstract void f(List ls); } + abstract class B extends A { abstract void f(List ls); } +} diff --git a/langtools/test/tools/javac/generics/6985719/T6985719h.out b/langtools/test/tools/javac/generics/6985719/T6985719h.out new file mode 100644 index 00000000000..64b3e4a3c84 --- /dev/null +++ b/langtools/test/tools/javac/generics/6985719/T6985719h.out @@ -0,0 +1,2 @@ +T6985719h.java:13:56: compiler.err.name.clash.same.erasure.no.override: f(java.util.List), T6985719h.B, f(java.util.List), T6985719h.A +1 error From 80fdc078e710704300eda600435cf887600dcfcb Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Mon, 15 Nov 2010 14:41:21 +0000 Subject: [PATCH 12/89] 6999635: Multicatch: crash while compiling simple code with a multicatch parameter Missing erasure when computing stackmaps leads to assertion error Reviewed-by: darcy --- .../com/sun/tools/javac/jvm/ClassWriter.java | 4 +- .../classes/com/sun/tools/javac/jvm/Code.java | 2 +- .../test/tools/javac/multicatch/Pos08.java | 46 +++++++++++++++++++ .../javac/multicatch/Pos08eff_final.java | 46 +++++++++++++++++++ 4 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 langtools/test/tools/javac/multicatch/Pos08.java create mode 100644 langtools/test/tools/javac/multicatch/Pos08eff_final.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java index 08797b63e69..dc1f5979b3c 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java @@ -993,7 +993,9 @@ public class ClassWriter extends ClassFile { /** Enter an inner class into the `innerClasses' set/queue. */ void enterInner(ClassSymbol c) { - assert !c.type.isCompound(); + if (c.type.isCompound()) { + throw new AssertionError("Unexpected intersection type: " + c.type); + } try { c.complete(); } catch (CompletionFailure ex) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java index d96613f1599..639d9c7cdc5 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java @@ -1304,7 +1304,7 @@ public class Code { stackCount = 0; for (int i=0; i Date: Mon, 15 Nov 2010 10:46:40 -0800 Subject: [PATCH 13/89] 6277781: Serialization of Enums over IIOP is broke Reviewed by Ken Cavanaugh Reviewed-by: coffeys --- .../classes/com/sun/corba/se/impl/io/IIOPInputStream.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java b/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java index 92e90afb9ae..830fd648df5 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java @@ -1012,7 +1012,11 @@ public class IIOPInputStream * else, * Handle it as a serializable class. */ - if (currentClassDesc.isExternalizable()) { + if (Enum.class.isAssignableFrom( clz )) { + int ordinal = orbStream.read_long() ; + String value = (String)orbStream.read_value( String.class ) ; + return Enum.valueOf( clz, value ) ; + } else if (currentClassDesc.isExternalizable()) { try { currentObject = (currentClass == null) ? null : currentClassDesc.newInstance(); From 09b7dae44143123acfcaab9db88b7895035c5287 Mon Sep 17 00:00:00 2001 From: Rob McKenna Date: Mon, 15 Nov 2010 10:47:48 -0800 Subject: [PATCH 14/89] 6763340: memory leak in com.sun.corba.se.* classes 6873605: Missing finishedDispatch() call in ORBImpl causes test failures after 5u20 b04 Reviewed by Ken Cavanaugh Reviewed-by: coffeys --- .../interceptors/ClientRequestInfoImpl.java | 11 +- .../se/impl/interceptors/PIHandlerImpl.java | 107 ++++++++++++------ .../impl/interceptors/PINoOpHandlerImpl.java | 5 + .../se/impl/interceptors/RequestInfoImpl.java | 3 +- .../com/sun/corba/se/impl/orb/ORBImpl.java | 7 +- .../CorbaClientRequestDispatcherImpl.java | 17 ++- .../sun/corba/se/spi/protocol/PIHandler.java | 21 ++++ .../sun/corba/se/spi/protocol/RetryType.java | 52 +++++++++ 8 files changed, 182 insertions(+), 41 deletions(-) create mode 100644 corba/src/share/classes/com/sun/corba/se/spi/protocol/RetryType.java diff --git a/corba/src/share/classes/com/sun/corba/se/impl/interceptors/ClientRequestInfoImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/interceptors/ClientRequestInfoImpl.java index df9f4d7a418..95224cbd882 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/interceptors/ClientRequestInfoImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/interceptors/ClientRequestInfoImpl.java @@ -74,6 +74,7 @@ import com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate; import com.sun.corba.se.spi.ior.iiop.GIOPVersion; import com.sun.corba.se.spi.orb.ORB; import com.sun.corba.se.spi.protocol.CorbaMessageMediator; +import com.sun.corba.se.spi.protocol.RetryType; import com.sun.corba.se.spi.transport.CorbaContactInfo; import com.sun.corba.se.spi.transport.CorbaContactInfoList; import com.sun.corba.se.spi.transport.CorbaContactInfoListIterator; @@ -110,7 +111,7 @@ public final class ClientRequestInfoImpl // The current retry request status. True if this request is being // retried and this info object is to be reused, or false otherwise. - private boolean retryRequest; + private RetryType retryRequest; // The number of times this info object has been (re)used. This is // incremented every time a request is retried, and decremented every @@ -163,7 +164,8 @@ public final class ClientRequestInfoImpl // Please keep these in the same order that they're declared above. - retryRequest = false; + // 6763340 + retryRequest = RetryType.NONE; // Do not reset entryCount because we need to know when to pop this // from the stack. @@ -824,14 +826,15 @@ public final class ClientRequestInfoImpl /** * Set or reset the retry request flag. */ - void setRetryRequest( boolean retryRequest ) { + void setRetryRequest( RetryType retryRequest ) { this.retryRequest = retryRequest; } /** * Retrieve the current retry request status. */ - boolean getRetryRequest() { + RetryType getRetryRequest() { + // 6763340 return this.retryRequest; } diff --git a/corba/src/share/classes/com/sun/corba/se/impl/interceptors/PIHandlerImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/interceptors/PIHandlerImpl.java index 68782b1f356..f5951362a54 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/interceptors/PIHandlerImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/interceptors/PIHandlerImpl.java @@ -70,6 +70,7 @@ import com.sun.corba.se.spi.orbutil.closure.ClosureFactory; import com.sun.corba.se.spi.protocol.CorbaMessageMediator; import com.sun.corba.se.spi.protocol.ForwardException; import com.sun.corba.se.spi.protocol.PIHandler; +import com.sun.corba.se.spi.protocol.RetryType; import com.sun.corba.se.spi.logging.CORBALogDomains; import com.sun.corba.se.impl.logging.InterceptorsSystemException; @@ -372,9 +373,24 @@ public class PIHandlerImpl implements PIHandler } } - public Exception invokeClientPIEndingPoint( - int replyStatus, Exception exception ) - { + // Needed when an error forces a retry AFTER initiateClientPIRequest + // but BEFORE invokeClientPIStartingPoint. + public Exception makeCompletedClientRequest( int replyStatus, + Exception exception ) { + + // 6763340 + return handleClientPIEndingPoint( replyStatus, exception, false ) ; + } + + public Exception invokeClientPIEndingPoint( int replyStatus, + Exception exception ) { + + // 6763340 + return handleClientPIEndingPoint( replyStatus, exception, true ) ; + } + + public Exception handleClientPIEndingPoint( + int replyStatus, Exception exception, boolean invokeEndingPoint ) { if( !hasClientInterceptors ) return exception; if( !isClientPIEnabledForThisThread() ) return exception; @@ -388,24 +404,31 @@ public class PIHandlerImpl implements PIHandler ClientRequestInfoImpl info = peekClientRequestInfoImplStack(); info.setReplyStatus( piReplyStatus ); info.setException( exception ); - interceptorInvoker.invokeClientInterceptorEndingPoint( info ); - piReplyStatus = info.getReplyStatus(); + + if (invokeEndingPoint) { + // 6763340 + interceptorInvoker.invokeClientInterceptorEndingPoint( info ); + piReplyStatus = info.getReplyStatus(); + } // Check reply status: if( (piReplyStatus == LOCATION_FORWARD.value) || - (piReplyStatus == TRANSPORT_RETRY.value) ) - { + (piReplyStatus == TRANSPORT_RETRY.value) ) { // If this is a forward or a retry, reset and reuse // info object: info.reset(); - info.setRetryRequest( true ); + + // fix for 6763340: + if (invokeEndingPoint) { + info.setRetryRequest( RetryType.AFTER_RESPONSE ) ; + } else { + info.setRetryRequest( RetryType.BEFORE_RESPONSE ) ; + } // ... and return a RemarshalException so the orb internals know exception = new RemarshalException(); - } - else if( (piReplyStatus == SYSTEM_EXCEPTION.value) || - (piReplyStatus == USER_EXCEPTION.value) ) - { + } else if( (piReplyStatus == SYSTEM_EXCEPTION.value) || + (piReplyStatus == USER_EXCEPTION.value) ) { exception = info.getException(); } @@ -421,18 +444,21 @@ public class PIHandlerImpl implements PIHandler RequestInfoStack infoStack = (RequestInfoStack)threadLocalClientRequestInfoStack.get(); ClientRequestInfoImpl info = null; - if( !infoStack.empty() ) info = - (ClientRequestInfoImpl)infoStack.peek(); - if( !diiRequest && (info != null) && info.isDIIInitiate() ) { + if (!infoStack.empty() ) { + info = (ClientRequestInfoImpl)infoStack.peek(); + } + + if (!diiRequest && (info != null) && info.isDIIInitiate() ) { // In RequestImpl.doInvocation we already called // initiateClientPIRequest( true ), so ignore this initiate. info.setDIIInitiate( false ); - } - else { + } else { // If there is no info object or if we are not retrying a request, // push a new ClientRequestInfoImpl on the stack: - if( (info == null) || !info.getRetryRequest() ) { + + // 6763340: don't push unless this is not a retry + if( (info == null) || !info.getRetryRequest().isRetry() ) { info = new ClientRequestInfoImpl( orb ); infoStack.push( info ); printPush(); @@ -442,9 +468,15 @@ public class PIHandlerImpl implements PIHandler // Reset the retry request flag so that recursive calls will // push a new info object, and bump up entry count so we know // when to pop this info object: - info.setRetryRequest( false ); + info.setRetryRequest( RetryType.NONE ); info.incrementEntryCount(); + // KMC 6763340: I don't know why this wasn't set earlier, + // but we do not want a retry to pick up the previous + // reply status, so clear it here. Most likely a new + // info was pushed before, so that this was not a problem. + info.setReplyStatus( RequestInfoImpl.UNINITIALIZED ) ; + // If this is a DII request, make sure we ignore the next initiate. if( diiRequest ) { info.setDIIInitiate( true ); @@ -457,25 +489,34 @@ public class PIHandlerImpl implements PIHandler if( !isClientPIEnabledForThisThread() ) return; ClientRequestInfoImpl info = peekClientRequestInfoImplStack(); + RetryType rt = info.getRetryRequest() ; - // If the replyStatus has not yet been set, this is an indication - // that the ORB threw an exception before we had a chance to - // invoke the client interceptor ending points. - // - // _REVISIT_ We cannot handle any exceptions or ForwardRequests - // flagged by the ending points here because there is no way - // to gracefully handle this in any of the calling code. - // This is a rare corner case, so we will ignore this for now. - short replyStatus = info.getReplyStatus(); - if( replyStatus == info.UNINITIALIZED ) { - invokeClientPIEndingPoint( ReplyMessage.SYSTEM_EXCEPTION, - wrapper.unknownRequestInvoke( - CompletionStatus.COMPLETED_MAYBE ) ) ; + // fix for 6763340 + if (!rt.equals( RetryType.BEFORE_RESPONSE )) { + + // If the replyStatus has not yet been set, this is an indication + // that the ORB threw an exception before we had a chance to + // invoke the client interceptor ending points. + // + // _REVISIT_ We cannot handle any exceptions or ForwardRequests + // flagged by the ending points here because there is no way + // to gracefully handle this in any of the calling code. + // This is a rare corner case, so we will ignore this for now. + short replyStatus = info.getReplyStatus(); + if (replyStatus == info.UNINITIALIZED ) { + invokeClientPIEndingPoint( ReplyMessage.SYSTEM_EXCEPTION, + wrapper.unknownRequestInvoke( + CompletionStatus.COMPLETED_MAYBE ) ) ; + } } // Decrement entry count, and if it is zero, pop it from the stack. info.decrementEntryCount(); - if( info.getEntryCount() == 0 ) { + + // fix for 6763340, and probably other cases (non-recursive retry) + if (info.getEntryCount() == 0 && !info.getRetryRequest().isRetry()) { + // RequestInfoStack infoStack = + // threadLocalClientRequestInfoStack.get(); RequestInfoStack infoStack = (RequestInfoStack)threadLocalClientRequestInfoStack.get(); infoStack.pop(); diff --git a/corba/src/share/classes/com/sun/corba/se/impl/interceptors/PINoOpHandlerImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/interceptors/PINoOpHandlerImpl.java index 98b1572cac7..972cc8d214c 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/interceptors/PINoOpHandlerImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/interceptors/PINoOpHandlerImpl.java @@ -107,6 +107,11 @@ public class PINoOpHandlerImpl implements PIHandler return null; } + public Exception makeCompletedClientRequest( + int replyStatus, Exception exception ) { + return null; + } + public void initiateClientPIRequest( boolean diiRequest ) { } diff --git a/corba/src/share/classes/com/sun/corba/se/impl/interceptors/RequestInfoImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/interceptors/RequestInfoImpl.java index 072d123d779..ecadabd33eb 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/interceptors/RequestInfoImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/interceptors/RequestInfoImpl.java @@ -187,7 +187,8 @@ public abstract class RequestInfoImpl startingPointCall = 0; intermediatePointCall = 0; endingPointCall = 0; - replyStatus = UNINITIALIZED; + // 6763340 + setReplyStatus( UNINITIALIZED ) ; currentExecutionPoint = EXECUTION_POINT_STARTING; alreadyExecuted = false; connection = null; diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java index e8aac1da709..0bdd1072128 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java @@ -1672,6 +1672,7 @@ public class ORBImpl extends com.sun.corba.se.spi.orb.ORB { StackImpl invocationInfoStack = (StackImpl)clientInvocationInfoStack.get(); + int entryCount = -1; ClientInvocationInfo clientInvocationInfo = null; if (!invocationInfoStack.empty()) { clientInvocationInfo = @@ -1680,8 +1681,12 @@ public class ORBImpl extends com.sun.corba.se.spi.orb.ORB throw wrapper.invocationInfoStackEmpty() ; } clientInvocationInfo.decrementEntryCount(); + entryCount = clientInvocationInfo.getEntryCount(); if (clientInvocationInfo.getEntryCount() == 0) { - invocationInfoStack.pop(); + // 6763340: don't pop if this is a retry! + if (!clientInvocationInfo.isRetryInvocation()) { + invocationInfoStack.pop(); + } finishedDispatch(); } } diff --git a/corba/src/share/classes/com/sun/corba/se/impl/protocol/CorbaClientRequestDispatcherImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/protocol/CorbaClientRequestDispatcherImpl.java index 9bde8981c13..5c7555f3c70 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/protocol/CorbaClientRequestDispatcherImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/protocol/CorbaClientRequestDispatcherImpl.java @@ -185,6 +185,7 @@ public class CorbaClientRequestDispatcherImpl if(getContactInfoListIterator(orb).hasNext()) { contactInfo = (ContactInfo) getContactInfoListIterator(orb).next(); + unregisterWaiter(orb); return beginRequest(self, opName, isOneWay, contactInfo); } else { @@ -292,10 +293,22 @@ public class CorbaClientRequestDispatcherImpl // ContactInfoList outside of subcontract. // Want to move that update to here. if (getContactInfoListIterator(orb).hasNext()) { - contactInfo = (ContactInfo) - getContactInfoListIterator(orb).next(); + contactInfo = (ContactInfo)getContactInfoListIterator(orb).next(); + if (orb.subcontractDebugFlag) { + dprint( "RemarshalException: hasNext true\ncontact info " + contactInfo ); + } + + // Fix for 6763340: Complete the first attempt before starting another. + orb.getPIHandler().makeCompletedClientRequest( + ReplyMessage.LOCATION_FORWARD, null ) ; + unregisterWaiter(orb); + orb.getPIHandler().cleanupClientPIRequest() ; + return beginRequest(self, opName, isOneWay, contactInfo); } else { + if (orb.subcontractDebugFlag) { + dprint( "RemarshalException: hasNext false" ); + } ORBUtilSystemException wrapper = ORBUtilSystemException.get(orb, CORBALogDomains.RPC_PROTOCOL); diff --git a/corba/src/share/classes/com/sun/corba/se/spi/protocol/PIHandler.java b/corba/src/share/classes/com/sun/corba/se/spi/protocol/PIHandler.java index f5ff9df590d..5aebbac4dea 100644 --- a/corba/src/share/classes/com/sun/corba/se/spi/protocol/PIHandler.java +++ b/corba/src/share/classes/com/sun/corba/se/spi/protocol/PIHandler.java @@ -141,6 +141,27 @@ public interface PIHandler { Exception invokeClientPIEndingPoint( int replyStatus, Exception exception ) ; + /** + * Called when a retry is needed after initiateClientPIRequest but + * before invokeClientPIRequest. In this case, we need to properly + * balance initiateClientPIRequest/cleanupClientPIRequest calls, + * but WITHOUT extraneous calls to invokeClientPIEndingPoint + * (see bug 6763340). + * + * @param replyStatus One of the constants in iiop.messages.ReplyMessage + * indicating which reply status to set. + * @param exception The exception before ending interception points have + * been invoked, or null if no exception at the moment. + * @return The exception to be thrown, after having gone through + * all ending points, or null if there is no exception to be + * thrown. Note that this exception can be either the same or + * different from the exception set using setClientPIException. + * There are four possible return types: null (no exception), + * SystemException, UserException, or RemarshalException. + */ + Exception makeCompletedClientRequest( + int replyStatus, Exception exception ) ; + /** * Invoked when a request is about to be created. Must be called before * any of the setClientPI* methods so that a new info object can be diff --git a/corba/src/share/classes/com/sun/corba/se/spi/protocol/RetryType.java b/corba/src/share/classes/com/sun/corba/se/spi/protocol/RetryType.java new file mode 100644 index 00000000000..6035011d3e9 --- /dev/null +++ b/corba/src/share/classes/com/sun/corba/se/spi/protocol/RetryType.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2010, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package com.sun.corba.se.spi.protocol ; + +// Introduce more information about WHY we are re-trying a request +// so we can properly handle the two cases: +// - BEFORE_RESPONSE means that the retry is caused by +// something that happened BEFORE the message was sent: either +// an exception from the SocketFactory, or one from the +// Client side send_request interceptor point. +// - AFTER_RESPONSE means that the retry is a result either of the +// request sent to the server (from the response), or from the +// Client side receive_xxx interceptor point. +public enum RetryType { + NONE( false ), + BEFORE_RESPONSE( true ), + AFTER_RESPONSE( true ) ; + + private final boolean isRetry ; + + RetryType( boolean isRetry ) { + this.isRetry = isRetry ; + } + + public boolean isRetry() { + return this.isRetry ; + } +} ; + From 64c60db32c6536df601bec1ad0da38b4400891a0 Mon Sep 17 00:00:00 2001 From: Valerie Peng Date: Mon, 15 Nov 2010 14:32:49 -0800 Subject: [PATCH 15/89] 6848930: JSN security test jce/Global/Cipher/PKCS5Padding cannot thrown expected BadPaddingException Disabled CKM_DES_CBC_PAD, CKM_DES3_CBC_PAD, CKM_AES_CBC_PAD mechs by default and use our own internal padding impl. Reviewed-by: wetmore --- jdk/src/share/lib/security/sunpkcs11-solaris.cfg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jdk/src/share/lib/security/sunpkcs11-solaris.cfg b/jdk/src/share/lib/security/sunpkcs11-solaris.cfg index 4ceccc3d08d..d0b34ca134d 100644 --- a/jdk/src/share/lib/security/sunpkcs11-solaris.cfg +++ b/jdk/src/share/lib/security/sunpkcs11-solaris.cfg @@ -31,5 +31,9 @@ disabledMechanisms = { CKM_SHA256_RSA_PKCS CKM_SHA384_RSA_PKCS CKM_SHA512_RSA_PKCS +# the following mechanisms are disabled to ensure backward compatibility (Solaris bug 6545046) + CKM_DES_CBC_PAD + CKM_DES3_CBC_PAD + CKM_AES_CBC_PAD } From 0ec3c185d5723e0bf6522923af4a12cae1534392 Mon Sep 17 00:00:00 2001 From: Valerie Peng Date: Mon, 15 Nov 2010 14:38:41 -0800 Subject: [PATCH 16/89] 6687725: Internal PKCS5Padding impl should throw IllegalBlockSizeException and not BadPaddingException Changed to throw IllegalBlockSizeException when the data length isn't multiples of block size Reviewed-by: wetmore --- .../sun/security/pkcs11/P11Cipher.java | 9 +- .../pkcs11/Cipher/TestPKCS5PaddingError.java | 132 ++++++++++++++++++ 2 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 jdk/test/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java b/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java index 1ea39e799d1..5568887a5f6 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java +++ b/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java @@ -74,7 +74,7 @@ final class P11Cipher extends CipherSpi { // DEC: return the length of trailing padding bytes given the specified // padded data int unpad(byte[] paddedData, int len) - throws BadPaddingException; + throws BadPaddingException, IllegalBlockSizeException; } private static class PKCS5Padding implements Padding { @@ -96,9 +96,10 @@ final class P11Cipher extends CipherSpi { } public int unpad(byte[] paddedData, int len) - throws BadPaddingException { - if (len < 1 || len > paddedData.length) { - throw new BadPaddingException("Invalid pad array length!"); + throws BadPaddingException, IllegalBlockSizeException { + if ((len < 1) || (len % blockSize != 0)) { + throw new IllegalBlockSizeException + ("Input length must be multiples of " + blockSize); } byte padValue = paddedData[len - 1]; if (padValue < 1 || padValue > blockSize) { diff --git a/jdk/test/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java b/jdk/test/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java new file mode 100644 index 00000000000..f0721daa2e5 --- /dev/null +++ b/jdk/test/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2010, 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 6687725 + * @summary Test internal PKCS5Padding impl with various error conditions. + * @author Valerie Peng + * @library .. + */ +import java.io.*; +import java.nio.*; +import java.util.*; + +import java.security.*; +import java.security.spec.AlgorithmParameterSpec; + +import javax.crypto.*; +import javax.crypto.spec.IvParameterSpec; + +public class TestPKCS5PaddingError extends PKCS11Test { + private static class CI { // class for holding Cipher Information + String transformation; + String keyAlgo; + + CI(String transformation, String keyAlgo) { + this.transformation = transformation; + this.keyAlgo = keyAlgo; + } + } + + private static final CI[] TEST_LIST = { + // algorithms which use the native padding impl + new CI("DES/CBC/PKCS5Padding", "DES"), + new CI("DESede/CBC/PKCS5Padding", "DESede"), + new CI("AES/CBC/PKCS5Padding", "AES"), + // algorithms which use SunPKCS11's own padding impl + new CI("DES/ECB/PKCS5Padding", "DES"), + new CI("DESede/ECB/PKCS5Padding", "DESede"), + new CI("AES/ECB/PKCS5Padding", "AES"), + }; + + private static StringBuffer debugBuf = new StringBuffer(); + + public void main(Provider p) throws Exception { + boolean status = true; + Random random = new Random(); + + try { + byte[] plainText = new byte[200]; + + for (int i = 0; i < TEST_LIST.length; i++) { + CI currTest = TEST_LIST[i]; + System.out.println("===" + currTest.transformation + "==="); + try { + KeyGenerator kg = + KeyGenerator.getInstance(currTest.keyAlgo, p); + SecretKey key = kg.generateKey(); + Cipher c1 = Cipher.getInstance(currTest.transformation, + "SunJCE"); + c1.init(Cipher.ENCRYPT_MODE, key); + byte[] cipherText = c1.doFinal(plainText); + AlgorithmParameters params = c1.getParameters(); + Cipher c2 = Cipher.getInstance(currTest.transformation, p); + c2.init(Cipher.DECRYPT_MODE, key, params); + + // 1st test: wrong output length + // NOTE: Skip NSS since it reports CKR_DEVICE_ERROR when + // the data passed to its EncryptUpdate/DecryptUpdate is + // not multiple of blocks + if (!p.getName().equals("SunPKCS11-NSS")) { + try { + System.out.println("Testing with wrong cipherText length"); + c2.doFinal(cipherText, 0, cipherText.length - 2); + } catch (IllegalBlockSizeException ibe) { + // expected + } catch (Exception ex) { + System.out.println("Error: Unexpected Ex " + ex); + ex.printStackTrace(); + } + } + // 2nd test: wrong padding value + try { + System.out.println("Testing with wrong padding bytes"); + cipherText[cipherText.length - 1]++; + c2.doFinal(cipherText); + } catch (BadPaddingException bpe) { + // expected + } catch (Exception ex) { + System.out.println("Error: Unexpected Ex " + ex); + ex.printStackTrace(); + } + System.out.println("DONE"); + } catch (NoSuchAlgorithmException nsae) { + System.out.println("Skipping unsupported algorithm: " + + nsae); + } + } + } catch (Exception ex) { + // print out debug info when exception is encountered + if (debugBuf != null) { + System.out.println(debugBuf.toString()); + debugBuf = new StringBuffer(); + } + throw ex; + } + } + + public static void main(String[] args) throws Exception { + main(new TestPKCS5PaddingError()); + } +} From 721443756bac195ac6d44c223777c8f25eed281f Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Tue, 16 Nov 2010 15:23:11 +0000 Subject: [PATCH 17/89] 6613829: (docs) Readable.read() ReadOnlyBufferException is not linked Reviewed-by: chegar, lancea --- jdk/src/share/classes/java/lang/Readable.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/java/lang/Readable.java b/jdk/src/share/classes/java/lang/Readable.java index c97d792cca8..51279ef27ec 100644 --- a/jdk/src/share/classes/java/lang/Readable.java +++ b/jdk/src/share/classes/java/lang/Readable.java @@ -44,11 +44,11 @@ public interface Readable { * rewinding of the buffer is performed. * * @param cb the buffer to read characters into - * @return @return The number of char values added to the buffer, + * @return The number of {@code char} values added to the buffer, * or -1 if this source of characters is at its end * @throws IOException if an I/O error occurs * @throws NullPointerException if cb is null - * @throws ReadOnlyBufferException if cb is a read only buffer + * @throws java.nio.ReadOnlyBufferException if cb is a read only buffer */ public int read(java.nio.CharBuffer cb) throws IOException; From e4d948e846fe03fb2e124fa96d7bae5f34f257ff Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Wed, 17 Nov 2010 14:29:51 +0000 Subject: [PATCH 18/89] 6725892: Http server stability issues Reviewed-by: chegar --- .../sun/net/httpserver/HttpsConfigurator.java | 2 + .../sun/net/httpserver/HttpsParameters.java | 4 + .../net/httpserver/ChunkedInputStream.java | 1 + .../classes/sun/net/httpserver/Event.java | 2 + .../sun/net/httpserver/ExchangeImpl.java | 1 + .../httpserver/FixedLengthInputStream.java | 3 + .../sun/net/httpserver/HttpConnection.java | 13 + .../classes/sun/net/httpserver/Request.java | 108 ++----- .../sun/net/httpserver/SSLStreams.java | 41 +-- .../sun/net/httpserver/SelectorCache.java | 134 --------- .../sun/net/httpserver/ServerConfig.java | 119 +++++--- .../sun/net/httpserver/ServerImpl.java | 284 ++++++++++++++---- jdk/test/com/sun/net/httpserver/Test.java | 12 + jdk/test/com/sun/net/httpserver/Test1.java | 1 + jdk/test/com/sun/net/httpserver/Test13.java | 16 +- .../sun/net/httpserver/bugs/6725892/Test.java | 273 +++++++++++++++++ .../com/sun/net/httpserver/bugs/B6401598.java | 2 +- 17 files changed, 674 insertions(+), 342 deletions(-) delete mode 100644 jdk/src/share/classes/sun/net/httpserver/SelectorCache.java create mode 100644 jdk/test/com/sun/net/httpserver/bugs/6725892/Test.java diff --git a/jdk/src/share/classes/com/sun/net/httpserver/HttpsConfigurator.java b/jdk/src/share/classes/com/sun/net/httpserver/HttpsConfigurator.java index a299c1acf5e..355242b8aa4 100644 --- a/jdk/src/share/classes/com/sun/net/httpserver/HttpsConfigurator.java +++ b/jdk/src/share/classes/com/sun/net/httpserver/HttpsConfigurator.java @@ -91,6 +91,7 @@ public class HttpsConfigurator { return context; } +//BEGIN_TIGER_EXCLUDE /** * Called by the HttpsServer to configure the parameters * for a https connection currently being established. @@ -111,4 +112,5 @@ public class HttpsConfigurator { public void configure (HttpsParameters params) { params.setSSLParameters (getSSLContext().getDefaultSSLParameters()); } +//END_TIGER_EXCLUDE } diff --git a/jdk/src/share/classes/com/sun/net/httpserver/HttpsParameters.java b/jdk/src/share/classes/com/sun/net/httpserver/HttpsParameters.java index c54e917c02e..d4dc1ee3cf8 100644 --- a/jdk/src/share/classes/com/sun/net/httpserver/HttpsParameters.java +++ b/jdk/src/share/classes/com/sun/net/httpserver/HttpsParameters.java @@ -25,7 +25,9 @@ package com.sun.net.httpserver; import java.net.InetSocketAddress; +//BEGIN_TIGER_EXCLUDE import javax.net.ssl.SSLParameters; +//END_TIGER_EXCLUDE /** * Represents the set of parameters for each https @@ -67,6 +69,7 @@ public abstract class HttpsParameters { */ public abstract InetSocketAddress getClientAddress(); +//BEGIN_TIGER_EXCLUDE /** * Sets the SSLParameters to use for this HttpsParameters. * The parameters must be supported by the SSLContext contained @@ -79,6 +82,7 @@ public abstract class HttpsParameters { * invalid or unsupported. */ public abstract void setSSLParameters (SSLParameters params); +//END_TIGER_EXCLUDE /** * Returns a copy of the array of ciphersuites or null if none diff --git a/jdk/src/share/classes/sun/net/httpserver/ChunkedInputStream.java b/jdk/src/share/classes/sun/net/httpserver/ChunkedInputStream.java index 8a7c88ac603..6339e87bd44 100644 --- a/jdk/src/share/classes/sun/net/httpserver/ChunkedInputStream.java +++ b/jdk/src/share/classes/sun/net/httpserver/ChunkedInputStream.java @@ -110,6 +110,7 @@ class ChunkedInputStream extends LeftOverInputStream { if (remaining == 0) { eof = true; consumeCRLF(); + t.getServerImpl().requestCompleted (t.getConnection()); return -1; } needToReadHeader = false; diff --git a/jdk/src/share/classes/sun/net/httpserver/Event.java b/jdk/src/share/classes/sun/net/httpserver/Event.java index fa7512b99e8..e3109eeb618 100644 --- a/jdk/src/share/classes/sun/net/httpserver/Event.java +++ b/jdk/src/share/classes/sun/net/httpserver/Event.java @@ -40,5 +40,7 @@ class Event { class WriteFinishedEvent extends Event { WriteFinishedEvent (ExchangeImpl t) { super (t); + assert !t.writefinished; + t.writefinished = true; } } diff --git a/jdk/src/share/classes/sun/net/httpserver/ExchangeImpl.java b/jdk/src/share/classes/sun/net/httpserver/ExchangeImpl.java index 26453e6973e..edf813e2814 100644 --- a/jdk/src/share/classes/sun/net/httpserver/ExchangeImpl.java +++ b/jdk/src/share/classes/sun/net/httpserver/ExchangeImpl.java @@ -38,6 +38,7 @@ class ExchangeImpl { Headers reqHdrs, rspHdrs; Request req; String method; + boolean writefinished; URI uri; HttpConnection connection; long reqContentLen; diff --git a/jdk/src/share/classes/sun/net/httpserver/FixedLengthInputStream.java b/jdk/src/share/classes/sun/net/httpserver/FixedLengthInputStream.java index a98779295cb..abc5bf9244b 100644 --- a/jdk/src/share/classes/sun/net/httpserver/FixedLengthInputStream.java +++ b/jdk/src/share/classes/sun/net/httpserver/FixedLengthInputStream.java @@ -56,6 +56,9 @@ class FixedLengthInputStream extends LeftOverInputStream { int n = in.read(b, off, len); if (n > -1) { remaining -= n; + if (remaining == 0) { + t.getServerImpl().requestCompleted (t.getConnection()); + } } return n; } diff --git a/jdk/src/share/classes/sun/net/httpserver/HttpConnection.java b/jdk/src/share/classes/sun/net/httpserver/HttpConnection.java index 6d2cf7f954c..adb79556fc5 100644 --- a/jdk/src/share/classes/sun/net/httpserver/HttpConnection.java +++ b/jdk/src/share/classes/sun/net/httpserver/HttpConnection.java @@ -55,10 +55,15 @@ class HttpConnection { SelectionKey selectionKey; String protocol; long time; + volatile long creationTime; // time this connection was created + volatile long rspStartedTime; // time we started writing the response int remaining; boolean closed = false; Logger logger; + public enum State {IDLE, REQUEST, RESPONSE}; + volatile State state; + public String toString() { String s = null; if (chan != null) { @@ -78,6 +83,14 @@ class HttpConnection { context = ctx; } + State getState() { + return state; + } + + void setState (State s) { + state = s; + } + void setParameters ( InputStream in, OutputStream rawout, SocketChannel chan, SSLEngine engine, SSLStreams sslStreams, SSLContext sslContext, String protocol, diff --git a/jdk/src/share/classes/sun/net/httpserver/Request.java b/jdk/src/share/classes/sun/net/httpserver/Request.java index 56c2e137f57..a51664b32b0 100644 --- a/jdk/src/share/classes/sun/net/httpserver/Request.java +++ b/jdk/src/share/classes/sun/net/httpserver/Request.java @@ -201,32 +201,22 @@ class Request { static class ReadStream extends InputStream { SocketChannel channel; - SelectorCache sc; - Selector selector; ByteBuffer chanbuf; - SelectionKey key; - int available; byte[] one; - boolean closed = false, eof = false; + private boolean closed = false, eof = false; ByteBuffer markBuf; /* reads may be satisifed from this buffer */ boolean marked; boolean reset; int readlimit; static long readTimeout; ServerImpl server; - - static { - readTimeout = ServerConfig.getReadTimeout(); - } + final static int BUFSIZE = 8 * 1024; public ReadStream (ServerImpl server, SocketChannel chan) throws IOException { this.channel = chan; this.server = server; - sc = SelectorCache.getSelectorCache(); - selector = sc.getSelector(); - chanbuf = ByteBuffer.allocate (8* 1024); - key = chan.register (selector, SelectionKey.OP_READ); - available = 0; + chanbuf = ByteBuffer.allocate (BUFSIZE); + chanbuf.clear(); one = new byte[1]; closed = marked = reset = false; } @@ -255,6 +245,12 @@ class Request { return -1; } + assert channel.isBlocking(); + + if (off < 0 || srclen < 0|| srclen > (b.length-off)) { + throw new IndexOutOfBoundsException (); + } + if (reset) { /* satisfy from markBuf */ canreturn = markBuf.remaining (); willreturn = canreturn>srclen ? srclen : canreturn; @@ -263,17 +259,19 @@ class Request { reset = false; } } else { /* satisfy from channel */ - canreturn = available(); - while (canreturn == 0 && !eof) { - block (); - canreturn = available(); + chanbuf.clear (); + if (srclen < BUFSIZE) { + chanbuf.limit (srclen); } - if (eof) { + do { + willreturn = channel.read (chanbuf); + } while (willreturn == 0); + if (willreturn == -1) { + eof = true; return -1; } - willreturn = canreturn>srclen ? srclen : canreturn; + chanbuf.flip (); chanbuf.get(b, off, willreturn); - available -= willreturn; if (marked) { /* copy into markBuf */ try { @@ -286,6 +284,11 @@ class Request { return willreturn; } + public boolean markSupported () { + return true; + } + + /* Does not query the OS socket */ public synchronized int available () throws IOException { if (closed) throw new IOException ("Stream is closed"); @@ -296,36 +299,7 @@ class Request { if (reset) return markBuf.remaining(); - if (available > 0) - return available; - - chanbuf.clear (); - available = channel.read (chanbuf); - if (available > 0) { - chanbuf.flip(); - } else if (available == -1) { - eof = true; - available = 0; - } - return available; - } - - /** - * block() only called when available==0 and buf is empty - */ - private synchronized void block () throws IOException { - long currtime = server.getTime(); - long maxtime = currtime + readTimeout; - - while (currtime < maxtime) { - if (selector.select (readTimeout) == 1) { - selector.selectedKeys().clear(); - available (); - return; - } - currtime = server.getTime(); - } - throw new SocketTimeoutException ("no data received"); + return chanbuf.remaining(); } public void close () throws IOException { @@ -333,8 +307,6 @@ class Request { return; } channel.close (); - selector.selectNow(); - sc.freeSelector(selector); closed = true; } @@ -362,23 +334,14 @@ class Request { SocketChannel channel; ByteBuffer buf; SelectionKey key; - SelectorCache sc; - Selector selector; boolean closed; byte[] one; ServerImpl server; - static long writeTimeout; - - static { - writeTimeout = ServerConfig.getWriteTimeout(); - } public WriteStream (ServerImpl server, SocketChannel channel) throws IOException { this.channel = channel; this.server = server; - sc = SelectorCache.getSelectorCache(); - selector = sc.getSelector(); - key = channel.register (selector, SelectionKey.OP_WRITE); + assert channel.isBlocking(); closed = false; one = new byte [1]; buf = ByteBuffer.allocate (4096); @@ -411,31 +374,14 @@ class Request { l -= n; if (l == 0) return; - block(); } } - void block () throws IOException { - long currtime = server.getTime(); - long maxtime = currtime + writeTimeout; - - while (currtime < maxtime) { - if (selector.select (writeTimeout) == 1) { - selector.selectedKeys().clear (); - return; - } - currtime = server.getTime(); - } - throw new SocketTimeoutException ("write blocked too long"); - } - - public void close () throws IOException { if (closed) return; + //server.logStackTrace ("Request.OS.close: isOpen="+channel.isOpen()); channel.close (); - selector.selectNow(); - sc.freeSelector(selector); closed = true; } } diff --git a/jdk/src/share/classes/sun/net/httpserver/SSLStreams.java b/jdk/src/share/classes/sun/net/httpserver/SSLStreams.java index fed7f4b4943..8578177a61b 100644 --- a/jdk/src/share/classes/sun/net/httpserver/SSLStreams.java +++ b/jdk/src/share/classes/sun/net/httpserver/SSLStreams.java @@ -53,8 +53,6 @@ class SSLStreams { EngineWrapper wrapper; OutputStream os; InputStream is; - static long readTimeout = ServerConfig.getReadTimeout(); - static long writeTimeout = ServerConfig.getWriteTimeout(); /* held by thread doing the hand-shake on this connection */ Lock handshaking = new ReentrantLock(); @@ -77,10 +75,13 @@ class SSLStreams { if (cfg != null) { Parameters params = new Parameters (cfg, addr); cfg.configure (params); +//BEGIN_TIGER_EXCLUDE SSLParameters sslParams = params.getSSLParameters(); if (sslParams != null) { engine.setSSLParameters (sslParams); - } else { + } else +//END_TIGER_EXCLUDE + { /* tiger compatibility */ if (params.getCipherSuites() != null) { try { @@ -104,7 +105,6 @@ class SSLStreams { class Parameters extends HttpsParameters { InetSocketAddress addr; - SSLParameters params; HttpsConfigurator cfg; Parameters (HttpsConfigurator cfg, InetSocketAddress addr) { @@ -117,12 +117,15 @@ class SSLStreams { public HttpsConfigurator getHttpsConfigurator() { return cfg; } +//BEGIN_TIGER_EXCLUDE + SSLParameters params; public void setSSLParameters (SSLParameters p) { params = p; } SSLParameters getSSLParameters () { return params; } +//END_TIGER_EXCLUDE } /** @@ -245,9 +248,6 @@ class SSLStreams { SocketChannel chan; SSLEngine engine; - SelectorCache sc; - Selector write_selector, read_selector; - SelectionKey wkey, rkey; Object wrapLock, unwrapLock; ByteBuffer unwrap_src, wrap_dst; boolean closed = false; @@ -260,16 +260,9 @@ class SSLStreams { unwrapLock = new Object(); unwrap_src = allocate(BufType.PACKET); wrap_dst = allocate(BufType.PACKET); - sc = SelectorCache.getSelectorCache(); - write_selector = sc.getSelector(); - wkey = chan.register (write_selector, SelectionKey.OP_WRITE); - read_selector = sc.getSelector(); - wkey = chan.register (read_selector, SelectionKey.OP_READ); } void close () throws IOException { - sc.freeSelector (write_selector); - sc.freeSelector (read_selector); } /* try to wrap and send the data in src. Handles OVERFLOW. @@ -304,15 +297,7 @@ class SSLStreams { wrap_dst.flip(); int l = wrap_dst.remaining(); assert l == r.result.bytesProduced(); - long currtime = time.getTime(); - long maxtime = currtime + writeTimeout; while (l>0) { - write_selector.select(writeTimeout); // timeout - currtime = time.getTime(); - if (currtime > maxtime) { - throw new SocketTimeoutException ("write timed out"); - } - write_selector.selectedKeys().clear(); l -= chan.write (wrap_dst); } } @@ -342,20 +327,12 @@ class SSLStreams { needData = true; } synchronized (unwrapLock) { - int x,y; + int x; do { if (needData) { - long currTime = time.getTime(); - long maxtime = currTime + readTimeout; do { - if (currTime > maxtime) { - throw new SocketTimeoutException ("read timedout"); - } - y = read_selector.select (readTimeout); - currTime = time.getTime(); - } while (y != 1); - read_selector.selectedKeys().clear(); x = chan.read (unwrap_src); + } while (x == 0); if (x == -1) { throw new IOException ("connection closed for reading"); } diff --git a/jdk/src/share/classes/sun/net/httpserver/SelectorCache.java b/jdk/src/share/classes/sun/net/httpserver/SelectorCache.java deleted file mode 100644 index afd87c02235..00000000000 --- a/jdk/src/share/classes/sun/net/httpserver/SelectorCache.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2006, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package sun.net.httpserver; - -import java.util.*; -import java.nio.*; -import java.net.*; -import java.io.*; -import java.security.*; -import java.nio.channels.*; - -/* - * Implements a cache of java.nio.channels.Selector - * where Selectors are allocated on demand and placed - * in a temporary cache for a period of time, so they - * can be reused. If a period of between 2 and 4 minutes - * elapses without being used, then they are closed. - */ -public class SelectorCache { - - static SelectorCache cache = null; - - private SelectorCache () { - freeSelectors = new LinkedList(); - CacheCleaner c = AccessController.doPrivileged( - new PrivilegedAction() { - public CacheCleaner run() { - CacheCleaner cleaner = new CacheCleaner(); - cleaner.setDaemon (true); - return cleaner; - } - }); - c.start(); - } - - /** - * factory method for creating single instance - */ - public static SelectorCache getSelectorCache () { - synchronized (SelectorCache.class) { - if (cache == null) { - cache = new SelectorCache (); - } - } - return cache; - } - - private static class SelectorWrapper { - private Selector sel; - private boolean deleteFlag; - private SelectorWrapper (Selector sel) { - this.sel = sel; - this.deleteFlag = false; - } - public Selector getSelector() { return sel;} - public boolean getDeleteFlag () {return deleteFlag;} - public void setDeleteFlag (boolean b) {deleteFlag = b;} - } - - /* list of free selectors. Can be re-allocated for a period - * of time, after which if not allocated will be closed - * and removed from the list (by CacheCleaner thread) - */ - LinkedList freeSelectors; - - synchronized Selector getSelector () throws IOException { - SelectorWrapper wrapper = null; - Selector selector; - - if (freeSelectors.size() > 0) { - wrapper = freeSelectors.remove(); - selector = wrapper.getSelector(); - } else { - selector = Selector.open(); - } - return selector; - } - - synchronized void freeSelector (Selector selector) { - freeSelectors.add (new SelectorWrapper (selector)); - } - - /* Thread ensures that entries on freeSelector list - * remain there for at least 2 minutes and no longer - * than 4 minutes. - */ - class CacheCleaner extends Thread { - public void run () { - long timeout = ServerConfig.getSelCacheTimeout() * 1000; - while (true) { - try {Thread.sleep (timeout); } catch (Exception e) {} - synchronized (freeSelectors) { - ListIterator l = freeSelectors.listIterator(); - while (l.hasNext()) { - SelectorWrapper w = l.next(); - if (w.getDeleteFlag()) { - /* 2nd pass. Close the selector */ - try { - w.getSelector().close(); - } catch (IOException e) {} - l.remove(); - } else { - /* 1st pass. Set the flag */ - w.setDeleteFlag (true); - } - } - } - } - } - } -} diff --git a/jdk/src/share/classes/sun/net/httpserver/ServerConfig.java b/jdk/src/share/classes/sun/net/httpserver/ServerConfig.java index d4c87847547..cae3cdd84d9 100644 --- a/jdk/src/share/classes/sun/net/httpserver/ServerConfig.java +++ b/jdk/src/share/classes/sun/net/httpserver/ServerConfig.java @@ -27,6 +27,8 @@ package sun.net.httpserver; import com.sun.net.httpserver.*; import com.sun.net.httpserver.spi.*; +import java.util.logging.Logger; +import java.security.PrivilegedAction; /** * Parameters that users will not likely need to set @@ -37,23 +39,26 @@ class ServerConfig { static int clockTick; - static int defaultClockTick = 10000 ; // 10 sec. + static final int DEFAULT_CLOCK_TICK = 10000 ; // 10 sec. /* These values must be a reasonable multiple of clockTick */ - static long defaultReadTimeout = 20 ; // 20 sec. - static long defaultWriteTimeout = 60 ; // 60 sec. - static long defaultIdleInterval = 300 ; // 5 min - static long defaultSelCacheTimeout = 120 ; // seconds - static int defaultMaxIdleConnections = 200 ; + static final long DEFAULT_IDLE_INTERVAL = 300 ; // 5 min + static final int DEFAULT_MAX_IDLE_CONNECTIONS = 200 ; - static long defaultDrainAmount = 64 * 1024; + static final long DEFAULT_MAX_REQ_TIME = -1; // default: forever + static final long DEFAULT_MAX_RSP_TIME = -1; // default: forever + static final long DEFAULT_TIMER_MILLIS = 1000; + + static final long DEFAULT_DRAIN_AMOUNT = 64 * 1024; - static long readTimeout; - static long writeTimeout; static long idleInterval; - static long selCacheTimeout; static long drainAmount; // max # of bytes to drain from an inputstream static int maxIdleConnections; + + // max time a request or response is allowed to take + static long maxReqTime; + static long maxRspTime; + static long timerMillis; static boolean debug = false; static { @@ -61,49 +66,79 @@ class ServerConfig { idleInterval = ((Long)java.security.AccessController.doPrivileged( new sun.security.action.GetLongAction( "sun.net.httpserver.idleInterval", - defaultIdleInterval))).longValue() * 1000; + DEFAULT_IDLE_INTERVAL))).longValue() * 1000; clockTick = ((Integer)java.security.AccessController.doPrivileged( new sun.security.action.GetIntegerAction( "sun.net.httpserver.clockTick", - defaultClockTick))).intValue(); + DEFAULT_CLOCK_TICK))).intValue(); maxIdleConnections = ((Integer)java.security.AccessController.doPrivileged( new sun.security.action.GetIntegerAction( "sun.net.httpserver.maxIdleConnections", - defaultMaxIdleConnections))).intValue(); - - readTimeout = ((Long)java.security.AccessController.doPrivileged( - new sun.security.action.GetLongAction( - "sun.net.httpserver.readTimeout", - defaultReadTimeout))).longValue()* 1000; - - selCacheTimeout = ((Long)java.security.AccessController.doPrivileged( - new sun.security.action.GetLongAction( - "sun.net.httpserver.selCacheTimeout", - defaultSelCacheTimeout))).longValue()* 1000; - - writeTimeout = ((Long)java.security.AccessController.doPrivileged( - new sun.security.action.GetLongAction( - "sun.net.httpserver.writeTimeout", - defaultWriteTimeout))).longValue()* 1000; + DEFAULT_MAX_IDLE_CONNECTIONS))).intValue(); drainAmount = ((Long)java.security.AccessController.doPrivileged( new sun.security.action.GetLongAction( "sun.net.httpserver.drainAmount", - defaultDrainAmount))).longValue(); + DEFAULT_DRAIN_AMOUNT))).longValue(); + + maxReqTime = ((Long)java.security.AccessController.doPrivileged( + new sun.security.action.GetLongAction( + "sun.net.httpserver.maxReqTime", + DEFAULT_MAX_REQ_TIME))).longValue(); + + maxRspTime = ((Long)java.security.AccessController.doPrivileged( + new sun.security.action.GetLongAction( + "sun.net.httpserver.maxRspTime", + DEFAULT_MAX_RSP_TIME))).longValue(); + + timerMillis = ((Long)java.security.AccessController.doPrivileged( + new sun.security.action.GetLongAction( + "sun.net.httpserver.timerMillis", + DEFAULT_TIMER_MILLIS))).longValue(); debug = ((Boolean)java.security.AccessController.doPrivileged( new sun.security.action.GetBooleanAction( "sun.net.httpserver.debug"))).booleanValue(); } - static long getReadTimeout () { - return readTimeout; - } - static long getSelCacheTimeout () { - return selCacheTimeout; + static void checkLegacyProperties (final Logger logger) { + + // legacy properties that are no longer used + // print a warning to logger if they are set. + + java.security.AccessController.doPrivileged( + new PrivilegedAction() { + public Void run () { + if (System.getProperty("sun.net.httpserver.readTimeout") + !=null) + { + logger.warning ("sun.net.httpserver.readTimeout "+ + "property is no longer used. "+ + "Use sun.net.httpserver.maxReqTime instead." + ); + } + if (System.getProperty("sun.net.httpserver.writeTimeout") + !=null) + { + logger.warning ("sun.net.httpserver.writeTimeout "+ + "property is no longer used. Use "+ + "sun.net.httpserver.maxRspTime instead." + ); + } + if (System.getProperty("sun.net.httpserver.selCacheTimeout") + !=null) + { + logger.warning ("sun.net.httpserver.selCacheTimeout "+ + "property is no longer used." + ); + } + return null; + } + } + ); } static boolean debugEnabled () { @@ -122,11 +157,19 @@ class ServerConfig { return maxIdleConnections; } - static long getWriteTimeout () { - return writeTimeout; - } - static long getDrainAmount () { return drainAmount; } + + static long getMaxReqTime () { + return maxReqTime; + } + + static long getMaxRspTime () { + return maxRspTime; + } + + static long getTimerMillis () { + return timerMillis; + } } diff --git a/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java b/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java index a8b02878082..08edeaf8a80 100644 --- a/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java +++ b/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java @@ -37,6 +37,7 @@ import java.util.logging.Level; import javax.net.ssl.*; import com.sun.net.httpserver.*; import com.sun.net.httpserver.spi.*; +import sun.net.httpserver.HttpConnection.State; /** * Provides implementation for both HTTP and HTTPS @@ -55,6 +56,12 @@ class ServerImpl implements TimeSource { private SelectionKey listenerKey; private Set idleConnections; private Set allConnections; + /* following two are used to keep track of the times + * when a connection/request is first received + * and when we start to send the response + */ + private Set reqConnections; + private Set rspConnections; private List events; private Object lolock = new Object(); private volatile boolean finished = false; @@ -62,14 +69,19 @@ class ServerImpl implements TimeSource { private boolean bound = false; private boolean started = false; private volatile long time; /* current time */ + private volatile long subticks = 0; private volatile long ticks; /* number of clock ticks since server started */ private HttpServer wrapper; final static int CLOCK_TICK = ServerConfig.getClockTick(); final static long IDLE_INTERVAL = ServerConfig.getIdleInterval(); final static int MAX_IDLE_CONNECTIONS = ServerConfig.getMaxIdleConnections(); + final static long TIMER_MILLIS = ServerConfig.getTimerMillis (); + final static long MAX_REQ_TIME=getTimeMillis(ServerConfig.getMaxReqTime()); + final static long MAX_RSP_TIME=getTimeMillis(ServerConfig.getMaxRspTime()); + final static boolean timer1Enabled = MAX_REQ_TIME != -1 || MAX_RSP_TIME != -1; - private Timer timer; + private Timer timer, timer1; private Logger logger; ServerImpl ( @@ -79,6 +91,7 @@ class ServerImpl implements TimeSource { this.protocol = protocol; this.wrapper = wrapper; this.logger = Logger.getLogger ("com.sun.net.httpserver"); + ServerConfig.checkLegacyProperties (logger); https = protocol.equalsIgnoreCase ("https"); this.address = addr; contexts = new ContextList(); @@ -94,9 +107,18 @@ class ServerImpl implements TimeSource { dispatcher = new Dispatcher(); idleConnections = Collections.synchronizedSet (new HashSet()); allConnections = Collections.synchronizedSet (new HashSet()); + reqConnections = Collections.synchronizedSet (new HashSet()); + rspConnections = Collections.synchronizedSet (new HashSet()); time = System.currentTimeMillis(); timer = new Timer ("server-timer", true); timer.schedule (new ServerTimerTask(), CLOCK_TICK, CLOCK_TICK); + if (timer1Enabled) { + timer1 = new Timer ("server-timer1", true); + timer1.schedule (new ServerTimerTask1(),TIMER_MILLIS,TIMER_MILLIS); + logger.config ("HttpServer timer1 enabled period in ms: "+TIMER_MILLIS); + logger.config ("MAX_REQ_TIME: "+MAX_REQ_TIME); + logger.config ("MAX_RSP_TIME: "+MAX_RSP_TIME); + } events = new LinkedList(); logger.config ("HttpServer created "+protocol+" "+ addr); } @@ -181,6 +203,9 @@ class ServerImpl implements TimeSource { allConnections.clear(); idleConnections.clear(); timer.cancel(); + if (timer1Enabled) { + timer1.cancel(); + } } Dispatcher dispatcher; @@ -236,13 +261,6 @@ class ServerImpl implements TimeSource { } } - int resultSize () { - synchronized (lolock) { - return events.size (); - } - } - - /* main server listener task */ class Dispatcher implements Runnable { @@ -257,7 +275,7 @@ class ServerImpl implements TimeSource { if (terminating && exchanges == 0) { finished = true; } - SocketChannel chan = c.getChannel(); + responseCompleted (c); LeftOverInputStream is = t.getOriginalInputStream(); if (!is.isEOF()) { t.close = true; @@ -268,17 +286,10 @@ class ServerImpl implements TimeSource { } else { if (is.isDataBuffered()) { /* don't re-enable the interestops, just handle it */ + requestStarted (c); handle (c.getChannel(), c); } else { - /* re-enable interestops */ - SelectionKey key = c.getSelectionKey(); - if (key.isValid()) { - key.interestOps ( - key.interestOps()|SelectionKey.OP_READ - ); - } - c.time = getTime() + IDLE_INTERVAL; - idleConnections.add (c); + connsToRegister.add (c); } } } @@ -290,21 +301,50 @@ class ServerImpl implements TimeSource { } } + final LinkedList connsToRegister = + new LinkedList(); + + void reRegister (HttpConnection c) { + /* re-register with selector */ + try { + SocketChannel chan = c.getChannel(); + chan.configureBlocking (false); + SelectionKey key = chan.register (selector, SelectionKey.OP_READ); + key.attach (c); + c.selectionKey = key; + c.time = getTime() + IDLE_INTERVAL; + idleConnections.add (c); + } catch (IOException e) { + dprint(e); + logger.log(Level.FINER, "Dispatcher(8)", e); + c.close(); + } + } + public void run() { while (!finished) { try { + ListIterator li = + connsToRegister.listIterator(); + for (HttpConnection c : connsToRegister) { + reRegister(c); + } + connsToRegister.clear(); - /* process the events list first */ - - while (resultSize() > 0) { - Event r; - synchronized (lolock) { - r = events.remove(0); - handleEvent (r); + List list = null; + selector.select(1000); + synchronized (lolock) { + if (events.size() > 0) { + list = events; + events = new LinkedList(); } } - selector.select(1000); + if (list != null) { + for (Event r: list) { + handleEvent (r); + } + } /* process the selected list now */ @@ -327,6 +367,7 @@ class ServerImpl implements TimeSource { c.selectionKey = newkey; c.setChannel (chan); newkey.attach (c); + requestStarted (c); allConnections.add (c); } else { try { @@ -334,27 +375,44 @@ class ServerImpl implements TimeSource { boolean closed; SocketChannel chan = (SocketChannel)key.channel(); HttpConnection conn = (HttpConnection)key.attachment(); - // interestOps will be restored at end of read - key.interestOps (0); + + key.cancel(); + chan.configureBlocking (true); + if (idleConnections.remove(conn)) { + // was an idle connection so add it + // to reqConnections set. + requestStarted (conn); + } handle (chan, conn); } else { assert false; } + } catch (CancelledKeyException e) { + handleException(key, null); } catch (IOException e) { - HttpConnection conn = (HttpConnection)key.attachment(); - logger.log ( - Level.FINER, "Dispatcher (2)", e - ); - conn.close(); + handleException(key, e); } } } + // call the selector just to process the cancelled keys + selector.selectNow(); + } catch (IOException e) { + logger.log (Level.FINER, "Dispatcher (4)", e); } catch (Exception e) { - logger.log (Level.FINER, "Dispatcher (3)", e); + e.printStackTrace(); + logger.log (Level.FINER, "Dispatcher (7)", e); } } } + private void handleException (SelectionKey key, Exception e) { + HttpConnection conn = (HttpConnection)key.attachment(); + if (e != null) { + logger.log (Level.FINER, "Dispatcher (2)", e); + } + closeConnection(conn); + } + public void handle (SocketChannel chan, HttpConnection conn) throws IOException { @@ -363,10 +421,10 @@ class ServerImpl implements TimeSource { executor.execute (t); } catch (HttpError e1) { logger.log (Level.FINER, "Dispatcher (4)", e1); - conn.close(); + closeConnection(conn); } catch (IOException e) { logger.log (Level.FINER, "Dispatcher (5)", e); - conn.close(); + closeConnection(conn); } } } @@ -390,7 +448,26 @@ class ServerImpl implements TimeSource { return logger; } - /* per exchange task */ + private void closeConnection(HttpConnection conn) { + conn.close(); + allConnections.remove(conn); + switch (conn.getState()) { + case REQUEST: + reqConnections.remove(conn); + break; + case RESPONSE: + rspConnections.remove(conn); + break; + case IDLE: + idleConnections.remove(conn); + break; + } + assert !reqConnections.remove(conn); + assert !rspConnections.remove(conn); + assert !idleConnections.remove(conn); + } + + /* per exchange task */ class Exchange implements Runnable { SocketChannel chan; @@ -450,8 +527,7 @@ class ServerImpl implements TimeSource { requestLine = req.requestLine(); if (requestLine == null) { /* connection closed */ - connection.close(); - allConnections.remove(connection); + closeConnection(connection); return; } int space = requestLine.indexOf (' '); @@ -482,6 +558,9 @@ class ServerImpl implements TimeSource { if (s != null) { clen = Long.parseLong(s); } + if (clen == 0) { + requestCompleted (connection); + } } ctx = contexts.findContext (protocol, uri.getPath()); if (ctx == null) { @@ -560,7 +639,7 @@ class ServerImpl implements TimeSource { } catch (IOException e1) { logger.log (Level.FINER, "ServerImpl.Exchange (1)", e1); - connection.close(); + closeConnection(connection); } catch (NumberFormatException e3) { reject (Code.HTTP_BAD_REQUEST, requestLine, "NumberFormatException thrown"); @@ -569,7 +648,7 @@ class ServerImpl implements TimeSource { requestLine, "URISyntaxException thrown"); } catch (Exception e4) { logger.log (Level.FINER, "ServerImpl.Exchange (2)", e4); - connection.close(); + closeConnection(connection); } } @@ -591,47 +670,60 @@ class ServerImpl implements TimeSource { rejected = true; logReply (code, requestStr, message); sendReply ( - code, true, "

"+code+Code.msg(code)+"

"+message + code, false, "

"+code+Code.msg(code)+"

"+message ); - /* connection is already closed by sendReply, now remove it */ - allConnections.remove(connection); + closeConnection(connection); } void sendReply ( int code, boolean closeNow, String text) { try { - String s = "HTTP/1.1 " + code + Code.msg(code) + "\r\n"; + StringBuilder builder = new StringBuilder (512); + builder.append ("HTTP/1.1 ") + .append (code).append (Code.msg(code)).append ("\r\n"); + if (text != null && text.length() != 0) { - s = s + "Content-Length: "+text.length()+"\r\n"; - s = s + "Content-Type: text/html\r\n"; + builder.append ("Content-Length: ") + .append (text.length()).append ("\r\n") + .append ("Content-Type: text/html\r\n"); } else { - s = s + "Content-Length: 0\r\n"; + builder.append ("Content-Length: 0\r\n"); text = ""; } if (closeNow) { - s = s + "Connection: close\r\n"; + builder.append ("Connection: close\r\n"); } - s = s + "\r\n" + text; + builder.append ("\r\n").append (text); + String s = builder.toString(); byte[] b = s.getBytes("ISO8859_1"); rawout.write (b); rawout.flush(); if (closeNow) { - connection.close(); + closeConnection(connection); } } catch (IOException e) { logger.log (Level.FINER, "ServerImpl.sendReply", e); - connection.close(); + closeConnection(connection); } } } void logReply (int code, String requestStr, String text) { + if (!logger.isLoggable(Level.FINE)) { + return; + } if (text == null) { text = ""; } - String message = requestStr + " [" + code + " " + + String r; + if (requestStr.length() > 80) { + r = requestStr.substring (0, 80) + ""; + } else { + r = requestStr; + } + String message = r + " [" + code + " " + Code.msg(code) + "] ("+text+")"; logger.fine (message); } @@ -667,6 +759,34 @@ class ServerImpl implements TimeSource { return wrapper; } + void requestStarted (HttpConnection c) { + c.creationTime = getTime(); + c.setState (State.REQUEST); + reqConnections.add (c); + } + + // called after a request has been completely read + // by the server. This stops the timer which would + // close the connection if the request doesn't arrive + // quickly enough. It then starts the timer + // that ensures the client reads the response in a timely + // fashion. + + void requestCompleted (HttpConnection c) { + assert c.getState() == State.REQUEST; + reqConnections.remove (c); + c.rspStartedTime = getTime(); + rspConnections.add (c); + c.setState (State.RESPONSE); + } + + // called after response has been sent + void responseCompleted (HttpConnection c) { + assert c.getState() == State.RESPONSE; + rspConnections.remove (c); + c.setState (State.IDLE); + } + /** * TimerTask run every CLOCK_TICK ms */ @@ -689,4 +809,62 @@ class ServerImpl implements TimeSource { } } } + + class ServerTimerTask1 extends TimerTask { + + // runs every TIMER_MILLIS + public void run () { + LinkedList toClose = new LinkedList(); + time = System.currentTimeMillis(); + synchronized (reqConnections) { + if (MAX_REQ_TIME != -1) { + for (HttpConnection c : reqConnections) { + if (c.creationTime + TIMER_MILLIS + MAX_REQ_TIME <= time) { + toClose.add (c); + } + } + for (HttpConnection c : toClose) { + logger.log (Level.FINE, "closing: no request: " + c); + reqConnections.remove (c); + allConnections.remove (c); + c.close(); + } + } + } + toClose = new LinkedList(); + synchronized (rspConnections) { + if (MAX_RSP_TIME != -1) { + for (HttpConnection c : rspConnections) { + if (c.rspStartedTime + TIMER_MILLIS +MAX_RSP_TIME <= time) { + toClose.add (c); + } + } + for (HttpConnection c : toClose) { + logger.log (Level.FINE, "closing: no response: " + c); + rspConnections.remove (c); + allConnections.remove (c); + c.close(); + } + } + } + } + } + + void logStackTrace (String s) { + logger.finest (s); + StringBuilder b = new StringBuilder (); + StackTraceElement[] e = Thread.currentThread().getStackTrace(); + for (int i=0; i Date: Wed, 17 Nov 2010 11:55:01 -0500 Subject: [PATCH 19/89] 6997515: KERNEL=0 in JDK7 build causes loss of lzma compression Reviewed-by: billyh, jqzuo --- make/deploy-rules.gmk | 2 -- 1 file changed, 2 deletions(-) diff --git a/make/deploy-rules.gmk b/make/deploy-rules.gmk index 7e080a60e40..6b9f50c9767 100644 --- a/make/deploy-rules.gmk +++ b/make/deploy-rules.gmk @@ -46,7 +46,6 @@ DEPLOY_BUILD_TARGETS = sanity deploy # Enable 7-Zip LZMA file (de)compression for Java Kernel if it is available ifeq ($(ARCH_DATA_MODEL), 32) ifeq ($(PLATFORM), windows) - ifneq ($(KERNEL), off) EC_TMP = $(shell if [ -d $(DEPLOY_TOPDIR)/make/lzma ] ; then \ $(ECHO) true ; \ else \ @@ -55,7 +54,6 @@ ifeq ($(ARCH_DATA_MODEL), 32) ifeq ($(EC_TMP), true) DEPLOY_BUILD_TARGETS += extra-comp-all endif - endif endif endif From 220f3b1c1b3c59318f88e7a0e881505bc975abf8 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Wed, 17 Nov 2010 15:07:43 -0800 Subject: [PATCH 20/89] 7000973: isBogus needs to be called on the to-be-returned entry, not on the current entry Reviewed-by: jjg --- langtools/src/share/classes/com/sun/tools/javac/code/Scope.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java index b491a49e69a..16672d57a4c 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java @@ -528,7 +528,7 @@ public class Scope { } public Entry next() { Entry e = super.shadowed; - while (isBogus()) + while (e.isBogus()) e = e.shadowed; return e; } From 8add507dbc7444a4313a3deb1cb380e04b5d1619 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Wed, 17 Nov 2010 15:10:42 -0800 Subject: [PATCH 21/89] 6615506: (fmt spec) Date/Time conversion table missing column for 'Z' Added the column entry back in Reviewed-by: alanb --- jdk/src/share/classes/java/util/Formatter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/src/share/classes/java/util/Formatter.java b/jdk/src/share/classes/java/util/Formatter.java index 55fd610d39d..6e115b5156b 100644 --- a/jdk/src/share/classes/java/util/Formatter.java +++ b/jdk/src/share/classes/java/util/Formatter.java @@ -1581,6 +1581,7 @@ import sun.misc.FormattedFloatingDecimal; * instance of the Java virtual machine. * * {@code 'Z'} + * '\u005a' * A string representing the abbreviation for the time zone. This * value will be adjusted as necessary for Daylight Saving Time. For * {@code long}, {@link Long}, and {@link Date} the time zone used is From 8aaa66c1f786d83307b8917a89ac5f1402dc8926 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Wed, 17 Nov 2010 21:33:16 -0800 Subject: [PATCH 22/89] 6217210: RFE: Support for Cp833 in 1.4.2 Forward port the Cp833 charset Reviewed-by: poonam --- jdk/make/sun/nio/cs/FILES_java.gmk | 3 + jdk/make/tools/CharsetMapping/IBM833.c2b | 94 ++++++++ jdk/make/tools/CharsetMapping/IBM833.map | 217 ++++++++++++++++++ jdk/make/tools/CharsetMapping/extsbcs | 1 + .../share/classes/sun/io/ByteToCharCp833.java | 42 ++++ .../share/classes/sun/io/CharToByteCp833.java | 46 ++++ .../classes/sun/io/CharacterEncoding.java | 7 +- .../sun/nio/cs/ext/ExtendedCharsets.java | 7 + jdk/test/sun/nio/cs/CheckHistoricalNames.java | 4 +- 9 files changed, 419 insertions(+), 2 deletions(-) create mode 100644 jdk/make/tools/CharsetMapping/IBM833.c2b create mode 100644 jdk/make/tools/CharsetMapping/IBM833.map create mode 100644 jdk/src/share/classes/sun/io/ByteToCharCp833.java create mode 100644 jdk/src/share/classes/sun/io/CharToByteCp833.java diff --git a/jdk/make/sun/nio/cs/FILES_java.gmk b/jdk/make/sun/nio/cs/FILES_java.gmk index d930065d83f..b177d64b4c1 100644 --- a/jdk/make/sun/nio/cs/FILES_java.gmk +++ b/jdk/make/sun/nio/cs/FILES_java.gmk @@ -85,6 +85,7 @@ FILES_src = \ sun/io/ByteToCharCp500.java \ sun/io/ByteToCharCp737.java \ sun/io/ByteToCharCp775.java \ + sun/io/ByteToCharCp833.java \ sun/io/ByteToCharCp834.java \ sun/io/ByteToCharCp838.java \ sun/io/ByteToCharCp850.java \ @@ -214,6 +215,7 @@ FILES_src = \ sun/io/CharToByteCp500.java \ sun/io/CharToByteCp737.java \ sun/io/CharToByteCp775.java \ + sun/io/CharToByteCp833.java \ sun/io/CharToByteCp834.java \ sun/io/CharToByteCp838.java \ sun/io/CharToByteCp850.java \ @@ -331,6 +333,7 @@ FILES_gen_extcs = \ sun/nio/cs/ext/IBM420.java \ sun/nio/cs/ext/IBM424.java \ sun/nio/cs/ext/IBM500.java \ + sun/nio/cs/ext/IBM833.java \ sun/nio/cs/ext/IBM838.java \ sun/nio/cs/ext/IBM856.java \ sun/nio/cs/ext/IBM860.java \ diff --git a/jdk/make/tools/CharsetMapping/IBM833.c2b b/jdk/make/tools/CharsetMapping/IBM833.c2b new file mode 100644 index 00000000000..b751d80bc00 --- /dev/null +++ b/jdk/make/tools/CharsetMapping/IBM833.c2b @@ -0,0 +1,94 @@ +0x5A U+FF01 +0x7F U+FF02 +0x7B U+FF03 +0x5B U+FF04 +0x6C U+FF05 +0x50 U+FF06 +0x7D U+FF07 +0x4D U+FF08 +0x5D U+FF09 +0x5C U+FF0A +0x4E U+FF0B +0x6B U+FF0C +0x60 U+FF0D +0x4B U+FF0E +0x61 U+FF0F +0xF0 U+FF10 +0xF1 U+FF11 +0xF2 U+FF12 +0xF3 U+FF13 +0xF4 U+FF14 +0xF5 U+FF15 +0xF6 U+FF16 +0xF7 U+FF17 +0xF8 U+FF18 +0xF9 U+FF19 +0x7A U+FF1A +0x5E U+FF1B +0x4C U+FF1C +0x7E U+FF1D +0x6E U+FF1E +0x6F U+FF1F +0x7C U+FF20 +0xC1 U+FF21 +0xC2 U+FF22 +0xC3 U+FF23 +0xC4 U+FF24 +0xC5 U+FF25 +0xC6 U+FF26 +0xC7 U+FF27 +0xC8 U+FF28 +0xC9 U+FF29 +0xD1 U+FF2A +0xD2 U+FF2B +0xD3 U+FF2C +0xD4 U+FF2D +0xD5 U+FF2E +0xD6 U+FF2F +0xD7 U+FF30 +0xD8 U+FF31 +0xD9 U+FF32 +0xE2 U+FF33 +0xE3 U+FF34 +0xE4 U+FF35 +0xE5 U+FF36 +0xE6 U+FF37 +0xE7 U+FF38 +0xE8 U+FF39 +0xE9 U+FF3A +0x70 U+FF3B +0xB2 U+FF3C +0x80 U+FF3D +0xB0 U+FF3E +0x6D U+FF3F +0x79 U+FF40 +0x81 U+FF41 +0x82 U+FF42 +0x83 U+FF43 +0x84 U+FF44 +0x85 U+FF45 +0x86 U+FF46 +0x87 U+FF47 +0x88 U+FF48 +0x89 U+FF49 +0x91 U+FF4A +0x92 U+FF4B +0x93 U+FF4C +0x94 U+FF4D +0x95 U+FF4E +0x96 U+FF4F +0x97 U+FF50 +0x98 U+FF51 +0x99 U+FF52 +0xA2 U+FF53 +0xA3 U+FF54 +0xA4 U+FF55 +0xA5 U+FF56 +0xA6 U+FF57 +0xA7 U+FF58 +0xA8 U+FF59 +0xA9 U+FF5A +0xC0 U+FF5B +0x4F U+FF5C +0xD0 U+FF5D +0xA1 U+FF5E diff --git a/jdk/make/tools/CharsetMapping/IBM833.map b/jdk/make/tools/CharsetMapping/IBM833.map new file mode 100644 index 00000000000..b36860ae4e7 --- /dev/null +++ b/jdk/make/tools/CharsetMapping/IBM833.map @@ -0,0 +1,217 @@ +0x00 U+0000 +0x01 U+0001 +0x02 U+0002 +0x03 U+0003 +0x37 U+0004 +0x2D U+0005 +0x2E U+0006 +0x2F U+0007 +0x16 U+0008 +0x05 U+0009 +0x25 U+000A +0x0B U+000B +0x0C U+000C +0x0D U+000D +0x0E U+000E +0x0F U+000F +0x10 U+0010 +0x11 U+0011 +0x12 U+0012 +0x13 U+0013 +0x3C U+0014 +0x3D U+0015 +0x32 U+0016 +0x26 U+0017 +0x18 U+0018 +0x19 U+0019 +0x3F U+001A +0x27 U+001B +0x1C U+001C +0x1D U+001D +0x1E U+001E +0x1F U+001F +0x40 U+0020 +0x5A U+0021 +0x7F U+0022 +0x7B U+0023 +0x5B U+0024 +0x6C U+0025 +0x50 U+0026 +0x7D U+0027 +0x4D U+0028 +0x5D U+0029 +0x5C U+002A +0x4E U+002B +0x6B U+002C +0x60 U+002D +0x4B U+002E +0x61 U+002F +0xF0 U+0030 +0xF1 U+0031 +0xF2 U+0032 +0xF3 U+0033 +0xF4 U+0034 +0xF5 U+0035 +0xF6 U+0036 +0xF7 U+0037 +0xF8 U+0038 +0xF9 U+0039 +0x7A U+003A +0x5E U+003B +0x4C U+003C +0x7E U+003D +0x6E U+003E +0x6F U+003F +0x7C U+0040 +0xC1 U+0041 +0xC2 U+0042 +0xC3 U+0043 +0xC4 U+0044 +0xC5 U+0045 +0xC6 U+0046 +0xC7 U+0047 +0xC8 U+0048 +0xC9 U+0049 +0xD1 U+004A +0xD2 U+004B +0xD3 U+004C +0xD4 U+004D +0xD5 U+004E +0xD6 U+004F +0xD7 U+0050 +0xD8 U+0051 +0xD9 U+0052 +0xE2 U+0053 +0xE3 U+0054 +0xE4 U+0055 +0xE5 U+0056 +0xE6 U+0057 +0xE7 U+0058 +0xE8 U+0059 +0xE9 U+005A +0x70 U+005B +0xB2 U+005C +0x80 U+005D +0xB0 U+005E +0x6D U+005F +0x79 U+0060 +0x81 U+0061 +0x82 U+0062 +0x83 U+0063 +0x84 U+0064 +0x85 U+0065 +0x86 U+0066 +0x87 U+0067 +0x88 U+0068 +0x89 U+0069 +0x91 U+006A +0x92 U+006B +0x93 U+006C +0x94 U+006D +0x95 U+006E +0x96 U+006F +0x97 U+0070 +0x98 U+0071 +0x99 U+0072 +0xA2 U+0073 +0xA3 U+0074 +0xA4 U+0075 +0xA5 U+0076 +0xA6 U+0077 +0xA7 U+0078 +0xA8 U+0079 +0xA9 U+007A +0xC0 U+007B +0x4F U+007C +0xD0 U+007D +0xA1 U+007E +0x07 U+007F +0x20 U+0080 +0x21 U+0081 +0x22 U+0082 +0x23 U+0083 +0x24 U+0084 +0x15 U+0085 +0x06 U+0086 +0x17 U+0087 +0x28 U+0088 +0x29 U+0089 +0x2A U+008A +0x2B U+008B +0x2C U+008C +0x09 U+008D +0x0A U+008E +0x1B U+008F +0x30 U+0090 +0x31 U+0091 +0x1A U+0092 +0x33 U+0093 +0x34 U+0094 +0x35 U+0095 +0x36 U+0096 +0x08 U+0097 +0x38 U+0098 +0x39 U+0099 +0x3A U+009A +0x3B U+009B +0x04 U+009C +0x14 U+009D +0x3E U+009E +0xFF U+009F +0x4A U+00A2 +0x6A U+00A6 +0x5F U+00AC +0xA0 U+203E +0xE0 U+20A9 +0x42 U+FFA0 +0x43 U+FFA1 +0x44 U+FFA2 +0x45 U+FFA3 +0x46 U+FFA4 +0x47 U+FFA5 +0x48 U+FFA6 +0x49 U+FFA7 +0x52 U+FFA8 +0x53 U+FFA9 +0x54 U+FFAA +0x55 U+FFAB +0x56 U+FFAC +0x57 U+FFAD +0x58 U+FFAE +0x59 U+FFAF +0x62 U+FFB0 +0x63 U+FFB1 +0x64 U+FFB2 +0x65 U+FFB3 +0x66 U+FFB4 +0x67 U+FFB5 +0x68 U+FFB6 +0x69 U+FFB7 +0x72 U+FFB8 +0x73 U+FFB9 +0x74 U+FFBA +0x75 U+FFBB +0x76 U+FFBC +0x77 U+FFBD +0x78 U+FFBE +0x8A U+FFC2 +0x8B U+FFC3 +0x8C U+FFC4 +0x8D U+FFC5 +0x8E U+FFC6 +0x8F U+FFC7 +0x9A U+FFCA +0x9B U+FFCB +0x9C U+FFCC +0x9D U+FFCD +0x9E U+FFCE +0x9F U+FFCF +0xAA U+FFD2 +0xAB U+FFD3 +0xAC U+FFD4 +0xAD U+FFD5 +0xAE U+FFD6 +0xAF U+FFD7 +0xBA U+FFDA +0xBB U+FFDB +0xBC U+FFDC diff --git a/jdk/make/tools/CharsetMapping/extsbcs b/jdk/make/tools/CharsetMapping/extsbcs index 81a6acdf817..e66fe5bbb1c 100644 --- a/jdk/make/tools/CharsetMapping/extsbcs +++ b/jdk/make/tools/CharsetMapping/extsbcs @@ -32,6 +32,7 @@ IBM297 IBM297 Cp297 false sun.nio.cs.ext IBM420 IBM420 Cp420 false sun.nio.cs.ext IBM424 IBM424 Cp424 false sun.nio.cs.ext IBM500 IBM500 Cp500 false sun.nio.cs.ext +IBM833 IBM833 Cp833 false sun.nio.cs.ext IBM838 IBM-Thai Cp838 false sun.nio.cs.ext IBM856 x-IBM856 Cp856 false sun.nio.cs.ext IBM860 IBM860 Cp860 false sun.nio.cs.ext diff --git a/jdk/src/share/classes/sun/io/ByteToCharCp833.java b/jdk/src/share/classes/sun/io/ByteToCharCp833.java new file mode 100644 index 00000000000..a83a893d137 --- /dev/null +++ b/jdk/src/share/classes/sun/io/ByteToCharCp833.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2010 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package sun.io; + +import sun.nio.cs.ext.IBM833; + +public class ByteToCharCp833 extends ByteToCharSingleByte { + + private final static IBM833 nioCoder = new IBM833(); + + public String getCharacterEncoding() { + return "Cp833"; + } + + public ByteToCharCp833() { + super.byteToCharTable = nioCoder.getDecoderSingleByteMappings(); + } +} + diff --git a/jdk/src/share/classes/sun/io/CharToByteCp833.java b/jdk/src/share/classes/sun/io/CharToByteCp833.java new file mode 100644 index 00000000000..2d531406c17 --- /dev/null +++ b/jdk/src/share/classes/sun/io/CharToByteCp833.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package sun.io; + +import sun.nio.cs.ext.IBM833; + +public class CharToByteCp833 extends CharToByteSingleByte { + + private final static IBM833 nioCoder = new IBM833(); + + public String getCharacterEncoding() { + return "Cp833"; + } + + public CharToByteCp833() { + super.mask1 = 0xFF00; + super.mask2 = 0x00FF; + super.shift = 8; + super.index1 = nioCoder.getEncoderIndex1(); + super.index2 = nioCoder.getEncoderIndex2(); + } +} + diff --git a/jdk/src/share/classes/sun/io/CharacterEncoding.java b/jdk/src/share/classes/sun/io/CharacterEncoding.java index 94ce7040f5d..f577a9bc79b 100644 --- a/jdk/src/share/classes/sun/io/CharacterEncoding.java +++ b/jdk/src/share/classes/sun/io/CharacterEncoding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2010, 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 @@ -406,6 +406,11 @@ public class CharacterEncoding { aliasTable.put("cp775", "Cp775"); aliasTable.put("775", "Cp775"); + aliasTable.put("ibm833", "Cp833"); + aliasTable.put("ibm-833", "Cp833"); + aliasTable.put("cp833", "Cp833"); + aliasTable.put("833", "Cp833"); + aliasTable.put("ibm834", "Cp834"); aliasTable.put("ibm-834", "Cp834"); aliasTable.put("cp834", "Cp834"); diff --git a/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java b/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java index ca6a49637c0..920e3372d42 100644 --- a/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java +++ b/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java @@ -778,6 +778,13 @@ public class ExtendedCharsets "csIBM500" }); + charset("x-IBM833", "IBM833", + new String[] { + "cp833", + "ibm833", + "ibm-833" + }); + //EBCDIC DBCS-only Korean charset("x-IBM834", "IBM834", new String[] { diff --git a/jdk/test/sun/nio/cs/CheckHistoricalNames.java b/jdk/test/sun/nio/cs/CheckHistoricalNames.java index fdab32d75ed..af04434bd82 100644 --- a/jdk/test/sun/nio/cs/CheckHistoricalNames.java +++ b/jdk/test/sun/nio/cs/CheckHistoricalNames.java @@ -22,7 +22,7 @@ */ /* @test - @bug 4513767 4961027 + @bug 4513767 4961027 6217210 @summary Checks canonical names match between old and (NIO) core charsets */ import java.io.InputStreamReader; @@ -154,6 +154,7 @@ public class CheckHistoricalNames { checkHistoricalName("Cp500"); checkHistoricalName("Cp737"); checkHistoricalName("Cp775"); + checkHistoricalName("Cp833"); checkHistoricalName("Cp838"); checkHistoricalName("Cp850"); checkHistoricalName("Cp852"); @@ -228,6 +229,7 @@ public class CheckHistoricalNames { checkMappedName("IBM856", "Cp856"); checkMappedName("IBM857", "Cp857"); checkMappedName("IBM00858", "Cp858"); + checkMappedName("IBM833", "Cp833"); checkMappedName("IBM860", "Cp860"); checkMappedName("IBM861", "Cp861"); checkMappedName("IBM862", "Cp862"); From cd9eaf7bcc75c244266bf8bc7883792d3c0b6a26 Mon Sep 17 00:00:00 2001 From: Andrei Dmitriev Date: Thu, 18 Nov 2010 14:26:19 +0300 Subject: [PATCH 23/89] 6990904: (dav) on oel5.5, Frame doesn't show if the Frame has only a MenuBar as its component Reviewed-by: dcherepanov, art --- .../classes/sun/awt/X11/XFramePeer.java | 4 +- .../MenuBar/DeadlockTest1/DeadlockTest1.java | 73 +++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/awt/MenuBar/DeadlockTest1/DeadlockTest1.java diff --git a/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java b/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java index 8ff374b0f37..771749fb8bb 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java @@ -150,6 +150,8 @@ class XFramePeer extends XDecoratedPeer implements FramePeer { void updateChildrenSizes() { super.updateChildrenSizes(); + int height = getMenuBarHeight(); + // XWindow.reshape calls XBaseWindow.xSetBounds, which acquires // the AWT lock, so we have to acquire the AWT lock here // before getStateLock() to avoid a deadlock with the Toolkit thread @@ -159,7 +161,7 @@ class XFramePeer extends XDecoratedPeer implements FramePeer { synchronized(getStateLock()) { int width = dimensions.getClientSize().width; if (menubarPeer != null) { - menubarPeer.reshape(0, 0, width, getMenuBarHeight()); + menubarPeer.reshape(0, 0, width, height); } } } finally { diff --git a/jdk/test/java/awt/MenuBar/DeadlockTest1/DeadlockTest1.java b/jdk/test/java/awt/MenuBar/DeadlockTest1/DeadlockTest1.java new file mode 100644 index 00000000000..dc9677b49e2 --- /dev/null +++ b/jdk/test/java/awt/MenuBar/DeadlockTest1/DeadlockTest1.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2010, 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 6990904 + @summary on oel5.5, Frame doesn't show if the Frame has only a MenuBar as its component. + @author Andrei Dmitriev: area=awt-menubar + @run main/timeout=30 DeadlockTest1 +*/ + +import java.awt.*; + +public class DeadlockTest1 { + Frame f = new Frame("Menu Frame"); + + DeadlockTest1() { + MenuBar menubar = new MenuBar(); + + Menu file = new Menu("File"); + Menu edit = new Menu("Edit"); + Menu help = new Menu("Help"); + + MenuItem open = new MenuItem("Open"); + MenuItem close = new MenuItem("Close"); + MenuItem copy = new MenuItem("Copy"); + MenuItem paste = new MenuItem("Paste"); + + file.add(open); + file.add(close); + + edit.add(copy); + edit.add(paste); + menubar.add(file); + menubar.add(edit); + menubar.add(help); + menubar.setHelpMenu(help); + + f.setMenuBar(menubar); + f.setSize(400,200); + f.setVisible(true); + try { + Thread.sleep(5000); + } catch (InterruptedException z) { + throw new RuntimeException(z); + } + f.dispose(); + } + + public static void main(String argv[]) { + new DeadlockTest1(); + } +} From c1b0efa73267cc8e859d10537de8a3d8f5c6d442 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Thu, 18 Nov 2010 19:16:45 +0000 Subject: [PATCH 24/89] 7000913: (bf) CharBuffer.wrap, slice, position, slice leads to CharBuffer with incorrect offser Reviewed-by: forax --- .../classes/java/nio/StringCharBuffer.java | 2 +- .../nio/Buffer/StringCharBufferSliceTest.java | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/classes/java/nio/StringCharBuffer.java b/jdk/src/share/classes/java/nio/StringCharBuffer.java index b5df238573c..52d7a2087a5 100644 --- a/jdk/src/share/classes/java/nio/StringCharBuffer.java +++ b/jdk/src/share/classes/java/nio/StringCharBuffer.java @@ -47,7 +47,7 @@ class StringCharBuffer // package-private 0, this.remaining(), this.remaining(), - this.position()); + offset + this.position()); } private StringCharBuffer(CharSequence s, diff --git a/jdk/test/java/nio/Buffer/StringCharBufferSliceTest.java b/jdk/test/java/nio/Buffer/StringCharBufferSliceTest.java index 0b8dc8aa09a..4840322845f 100644 --- a/jdk/test/java/nio/Buffer/StringCharBufferSliceTest.java +++ b/jdk/test/java/nio/Buffer/StringCharBufferSliceTest.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 4997655 + * @bug 4997655 7000913 * @summary (bf) CharBuffer.slice() on wrapped CharSequence results in wrong position */ @@ -75,12 +75,27 @@ public class StringCharBufferSliceTest { } } + System.out.println( + ">>> StringCharBufferSliceTest-main: testing slice with result of slice"); + buff.position(0); + buff.limit(buff.capacity()); + slice = buff.slice(); + for (int i=0; i<4; i++) { + slice.position(i); + CharBuffer nextSlice = slice.slice(); + if (nextSlice.position() != 0) + throw new RuntimeException("New buffer's position should be zero"); + if (!nextSlice.equals(slice)) + throw new RuntimeException("New buffer should be equal"); + slice = nextSlice; + } + System.out.println( ">>> StringCharBufferSliceTest-main: testing toString."); buff.position(4); buff.limit(7); slice = buff.slice(); - if (! slice.toString().equals("tes")) { + if (!slice.toString().equals("tes")) { throw new RuntimeException("bad toString() after slice(): " + slice.toString()); } @@ -104,6 +119,7 @@ public class StringCharBufferSliceTest { || dupe.charAt(2) != 's' || dupe.charAt(3) != 't') { throw new RuntimeException("bad duplicate() after slice(): '" + dupe + "'"); } + System.out.println(">>> StringCharBufferSliceTest-main: done!"); } From 35e7f8d2a730961271d27795f016e173a4a307e9 Mon Sep 17 00:00:00 2001 From: Jennifer Godinez Date: Thu, 18 Nov 2010 14:44:44 -0800 Subject: [PATCH 25/89] 6689925: Add transform attributes to the rendering tests in J2DBench Reviewed-by: flar, prr --- .../J2DBench/src/j2dbench/J2DBench.java | 39 +-- .../java2d/J2DBench/src/j2dbench/Option.java | 176 ++++++++++- .../java2d/J2DBench/src/j2dbench/Result.java | 295 ++++++++++++++---- .../src/j2dbench/report/J2DAnalyzer.java | 24 +- .../src/j2dbench/tests/GraphicsTests.java | 236 +++++++++++++- .../src/j2dbench/tests/text/TextTests.java | 3 +- 6 files changed, 677 insertions(+), 96 deletions(-) diff --git a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/J2DBench.java b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/J2DBench.java index 193264670d5..e198c0c8424 100644 --- a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/J2DBench.java +++ b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/J2DBench.java @@ -75,7 +75,8 @@ public class J2DBench { static JFrame guiFrame; - static final SimpleDateFormat sdf = new SimpleDateFormat("MM.dd.yyyy 'at' HH:mm aaa z"); + static final SimpleDateFormat sdf = + new SimpleDateFormat("MM.dd.yyyy 'at' HH:mm aaa z"); public static void init() { progoptroot = new Group("prog", "Program Options"); @@ -176,6 +177,8 @@ public class J2DBench { public static void main(String argv[]) { init(); TestEnvironment.init(); + Result.init(); + Destinations.init(); GraphicsTests.init(); RenderTests.init(); @@ -323,7 +326,7 @@ public class J2DBench { } else if (type.equalsIgnoreCase("m")) { multiplyWith = 60; } else { - System.out.println("Invalid \"-loop\" option specified."); + System.err.println("Invalid \"-loop\" option specified."); usage(1); } @@ -331,32 +334,20 @@ public class J2DBench { try { val = Integer.parseInt(argv[i].substring(0, argv[i].length() - 1)); } catch(Exception e) { - System.out.println("Invalid \"-loop\" option specified."); + System.err.println("Invalid \"-loop\" option specified."); usage(1); } requiredLoopTime = val * multiplyWith * 1000; } - } else if (arg.length() > 7 && - arg.substring(0, 7).equalsIgnoreCase("-report")) - { - for (int j = 7; j < arg.length(); j++) { - char c = arg.charAt(j); - switch (c) { - case 'N': Result.unitScale = Result.UNITS_WHOLE; break; - case 'M': Result.unitScale = Result.UNITS_MILLIONS; break; - case 'K': Result.unitScale = Result.UNITS_THOUSANDS; break; - case 'A': Result.unitScale = Result.UNITS_AUTO; break; - case 'U': Result.useUnits = true; break; - case 'O': Result.useUnits = false; break; - case 's': Result.timeScale = Result.SECONDS_WHOLE; break; - case 'm': Result.timeScale = Result.SECONDS_MILLIS; break; - case 'u': Result.timeScale = Result.SECONDS_MICROS; break; - case 'n': Result.timeScale = Result.SECONDS_NANOS; break; - case 'a': Result.timeScale = Result.SECONDS_AUTO; break; - case '/': Result.invertRate = !Result.invertRate; break; - } + } else if (arg.length() > 8 && + arg.substring(0, 8).equalsIgnoreCase("-report:")) + { + String error = Result.parseRateOpt(arg.substring(8)); + if (error != null) { + System.err.println("Invalid rate: "+error); + usage(1); } } else { String reason = Group.root.setOption(arg); @@ -411,7 +402,7 @@ public class J2DBench { writer.flush(); } catch(IOException ioe) { ioe.printStackTrace(); - System.out.println("\nERROR : Could not create Loop-Report. Exit"); + System.err.println("\nERROR : Could not create Loop-Report. Exit"); System.exit(1); } } @@ -466,7 +457,7 @@ public class J2DBench { } while(J2DBench.looping); - if(J2DBench.looping) { + if (J2DBench.looping) { writer.println(""); writer.flush(); writer.close(); diff --git a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/Option.java b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/Option.java index 8ca540337f3..91186bd580a 100644 --- a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/Option.java +++ b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/Option.java @@ -170,7 +170,7 @@ public abstract class Option extends Node implements Modifier { updateGUI(); jcb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == e.SELECTED) { + if (e.getStateChange() == ItemEvent.SELECTED) { JComboBox jcb = (JComboBox) e.getItemSelectable(); value = jcb.getSelectedIndex(); if (J2DBench.verbose.isEnabled()) { @@ -261,7 +261,7 @@ public abstract class Option extends Node implements Modifier { updateGUI(); jcb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { - value = (e.getStateChange() == e.SELECTED); + value = (e.getStateChange() == ItemEvent.SELECTED); if (J2DBench.verbose.isEnabled()) { System.out.println(getOptionString()); } @@ -569,8 +569,6 @@ public abstract class Option extends Node implements Modifier { } public String setValueFromString(String value) { - int prev = 0; - int next = 0; int enabled = 0; StringTokenizer st = new StringTokenizer(value, ","); while (st.hasMoreTokens()) { @@ -588,7 +586,6 @@ public abstract class Option extends Node implements Modifier { if (s != null) { return "Bad value in list ("+s+")"; } - prev = next+1; } this.enabled = enabled; updateGUI(); @@ -623,6 +620,175 @@ public abstract class Option extends Node implements Modifier { } } + public static class ObjectChoice extends Option { + int size; + String optionnames[]; + Object optionvalues[]; + String abbrevnames[]; + String descnames[]; + int defaultselected; + int selected; + JPanel jp; + JComboBox jcombo; + + public ObjectChoice(Group parent, String nodeName, String description, + String optionnames[], + Object optionvalues[], + String abbrevnames[], + String descnames[], + int defaultselected) + { + this(parent, nodeName, description, + Math.min(Math.min(optionnames.length, + optionvalues.length), + Math.min(abbrevnames.length, + descnames.length)), + optionnames, optionvalues, + abbrevnames, descnames, defaultselected); + } + + public ObjectChoice(Group parent, String nodeName, String description, + int size, + String optionnames[], + Object optionvalues[], + String abbrevnames[], + String descnames[], + int defaultselected) + { + super(parent, nodeName, description); + this.size = size; + this.optionnames = trim(optionnames, size); + this.optionvalues = trim(optionvalues, size); + this.abbrevnames = trim(abbrevnames, size); + this.descnames = trim(descnames, size); + this.selected = this.defaultselected = defaultselected; + } + + private static String[] trim(String list[], int size) { + if (list.length == size) { + return list; + } + String newlist[] = new String[size]; + System.arraycopy(list, 0, newlist, 0, size); + return newlist; + } + + private static Object[] trim(Object list[], int size) { + if (list.length == size) { + return list; + } + Object newlist[] = new Object[size]; + System.arraycopy(list, 0, newlist, 0, size); + return newlist; + } + + public void restoreDefault() { + if (selected != defaultselected) { + selected = defaultselected; + updateGUI(); + } + } + + public void updateGUI() { + if (jcombo != null) { + jcombo.setSelectedIndex(this.selected); + } + } + + public boolean isDefault() { + return (selected == defaultselected); + } + + public Modifier.Iterator getIterator(TestEnvironment env) { + return new SwitchIterator(optionvalues, 1 << selected); + } + + public JComponent getJComponent() { + if (jp == null) { + jp = new JPanel(); + jp.setLayout(new BorderLayout()); + jp.add(new JLabel(getDescription()), BorderLayout.WEST); + jcombo = new JComboBox(descnames); + updateGUI(); + jcombo.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + selected = jcombo.getSelectedIndex(); + if (J2DBench.verbose.isEnabled()) { + System.out.println(getOptionString()); + } + } + } + }); + jp.add(jcombo, BorderLayout.EAST); + } + return jp; + } + + public Object getValue() { + return optionvalues[selected]; + } + + public int getIntValue() { + return ((Integer) optionvalues[selected]).intValue(); + } + + public boolean getBooleanValue() { + return ((Boolean) optionvalues[selected]).booleanValue(); + } + + public String getValString() { + return optionnames[selected]; + } + + int findValueIndex(Object value) { + for (int i = 0; i < size; i++) { + if (optionvalues[i] == value) { + return i; + } + } + return -1; + } + + public String getValString(Object value) { + return optionnames[findValueIndex(value)]; + } + + public String getAbbreviatedModifierDescription(Object value) { + return abbrevnames[findValueIndex(value)]; + } + + public String setValue(int v) { + return setValue(new Integer(v)); + } + + public String setValue(boolean v) { + return setValue(new Boolean(v)); + } + + public String setValue(Object value) { + for (int i = 0; i < size; i++) { + if (optionvalues[i].equals(value)) { + this.selected = i; + updateGUI(); + return null; + } + } + return "Bad value"; + } + + public String setValueFromString(String value) { + for (int i = 0; i < size; i++) { + if (optionnames[i].equals(value)) { + this.selected = i; + updateGUI(); + return null; + } + } + return "Bad value"; + } + } + public static class BooleanIterator implements Modifier.Iterator { private Boolean list[]; private int index; diff --git a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/Result.java b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/Result.java index 70dce030026..af056bb76ff 100644 --- a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/Result.java +++ b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/Result.java @@ -35,23 +35,199 @@ import java.util.Vector; import java.util.Hashtable; import java.util.Enumeration; import java.io.PrintWriter; +import java.util.HashMap; public class Result { - public static final int UNITS_WHOLE = 0; - public static final int UNITS_THOUSANDS = 1; - public static final int UNITS_MILLIONS = 2; - public static final int UNITS_AUTO = 3; + public static final int RATE_UNKNOWN = 0; - public static final int SECONDS_WHOLE = 0; - public static final int SECONDS_MILLIS = 1; - public static final int SECONDS_MICROS = 2; - public static final int SECONDS_NANOS = 3; - public static final int SECONDS_AUTO = 4; + public static final int WORK_OPS = 1; + public static final int WORK_UNITS = 2; + public static final int WORK_THOUSANDS = 4; + public static final int WORK_MILLIONS = 6; + public static final int WORK_AUTO = 8; - public static int unitScale = UNITS_WHOLE; - public static int timeScale = SECONDS_WHOLE; - public static boolean useUnits = true; - public static boolean invertRate = false; + public static final int TIME_SECONDS = 10; + public static final int TIME_MILLIS = 11; + public static final int TIME_MICROS = 12; + public static final int TIME_NANOS = 13; + public static final int TIME_AUTO = 14; + + static Group resultoptroot; + static Option.ObjectChoice timeOpt; + static Option.ObjectChoice workOpt; + static Option.ObjectChoice rateOpt; + + public static void init() { + resultoptroot = new Group(TestEnvironment.globaloptroot, + "results", "Result Options"); + + String workStrings[] = { + "units", + "kilounits", + "megaunits", + "autounits", + "ops", + "kiloops", + "megaops", + "autoops", + }; + String workDescriptions[] = { + "Test Units", + "Thousands of Test Units", + "Millions of Test Units", + "Auto-scaled Test Units", + "Operations", + "Thousands of Operations", + "Millions of Operations", + "Auto-scaled Operations", + }; + Integer workObjects[] = { + new Integer(WORK_UNITS), + new Integer(WORK_THOUSANDS), + new Integer(WORK_MILLIONS), + new Integer(WORK_AUTO), + new Integer(WORK_OPS | WORK_UNITS), + new Integer(WORK_OPS | WORK_THOUSANDS), + new Integer(WORK_OPS | WORK_MILLIONS), + new Integer(WORK_OPS | WORK_AUTO), + }; + workOpt = new Option.ObjectChoice(resultoptroot, + "workunits", "Work Units", + workStrings, workObjects, + workStrings, workDescriptions, + 0); + String timeStrings[] = { + "sec", + "msec", + "usec", + "nsec", + "autosec", + }; + String timeDescriptions[] = { + "Seconds", + "Milliseconds", + "Microseconds", + "Nanoseconds", + "Auto-scaled seconds", + }; + Integer timeObjects[] = { + new Integer(TIME_SECONDS), + new Integer(TIME_MILLIS), + new Integer(TIME_MICROS), + new Integer(TIME_NANOS), + new Integer(TIME_AUTO), + }; + timeOpt = new Option.ObjectChoice(resultoptroot, + "timeunits", "Time Units", + timeStrings, timeObjects, + timeStrings, timeDescriptions, + 0); + String rateStrings[] = { + "unitspersec", + "secsperunit", + }; + String rateDescriptions[] = { + "Work units per Time", + "Time units per Work", + }; + Boolean rateObjects[] = { + Boolean.FALSE, + Boolean.TRUE, + }; + rateOpt = new Option.ObjectChoice(resultoptroot, + "ratio", "Rate Ratio", + rateStrings, rateObjects, + rateStrings, rateDescriptions, + 0); + } + + public static boolean isTimeUnit(int unit) { + return (unit >= TIME_SECONDS && unit <= TIME_AUTO); + } + + public static boolean isWorkUnit(int unit) { + return (unit >= WORK_OPS && unit <= (WORK_AUTO | WORK_OPS)); + } + + public static String parseRateOpt(String opt) { + int timeScale = timeOpt.getIntValue(); + int workScale = workOpt.getIntValue(); + boolean invertRate = rateOpt.getBooleanValue(); + int divindex = opt.indexOf('/'); + if (divindex < 0) { + int unit = parseUnit(opt); + if (isTimeUnit(unit)) { + timeScale = unit; + } else if (isWorkUnit(unit)) { + workScale = unit; + } else { + return "Bad unit: "+opt; + } + } else { + int unit1 = parseUnit(opt.substring(0,divindex)); + int unit2 = parseUnit(opt.substring(divindex+1)); + if (isTimeUnit(unit1)) { + if (isWorkUnit(unit2)) { + timeScale = unit1; + workScale = unit2; + invertRate = true; + } else if (isTimeUnit(unit2)) { + return "Both time units: "+opt; + } else { + return "Bad denominator: "+opt; + } + } else if (isWorkUnit(unit1)) { + if (isWorkUnit(unit2)) { + return "Both work units: "+opt; + } else if (isTimeUnit(unit2)) { + timeScale = unit2; + workScale = unit1; + invertRate = false; + } else { + return "Bad denominator: "+opt; + } + } else { + return "Bad numerator: "+opt; + } + } + timeOpt.setValue(timeScale); + workOpt.setValue(workScale); + rateOpt.setValue(invertRate); + return null; + } + + private static HashMap unitMap; + + static { + unitMap = new HashMap(); + unitMap.put("U", new Integer(WORK_UNITS)); + unitMap.put("M", new Integer(WORK_MILLIONS)); + unitMap.put("K", new Integer(WORK_THOUSANDS)); + unitMap.put("A", new Integer(WORK_AUTO)); + unitMap.put("MU", new Integer(WORK_MILLIONS)); + unitMap.put("KU", new Integer(WORK_THOUSANDS)); + unitMap.put("AU", new Integer(WORK_AUTO)); + + unitMap.put("O", new Integer(WORK_UNITS | WORK_OPS)); + unitMap.put("NO", new Integer(WORK_UNITS | WORK_OPS)); + unitMap.put("MO", new Integer(WORK_MILLIONS | WORK_OPS)); + unitMap.put("KO", new Integer(WORK_THOUSANDS | WORK_OPS)); + unitMap.put("AO", new Integer(WORK_AUTO | WORK_OPS)); + + unitMap.put("s", new Integer(TIME_SECONDS)); + unitMap.put("m", new Integer(TIME_MILLIS)); + unitMap.put("u", new Integer(TIME_MICROS)); + unitMap.put("n", new Integer(TIME_NANOS)); + unitMap.put("a", new Integer(TIME_AUTO)); + } + + public static int parseUnit(String c) { + Integer u = (Integer) unitMap.get(c); + if (u != null) { + return u.intValue(); + } + return RATE_UNKNOWN; + } String unitname = "unit"; Test test; @@ -157,69 +333,76 @@ public class Result { } public String getAverageString() { - double units = (useUnits ? getTotalUnits() : getTotalReps()); + int timeScale = timeOpt.getIntValue(); + int workScale = workOpt.getIntValue(); + boolean invertRate = rateOpt.getBooleanValue(); double time = getTotalTime(); + String timeprefix = ""; + switch (timeScale) { + case TIME_AUTO: + case TIME_SECONDS: + time /= 1000; + break; + case TIME_MILLIS: + timeprefix = "m"; + break; + case TIME_MICROS: + time *= 1000.0; + timeprefix = "u"; + break; + case TIME_NANOS: + time *= 1000000.0; + timeprefix = "n"; + break; + } + + String workprefix = ""; + boolean isOps = (workScale & WORK_OPS) != 0; + String workname = isOps ? "op" : unitname; + double work = isOps ? getTotalReps() : getTotalUnits(); + switch (workScale & (~WORK_OPS)) { + case WORK_AUTO: + case WORK_UNITS: + break; + case WORK_THOUSANDS: + work /= 1000.0; + workprefix = "K"; + break; + case WORK_MILLIONS: + work /= 1000000.0; + workprefix = "M"; + break; + } if (invertRate) { - double rate = time / units; - String prefix = ""; - switch (timeScale) { - case SECONDS_WHOLE: - rate /= 1000; - break; - case SECONDS_MILLIS: - prefix = "m"; - break; - case SECONDS_MICROS: - rate *= 1000.0; - prefix = "u"; - break; - case SECONDS_NANOS: - rate *= 1000000.0; - prefix = "n"; - break; - case SECONDS_AUTO: - rate /= 1000.0; + double rate = time / work; + if (timeScale == TIME_AUTO) { if (rate < 1.0) { rate *= 1000.0; - prefix = "m"; + timeprefix = "m"; if (rate < 1.0) { rate *= 1000.0; - prefix = "u"; + timeprefix = "u"; if (rate < 1.0) { rate *= 1000.0; - prefix = "n"; + timeprefix = "n"; } } } - break; } - return rate+" "+prefix+"secs/"+(useUnits ? unitname : "op"); + return rate+" "+timeprefix+"secs/"+workprefix+workname; } else { - double rate = units / (time / 1000.0); - String prefix = ""; - switch (unitScale) { - case UNITS_WHOLE: - break; - case UNITS_THOUSANDS: - rate /= 1000.0; - prefix = "K"; - break; - case UNITS_MILLIONS: - rate /= 1000000.0; - prefix = "M"; - break; - case UNITS_AUTO: + double rate = work / time; + if (workScale == WORK_AUTO) { if (rate > 1000.0) { rate /= 1000.0; - prefix = "K"; + workprefix = "K"; if (rate > 1000.0) { rate /= 1000.0; - prefix = "M"; + workprefix = "M"; } } - break; } - return rate+" "+prefix+(useUnits ? unitname : "op")+"s/sec"; + return rate+" "+workprefix+workname+"s/"+timeprefix+"sec"; } } diff --git a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/report/J2DAnalyzer.java b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/report/J2DAnalyzer.java index 37cab7587d4..ed3c7712c4d 100644 --- a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/report/J2DAnalyzer.java +++ b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/report/J2DAnalyzer.java @@ -61,6 +61,8 @@ public class J2DAnalyzer { "the following result sets are combined into a group"); out.println(" -NoGroup "+ "the following result sets stand on their own"); + out.println(" -ShowUncontested "+ + "show results even when only result set has a result"); out.println(" -Graph "+ "graph the results visually (using lines of *'s)"); out.println(" -Best "+ @@ -83,6 +85,7 @@ public class J2DAnalyzer { public static void main(String argv[]) { boolean gavehelp = false; boolean graph = false; + boolean ignoreuncontested = true; if (argv.length > 0 && argv[0].equalsIgnoreCase("-html")) { String newargs[] = new String[argv.length-1]; System.arraycopy(argv, 1, newargs, 0, newargs.length); @@ -97,6 +100,8 @@ public class J2DAnalyzer { results.add(groupHolder); } else if (arg.equalsIgnoreCase("-NoGroup")) { groupHolder = null; + } else if (arg.equalsIgnoreCase("-ShowUncontested")) { + ignoreuncontested = false; } else if (arg.equalsIgnoreCase("-Graph")) { graph = true; } else if (arg.equalsIgnoreCase("-Best")) { @@ -171,18 +176,23 @@ public class J2DAnalyzer { String key = keys[k]; ResultHolder rh = base.getResultByKey(key); double score = rh.getScore(); - System.out.println(rh.getShortKey()+":"); double maxscore = score; - if (graph) { - for (int i = 0; i < numsets; i++) { - ResultSetHolder rsh = - (ResultSetHolder) results.elementAt(i); - ResultHolder rh2 = rsh.getResultByKey(key); - if (rh2 != null) { + int numcontesting = 0; + for (int i = 0; i < numsets; i++) { + ResultSetHolder rsh = + (ResultSetHolder) results.elementAt(i); + ResultHolder rh2 = rsh.getResultByKey(key); + if (rh2 != null) { + if (graph) { maxscore = Math.max(maxscore, rh2.getBestScore()); } + numcontesting++; } } + if (ignoreuncontested && numcontesting < 2) { + continue; + } + System.out.println(rh.getShortKey()+":"); for (int i = 0; i < numsets; i++) { ResultSetHolder rsh = (ResultSetHolder) results.elementAt(i); System.out.print(rsh.getTitle()+": "); diff --git a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/GraphicsTests.java b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/GraphicsTests.java index 2f638c634e7..0746d6b12ae 100644 --- a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/GraphicsTests.java +++ b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/GraphicsTests.java @@ -38,6 +38,8 @@ import java.awt.RenderingHints; import java.awt.Polygon; import java.awt.Color; import java.awt.Dimension; +import java.awt.geom.Point2D; +import java.awt.geom.AffineTransform; import java.lang.reflect.Field; import j2dbench.Destinations; @@ -74,6 +76,7 @@ public abstract class GraphicsTests extends Test { static Option animList; static Option sizeList; static Option compRules; + static Option transforms; static Option doExtraAlpha; static Option doXor; static Option doClipping; @@ -167,6 +170,29 @@ public abstract class GraphicsTests extends Test { j, rulenames, rules, rulenames, ruledescs, (1 << defrule)); ((Option.ObjectList) compRules).setNumRows(4); + + Transform xforms[] = { + Identity.instance, + FTranslate.instance, + Scale2x2.instance, + Rotate15.instance, + ShearX.instance, + ShearY.instance, + }; + String xformnames[] = new String[xforms.length]; + String xformdescs[] = new String[xforms.length]; + for (int i = 0; i < xforms.length; i++) { + xformnames[i] = xforms[i].getShortName(); + xformdescs[i] = xforms[i].getDescription(); + } + transforms = + new Option.ObjectList(groptroot, "transform", + "Affine Transform", + xforms.length, + xformnames, xforms, xformnames, + xformdescs, 0x1); + ((Option.ObjectList) transforms).setNumRows(3); + doExtraAlpha = new Option.Toggle(groptroot, "extraalpha", "Render with an \"extra alpha\" of 0.125", @@ -200,6 +226,7 @@ public abstract class GraphicsTests extends Test { int orgX, orgY; int initX, initY; int maxX, maxY; + double pixscale; } public GraphicsTests(Group parent, String nodeName, String description) { @@ -211,7 +238,7 @@ public abstract class GraphicsTests extends Test { public Object initTest(TestEnvironment env, Result result) { Context ctx = createContext(); initContext(env, ctx); - result.setUnits(pixelsTouched(ctx)); + result.setUnits((int) (ctx.pixscale * pixelsTouched(ctx))); result.setUnitName("pixel"); return ctx; } @@ -232,6 +259,9 @@ public abstract class GraphicsTests extends Test { ctx.graphics = env.getGraphics(); int w = env.getWidth(); int h = env.getHeight(); + ctx.size = env.getIntValue(sizeList); + ctx.outdim = getOutputSize(ctx.size, ctx.size); + ctx.pixscale = 1.0; if (hasGraphics2D) { Graphics2D g2d = (Graphics2D) ctx.graphics; AlphaComposite ac = (AlphaComposite) env.getModifier(compRules); @@ -251,11 +281,14 @@ public abstract class GraphicsTests extends Test { p.addPoint(0, 0); g2d.clip(p); } + Transform tx = (Transform) env.getModifier(transforms); + Dimension envdim = new Dimension(w, h); + tx.init(g2d, ctx, envdim); + w = envdim.width; + h = envdim.height; g2d.setRenderingHint(RenderingHints.KEY_RENDERING, env.getModifier(renderHint)); } - ctx.size = env.getIntValue(sizeList); - ctx.outdim = getOutputSize(ctx.size, ctx.size); switch (env.getIntValue(animList)) { case 0: ctx.animate = false; @@ -290,4 +323,201 @@ public abstract class GraphicsTests extends Test { graphics.dispose(); ((Context) ctx).graphics = null; } + + public abstract static class Transform { + public abstract String getShortName(); + public abstract String getDescription(); + public abstract void init(Graphics2D g2d, Context ctx, Dimension dim); + + public static double scaleForPoint(AffineTransform at, + double xorig, double yorig, + double x, double y, + int w, int h) + { + Point2D.Double ptd = new Point2D.Double(x, y); + at.transform(ptd, ptd); + x = ptd.getX(); + y = ptd.getY(); + double scale = 1.0; + if (x < 0) { + scale = Math.min(scale, xorig / (xorig - x)); + } else if (x > w) { + scale = Math.min(scale, (w - xorig) / (x - xorig)); + } + if (y < 0) { + scale = Math.min(scale, yorig / (yorig - y)); + } else if (y > h) { + scale = Math.min(scale, (h - yorig) / (y - yorig)); + } + return scale; + } + + public static Dimension scaleForTransform(AffineTransform at, + Dimension dim) + { + int w = dim.width; + int h = dim.height; + Point2D.Double ptd = new Point2D.Double(0, 0); + at.transform(ptd, ptd); + double ox = ptd.getX(); + double oy = ptd.getY(); + if (ox < 0 || ox > w || oy < 0 || oy > h) { + throw new InternalError("origin outside destination"); + } + double scalex = scaleForPoint(at, ox, oy, w, h, w, h); + double scaley = scalex; + scalex = Math.min(scaleForPoint(at, ox, oy, w, 0, w, h), scalex); + scaley = Math.min(scaleForPoint(at, ox, oy, 0, h, w, h), scaley); + if (scalex < 0 || scaley < 0) { + throw new InternalError("could not fit dims to transform"); + } + return new Dimension((int) Math.floor(w * scalex), + (int) Math.floor(h * scaley)); + } + } + + public static class Identity extends Transform { + public static final Identity instance = new Identity(); + + private Identity() {} + + public String getShortName() { + return "ident"; + } + + public String getDescription() { + return "Identity"; + } + + public void init(Graphics2D g2d, Context ctx, Dimension dim) { + } + } + + public static class FTranslate extends Transform { + public static final FTranslate instance = new FTranslate(); + + private FTranslate() {} + + public String getShortName() { + return "ftrans"; + } + + public String getDescription() { + return "FTranslate 1.5"; + } + + public void init(Graphics2D g2d, Context ctx, Dimension dim) { + int w = dim.width; + int h = dim.height; + AffineTransform at = new AffineTransform(); + at.translate(1.5, 1.5); + g2d.transform(at); + dim.setSize(w-3, h-3); + } + } + + public static class Scale2x2 extends Transform { + public static final Scale2x2 instance = new Scale2x2(); + + private Scale2x2() {} + + public String getShortName() { + return "scale2x2"; + } + + public String getDescription() { + return "Scale 2x by 2x"; + } + + public void init(Graphics2D g2d, Context ctx, Dimension dim) { + int w = dim.width; + int h = dim.height; + AffineTransform at = new AffineTransform(); + at.scale(2.0, 2.0); + g2d.transform(at); + dim.setSize(w/2, h/2); + ctx.pixscale = 4; + } + } + + public static class Rotate15 extends Transform { + public static final Rotate15 instance = new Rotate15(); + + private Rotate15() {} + + public String getShortName() { + return "rot15"; + } + + public String getDescription() { + return "Rotate 15 degrees"; + } + + public void init(Graphics2D g2d, Context ctx, Dimension dim) { + int w = dim.width; + int h = dim.height; + double theta = Math.toRadians(15); + double cos = Math.cos(theta); + double sin = Math.sin(theta); + double xsize = sin * h + cos * w; + double ysize = sin * w + cos * h; + double scale = Math.min(w / xsize, h / ysize); + xsize *= scale; + ysize *= scale; + AffineTransform at = new AffineTransform(); + at.translate((w - xsize) / 2.0, (h - ysize) / 2.0); + at.translate(sin * h * scale, 0.0); + at.rotate(theta); + g2d.transform(at); + dim.setSize(scaleForTransform(at, dim)); + } + } + + public static class ShearX extends Transform { + public static final ShearX instance = new ShearX(); + + private ShearX() {} + + public String getShortName() { + return "shearx"; + } + + public String getDescription() { + return "Shear X to the right"; + } + + public void init(Graphics2D g2d, Context ctx, Dimension dim) { + int w = dim.width; + int h = dim.height; + AffineTransform at = new AffineTransform(); + at.translate(0.0, (h - (w*h)/(w + h*0.1)) / 2); + at.shear(0.1, 0.0); + g2d.transform(at); + dim.setSize(scaleForTransform(at, dim)); + } + } + + public static class ShearY extends Transform { + public static final ShearY instance = new ShearY(); + + private ShearY() {} + + public String getShortName() { + return "sheary"; + } + + public String getDescription() { + return "Shear Y down"; + } + + public void init(Graphics2D g2d, Context ctx, Dimension dim) { + int w = dim.width; + int h = dim.height; + AffineTransform at = new AffineTransform(); + at.translate((w - (w*h)/(h + w*0.1)) / 2, 0.0); + at.shear(0.0, 0.1); + g2d.transform(at); + dim.setSize(scaleForTransform(at, dim)); + } + } } diff --git a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/text/TextTests.java b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/text/TextTests.java index 9960a7b7046..ef607fd0b08 100644 --- a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/text/TextTests.java +++ b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/text/TextTests.java @@ -454,7 +454,7 @@ public abstract class TextTests extends Test { taaNames, taaHints, taaNames, taaNames, 0x1); - ((Option.ObjectList) taaList).setNumRows(2); + ((Option.ObjectList) taaList).setNumRows(6); // add special TextAAOpt for backwards compatibility with // older options files new TextAAOpt(); @@ -707,3 +707,4 @@ public abstract class TextTests extends Test { } } } + From bdc7e81168860235f4d9dead833a375674f2207a Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 18 Nov 2010 16:13:11 -0800 Subject: [PATCH 26/89] 6999438: remove support for exotic identifiers from JDK 7 Reviewed-by: mcimadamore --- .../com/sun/tools/javac/code/Source.java | 3 - .../com/sun/tools/javac/jvm/ClassReader.java | 1 - .../com/sun/tools/javac/parser/Scanner.java | 61 +------- .../tools/javac/resources/compiler.properties | 10 -- .../diags/examples/EmptyBytecodeIdent.java | 28 ---- .../examples/IllegalBytecodeIdentChar.java | 28 ---- .../diags/examples/UnclosedBytecodeIdent.java | 28 ---- .../diags/examples/UnsupportedExoticID.java | 31 ---- .../test/tools/javac/meth/InvokeDyn.java | 2 +- .../test/tools/javac/meth/InvokeDynTrans.java | 4 +- .../test/tools/javac/meth/InvokeDynTrans.out | 3 +- .../test/tools/javac/quid/QuotedIdent.java | 136 ------------------ .../test/tools/javac/quid/QuotedIdent2.java | 85 ----------- langtools/test/tools/javac/quid/T6999438.java | 9 ++ langtools/test/tools/javac/quid/T6999438.out | 6 + 15 files changed, 20 insertions(+), 415 deletions(-) delete mode 100644 langtools/test/tools/javac/diags/examples/EmptyBytecodeIdent.java delete mode 100644 langtools/test/tools/javac/diags/examples/IllegalBytecodeIdentChar.java delete mode 100644 langtools/test/tools/javac/diags/examples/UnclosedBytecodeIdent.java delete mode 100644 langtools/test/tools/javac/diags/examples/UnsupportedExoticID.java delete mode 100644 langtools/test/tools/javac/quid/QuotedIdent.java delete mode 100644 langtools/test/tools/javac/quid/QuotedIdent2.java create mode 100644 langtools/test/tools/javac/quid/T6999438.java create mode 100644 langtools/test/tools/javac/quid/T6999438.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java index 3a21ce72135..a29bb98fc76 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java @@ -174,9 +174,6 @@ public enum Source { public boolean allowUnderscoresInLiterals() { return compareTo(JDK1_7) >= 0; } - public boolean allowExoticIdentifiers() { - return compareTo(JDK1_7) >= 0; - } public boolean allowStringsInSwitch() { return compareTo(JDK1_7) >= 0; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java index 912d0dbf293..bec036c5b45 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java @@ -2615,7 +2615,6 @@ public class ClassReader implements Completer { String binaryName = fileManager.inferBinaryName(currentLoc, fo); String simpleName = binaryName.substring(binaryName.lastIndexOf(".") + 1); if (SourceVersion.isIdentifier(simpleName) || - fo.getKind() == JavaFileObject.Kind.CLASS || simpleName.equals("package-info")) includeClassFile(p, fo); break; diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java b/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java index 2b558d8fa39..cdf54b219f4 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java @@ -66,10 +66,6 @@ public class Scanner implements Lexer { */ private boolean allowUnderscoresInLiterals; - /** Allow exotic identifiers. - */ - private boolean allowExoticIdentifiers; - /** The source language setting. */ private Source source; @@ -143,7 +139,6 @@ public class Scanner implements Lexer { allowBinaryLiterals = source.allowBinaryLiterals(); allowHexFloats = source.allowHexFloats(); allowUnderscoresInLiterals = source.allowBinaryLiterals(); - allowExoticIdentifiers = source.allowExoticIdentifiers(); // for invokedynamic } private static final boolean hexFloatsWork = hexFloatsWork(); @@ -295,7 +290,7 @@ public class Scanner implements Lexer { /** Read next character in character or string literal and copy into sbuf. */ - private void scanLitChar(boolean forBytecodeName) { + private void scanLitChar() { if (ch == '\\') { if (buf[bp+1] == '\\' && unicodeConversionBp != bp) { bp++; @@ -335,18 +330,6 @@ public class Scanner implements Lexer { putChar('\"'); scanChar(); break; case '\\': putChar('\\'); scanChar(); break; - case '|': case ',': case '?': case '%': - case '^': case '_': case '{': case '}': - case '!': case '-': case '=': - if (forBytecodeName) { - // Accept escape sequences for dangerous bytecode chars. - // This is illegal in normal Java string or character literals. - // Note that the escape sequence itself is passed through. - putChar('\\'); putChar(ch); scanChar(); - } else { - lexError(bp, "illegal.esc.char"); - } - break; default: lexError(bp, "illegal.esc.char"); } @@ -355,24 +338,6 @@ public class Scanner implements Lexer { putChar(ch); scanChar(); } } - private void scanLitChar() { - scanLitChar(false); - } - - /** Read next character in an exotic name #"foo" - */ - private void scanBytecodeNameChar() { - switch (ch) { - // reject any "dangerous" char which is illegal somewhere in the JVM spec - // cf. http://blogs.sun.com/jrose/entry/symbolic_freedom_in_the_vm - case '/': case '.': case ';': // illegal everywhere - case '<': case '>': // illegal in methods, dangerous in classes - case '[': // illegal in classes - lexError(bp, "illegal.bytecode.ident.char", String.valueOf((int)ch)); - break; - } - scanLitChar(true); - } private void scanDigits(int digitRadix) { char saveCh; @@ -970,30 +935,6 @@ public class Scanner implements Lexer { lexError(pos, "unclosed.str.lit"); } return; - case '#': - scanChar(); - if (ch == '\"') { - if (!allowExoticIdentifiers) { - lexError("unsupported.exotic.id", source.name); - allowExoticIdentifiers = true; - } - scanChar(); - if (ch == '\"') - lexError(pos, "empty.bytecode.ident"); - while (ch != '\"' && ch != CR && ch != LF && bp < buflen) { - scanBytecodeNameChar(); - } - if (ch == '\"') { - name = names.fromChars(sbuf, 0, sp); - token = IDENTIFIER; // even if #"int" or #"do" - scanChar(); - } else { - lexError(pos, "unclosed.bytecode.ident"); - } - } else { - lexError("illegal.char", String.valueOf((int)'#')); - } - return; default: if (isSpecial(ch)) { scanOperator(); diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties index 7fb2e66a574..58c1f660ef3 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -153,8 +153,6 @@ compiler.err.duplicate.default.label=\ compiler.err.else.without.if=\ ''else'' without ''if'' -compiler.err.empty.bytecode.ident=\ - empty bytecode identifier compiler.err.empty.char.lit=\ empty character literal compiler.err.encl.class.required=\ @@ -201,8 +199,6 @@ compiler.err.generic.throwable=\ compiler.err.icls.cant.have.static.decl=\ inner classes cannot have static declarations -compiler.err.illegal.bytecode.ident.char=\ - illegal bytecode identifier character: \\{0} compiler.err.illegal.char=\ illegal character: \\{0} compiler.err.illegal.char.for.encoding=\ @@ -472,8 +468,6 @@ compiler.err.type.var.more.than.once.in.result=\ compiler.err.types.incompatible.diff.ret=\ types {0} and {1} are incompatible; both define {2}, but with unrelated return types -compiler.err.unclosed.bytecode.ident=\ - unclosed bytecode identifier compiler.err.unclosed.char.lit=\ unclosed character literal compiler.err.unclosed.comment=\ @@ -1269,10 +1263,6 @@ compiler.err.unsupported.underscore.lit=\ underscores in literals are not supported in -source {0}\n\ (use -source 7 or higher to enable underscores in literals) -compiler.err.unsupported.exotic.id=\ - exotic identifiers #"___" are not supported in -source {0}\n\ -(use -source 7 or higher to enable exotic identifiers) - compiler.err.try.with.resources.not.supported.in.source=\ try-with-resources is not supported in -source {0}\n\ (use -source 7 or higher to enable try-with-resources) diff --git a/langtools/test/tools/javac/diags/examples/EmptyBytecodeIdent.java b/langtools/test/tools/javac/diags/examples/EmptyBytecodeIdent.java deleted file mode 100644 index 11cf6f95f8b..00000000000 --- a/langtools/test/tools/javac/diags/examples/EmptyBytecodeIdent.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2010, 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. - */ - -// key: compiler.err.empty.bytecode.ident - -class EmptyBytecodeIdent { - int #"" = 3; -} diff --git a/langtools/test/tools/javac/diags/examples/IllegalBytecodeIdentChar.java b/langtools/test/tools/javac/diags/examples/IllegalBytecodeIdentChar.java deleted file mode 100644 index 186fb5655c4..00000000000 --- a/langtools/test/tools/javac/diags/examples/IllegalBytecodeIdentChar.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2010, 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. - */ - -// key: compiler.err.illegal.bytecode.ident.char - -class IllegalBytecodeIdentChar { - int #"abc/def" = 3; -} diff --git a/langtools/test/tools/javac/diags/examples/UnclosedBytecodeIdent.java b/langtools/test/tools/javac/diags/examples/UnclosedBytecodeIdent.java deleted file mode 100644 index 0f74d279b99..00000000000 --- a/langtools/test/tools/javac/diags/examples/UnclosedBytecodeIdent.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2010, 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. - */ - -// key: compiler.err.unclosed.bytecode.ident - -class UnclosedBytecodeIdent { - int #"abc -} diff --git a/langtools/test/tools/javac/diags/examples/UnsupportedExoticID.java b/langtools/test/tools/javac/diags/examples/UnsupportedExoticID.java deleted file mode 100644 index c14e9cd49d0..00000000000 --- a/langtools/test/tools/javac/diags/examples/UnsupportedExoticID.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2010, 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. - */ - -// key: compiler.err.unsupported.exotic.id -// options: -source 6 - -class UnsupportedExoticID { - void m() { - Object #"Hello!" = null; - } -} diff --git a/langtools/test/tools/javac/meth/InvokeDyn.java b/langtools/test/tools/javac/meth/InvokeDyn.java index b9b9f90a3f9..6285e8c1be1 100644 --- a/langtools/test/tools/javac/meth/InvokeDyn.java +++ b/langtools/test/tools/javac/meth/InvokeDyn.java @@ -58,7 +58,7 @@ public class InvokeDyn { ojunk = InvokeDynamic.greet(x, "mundus", 456); ojunk = InvokeDynamic.greet(x, "kosmos", 789); ojunk = (String) InvokeDynamic.cogitate(10.11121, 3.14); - InvokeDynamic.#"yow: what I mean to say is, please treat this one specially"(null); + //InvokeDynamic.#"yow: what I mean to say is, please treat this one specially"(null); ijunk = (int) InvokeDynamic.invoke("goodbye"); } } diff --git a/langtools/test/tools/javac/meth/InvokeDynTrans.java b/langtools/test/tools/javac/meth/InvokeDynTrans.java index b4e992aca28..092d649923b 100644 --- a/langtools/test/tools/javac/meth/InvokeDynTrans.java +++ b/langtools/test/tools/javac/meth/InvokeDynTrans.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2010, 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 @@ -53,7 +53,7 @@ public class InvokeDynTrans { InvokeDynamic.greet(x, "mundus", 456); InvokeDynamic.greet(x, "kosmos", 789); InvokeDynamic.cogitate(10.11121, 3.14); - InvokeDynamic.#"yow: what I mean to say is, please treat this one specially"(null); + //InvokeDynamic.#"yow: what I mean to say is, please treat this one specially"(null); InvokeDynamic.invoke("goodbye"); } } diff --git a/langtools/test/tools/javac/meth/InvokeDynTrans.out b/langtools/test/tools/javac/meth/InvokeDynTrans.out index fc7d7bd8851..06ed485189c 100644 --- a/langtools/test/tools/javac/meth/InvokeDynTrans.out +++ b/langtools/test/tools/javac/meth/InvokeDynTrans.out @@ -1,6 +1,5 @@ InvokeDynTrans.java:55:39: compiler.warn.type.parameter.on.polymorphic.signature -InvokeDynTrans.java:56:91: compiler.warn.type.parameter.on.polymorphic.signature InvokeDynTrans.java:57:34: compiler.warn.type.parameter.on.polymorphic.signature - compiler.err.warnings.and.werror 1 error -3 warnings +2 warnings diff --git a/langtools/test/tools/javac/quid/QuotedIdent.java b/langtools/test/tools/javac/quid/QuotedIdent.java deleted file mode 100644 index 6920dc5a240..00000000000 --- a/langtools/test/tools/javac/quid/QuotedIdent.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2008, 2010, 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 6746458 - * @summary Verify correct lexing of quoted identifiers. - * @author jrose - * @ignore 6877225 test fails on Windows: - * QuotedIdent.java:81: error while writing QuotedIdent.*86: PATH\QuotedIdent$*86.class - * (The filename, directory name, or volume label syntax is incorrect) - * - * @library .. - * @compile -source 7 -target 7 -XDinvokedynamic QuotedIdent.java - * @run main quid.QuotedIdent - */ - -/* - * Standalone testing: - * - * $ cd $MY_REPO_DIR/langtools - * $ (cd make; make) - * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent.java - * $ java -version # should print 1.6 or later - * $ java -cp dist quid.QuotedIdent - * - */ - -package quid; - -public class QuotedIdent { - static void check(int testid, String have, String expect) - throws RuntimeException { - if ((have == null && have != expect) || - (have != null && !have.equals(expect))) { - String msg = - "TEST " + testid + ": HAVE \"" + - have + "\" EXPECT \"" + expect + "\""; - System.out.println("StringConversion: " + msg); - throw new RuntimeException(msg); - } - } - - // negative tests: - //static class #"" { } //BAD empty ident name - //static class #"" { } //BAD bad char in ident name - /*static class /*(//BAD ident name interrupted by newline) #"jump: - " { } /* uncomment previous line to attempt class w/ bad name */ - - static class #"int" extends Number { - final int #"int"; - #"int"(int #"int") { - this.#"int" = #"int"; - } - static #"int" valueOf(int #"int") { - return new #"int"(#"int"); - } - public int intValue() { return #"int"; } - public long longValue() { return #"int"; } - public float floatValue() { return #"int"; } - public double doubleValue() { return #"int"; } - public String toString() { return String.valueOf(#"int"); } - } - - class #"*86" { - String #"555-1212"() { return "[*86.555-1212]"; } - } - static#"*86"#"MAKE-*86"() { // note close spacing - return new QuotedIdent().new#"*86"(); - } - - static String bar() { return "[bar]"; } - - public static void main(String[] args) throws Exception { - String s; - - String #"sticky \' wicket" = "wicked ' stick"; - s = #"sticky ' wicket"; - check(11, s, "wicked \' stick"); - check(12, #"s", s); - check(13, #"\163", s); - - s = #"QuotedIdent".bar(); - check(21, s, "[bar]"); - - s = #"int".valueOf(123).toString(); - check(22, s, "123"); - - s = #"MAKE-*86"().#"555-1212"(); - check(23, s, "[*86.555-1212]"); - - class#"{{{inmost}}}" { } - s = new#"{{{inmost}}}"().getClass().getName(); - if (!s.endsWith("{{{inmost}}}")) - check(24, s, "should end with \"{{{inmost}}}\""); - - s = #"Yog-Shoggoth".#"(nameless ululation)"; - check(25, s, "Tekeli-li!"); - - s = #"int".class.getName(); - check(31, s, QuotedIdent.class.getName()+"$int"); - - Class x86 = Class.forName(QuotedIdent.class.getName()+"$*86"); - if (x86 != #"*86".class) - check(32, "reflected "+x86, "static "+#"*86".class); - - s = (String) x86.getDeclaredMethod("555-1212").invoke(#"MAKE-*86"()); - check(31, s, "[*86.555-1212]"); - - System.out.println("OK"); - } -} - -interface #"Yog-Shoggoth" { - final String #"(nameless ululation)" = "Tekeli-li!"; -} diff --git a/langtools/test/tools/javac/quid/QuotedIdent2.java b/langtools/test/tools/javac/quid/QuotedIdent2.java deleted file mode 100644 index eeea1538277..00000000000 --- a/langtools/test/tools/javac/quid/QuotedIdent2.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2008, 2010, 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 6746458 - * @summary Verify correct separate compilation of classes with extended identifiers. - * @author jrose - * @ignore 6877225 test fails on Windows: - * QuotedIdent.java:81: error while writing QuotedIdent.*86: PATH\QuotedIdent$*86.class - * (The filename, directory name, or volume label syntax is incorrect) - * - * @library .. - * @compile -source 7 -target 7 -XDinvokedynamic QuotedIdent.java - * @run main quid.QuotedIdent2 - */ -/* - * Standalone testing: - * - * $ cd $MY_REPO_DIR/langtools - * $ (cd make; make) - * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent.java - * $ ./dist/bootstrap/bin/javac -d dist -cp dist test/tools/javac/quid/QuotedIdent2.java - * $ java -version # should print 1.6 or later - * $ java -cp dist QuotedIdent2 - * - */ - -package quid; - -import quid.QuotedIdent.*; -import quid.QuotedIdent.#"*86"; -import static quid.QuotedIdent.#"MAKE-*86"; - -public class QuotedIdent2 { - static void check(int testid, String have, String expect) - throws RuntimeException { - QuotedIdent.check(testid, have, expect); - } - - public static void main(String[] args) throws Exception { - String s; - - s = #"int".valueOf(123).toString(); - check(22, s, "123"); - - s = #"MAKE-*86"().#"555-1212"(); - check(23, s, "[*86.555-1212]"); - - s = #"Yog-Shoggoth".#"(nameless ululation)"; - check(25, s, "Tekeli-li!"); - - s = QuotedIdent.#"int".class.getName(); - check(31, s, QuotedIdent.class.getName()+"$int"); - - Class x86 = Class.forName(QuotedIdent.class.getName()+"$*86"); - if (x86 != #"*86".class) - check(32, "reflected "+x86, "static "+#"*86".class); - - s = (String) x86.getDeclaredMethod("555-1212").invoke(QuotedIdent.#"MAKE-*86"()); - check(31, s, "[*86.555-1212]"); - - System.out.println("OK"); - } -} diff --git a/langtools/test/tools/javac/quid/T6999438.java b/langtools/test/tools/javac/quid/T6999438.java new file mode 100644 index 00000000000..c42b1f74960 --- /dev/null +++ b/langtools/test/tools/javac/quid/T6999438.java @@ -0,0 +1,9 @@ +/* @test /nodynamiccopyright/ + * @bug 6999438 + * @summary remove support for exotic identifiers from JDK 7 + * @compile/fail/ref=T6999438.out -XDrawDiagnostics -source 7 T6999438.java + */ + +class Test { + int #"not supported"; +} diff --git a/langtools/test/tools/javac/quid/T6999438.out b/langtools/test/tools/javac/quid/T6999438.out new file mode 100644 index 00000000000..cd6266895d1 --- /dev/null +++ b/langtools/test/tools/javac/quid/T6999438.out @@ -0,0 +1,6 @@ +T6999438.java:8:9: compiler.err.illegal.char: 35 +T6999438.java:8:10: compiler.err.illegal.start.of.type +T6999438.java:8:25: compiler.err.expected: token.identifier +T6999438.java:8:26: compiler.err.expected: ';' +T6999438.java:9:2: compiler.err.premature.eof +5 errors From 823b331f15a86358f22c79c5db19a396a3572ef6 Mon Sep 17 00:00:00 2001 From: Doug Lea Date: Fri, 19 Nov 2010 10:43:24 +0000 Subject: [PATCH 27/89] 6712185: java/util/concurrent/Executors/AutoShutdown.java fails on slow or busy systems Reviewed-by: chegar, alanb --- jdk/test/ProblemList.txt | 4 --- .../concurrent/Executors/AutoShutdown.java | 35 ++++++++++++++----- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index ed75606e211..be1f7850556 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -734,10 +734,6 @@ java/util/concurrent/FutureTask/BlockingTaskExecutor.java generic-all # Problems on windows, jmap.exe hangs? (these run jmap), fails on Solaris 10 x86 java/util/concurrent/locks/Lock/TimedAcquireLeak.java generic-all -# Solaris sparc client, some failures, "1 not equal to 3"? -# also Linux problems with samevm mode, -server linux i586? 1 not equal to 3? -java/util/concurrent/Executors/AutoShutdown.java generic-all - # Fails on solaris-sparc -server (Set not equal to copy. 1) java/util/EnumSet/EnumSetBash.java solaris-sparc diff --git a/jdk/test/java/util/concurrent/Executors/AutoShutdown.java b/jdk/test/java/util/concurrent/Executors/AutoShutdown.java index 67fe405f3c9..3858ca79b64 100644 --- a/jdk/test/java/util/concurrent/Executors/AutoShutdown.java +++ b/jdk/test/java/util/concurrent/Executors/AutoShutdown.java @@ -32,21 +32,40 @@ import java.io.*; import java.util.*; import java.util.concurrent.*; import static java.util.concurrent.Executors.*; +import java.util.concurrent.Phaser; public class AutoShutdown { - private static void waitForFinalizersToRun() throws Throwable { - System.gc(); System.runFinalization(); Thread.sleep(10); - System.gc(); System.runFinalization(); Thread.sleep(10); + private static void waitForFinalizersToRun() { + for (int i = 0; i < 2; i++) + tryWaitForFinalizersToRun(); + } + + private static void tryWaitForFinalizersToRun() { + System.gc(); + final CountDownLatch fin = new CountDownLatch(1); + new Object() { protected void finalize() { fin.countDown(); }}; + System.gc(); + try { fin.await(); } + catch (InterruptedException ie) { throw new Error(ie); } } private static void realMain(String[] args) throws Throwable { - Runnable trivialRunnable = new Runnable() { public void run() {}}; + final Phaser phaser = new Phaser(3); + Runnable trivialRunnable = new Runnable() { + public void run() { + phaser.arriveAndAwaitAdvance(); + } + }; int count0 = Thread.activeCount(); - newSingleThreadExecutor().execute(trivialRunnable); - newSingleThreadExecutor(defaultThreadFactory()).execute(trivialRunnable); - Thread.sleep(100); + Executor e1 = newSingleThreadExecutor(); + Executor e2 = newSingleThreadExecutor(defaultThreadFactory()); + e1.execute(trivialRunnable); + e2.execute(trivialRunnable); + phaser.arriveAndAwaitAdvance(); equal(Thread.activeCount(), count0 + 2); - waitForFinalizersToRun(); + e1 = e2 = null; + for (int i = 0; i < 10 && Thread.activeCount() > count0; i++) + tryWaitForFinalizersToRun(); equal(Thread.activeCount(), count0); } From f6639fefed0150adef46994194df903b4511bf64 Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Fri, 19 Nov 2010 13:30:02 +0000 Subject: [PATCH 28/89] 7001301: com/sun/net/httpserver/bugs/6725892/Test.java failing Reviewed-by: alanb --- jdk/test/com/sun/net/httpserver/bugs/6725892/Test.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/jdk/test/com/sun/net/httpserver/bugs/6725892/Test.java b/jdk/test/com/sun/net/httpserver/bugs/6725892/Test.java index a4bfba757e5..5588f9d2275 100644 --- a/jdk/test/com/sun/net/httpserver/bugs/6725892/Test.java +++ b/jdk/test/com/sun/net/httpserver/bugs/6725892/Test.java @@ -65,13 +65,7 @@ public class Test { public static void main (String[] args) throws Exception { ExecutorService exec = Executors.newCachedThreadPool(); - //Logger log = Logger.getLogger ("com.sun.net.httpserver"); - //log.setLevel(Level.ALL); - //ConsoleHandler hg = new ConsoleHandler(); - //hg.setLevel (Level.ALL); - //log.addHandler(hg); - sun.net.httpserver.HttpServerImpl x = null; try { InetSocketAddress addr = new InetSocketAddress (0); s1 = HttpServer.create (addr, 0); @@ -82,11 +76,10 @@ public class Test { port = s1.getAddress().getPort(); System.out.println ("Server on port " + port); - url = new URL ("http://rialto.ireland:"+port+"/foo"); + url = new URL ("http://127.0.0.1:"+port+"/foo"); test1(); test2(); test3(); - x = (sun.net.httpserver.HttpServerImpl)s1; Thread.sleep (2000); } catch (Exception e) { e.printStackTrace(); From a48d403c44ad59f434e95e4e089c1290c9df5925 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Fri, 19 Nov 2010 10:00:08 -0800 Subject: [PATCH 29/89] 6631046: BufferedInputStream.available() reports negative int on very large inputstream Reviewed-by: dholmes, alanb, mduigou --- jdk/src/share/classes/java/io/BufferedInputStream.java | 6 +++++- jdk/src/share/classes/java/io/PushbackInputStream.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/java/io/BufferedInputStream.java b/jdk/src/share/classes/java/io/BufferedInputStream.java index d61f74bcbd3..73885f318d9 100644 --- a/jdk/src/share/classes/java/io/BufferedInputStream.java +++ b/jdk/src/share/classes/java/io/BufferedInputStream.java @@ -395,7 +395,11 @@ class BufferedInputStream extends FilterInputStream { * or an I/O error occurs. */ public synchronized int available() throws IOException { - return getInIfOpen().available() + (count - pos); + int n = count - pos; + int avail = getInIfOpen().available(); + return n > (Integer.MAX_VALUE - avail) + ? Integer.MAX_VALUE + : n + avail; } /** diff --git a/jdk/src/share/classes/java/io/PushbackInputStream.java b/jdk/src/share/classes/java/io/PushbackInputStream.java index 1984247e575..0a8e0c9cf64 100644 --- a/jdk/src/share/classes/java/io/PushbackInputStream.java +++ b/jdk/src/share/classes/java/io/PushbackInputStream.java @@ -273,7 +273,11 @@ class PushbackInputStream extends FilterInputStream { */ public int available() throws IOException { ensureOpen(); - return (buf.length - pos) + super.available(); + int n = buf.length - pos; + int avail = super.available(); + return n > (Integer.MAX_VALUE - avail) + ? Integer.MAX_VALUE + : n + avail; } /** From 1848635fab69b6d29ea88a8b56563efe96fa43ab Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Fri, 19 Nov 2010 12:55:42 -0800 Subject: [PATCH 30/89] 6989471: compiler warnings building java/zip native code Remvoed the warning Reviewed-by: ohair, alanb --- jdk/src/share/native/java/util/zip/zip_util.c | 25 +++++++++++++------ .../java/util/zip/zlib-1.2.3/compress.c | 2 +- .../native/java/util/zip/zlib-1.2.3/uncompr.c | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/jdk/src/share/native/java/util/zip/zip_util.c b/jdk/src/share/native/java/util/zip/zip_util.c index 222fe738758..3fea30c549e 100644 --- a/jdk/src/share/native/java/util/zip/zip_util.c +++ b/jdk/src/share/native/java/util/zip/zip_util.c @@ -314,7 +314,7 @@ findEND(jzfile *zip, void *endbuf) if (pos < 0) { /* Pretend there are some NUL bytes before start of file */ off = -pos; - memset(buf, '\0', off); + memset(buf, '\0', (size_t)off); } if (readFullyAt(zfd, buf + off, sizeof(buf) - off, @@ -426,7 +426,7 @@ static int isMetaName(const char *name, int length) { const char *s; - if (length < sizeof("META-INF/") - 1) + if (length < (int)sizeof("META-INF/") - 1) return 0; for (s = "META-INF/"; *s != '\0'; s++) { char c = *name++; @@ -912,7 +912,7 @@ readCENHeader(jzfile *zip, jlong cenpos, jint bufsize) ZFILE zfd = zip->zfd; char *cen; if (bufsize > zip->len - cenpos) - bufsize = zip->len - cenpos; + bufsize = (jint)(zip->len - cenpos); if ((cen = malloc(bufsize)) == NULL) goto Catch; if (readFullyAt(zfd, cen, bufsize, cenpos) == -1) goto Catch; censize = CENSIZE(cen); @@ -1256,6 +1256,9 @@ ZIP_GetEntryDataOffset(jzfile *zip, jzentry *entry) * file had been previously locked with ZIP_Lock(). Returns the * number of bytes read, or -1 if an error occurred. If zip->msg != 0 * then a zip error occurred and zip->msg contains the error text. + * + * The current implementation does not support reading an entry that + * has the size bigger than 2**32 bytes in ONE invocation. */ jint ZIP_Read(jzfile *zip, jzentry *entry, jlong pos, void *buf, jint len) @@ -1276,7 +1279,7 @@ ZIP_Read(jzfile *zip, jzentry *entry, jlong pos, void *buf, jint len) if (len <= 0) return 0; if (len > entry_size - pos) - len = entry_size - pos; + len = (jint)(entry_size - pos); /* Get file offset to start reading data */ start = ZIP_GetEntryDataOffset(zip, entry); @@ -1306,6 +1309,9 @@ ZIP_Read(jzfile *zip, jzentry *entry, jlong pos, void *buf, jint len) * from ZIP/JAR files specified in the class path. It is defined here * so that it can be dynamically loaded by the runtime if the zip library * is found. + * + * The current implementation does not support reading an entry that + * has the size bigger than 2**32 bytes in ONE invocation. */ jboolean InflateFully(jzfile *zip, jzentry *entry, void *buf, char **msg) @@ -1314,7 +1320,6 @@ InflateFully(jzfile *zip, jzentry *entry, void *buf, char **msg) char tmp[BUF_SIZE]; jlong pos = 0; jlong count = entry->csize; - jboolean status; *msg = 0; /* Reset error message */ @@ -1330,10 +1335,10 @@ InflateFully(jzfile *zip, jzentry *entry, void *buf, char **msg) } strm.next_out = buf; - strm.avail_out = entry->size; + strm.avail_out = (uInt)entry->size; while (count > 0) { - jint n = count > (jlong)sizeof(tmp) ? (jint)sizeof(tmp) : count; + jint n = count > (jlong)sizeof(tmp) ? (jint)sizeof(tmp) : (jint)count; ZIP_Lock(zip); n = ZIP_Read(zip, entry, pos, tmp, n); ZIP_Unlock(zip); @@ -1368,12 +1373,16 @@ InflateFully(jzfile *zip, jzentry *entry, void *buf, char **msg) return JNI_TRUE; } +/* + * The current implementation does not support reading an entry that + * has the size bigger than 2**32 bytes in ONE invocation. + */ jzentry * JNICALL ZIP_FindEntry(jzfile *zip, char *name, jint *sizeP, jint *nameLenP) { jzentry *entry = ZIP_GetEntry(zip, name, 0); if (entry) { - *sizeP = entry->size; + *sizeP = (jint)entry->size; *nameLenP = strlen(entry->name); } return entry; diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/compress.c b/jdk/src/share/native/java/util/zip/zlib-1.2.3/compress.c index c82999dcf9d..58669987caf 100644 --- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/compress.c +++ b/jdk/src/share/native/java/util/zip/zlib-1.2.3/compress.c @@ -75,7 +75,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) deflateEnd(&stream); return err == Z_OK ? Z_BUF_ERROR : err; } - *destLen = stream.total_out; + *destLen = (uLong)stream.total_out; err = deflateEnd(&stream); return err; diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/uncompr.c b/jdk/src/share/native/java/util/zip/zlib-1.2.3/uncompr.c index c38dc304c45..d2e4ef4c97e 100644 --- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/uncompr.c +++ b/jdk/src/share/native/java/util/zip/zlib-1.2.3/uncompr.c @@ -78,7 +78,7 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen) return Z_DATA_ERROR; return err; } - *destLen = stream.total_out; + *destLen = (uLong)stream.total_out; err = inflateEnd(&stream); return err; From 76c49b73fc722d091c9d50ceedf93087c7801db3 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Fri, 19 Nov 2010 12:58:32 -0800 Subject: [PATCH 31/89] 6957230: CharsetEncoder.maxBytesPerChar() reports 4 for UTF-8; should be 3 Changged utf-8's CharsetEncoder.maxBytesPerChar to 3 Reviewed-by: alanb --- jdk/src/share/classes/sun/nio/cs/UTF_8.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/sun/nio/cs/UTF_8.java b/jdk/src/share/classes/sun/nio/cs/UTF_8.java index 2b62e92f6c1..ae2d09b8c08 100644 --- a/jdk/src/share/classes/sun/nio/cs/UTF_8.java +++ b/jdk/src/share/classes/sun/nio/cs/UTF_8.java @@ -358,7 +358,7 @@ class UTF_8 extends Unicode private static class Encoder extends CharsetEncoder { private Encoder(Charset cs) { - super(cs, 1.1f, 4.0f); + super(cs, 1.1f, 3.0f); } public boolean canEncode(char c) { From f4f78e456b0d2db3006891f18a4b3ab48e5aa15a Mon Sep 17 00:00:00 2001 From: Lance Andersen Date: Fri, 19 Nov 2010 17:15:03 -0500 Subject: [PATCH 32/89] 7000752: Duplicate entry in RowSetResourceBundles.properties Reviewed-by: alanb --- .../com/sun/rowset/RowSetResourceBundle.properties | 8 ++++---- .../com/sun/rowset/internal/XmlReaderContentHandler.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/jdk/src/share/classes/com/sun/rowset/RowSetResourceBundle.properties b/jdk/src/share/classes/com/sun/rowset/RowSetResourceBundle.properties index fce926ea4ef..47ad98d28ae 100644 --- a/jdk/src/share/classes/com/sun/rowset/RowSetResourceBundle.properties +++ b/jdk/src/share/classes/com/sun/rowset/RowSetResourceBundle.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2010, 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 @@ -140,7 +140,7 @@ syncrsimpl.valtores = Value to be resolved can either be in the database or in c #WebRowSetXmlReader exception wrsxmlreader.invalidcp = End of RowSet reached. Invalid cursor position wrsxmlreader.readxml = readXML : {0} -wrsxmlreader.parseerr = ** Parsing Error : {0} , line : {0} , uri : {0} +wrsxmlreader.parseerr = ** Parsing Error : {0} , line : {1} , uri : {2} #WebRowSetXmlWriter exceptions wrsxmlwriter.ioex = IOException : {0} @@ -151,7 +151,7 @@ wsrxmlwriter.notproper = Not a proper type #XmlReaderContentHandler exceptions xmlrch.errmap = Error setting Map : {0} xmlrch.errmetadata = Error setting metadata : {0} -xmlrch.errinsert = Error inserting values : {0} +xmlrch.errinsertval = Error inserting values : {0} xmlrch.errconstr = Error constructing row : {0} xmlrch.errdel = Error deleting row : {0} xmlrch.errinsert = Error constructing insert row : {0} @@ -161,7 +161,7 @@ xmlrch.errupdrow = Error updating row : {0} xmlrch.chars = characters : xmlrch.badvalue = Bad value ; non-nullable property xmlrch.badvalue1 = Bad value ; non-nullable metadata -xmlrch.warning = ** Warning : {0} , line : {0} , uri : {0} +xmlrch.warning = ** Warning : {0} , line : {1} , uri : {2} #RIOptimisticProvider Exceptions riop.locking = Locking classification is not supported diff --git a/jdk/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java b/jdk/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java index 5008a289e20..47b78fd8285 100644 --- a/jdk/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java +++ b/jdk/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java @@ -738,7 +738,7 @@ public class XmlReaderContentHandler extends DefaultHandler { // columnValue now need to be reset to the empty string columnValue = ""; } catch (SQLException ex) { - throw new SAXException(MessageFormat.format(resBundle.handleGetObject("xmlrch.errinsert").toString(), ex.getMessage())); + throw new SAXException(MessageFormat.format(resBundle.handleGetObject("xmlrch.errinsertval").toString(), ex.getMessage())); } break; case RowTag: From 5731d03344e75f865ccf9bb905107de299d5903f Mon Sep 17 00:00:00 2001 From: Lance Andersen Date: Fri, 19 Nov 2010 17:18:31 -0500 Subject: [PATCH 33/89] 7001669: Typo in javadocs for SQLPermission Reviewed-by: alanb --- jdk/src/share/classes/java/sql/SQLPermission.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/java/sql/SQLPermission.java b/jdk/src/share/classes/java/sql/SQLPermission.java index e7e799c1cac..9f45718853d 100644 --- a/jdk/src/share/classes/java/sql/SQLPermission.java +++ b/jdk/src/share/classes/java/sql/SQLPermission.java @@ -84,7 +84,7 @@ import java.security.*; * {@code setJNDIContext} and {@code setLogger} * Permits an application to specify the JNDI context from which the * {@code SyncProvider} implementations can be retrieved from and the logging - * object to be used by the{@codeSyncProvider} implementation. + * object to be used by the {@code SyncProvider} implementation. * * * From b3d56521491e6ff4c59077eb38040170263e88dd Mon Sep 17 00:00:00 2001 From: Valerie Peng Date: Fri, 19 Nov 2010 16:59:48 -0800 Subject: [PATCH 34/89] 6203816: Can not run test/java/security/Security/ClassLoaderDeadlock.sh from the command line Fixed the script to not delete the provider sub-directory Reviewed-by: weijun --- .../ClassLoaderDeadlock/ClassLoaderDeadlock.sh | 16 +++++++++++----- .../Security/ClassLoaderDeadlock/Deadlock2.sh | 8 +++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/jdk/test/java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh b/jdk/test/java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh index 717857c9cbc..b11ddd8929c 100644 --- a/jdk/test/java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh +++ b/jdk/test/java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh @@ -68,11 +68,10 @@ case "$OS" in ;; esac -# remove old class files cd ${TESTCLASSES}${FILESEP} -rm -f ClassLoaderDeadlock.class -rm -rf provider -mkdir provider +if [ ! -d provider ] ; then + mkdir provider +fi # compile the test program ${TESTJAVA}${FILESEP}bin${FILESEP}javac \ @@ -88,4 +87,11 @@ ${TESTJAVA}${FILESEP}bin${FILESEP}java \ -classpath "${TESTCLASSES}${PATHSEP}${TESTSRC}${FILESEP}Deadlock.jar" \ ClassLoaderDeadlock -exit $? +STATUS=$? + +# clean up +rm -f 'ClassLoaderDeadlock.class' 'ClassLoaderDeadlock$1.class' \ +'ClassLoaderDeadlock$DelayClassLoader.class' \ +provider${FILESEP}HashProvider.class + +exit $STATUS diff --git a/jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh b/jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh index 2ed6da135cf..f084942af21 100644 --- a/jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh +++ b/jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh @@ -26,7 +26,6 @@ # @test # @bug 6440846 -# @ignore until 6203816 is dealt with. # @summary make sure we do not deadlock between ExtClassLoader and AppClassLoader # @author Valerie Peng # @run shell/timeout=20 Deadlock2.sh @@ -71,11 +70,14 @@ esac # remove old class files cd ${TESTCLASSES} -rm -f Deadlock2*.class if [ -d testlib ] ; then rm -rf testlib fi -cp -r ${TESTJAVA}${FILESEP}lib${FILESEP}ext testlib +if [ -d ${TESTJAVA}${FILESEP}lib${FILESEP}ext ] ; then + cp -r ${TESTJAVA}${FILESEP}lib${FILESEP}ext testlib +else + cp -r ${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}ext testlib +fi # compile and package the test program ${TESTJAVA}${FILESEP}bin${FILESEP}javac \ From 358ee90f29dc4b3ad7deda3ea37dae6f15319aab Mon Sep 17 00:00:00 2001 From: Valerie Peng Date: Fri, 19 Nov 2010 17:05:47 -0800 Subject: [PATCH 35/89] 6720456: New 4150 may have larger blowfish keysizes Changed to use TBD value instead of FAIL Reviewed-by: weijun --- .../security/pkcs11/KeyGenerator/TestKeyGenerator.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jdk/test/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java b/jdk/test/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java index 0c79da6826f..912d9335b33 100644 --- a/jdk/test/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java +++ b/jdk/test/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java @@ -23,7 +23,7 @@ /** * @test - * @bug 4917233 6461727 6490213 + * @bug 4917233 6461727 6490213 6720456 * @summary test the KeyGenerator * @author Andreas Sterbenz * @library .. @@ -104,7 +104,7 @@ public class TestKeyGenerator extends PKCS11Test { // Different PKCS11 impls have different ranges // of supported key sizes for variable-key-length // algorithms. - // Solaris> Blowfish: 32-128 bits, RC4: 8-128 bits + // Solaris> Blowfish: 32-128 or even 448 bits, RC4: 8-128 bits or as much as 2048 bits // NSS> Blowfish: n/a, RC4: 8-2048 bits // However, we explicitly disallowed key sizes less // than 40-bits. @@ -114,8 +114,8 @@ public class TestKeyGenerator extends PKCS11Test { test("Blowfish", 32, p, TestResult.FAIL); test("Blowfish", 40, p, TestResult.PASS); test("Blowfish", 128, p, TestResult.PASS); - test("Blowfish", 136, p, TestResult.FAIL); - test("Blowfish", 448, p, TestResult.FAIL); + test("Blowfish", 136, p, TestResult.TBD); + test("Blowfish", 448, p, TestResult.TBD); test("Blowfish", 456, p, TestResult.FAIL); test("ARCFOUR", 0, p, TestResult.FAIL); @@ -124,7 +124,7 @@ public class TestKeyGenerator extends PKCS11Test { test("ARCFOUR", 128, p, TestResult.PASS); if (p.getName().equals("SunPKCS11-Solaris")) { - test("ARCFOUR", 1024, p, TestResult.FAIL); + test("ARCFOUR", 1024, p, TestResult.TBD); } else if (p.getName().equals("SunPKCS11-NSS")) { test("ARCFOUR", 1024, p, TestResult.PASS); test("ARCFOUR", 2048, p, TestResult.PASS); From ae111e5e4ae7a9f4da7e6403871286475ed67f41 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Sat, 20 Nov 2010 07:00:31 -0800 Subject: [PATCH 36/89] 6903584: Legal notice repair: Three files under jdk/src/share/classes/sun/security/ssl/ Reviewed-by: weijun --- jdk/src/share/classes/sun/security/ssl/Krb5Helper.java | 2 +- jdk/src/share/classes/sun/security/ssl/Krb5Proxy.java | 2 +- jdk/src/share/classes/sun/security/ssl/krb5/Krb5ProxyImpl.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/classes/sun/security/ssl/Krb5Helper.java b/jdk/src/share/classes/sun/security/ssl/Krb5Helper.java index 440b119861e..b61ab4f2938 100644 --- a/jdk/src/share/classes/sun/security/ssl/Krb5Helper.java +++ b/jdk/src/share/classes/sun/security/ssl/Krb5Helper.java @@ -10,7 +10,7 @@ * * 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 + * 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). * diff --git a/jdk/src/share/classes/sun/security/ssl/Krb5Proxy.java b/jdk/src/share/classes/sun/security/ssl/Krb5Proxy.java index 2e591585942..24ace2b85db 100644 --- a/jdk/src/share/classes/sun/security/ssl/Krb5Proxy.java +++ b/jdk/src/share/classes/sun/security/ssl/Krb5Proxy.java @@ -10,7 +10,7 @@ * * 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 + * 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). * diff --git a/jdk/src/share/classes/sun/security/ssl/krb5/Krb5ProxyImpl.java b/jdk/src/share/classes/sun/security/ssl/krb5/Krb5ProxyImpl.java index 70dc7532e5b..ce0479d78af 100644 --- a/jdk/src/share/classes/sun/security/ssl/krb5/Krb5ProxyImpl.java +++ b/jdk/src/share/classes/sun/security/ssl/krb5/Krb5ProxyImpl.java @@ -10,7 +10,7 @@ * * 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 + * 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). * From 11c0d2dbecaf185312a3ae0aa7081690c74996af Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Mon, 22 Nov 2010 09:43:58 +0800 Subject: [PATCH 37/89] 6979329: CCacheInputStream fails to read ticket cache files from Kerberos 1.8.1 Reviewed-by: valeriep --- .../internal/ccache/CCacheInputStream.java | 43 ++-- .../internal/ccache/FileCredentialsCache.java | 7 +- .../sun/security/krb5/UnknownCCEntry.java | 219 ++++++++++++++++++ 3 files changed, 251 insertions(+), 18 deletions(-) create mode 100644 jdk/test/sun/security/krb5/UnknownCCEntry.java diff --git a/jdk/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java b/jdk/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java index 0649ae10da8..4f387b99f96 100644 --- a/jdk/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java +++ b/jdk/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java @@ -250,16 +250,16 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC else return null; } - Ticket readData() throws IOException, RealmException, KrbApErrException, Asn1Exception { + byte[] readData() throws IOException { int length; length = read(4); - if (length > 0) { + if (length == 0) { + return null; + } else { byte[] bytes = new byte[length]; read(bytes, 0, length); - Ticket ticket = new Ticket(bytes); - return ticket; + return bytes; } - else return null; } boolean[] readFlags() throws IOException { @@ -328,6 +328,17 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC } return flags; } + + /** + * Reads the next cred in stream. + * @return the next cred, null if ticket or second_ticket unparseable. + * + * Note: MIT krb5 1.8.1 might generate a config entry with server principal + * X-CACHECONF:/krb5_ccache_conf_data/fast_avail/krbtgt/REALM@REALM. The + * entry is used by KDC to inform the client that it support certain + * features. Its ticket is not a valid krb5 ticket and thus this method + * returns null. + */ Credentials readCred(int version) throws IOException,RealmException, KrbApErrException, Asn1Exception { PrincipalName cpname = readPrincipal(version); if (DEBUG) @@ -367,17 +378,17 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC if (auData != null) { auData = new AuthorizationData(auDataEntry); } - Ticket ticket = readData(); - if (DEBUG) { - System.out.println(">>>DEBUG "); - if (ticket == null) { - System.out.println("///ticket is null"); - } + byte[] ticketData = readData(); + byte[] ticketData2 = readData(); + + try { + return new Credentials(cpname, spname, key, authtime, starttime, + endtime, renewTill, skey, tFlags, + addrs, auData, + ticketData != null ? new Ticket(ticketData) : null, + ticketData2 != null ? new Ticket(ticketData2) : null); + } catch (Exception e) { // If any of new Ticket(*) fails. + return null; } - Ticket secTicket = readData(); - Credentials cred = new Credentials(cpname, spname, key, authtime, starttime, - endtime, renewTill, skey, tFlags, - addrs, auData, ticket, secTicket); - return cred; } } diff --git a/jdk/src/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java b/jdk/src/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java index 6095077f503..4f874903f79 100644 --- a/jdk/src/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java +++ b/jdk/src/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2010, 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 @@ -186,7 +186,10 @@ public class FileCredentialsCache extends CredentialsCache primaryRealm = primaryPrincipal.getRealm(); credentialsList = new Vector (); while (cis.available() > 0) { - credentialsList.addElement(cis.readCred(version)); + Credentials cred = cis.readCred(version); + if (cred != null) { + credentialsList.addElement(cred); + } } cis.close(); } diff --git a/jdk/test/sun/security/krb5/UnknownCCEntry.java b/jdk/test/sun/security/krb5/UnknownCCEntry.java new file mode 100644 index 00000000000..17af51e2847 --- /dev/null +++ b/jdk/test/sun/security/krb5/UnknownCCEntry.java @@ -0,0 +1,219 @@ +/* + * Copyright (c) 2010, 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 6979329 + * @summary CCacheInputStream fails to read ticket cache files from Kerberos 1.8.1 + */ + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileOutputStream; +import sun.security.krb5.internal.ccache.CCacheInputStream; +import sun.security.krb5.internal.ccache.CredentialsCache; + +public class UnknownCCEntry { + public static void main(String[] args) throws Exception { + // This is a ccache file generated on a test machine: + // Default principal: dummy@MAX.LOCAL + // Valid starting Expires Service principal + // 08/24/10 10:37:28 08/25/10 10:37:28 krbtgt/MAX.LOCAL@MAX.LOCAL + // Flags: FI, Etype (skey, tkt): AES-128 CTS mode with 96-bit SHA-1 + // HMAC, AES-256 CTS mode with 96-bit SHA-1 HMAC + byte[] krb5cc = { + (byte)0x05, (byte)0x04, (byte)0x00, (byte)0x0C, + (byte)0x00, (byte)0x01, (byte)0x00, (byte)0x08, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFA, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, + (byte)0x4D, (byte)0x41, (byte)0x58, (byte)0x2E, + (byte)0x4C, (byte)0x4F, (byte)0x43, (byte)0x41, + (byte)0x4C, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x05, (byte)0x64, (byte)0x75, (byte)0x6D, + (byte)0x6D, (byte)0x79, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x01, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x01, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x09, (byte)0x4D, (byte)0x41, + (byte)0x58, (byte)0x2E, (byte)0x4C, (byte)0x4F, + (byte)0x43, (byte)0x41, (byte)0x4C, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x05, (byte)0x64, + (byte)0x75, (byte)0x6D, (byte)0x6D, (byte)0x79, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x02, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, + (byte)0x4D, (byte)0x41, (byte)0x58, (byte)0x2E, + (byte)0x4C, (byte)0x4F, (byte)0x43, (byte)0x41, + (byte)0x4C, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x06, (byte)0x6B, (byte)0x72, (byte)0x62, + (byte)0x74, (byte)0x67, (byte)0x74, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x4D, + (byte)0x41, (byte)0x58, (byte)0x2E, (byte)0x4C, + (byte)0x4F, (byte)0x43, (byte)0x41, (byte)0x4C, + (byte)0x00, (byte)0x11, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x10, (byte)0x92, (byte)0x1D, + (byte)0x1A, (byte)0x0C, (byte)0x7F, (byte)0xB8, + (byte)0x01, (byte)0x2E, (byte)0xC9, (byte)0xF5, + (byte)0x7B, (byte)0x92, (byte)0x81, (byte)0xCA, + (byte)0x49, (byte)0xC5, (byte)0x4C, (byte)0x73, + (byte)0x30, (byte)0x68, (byte)0x4C, (byte)0x73, + (byte)0x30, (byte)0x68, (byte)0x4C, (byte)0x74, + (byte)0x81, (byte)0xE8, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x40, + (byte)0x41, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x01, (byte)0x29, (byte)0x61, + (byte)0x82, (byte)0x01, (byte)0x25, (byte)0x30, + (byte)0x82, (byte)0x01, (byte)0x21, (byte)0xA0, + (byte)0x03, (byte)0x02, (byte)0x01, (byte)0x05, + (byte)0xA1, (byte)0x0B, (byte)0x1B, (byte)0x09, + (byte)0x4D, (byte)0x41, (byte)0x58, (byte)0x2E, + (byte)0x4C, (byte)0x4F, (byte)0x43, (byte)0x41, + (byte)0x4C, (byte)0xA2, (byte)0x1E, (byte)0x30, + (byte)0x1C, (byte)0xA0, (byte)0x03, (byte)0x02, + (byte)0x01, (byte)0x00, (byte)0xA1, (byte)0x15, + (byte)0x30, (byte)0x13, (byte)0x1B, (byte)0x06, + (byte)0x6B, (byte)0x72, (byte)0x62, (byte)0x74, + (byte)0x67, (byte)0x74, (byte)0x1B, (byte)0x09, + (byte)0x4D, (byte)0x41, (byte)0x58, (byte)0x2E, + (byte)0x4C, (byte)0x4F, (byte)0x43, (byte)0x41, + (byte)0x4C, (byte)0xA3, (byte)0x81, (byte)0xEC, + (byte)0x30, (byte)0x81, (byte)0xE9, (byte)0xA0, + (byte)0x03, (byte)0x02, (byte)0x01, (byte)0x12, + (byte)0xA1, (byte)0x03, (byte)0x02, (byte)0x01, + (byte)0x01, (byte)0xA2, (byte)0x81, (byte)0xDC, + (byte)0x04, (byte)0x81, (byte)0xD9, (byte)0xFB, + (byte)0x4B, (byte)0xD2, (byte)0x55, (byte)0x33, + (byte)0xA8, (byte)0x1A, (byte)0xE6, (byte)0xB5, + (byte)0x3D, (byte)0x67, (byte)0x46, (byte)0x69, + (byte)0x6F, (byte)0x0A, (byte)0x64, (byte)0xE7, + (byte)0x3D, (byte)0xEF, (byte)0x22, (byte)0xBE, + (byte)0x81, (byte)0x32, (byte)0xF3, (byte)0x72, + (byte)0xB4, (byte)0x50, (byte)0xE3, (byte)0xC3, + (byte)0xDB, (byte)0xE5, (byte)0x38, (byte)0x3C, + (byte)0x60, (byte)0xC8, (byte)0x08, (byte)0x53, + (byte)0x44, (byte)0x6F, (byte)0xDF, (byte)0x55, + (byte)0x67, (byte)0x32, (byte)0x02, (byte)0xDD, + (byte)0x6B, (byte)0xFB, (byte)0x23, (byte)0x1A, + (byte)0x88, (byte)0x71, (byte)0xE0, (byte)0xF8, + (byte)0xBB, (byte)0x51, (byte)0x1E, (byte)0x76, + (byte)0xC9, (byte)0x1F, (byte)0x45, (byte)0x9B, + (byte)0xA0, (byte)0xA5, (byte)0x61, (byte)0x45, + (byte)0x9E, (byte)0x65, (byte)0xB8, (byte)0xD6, + (byte)0x0E, (byte)0x3C, (byte)0xD9, (byte)0x56, + (byte)0xD6, (byte)0xA6, (byte)0xDD, (byte)0x36, + (byte)0x21, (byte)0x25, (byte)0x0E, (byte)0xE6, + (byte)0xAD, (byte)0xA0, (byte)0x3A, (byte)0x9B, + (byte)0x21, (byte)0x87, (byte)0xE2, (byte)0xAF, + (byte)0x3A, (byte)0xEF, (byte)0x75, (byte)0x85, + (byte)0xA8, (byte)0xD7, (byte)0xE5, (byte)0x46, + (byte)0xD8, (byte)0x5C, (byte)0x17, (byte)0x4E, + (byte)0x64, (byte)0x51, (byte)0xDB, (byte)0x38, + (byte)0x8E, (byte)0x6B, (byte)0x02, (byte)0x05, + (byte)0x46, (byte)0x77, (byte)0xD0, (byte)0x75, + (byte)0x8A, (byte)0xE0, (byte)0x42, (byte)0x5E, + (byte)0x8D, (byte)0x49, (byte)0x86, (byte)0xDE, + (byte)0x6C, (byte)0xBC, (byte)0xAF, (byte)0x10, + (byte)0x9A, (byte)0x97, (byte)0x64, (byte)0xA6, + (byte)0xBD, (byte)0xDB, (byte)0x01, (byte)0x40, + (byte)0xA9, (byte)0x3D, (byte)0x74, (byte)0x99, + (byte)0xDC, (byte)0x63, (byte)0x34, (byte)0x40, + (byte)0x31, (byte)0x57, (byte)0xC7, (byte)0x70, + (byte)0x9F, (byte)0xCE, (byte)0xC6, (byte)0x7B, + (byte)0x00, (byte)0x5B, (byte)0x02, (byte)0x5C, + (byte)0xC7, (byte)0x81, (byte)0x40, (byte)0x4D, + (byte)0xA7, (byte)0xB1, (byte)0xD2, (byte)0xEA, + (byte)0x8E, (byte)0xEC, (byte)0xA0, (byte)0xB3, + (byte)0x03, (byte)0x29, (byte)0xB8, (byte)0x44, + (byte)0xD7, (byte)0xA1, (byte)0x2B, (byte)0x37, + (byte)0x9D, (byte)0x19, (byte)0x11, (byte)0x1D, + (byte)0x58, (byte)0xE8, (byte)0x06, (byte)0xE7, + (byte)0x06, (byte)0xE3, (byte)0xF7, (byte)0xEF, + (byte)0x05, (byte)0xA9, (byte)0x05, (byte)0x93, + (byte)0x42, (byte)0x94, (byte)0x5A, (byte)0xD6, + (byte)0xA0, (byte)0x24, (byte)0x3A, (byte)0x52, + (byte)0x92, (byte)0xA3, (byte)0x79, (byte)0x98, + (byte)0x3C, (byte)0x68, (byte)0x55, (byte)0x1B, + (byte)0x6A, (byte)0xC5, (byte)0x83, (byte)0x89, + (byte)0x5A, (byte)0x79, (byte)0x5C, (byte)0x52, + (byte)0xBA, (byte)0xB8, (byte)0xF7, (byte)0x72, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, + (byte)0x4D, (byte)0x41, (byte)0x58, (byte)0x2E, + (byte)0x4C, (byte)0x4F, (byte)0x43, (byte)0x41, + (byte)0x4C, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x05, (byte)0x64, (byte)0x75, (byte)0x6D, + (byte)0x6D, (byte)0x79, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x03, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x0C, (byte)0x58, (byte)0x2D, + (byte)0x43, (byte)0x41, (byte)0x43, (byte)0x48, + (byte)0x45, (byte)0x43, (byte)0x4F, (byte)0x4E, + (byte)0x46, (byte)0x3A, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x15, (byte)0x6B, (byte)0x72, + (byte)0x62, (byte)0x35, (byte)0x5F, (byte)0x63, + (byte)0x63, (byte)0x61, (byte)0x63, (byte)0x68, + (byte)0x65, (byte)0x5F, (byte)0x63, (byte)0x6F, + (byte)0x6E, (byte)0x66, (byte)0x5F, (byte)0x64, + (byte)0x61, (byte)0x74, (byte)0x61, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x0A, (byte)0x66, + (byte)0x61, (byte)0x73, (byte)0x74, (byte)0x5F, + (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x69, + (byte)0x6C, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x1A, (byte)0x6B, (byte)0x72, (byte)0x62, + (byte)0x74, (byte)0x67, (byte)0x74, (byte)0x2F, + (byte)0x4D, (byte)0x41, (byte)0x58, (byte)0x2E, + (byte)0x4C, (byte)0x4F, (byte)0x43, (byte)0x41, + (byte)0x4C, (byte)0x40, (byte)0x4D, (byte)0x41, + (byte)0x58, (byte)0x2E, (byte)0x4C, (byte)0x4F, + (byte)0x43, (byte)0x41, (byte)0x4C, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x03, (byte)0x79, (byte)0x65, + (byte)0x73, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, + }; + + File f = File.createTempFile("ccache", "cc", new File(".")); + FileOutputStream fout = new FileOutputStream(f); + fout.write(krb5cc); + fout.close(); + + CredentialsCache cc = CredentialsCache.getInstance(f.getPath()); + if (!cc.getDefaultCreds().getServicePrincipal().getNameStrings()[0] + .equals("krbtgt")) { + throw new Exception("No TGT found"); + } + } +} From c5c0369dc29db34e015172e387d9ab59ec9b88c8 Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Mon, 22 Nov 2010 10:16:07 -0500 Subject: [PATCH 38/89] 6995424: Eliminate dependency to a deprecated API com.sun.security.auth.PolicyFile Reviewed-by: mchung --- .../classes/javax/security/auth/Policy.java | 49 +++++++++++++++++++ .../security/auth/SubjectDomainCombiner.java | 39 +++------------ 2 files changed, 55 insertions(+), 33 deletions(-) diff --git a/jdk/src/share/classes/javax/security/auth/Policy.java b/jdk/src/share/classes/javax/security/auth/Policy.java index 6c508b2ce95..88264b3fc49 100644 --- a/jdk/src/share/classes/javax/security/auth/Policy.java +++ b/jdk/src/share/classes/javax/security/auth/Policy.java @@ -25,6 +25,9 @@ package javax.security.auth; +import java.security.Security; +import sun.security.util.Debug; + /** *

This is an abstract class for representing the system policy for * Subject-based authorization. A subclass implementation @@ -159,6 +162,10 @@ public abstract class Policy { private static Policy policy; private static ClassLoader contextClassLoader; + // true if a custom (not com.sun.security.auth.PolicyFile) system-wide + // policy object is set + private static boolean isCustomPolicy; + static { contextClassLoader = java.security.AccessController.doPrivileged (new java.security.PrivilegedAction() { @@ -234,6 +241,8 @@ public abstract class Policy { contextClassLoader).newInstance(); } }); + isCustomPolicy = + !finalClass.equals("com.sun.security.auth.PolicyFile"); } catch (Exception e) { throw new SecurityException (sun.security.util.ResourcesMgr.getString @@ -265,6 +274,46 @@ public abstract class Policy { java.lang.SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(new AuthPermission("setPolicy")); Policy.policy = policy; + // all non-null policy objects are assumed to be custom + isCustomPolicy = policy != null ? true : false; + } + + /** + * Returns true if a custom (not com.sun.security.auth.PolicyFile) + * system-wide policy object has been set or installed. This method is + * called by SubjectDomainCombiner to provide backwards compatibility for + * developers that provide their own javax.security.auth.Policy + * implementations. + * + * @return true if a custom (not com.sun.security.auth.PolicyFile) + * system-wide policy object has been set; false otherwise + */ + static boolean isCustomPolicySet(Debug debug) { + if (policy != null) { + if (debug != null && isCustomPolicy) { + debug.println("Providing backwards compatibility for " + + "javax.security.auth.policy implementation: " + + policy.toString()); + } + return isCustomPolicy; + } + // check if custom policy has been set using auth.policy.provider prop + String policyClass = java.security.AccessController.doPrivileged + (new java.security.PrivilegedAction() { + public String run() { + return Security.getProperty("auth.policy.provider"); + } + }); + if (policyClass != null + && !policyClass.equals("com.sun.security.auth.PolicyFile")) { + if (debug != null) { + debug.println("Providing backwards compatibility for " + + "javax.security.auth.policy implementation: " + + policyClass); + } + return true; + } + return false; } /** diff --git a/jdk/src/share/classes/javax/security/auth/SubjectDomainCombiner.java b/jdk/src/share/classes/javax/security/auth/SubjectDomainCombiner.java index 00d57f6c6da..9dc82fc0153 100644 --- a/jdk/src/share/classes/javax/security/auth/SubjectDomainCombiner.java +++ b/jdk/src/share/classes/javax/security/auth/SubjectDomainCombiner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2010, 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 @@ -26,8 +26,6 @@ package javax.security.auth; import java.security.AccessController; -import java.security.AccessControlContext; -import java.security.AllPermission; import java.security.Permission; import java.security.Permissions; import java.security.PermissionCollection; @@ -35,10 +33,8 @@ import java.security.Policy; import java.security.Principal; import java.security.PrivilegedAction; import java.security.ProtectionDomain; -import java.lang.ClassLoader; import java.security.Security; import java.util.Set; -import java.util.Iterator; import java.util.WeakHashMap; import java.lang.ref.WeakReference; @@ -61,7 +57,8 @@ public class SubjectDomainCombiner implements java.security.DomainCombiner { "\t[SubjectDomainCombiner]"); // Note: check only at classloading time, not dynamically during combine() - private static final boolean useJavaxPolicy = compatPolicy(); + private static final boolean useJavaxPolicy = + javax.security.auth.Policy.isCustomPolicySet(debug); // Relevant only when useJavaxPolicy is true private static final boolean allowCaching = @@ -202,8 +199,8 @@ public class SubjectDomainCombiner implements java.security.DomainCombiner { return null; } - // maintain backwards compatibility for people who provide - // their own javax.security.auth.Policy implementations + // maintain backwards compatibility for developers who provide + // their own custom javax.security.auth.Policy implementations if (useJavaxPolicy) { return combineJavaxPolicy(currentDomains, assignedDomains); } @@ -476,8 +473,7 @@ public class SubjectDomainCombiner implements java.security.DomainCombiner { String s = AccessController.doPrivileged (new PrivilegedAction() { public String run() { - return java.security.Security.getProperty - ("cache.auth.policy"); + return Security.getProperty("cache.auth.policy"); } }); if (s != null) { @@ -488,29 +484,6 @@ public class SubjectDomainCombiner implements java.security.DomainCombiner { return true; } - // maintain backwards compatibility for people who provide - // their own javax.security.auth.Policy implementations - private static boolean compatPolicy() { - javax.security.auth.Policy javaxPolicy = AccessController.doPrivileged - (new PrivilegedAction() { - public javax.security.auth.Policy run() { - return javax.security.auth.Policy.getPolicy(); - } - }); - - if (!(javaxPolicy instanceof com.sun.security.auth.PolicyFile)) { - if (debug != null) { - debug.println("Providing backwards compatibility for " + - "javax.security.auth.policy implementation: " + - javaxPolicy.toString()); - } - - return true; - } else { - return false; - } - } - private static void printInputDomains(ProtectionDomain[] currentDomains, ProtectionDomain[] assignedDomains) { if (currentDomains == null || currentDomains.length == 0) { From 5bec7cedec1653f77d85d5b40aa549e565b63479 Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Mon, 22 Nov 2010 16:09:31 +0000 Subject: [PATCH 39/89] 6984182: Setting SO_RCVBUF/SO_SNDBUF to larger than tcp_max_buf fails on Solaris 11 if kernel params changed Reviewed-by: alanb, chegar --- jdk/src/solaris/native/java/net/net_util_md.c | 96 ++++++++++++++++--- 1 file changed, 83 insertions(+), 13 deletions(-) diff --git a/jdk/src/solaris/native/java/net/net_util_md.c b/jdk/src/solaris/native/java/net/net_util_md.c index 43baab96ea8..236c643c959 100644 --- a/jdk/src/solaris/native/java/net/net_util_md.c +++ b/jdk/src/solaris/native/java/net/net_util_md.c @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef __solaris__ #include @@ -75,17 +76,17 @@ getnameinfo_f getnameinfo_ptr = NULL; #endif #ifdef __solaris__ -static int init_max_buf; +static int init_tcp_max_buf, init_udp_max_buf; static int tcp_max_buf; static int udp_max_buf; /* * Get the specified parameter from the specified driver. The value * of the parameter is assumed to be an 'int'. If the parameter - * cannot be obtained return the specified default value. + * cannot be obtained return -1 */ static int -getParam(char *driver, char *param, int dflt) +getParam(char *driver, char *param) { struct strioctl stri; char buf [64]; @@ -94,7 +95,7 @@ getParam(char *driver, char *param, int dflt) s = open (driver, O_RDWR); if (s < 0) { - return dflt; + return -1; } strncpy (buf, param, sizeof(buf)); stri.ic_cmd = ND_GET; @@ -102,13 +103,64 @@ getParam(char *driver, char *param, int dflt) stri.ic_dp = buf; stri.ic_len = sizeof(buf); if (ioctl (s, I_STR, &stri) < 0) { - value = dflt; + value = -1; } else { value = atoi(buf); } close (s); return value; } + +/* + * Iterative way to find the max value that SO_SNDBUF or SO_RCVBUF + * for Solaris versions that do not support the ioctl() in getParam(). + * Ugly, but only called once (for each sotype). + * + * As an optimisation, we make a guess using the default values for Solaris + * assuming they haven't been modified with ndd. + */ + +#define MAX_TCP_GUESS 1024 * 1024 +#define MAX_UDP_GUESS 2 * 1024 * 1024 + +#define FAIL_IF_NOT_ENOBUFS if (errno != ENOBUFS) return -1 + +static int findMaxBuf(int fd, int opt, int sotype) { + int a = 0; + int b = MAXINT; + int initial_guess; + int limit = -1; + + if (sotype == SOCK_DGRAM) { + initial_guess = MAX_UDP_GUESS; + } else { + initial_guess = MAX_TCP_GUESS; + } + + if (setsockopt(fd, SOL_SOCKET, opt, &initial_guess, sizeof(int)) == 0) { + initial_guess++; + if (setsockopt(fd, SOL_SOCKET, opt, &initial_guess,sizeof(int)) < 0) { + FAIL_IF_NOT_ENOBUFS; + return initial_guess - 1; + } + a = initial_guess; + } else { + FAIL_IF_NOT_ENOBUFS; + b = initial_guess - 1; + } + do { + int mid = a + (b-a)/2; + if (setsockopt(fd, SOL_SOCKET, opt, &mid, sizeof(int)) == 0) { + limit = mid; + a = mid + 1; + } else { + FAIL_IF_NOT_ENOBUFS; + b = mid - 1; + } + } while (b >= a); + + return limit; +} #endif #ifdef __linux__ @@ -1148,7 +1200,6 @@ NET_GetSockOpt(int fd, int level, int opt, void *result, return rv; } - /* * Wrapper for setsockopt system routine - performs any * necessary pre/post processing to deal with OS specific @@ -1212,7 +1263,7 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg, #ifdef __solaris__ if (level == SOL_SOCKET) { if (opt == SO_SNDBUF || opt == SO_RCVBUF) { - int sotype, arglen; + int sotype=0, arglen; int *bufsize, maxbuf; int ret; @@ -1223,18 +1274,37 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg, /* Exceeded system limit so clamp and retry */ - if (!init_max_buf) { - tcp_max_buf = getParam("/dev/tcp", "tcp_max_buf", 1024*1024); - udp_max_buf = getParam("/dev/udp", "udp_max_buf", 2048*1024); - init_max_buf = 1; - } - arglen = sizeof(sotype); if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void *)&sotype, &arglen) < 0) { return -1; } + /* + * We try to get tcp_maxbuf (and udp_max_buf) using + * an ioctl() that isn't available on all versions of Solaris. + * If that fails, we use the search algorithm in findMaxBuf() + */ + if (!init_tcp_max_buf && sotype == SOCK_STREAM) { + tcp_max_buf = getParam("/dev/tcp", "tcp_max_buf"); + if (tcp_max_buf == -1) { + tcp_max_buf = findMaxBuf(fd, opt, SOCK_STREAM); + if (tcp_max_buf == -1) { + return -1; + } + } + init_tcp_max_buf = 1; + } else if (!init_udp_max_buf && sotype == SOCK_DGRAM) { + udp_max_buf = getParam("/dev/udp", "udp_max_buf"); + if (udp_max_buf == -1) { + udp_max_buf = findMaxBuf(fd, opt, SOCK_DGRAM); + if (udp_max_buf == -1) { + return -1; + } + } + init_udp_max_buf = 1; + } + maxbuf = (sotype == SOCK_STREAM) ? tcp_max_buf : udp_max_buf; bufsize = (int *)arg; if (*bufsize > maxbuf) { From 7e92fd9fb273eec383d8031870c350da5aa57db7 Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Mon, 22 Nov 2010 14:57:05 -0800 Subject: [PATCH 40/89] Added tag jdk7-b119 for changeset fa550ae6eb32 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 127ed7324f8..35f1f600c87 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -93,3 +93,4 @@ e8ebdf41b9c01a26642848f4134f5504e8fb3233 jdk7-b115 94e9a1bfba8b8d1fe0bfd43b88629b1f27b02a76 jdk7-b116 7220e60b097fa027e922f1aeecdd330f3e37409f jdk7-b117 a12a9e78df8a9d534da0b4a244ed68f0de0bd58e jdk7-b118 +661360bef6ccad6c119f067f5829b207de80c936 jdk7-b119 From 89974462e7cc0f9dafcc465521f70cb2d55143ee Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Mon, 22 Nov 2010 14:57:06 -0800 Subject: [PATCH 41/89] Added tag jdk7-b119 for changeset d45d466d6759 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 4245e3a1d43..a3294eefb5c 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -93,3 +93,4 @@ da7561d479e0ddaa4650d8023ac0fc7294e014e3 jdk7-b115 98c028de4301106f2285ac0e128a1bb9b4c24f5c jdk7-b116 fa502e4834dac2176499cc1f44794d5dc32a11b9 jdk7-b117 42e77836fded7c2a3080d27316b96634ea9e33c6 jdk7-b118 +39829414ae31a0080578a49b751899edd518cd7d jdk7-b119 From b23d739ffb9ac691d4a73bc4fa5b77f19eb00b3f Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Mon, 22 Nov 2010 14:57:11 -0800 Subject: [PATCH 42/89] Added tag jdk7-b119 for changeset a683e80b9ca8 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 3708e167562..a04c44511d9 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -131,3 +131,4 @@ bdbc48857210a509b3c50a3291ecb9dd6a72e016 jdk7-b115 806d0c037e6bbb88dac0699673f4ba55ee8c02da jdk7-b117 698b7b727e12de44139d8cca6ab9a494ead13253 jdk7-b118 3ef7426b4deac5dcfd4afb35cabe9ab3d666df91 hs20-b02 +5484e7c53fa7da5e869902437ee08a9ae10c1c69 jdk7-b119 From 7daccf11f86aa73ac6583fa04d8125be95d053f1 Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Mon, 22 Nov 2010 14:57:16 -0800 Subject: [PATCH 43/89] Added tag jdk7-b119 for changeset 1db26590e632 --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 32c4b81eb67..f8033c1011a 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -93,3 +93,4 @@ dc1612e1d3ac08eb8fcad764daff21c9247d33c9 jdk7-b115 f8d4e6c6cfce1cda23fcbd144628a9791a9e1a63 jdk7-b116 9ee4d96e893436a48607924227dadd2d93b9b00d jdk7-b117 b2f6d9c4f12ffd307a5de40455b2b61b31a5cb79 jdk7-b118 +9ee900f01c5872551c06f33ae909662ffd8463ac jdk7-b119 From 848bdbff6e8f0ff402b2c941dc1c7888b2953ce7 Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Mon, 22 Nov 2010 14:57:17 -0800 Subject: [PATCH 44/89] Added tag jdk7-b119 for changeset 80bacb622b68 --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 0f3de0a3898..db1808eed9f 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -93,3 +93,4 @@ d35c94fd22362f478f75b4bfcd2bef6a83cb9b3f jdk7-b113 376ac153078dd3b5f6d4a0981feee092c1492c96 jdk7-b116 1320fb3bb588298c79716bd2d10b5b4afacb9370 jdk7-b117 19a2fab3f91a275f90791c15d1c21a24e820ff2d jdk7-b118 +41fa02b3663795ddf529690df7aa6714210093ec jdk7-b119 From c61a6186f39ec3d33f53148e980f55a68654aebc Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Mon, 22 Nov 2010 14:57:23 -0800 Subject: [PATCH 45/89] Added tag jdk7-b119 for changeset 7f370da0805b --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 24dc9213f13..02e3d70214f 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -93,3 +93,4 @@ e250cef36ea05e627e7e6f7d75e5e19f529e2ba3 jdk7-b114 1657ed4e1d86c8aa2028ab5a41f9da1ac4a369f8 jdk7-b116 3e6726bbf80a4254ecd01051c8ed77ee19325e46 jdk7-b117 b357910aa04aead2a16b6d6ff395a8df4b51d1dd jdk7-b118 +ecab7eefb8f2326fd90fb632f47f1b6f81e928f8 jdk7-b119 From dac44785bf75b4140f784c5710ce28ebfcee8084 Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Mon, 22 Nov 2010 14:57:34 -0800 Subject: [PATCH 46/89] Added tag jdk7-b119 for changeset 2322464ada6f --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 3e96fb4dfbe..3b8426e7040 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -93,3 +93,4 @@ e4e7408cdc5b3d91d39161e1e94aad576ecc2dcd jdk7-b114 857bfcea3f30cb5f4ae96f46a53ae1c772f9b0e5 jdk7-b116 2129a046f117547fc8a5cb3397a767e6d528f5b6 jdk7-b117 c491eec0acc73fa41b77e1619ed03e56d8a75b83 jdk7-b118 +814561077c448292f78de461b6de5d78d57c2089 jdk7-b119 From 1558c2f9b147276ebf17aebbdc10b67210da6b1a Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Mon, 22 Nov 2010 16:03:13 -0800 Subject: [PATCH 47/89] 6858865: Fix for 6728376 causes regression if the size of "data" is 0 and malloc returns Null for 0-length Don't throw OOME when in or out buffer size is 0 length Reviewed-by: alanb --- jdk/src/share/native/java/util/zip/Deflater.c | 13 +++++++++---- jdk/src/share/native/java/util/zip/Inflater.c | 6 ++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/jdk/src/share/native/java/util/zip/Deflater.c b/jdk/src/share/native/java/util/zip/Deflater.c index f0923c447ba..e12d540a544 100644 --- a/jdk/src/share/native/java/util/zip/Deflater.c +++ b/jdk/src/share/native/java/util/zip/Deflater.c @@ -132,14 +132,17 @@ Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this, jlong addr, in_buf = (jbyte *) malloc(this_len); if (in_buf == 0) { - JNU_ThrowOutOfMemoryError(env, 0); + // Throw OOME only when length is not zero + if (this_len != 0) + JNU_ThrowOutOfMemoryError(env, 0); return 0; } (*env)->GetByteArrayRegion(env, this_buf, this_off, this_len, in_buf); out_buf = (jbyte *) malloc(len); if (out_buf == 0) { free(in_buf); - JNU_ThrowOutOfMemoryError(env, 0); + if (len != 0) + JNU_ThrowOutOfMemoryError(env, 0); return 0; } @@ -173,7 +176,8 @@ Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this, jlong addr, jboolean finish = (*env)->GetBooleanField(env, this, finishID); in_buf = (jbyte *) malloc(this_len); if (in_buf == 0) { - JNU_ThrowOutOfMemoryError(env, 0); + if (this_len != 0) + JNU_ThrowOutOfMemoryError(env, 0); return 0; } (*env)->GetByteArrayRegion(env, this_buf, this_off, this_len, in_buf); @@ -181,7 +185,8 @@ Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this, jlong addr, out_buf = (jbyte *) malloc(len); if (out_buf == 0) { free(in_buf); - JNU_ThrowOutOfMemoryError(env, 0); + if (len != 0) + JNU_ThrowOutOfMemoryError(env, 0); return 0; } diff --git a/jdk/src/share/native/java/util/zip/Inflater.c b/jdk/src/share/native/java/util/zip/Inflater.c index 78619f4ac0f..c1667a022e8 100644 --- a/jdk/src/share/native/java/util/zip/Inflater.c +++ b/jdk/src/share/native/java/util/zip/Inflater.c @@ -135,7 +135,8 @@ Java_java_util_zip_Inflater_inflateBytes(JNIEnv *env, jobject this, jlong addr, in_buf = (jbyte *) malloc(in_len); if (in_buf == 0) { - JNU_ThrowOutOfMemoryError(env, 0); + if (in_len != 0) + JNU_ThrowOutOfMemoryError(env, 0); return 0; } (*env)->GetByteArrayRegion(env, this_buf, this_off, in_len, in_buf); @@ -143,7 +144,8 @@ Java_java_util_zip_Inflater_inflateBytes(JNIEnv *env, jobject this, jlong addr, out_buf = (jbyte *) malloc(len); if (out_buf == 0) { free(in_buf); - JNU_ThrowOutOfMemoryError(env, 0); + if (len != 0) + JNU_ThrowOutOfMemoryError(env, 0); return 0; } From bf54a0ce83eba4c379f01cc5e978c468c586cd52 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Mon, 22 Nov 2010 16:12:23 -0800 Subject: [PATCH 48/89] 7001434: charset name for Cp833 should be x-IBM833 Changed the name to x-IBM833 in extsbcs Reviewed-by: alanb --- jdk/make/tools/CharsetMapping/extsbcs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/make/tools/CharsetMapping/extsbcs b/jdk/make/tools/CharsetMapping/extsbcs index e66fe5bbb1c..ac24dbe7a7d 100644 --- a/jdk/make/tools/CharsetMapping/extsbcs +++ b/jdk/make/tools/CharsetMapping/extsbcs @@ -32,7 +32,7 @@ IBM297 IBM297 Cp297 false sun.nio.cs.ext IBM420 IBM420 Cp420 false sun.nio.cs.ext IBM424 IBM424 Cp424 false sun.nio.cs.ext IBM500 IBM500 Cp500 false sun.nio.cs.ext -IBM833 IBM833 Cp833 false sun.nio.cs.ext +IBM833 x-IBM833 Cp833 false sun.nio.cs.ext IBM838 IBM-Thai Cp838 false sun.nio.cs.ext IBM856 x-IBM856 Cp856 false sun.nio.cs.ext IBM860 IBM860 Cp860 false sun.nio.cs.ext From 3e65664acfe744e53bde296e3a57987e7839146d Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 23 Nov 2010 11:08:43 +0000 Subject: [PATCH 49/89] 6995200: JDK 7 compiler crashes when type-variable is inferred from expected primitive type 15.12.2.8 should use boxing when expected type in assignment context is a primitive type Reviewed-by: jjg --- .../com/sun/tools/javac/code/Types.java | 11 +++ .../com/sun/tools/javac/comp/Infer.java | 3 +- .../generics/inference/6638712/T6638712a.java | 2 +- .../generics/inference/6995200/T6995200.java | 67 +++++++++++++++++++ 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 langtools/test/tools/javac/generics/inference/6995200/T6995200.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index d9bd17efd92..e8e6935028f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -2772,6 +2772,8 @@ public class Types { public Type glb(Type t, Type s) { if (s == null) return t; + else if (t.isPrimitive() || s.isPrimitive()) + return syms.errType; else if (isSubtypeNoCapture(t, s)) return t; else if (isSubtypeNoCapture(s, t)) @@ -2927,6 +2929,15 @@ public class Types { return reader.enterClass(syms.boxedName[t.tag]); } + /** + * Return the boxed type if 't' is primitive, otherwise return 't' itself. + */ + public Type boxedTypeOrType(Type t) { + return t.isPrimitive() ? + boxedClass(t).type : + t; + } + /** * Return the primitive type corresponding to a boxed type. */ diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java index 0e60e5e7fd9..fb117b02999 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java @@ -305,7 +305,8 @@ public class Infer { uv.hibounds = hibounds.toList(); } Type qtype1 = types.subst(that.qtype, that.tvars, undetvars); - if (!types.isSubtype(qtype1, to)) { + if (!types.isSubtype(qtype1, + qtype1.tag == UNDETVAR ? types.boxedTypeOrType(to) : to)) { throw unambiguousNoInstanceException .setMessage("infer.no.conforming.instance.exists", that.tvars, that.qtype, to); diff --git a/langtools/test/tools/javac/generics/inference/6638712/T6638712a.java b/langtools/test/tools/javac/generics/inference/6638712/T6638712a.java index b6f70f486de..768e99f15d7 100644 --- a/langtools/test/tools/javac/generics/inference/6638712/T6638712a.java +++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712a.java @@ -10,7 +10,7 @@ import java.util.*; class T6638712a { - Comparator compound(Iterable> it) {} + Comparator compound(Iterable> it) { return null; } public void test(List> x) { Comparator c3 = compound(x); diff --git a/langtools/test/tools/javac/generics/inference/6995200/T6995200.java b/langtools/test/tools/javac/generics/inference/6995200/T6995200.java new file mode 100644 index 00000000000..0afc684377e --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/6995200/T6995200.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2010, 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 6995200 + * + * @summary JDK 7 compiler crashes when type-variable is inferred from expected primitive type + * @author mcimadamore + * @compile T6995200.java + * + */ + +import java.util.List; + +class T6995200 { + static T getValue() { + return null; + } + + void test() { + byte v1 = getValue(); + short v2 = getValue(); + int v3 = getValue(); + long v4 = getValue(); + float v5 = getValue(); + double v6 = getValue(); + String v7 = getValue(); + String[] v8 = getValue(); + List v9 = getValue(); + List[] v10 = getValue(); + List v11 = getValue(); + List[] v12 = getValue(); + List v13 = getValue(); + List[] v14 = getValue(); + List v15 = getValue(); + List[] v16 = getValue(); + X v17 = getValue(); + X[] v18 = getValue(); + List v19 = getValue(); + List[] v20 = getValue(); + List v21 = getValue(); + List[] v22 = getValue(); + List v23 = getValue(); + List[] v24 = getValue(); + } +} From 9abcddfc694dfdf9214639df8f09f09db21fd59d Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Tue, 23 Nov 2010 10:04:15 -0800 Subject: [PATCH 50/89] 7002248: Update urls for jaxp and jaxws source downloads Reviewed-by: darcy --- jaxp/jaxp.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jaxp/jaxp.properties b/jaxp/jaxp.properties index 296ed0b08f2..b900f60724e 100644 --- a/jaxp/jaxp.properties +++ b/jaxp/jaxp.properties @@ -28,10 +28,10 @@ drops.master.copy.base=${drops.dir} jaxp_src.bundle.name=jaxp-1_4_4.zip jaxp_src.bundle.md5.checksum=2c40a758392c4abf2d59f355240df46a jaxp_src.master.bundle.dir=${drops.master.copy.base} -jaxp_src.master.bundle.url.base=https://jaxp.dev.java.net/files/documents/913/152561 +jaxp_src.master.bundle.url.base=https://java.net/downloads/jaxp/jdk7 #jaxp_tests.bundle.name=jaxp-unittests-1_4_4.zip #jaxp_tests.bundle.md5.checksum=51845e38b02920cf5374d0331ab3a4ee #jaxp_tests.master.bundle.dir=${drops.master.copy.base} -#jaxp_tests.master.bundle.url.base=https://jaxp.dev.java.net/files/documents/913/152562 +#jaxp_tests.master.bundle.url.base=https://java.net/downloads/jaxp/jdk7 From 9897a1dfae3d39870b8d5215ad1bee5d32aa1164 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Tue, 23 Nov 2010 10:04:43 -0800 Subject: [PATCH 51/89] 7002248: Update urls for jaxp and jaxws source downloads Reviewed-by: darcy --- jaxws/jaxws.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jaxws/jaxws.properties b/jaxws/jaxws.properties index 3314617b2d4..9914d2a2620 100644 --- a/jaxws/jaxws.properties +++ b/jaxws/jaxws.properties @@ -28,14 +28,14 @@ drops.master.copy.base=${drops.dir} jaxws_src.bundle.name= jdk7-jaxws2_2-2010_08_19.zip jaxws_src.bundle.md5.checksum=8775ccefd3b4fa2dde5155ec4b7e4ceb jaxws_src.master.bundle.dir=${drops.master.copy.base} -jaxws_src.master.bundle.url.base=https://jax-ws.dev.java.net/files/documents/4202/152532 +jaxws_src.master.bundle.url.base=https://java.net/downloads/jax-ws/JDK7 jaf_src.bundle.name=jdk7-jaf-2010_08_19.zip jaf_src.bundle.md5.checksum=18d15dfd71117daadb332af003d08212 jaf_src.master.bundle.dir=${drops.master.copy.base} -jaf_src.master.bundle.url.base=https://jax-ws.dev.java.net/files/documents/4202/152336 +jaf_src.master.bundle.url.base=https://java.net/downloads/jax-ws/JDK7 #jaxws_tests.bundle.name=jdk7-jaxws-tests-2009_08_28.zip #jaxws_tests.master.bundle.dir=${drops.master.copy.base} -#jaxws_tests.master.bundle.url.base=http://kenai.com/projects/jdk7-drops/downloads/download +#jaxws_tests.master.bundle.url.base=https://java.net/downloads/jax-ws/JDK7 From df07a3e457cb1322c23bb6b07872372bd489964f Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 23 Nov 2010 13:32:29 -0800 Subject: [PATCH 52/89] 6942366: javadoc no longer inherits doc from sourcepath Reviewed-by: mcimadamore --- .../sun/tools/javadoc/JavadocClassReader.java | 1 + .../test/tools/javadoc/6942366/T6942366.java | 134 ++++++++++++++++++ .../test/tools/javadoc/6942366/Test.java | 28 ++++ .../test/tools/javadoc/6942366/p/Base.java | 30 ++++ 4 files changed, 193 insertions(+) create mode 100644 langtools/test/tools/javadoc/6942366/T6942366.java create mode 100644 langtools/test/tools/javadoc/6942366/Test.java create mode 100644 langtools/test/tools/javadoc/6942366/p/Base.java diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java index 8e1b4fbb5f4..e32da303eb0 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java @@ -62,6 +62,7 @@ class JavadocClassReader extends ClassReader { private JavadocClassReader(Context context) { super(context, true); docenv = DocEnv.instance(context); + preferSource = true; } /** diff --git a/langtools/test/tools/javadoc/6942366/T6942366.java b/langtools/test/tools/javadoc/6942366/T6942366.java new file mode 100644 index 00000000000..c5199981e66 --- /dev/null +++ b/langtools/test/tools/javadoc/6942366/T6942366.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2010, 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 6942366 + * @summary javadoc no longer inherits doc from sourcepath + * @build p.Base Test + * @run main T6942366 + */ + +import java.io.*; +import java.util.*; + +public class T6942366 { + public static void main(String... args) throws Exception { + new T6942366().run(); + } + + File testSrc; + File testClasses; + int count; + int errors; + + void run() throws Exception { + testSrc = new File(System.getProperty("test.src")); + testClasses = new File(System.getProperty("test.classes")); + + test(true, false); + test(false, true); + test(true, true); + + if (errors > 0) + throw new Exception(errors + " errors found"); + } + + void test(boolean useSourcePath, boolean useClassPath) throws Exception { + System.out.println("test " + (++count) + " sp:" + useSourcePath + " cp:" + useClassPath); + File testDir = new File("test" + count); + testDir.mkdirs(); + + List args = new ArrayList(); + //args.add("-verbose"); + args.add("-d"); + args.add(testDir.getPath()); + if (useSourcePath) { + args.add("-sourcepath"); + args.add(testSrc.getPath()); + } + if (useClassPath) { + args.add("-classpath"); + args.add(testClasses.getPath()); + } else { + // override classpath to avoid stuff jtreg might have put on papth + args.add("-classpath"); + args.add("."); + } + + // use a very simple bootclasspath to avoid stuff jtreg might have put on path + File javaHome = new File(System.getProperty("java.home")); + File rt_jar = new File(javaHome, "lib/rt.jar"); + if (!rt_jar.exists()) + throw new Exception("rt.jar not found"); + args.add("-bootclasspath"); + args.add(rt_jar.getPath()); + + args.add(new File(testSrc, "Test.java").getPath()); + System.out.println("javadoc: " + args); + + int rc = com.sun.tools.javadoc.Main.execute(args.toArray(new String[args.size()])); + if (rc != 0) + throw new Exception("unexpected exit from javadoc, rc=" + rc); + + if (useSourcePath && useClassPath) { + long srcLastMod = new File(testSrc, "Test.java").lastModified(); + long classLastMod = new File(testClasses, "Test.class").lastModified(); + System.out.println("Test.java last modified: " + new Date(srcLastMod)); + System.out.println("Test.class last modified: " + new Date(classLastMod)); + System.out.println((srcLastMod > classLastMod ? "source" : "class") + " is newer"); + } + + String s = "javadoc-for-Base.m"; + boolean expect = useSourcePath; + boolean found = contains(new File(testDir, "Test.html"), s); + if (found) { + if (expect) + System.out.println("javadoc content \"" + s + "\" found, as expected"); + else + error("javadoc content \"" + s + "\" found unexpectedly"); + } else { + if (expect) + error("javadoc content \"" + s + "\" not found"); + else + System.out.println("javadoc content \"" + s + "\" not found, as expected"); + } + + System.out.println(); + } + + boolean contains(File f, String s) throws Exception { + byte[] buf = new byte[(int) f.length()]; + try (DataInputStream in = new DataInputStream(new FileInputStream(f))) { + in.readFully(buf); + } + return new String(buf).contains(s); + } + + void error(String msg) { + System.out.println("Error: " + msg); + errors++; + } + +} + diff --git a/langtools/test/tools/javadoc/6942366/Test.java b/langtools/test/tools/javadoc/6942366/Test.java new file mode 100644 index 00000000000..a9ac75624e4 --- /dev/null +++ b/langtools/test/tools/javadoc/6942366/Test.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2010, 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. + */ + +public class Test extends p.Base { + // overrides Base.m + public void m() { } +} + diff --git a/langtools/test/tools/javadoc/6942366/p/Base.java b/langtools/test/tools/javadoc/6942366/p/Base.java new file mode 100644 index 00000000000..df70cad735c --- /dev/null +++ b/langtools/test/tools/javadoc/6942366/p/Base.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2010, 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. + */ + +package p; + +public class Base { + /** javadoc-for-Base.m. */ + public void m() { } +} + From cba5c7df9f8e590ec6997bd4545744345418e4b2 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 23 Nov 2010 15:28:34 -0800 Subject: [PATCH 53/89] 7002346: javap test relies on location of scratch directory Reviewed-by: ksrini --- langtools/test/tools/javap/T6729471.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/langtools/test/tools/javap/T6729471.java b/langtools/test/tools/javap/T6729471.java index d55017f0845..00d4860a99d 100644 --- a/langtools/test/tools/javap/T6729471.java +++ b/langtools/test/tools/javap/T6729471.java @@ -39,6 +39,8 @@ public class T6729471 } void run() { + File testClasses = new File(System.getProperty("test.classes")); + // simple class verify("java.util.Map", "public abstract boolean containsKey(java.lang.Object)"); @@ -48,11 +50,11 @@ public class T6729471 "public abstract K getKey()"); // file name - verify("../classes/tools/javap/T6729471.class", + verify(new File(testClasses, "T6729471.class").getPath(), "public static void main(java.lang.String...)"); // file url - verify("file:../classes/tools/javap/T6729471.class", + verify(new File(testClasses, "T6729471.class").toURI().toString(), "public static void main(java.lang.String...)"); // jar url: rt.jar From 9f743252e514dc0d2489c1bcbcdc03b17bc84c15 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Wed, 24 Nov 2010 07:43:06 +0800 Subject: [PATCH 54/89] 7002036: ktab return code changes on a error case Reviewed-by: valeriep --- .../security/krb5/internal/tools/Ktab.java | 4 +- jdk/test/sun/security/krb5/tools/ktarg.sh | 67 +++++++++++++++++++ 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 jdk/test/sun/security/krb5/tools/ktarg.sh diff --git a/jdk/src/windows/classes/sun/security/krb5/internal/tools/Ktab.java b/jdk/src/windows/classes/sun/security/krb5/internal/tools/Ktab.java index 9bcc935a1ca..216c3a30c12 100644 --- a/jdk/src/windows/classes/sun/security/krb5/internal/tools/Ktab.java +++ b/jdk/src/windows/classes/sun/security/krb5/internal/tools/Ktab.java @@ -129,7 +129,7 @@ public class Ktab { ktab.deleteEntry(); break; default: - ktab.printHelp(); + ktab.error("A command must be provided"); } } @@ -232,7 +232,7 @@ public class Ktab { append = true; break; default: - printHelp(); + error("Unknown command: " + args[i]); break; } } else { // optional standalone arguments diff --git a/jdk/test/sun/security/krb5/tools/ktarg.sh b/jdk/test/sun/security/krb5/tools/ktarg.sh new file mode 100644 index 00000000000..ed78b5807ce --- /dev/null +++ b/jdk/test/sun/security/krb5/tools/ktarg.sh @@ -0,0 +1,67 @@ +# +# Copyright (c) 2010, 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 7002036 +# @summary ktab return code changes on a error case +# @run shell ktarg.sh +# + +if [ "${TESTJAVA}" = "" ] ; then + JAVAC_CMD=`which javac` + TESTJAVA=`dirname $JAVAC_CMD`/.. +fi + +if [ "${TESTSRC}" = "" ] ; then + TESTSRC="." +fi + +OS=`uname -s` +case "$OS" in + CYGWIN* ) + FS="/" + ;; + Windows_* ) + FS="\\" + ;; + * ) + FS="/" + echo "Unsupported system!" + exit 0; + ;; +esac + +KEYTAB=ktarg.tmp + +rm $KEYTAB 2> /dev/null +KTAB="${TESTJAVA}${FS}bin${FS}ktab -k $KEYTAB" + +$KTAB -a me mine || exit 1 + +$KTAB -hello +if [ $? = 0 ]; then exit 2; fi + +$KTAB +if [ $? = 0 ]; then exit 3; fi + +exit 0 From fac39410b5ff1d9bc9a549bdffdb1037424b0e4f Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Tue, 23 Nov 2010 16:52:39 -0800 Subject: [PATCH 55/89] 6452854: Provide a flag to print the java configuration Reviewed-by: darcy, mchung, sherman, dholmes, mduigou --- jdk/src/share/bin/java.c | 52 ++++- .../classes/sun/launcher/LauncherHelper.java | 197 ++++++++++++++++++ .../launcher/resources/launcher.properties | 12 +- jdk/test/tools/launcher/Settings.java | 137 ++++++++++++ 4 files changed, 391 insertions(+), 7 deletions(-) create mode 100644 jdk/test/tools/launcher/Settings.java diff --git a/jdk/src/share/bin/java.c b/jdk/src/share/bin/java.c index 01eeb2a0547..e02b8ac8bb0 100644 --- a/jdk/src/share/bin/java.c +++ b/jdk/src/share/bin/java.c @@ -65,6 +65,7 @@ static jboolean printVersion = JNI_FALSE; /* print and exit */ static jboolean showVersion = JNI_FALSE; /* print but continue */ static jboolean printUsage = JNI_FALSE; /* print and exit*/ static jboolean printXUsage = JNI_FALSE; /* print and exit*/ +static char *showSettings = NULL; /* print but continue */ static const char *_program_name; static const char *_launcher_name; @@ -109,6 +110,7 @@ static void SetApplicationClassPath(const char**); static void PrintJavaVersion(JNIEnv *env, jboolean extraLF); static void PrintUsage(JNIEnv* env, jboolean doXUsage); +static void ShowSettings(JNIEnv* env, char *optString); static void SetPaths(int argc, char **argv); @@ -157,6 +159,7 @@ static jboolean IsWildCardEnabled(); * create a new thread to invoke JVM. See 6316197 for more information. */ static jlong threadStackSize = 0; /* stack size of the new thread */ +static jlong heapSize = 0; /* heap size */ int JNICALL JavaMain(void * args); /* entry point */ @@ -376,6 +379,10 @@ JavaMain(void * _args) } } + if (showSettings != NULL) { + ShowSettings(env, showSettings); + CHECK_EXCEPTION_LEAVE(0); + } /* If the user specified neither a class name nor a JAR file */ if (printXUsage || printUsage || (jarfile == 0 && classname == 0)) { PrintUsage(env, printXUsage); @@ -611,7 +618,7 @@ CheckJvmType(int *pargc, char ***argv, jboolean speculative) { /* copied from HotSpot function "atomll()" */ static int -parse_stack_size(const char *s, jlong *result) { +parse_size(const char *s, jlong *result) { jlong n = 0; int args_read = sscanf(s, jlong_format_specifier(), &n); if (args_read != 1) { @@ -673,10 +680,17 @@ AddOption(char *str, void *info) options[numOptions++].extraInfo = info; if (JLI_StrCCmp(str, "-Xss") == 0) { - jlong tmp; - if (parse_stack_size(str + 4, &tmp)) { - threadStackSize = tmp; - } + jlong tmp; + if (parse_size(str + 4, &tmp)) { + threadStackSize = tmp; + } + } + + if (JLI_StrCCmp(str, "-Xmx") == 0) { + jlong tmp; + if (parse_size(str + 4, &tmp)) { + heapSize = tmp; + } } } @@ -1014,6 +1028,13 @@ ParseArguments(int *pargc, char ***pargv, char **pjarfile, } else if (JLI_StrCmp(arg, "-X") == 0) { printXUsage = JNI_TRUE; return JNI_TRUE; +/* + * The following case checks for -XshowSettings OR -XshowSetting:SUBOPT. + * In the latter case, any SUBOPT value not recognized will default to "all" + */ + } else if (JLI_StrCmp(arg, "-XshowSettings") == 0 || + JLI_StrCCmp(arg, "-XshowSettings:") == 0) { + showSettings = arg; /* * The following case provide backward compatibility with old-style * command line options. @@ -1474,6 +1495,27 @@ PrintJavaVersion(JNIEnv *env, jboolean extraLF) (*env)->CallStaticVoidMethod(env, ver, print); } +/* + * Prints all the Java settings, see the java implementation for more details. + */ +static void +ShowSettings(JNIEnv *env, char *optString) +{ + jclass cls; + jmethodID showSettingsID; + jstring joptString; + NULL_CHECK(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper")); + NULL_CHECK(showSettingsID = (*env)->GetStaticMethodID(env, cls, + "showSettings", "(ZLjava/lang/String;JJZ)V")); + joptString = (*env)->NewStringUTF(env, optString); + (*env)->CallStaticVoidMethod(env, cls, showSettingsID, + JNI_TRUE, + joptString, + (jlong)heapSize, + (jlong)threadStackSize, + ServerClassMachine()); +} + /* * Prints default usage or the Xusage message, see sun.launcher.LauncherHelper.java */ diff --git a/jdk/src/share/classes/sun/launcher/LauncherHelper.java b/jdk/src/share/classes/sun/launcher/LauncherHelper.java index cba795968c6..dbaebc0ee86 100644 --- a/jdk/src/share/classes/sun/launcher/LauncherHelper.java +++ b/jdk/src/share/classes/sun/launcher/LauncherHelper.java @@ -44,8 +44,16 @@ import java.io.IOException; import java.io.PrintStream; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.math.BigDecimal; +import java.math.MathContext; +import java.math.RoundingMode; import java.util.ResourceBundle; import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.Properties; import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.jar.Manifest; @@ -59,6 +67,17 @@ public enum LauncherHelper { private static StringBuilder outBuf = new StringBuilder(); private static ResourceBundle javarb = null; + + private static final String INDENT = " "; + private static final String VM_SETTINGS = "VM settings:"; + private static final String PROP_SETTINGS = "Property settings:"; + private static final String LOCALE_SETTINGS = "Locale settings:"; + + private static final long K = 1024; + private static final long M = K * K; + private static final long G = M * K; + private static final long T = G * K; + private static synchronized ResourceBundle getLauncherResourceBundle() { if (javarb == null) { javarb = ResourceBundle.getBundle(defaultBundleName); @@ -66,6 +85,184 @@ public enum LauncherHelper { return javarb; } + /* + * A method called by the launcher to print out the standard settings, + * by default -XshowSettings is equivalent to -XshowSettings:all, + * Specific information may be gotten by using suboptions with possible + * values vm, properties and locale. + * + * printToStderr: choose between stdout and stderr + * + * optionFlag: specifies which options to print default is all other + * possible values are vm, properties, locale. + * + * maxHeapSize: in bytes, as set by the launcher, a zero-value indicates + * this code should determine this value, using a suitable method. + * + * stackSize: in bytes, as set by the launcher, a zero-value indicates + * this code determine this value, using a suitable method. + */ + static void showSettings(boolean printToStderr, String optionFlag, + long maxHeapSize, long stackSize, boolean isServer) { + + PrintStream ostream = (printToStderr) ? System.err : System.out; + String opts[] = optionFlag.split(":"); + String optStr = (opts.length > 1 && opts[1] != null) + ? opts[1].trim() + : "all"; + switch (optStr) { + case "vm": + printVmSettings(ostream, maxHeapSize, stackSize, isServer); + break; + case "properties": + printProperties(ostream); + break; + case "locale": + printLocale(ostream); + break; + default: + printVmSettings(ostream, maxHeapSize, stackSize, isServer); + printProperties(ostream); + printLocale(ostream); + break; + } + } + + /* + * prints the main vm settings subopt/section + */ + private static void printVmSettings(PrintStream ostream, long maxHeapSize, + long stackSize, boolean isServer) { + + ostream.println(VM_SETTINGS); + if (stackSize != 0L) { + ostream.println(INDENT + "Stack Size: " + scaleValue(stackSize)); + } + if (maxHeapSize != 0L) { + ostream.println(INDENT + "Max. Heap Size: " + scaleValue(maxHeapSize)); + } else { + ostream.println(INDENT + "Max. Heap Size (Estimated): " + + scaleValue(Runtime.getRuntime().maxMemory())); + } + ostream.println(INDENT + "Ergonomics Machine Class: " + + ((isServer) ? "server" : "client")); + ostream.println(INDENT + "Using VM: " + + System.getProperty("java.vm.name")); + ostream.println(); + } + + /* + * scale the incoming values to a human readable form, represented as + * K, M, G and T, see java.c parse_size for the scaled values and + * suffixes. + */ + + private static String scaleValue(double v) { + MathContext mc2 = new MathContext(3, RoundingMode.HALF_EVEN); + + if (v >= K && v < M) { + return (new BigDecimal(v / K, mc2)).toPlainString() + "K"; + } else if (v >= M && v < G) { + return (new BigDecimal(v / M, mc2)).toPlainString() + "M"; + } else if (v >= G && v < T) { + return (new BigDecimal(v / G, mc2)).toPlainString() + "G"; + } else if (v >= T) { + return (new BigDecimal(v / T, mc2)).toPlainString() + "T"; + } else { + return String.format("%.0f", v); + } + } + + /* + * prints the properties subopt/section + */ + private static void printProperties(PrintStream ostream) { + Properties p = System.getProperties(); + ostream.println(PROP_SETTINGS); + List sortedPropertyKeys = new ArrayList<>(); + sortedPropertyKeys.addAll(p.stringPropertyNames()); + Collections.sort(sortedPropertyKeys); + for (String x : sortedPropertyKeys) { + printPropertyValue(ostream, x, p.getProperty(x)); + } + ostream.println(); + } + + private static boolean isPath(String key) { + return key.endsWith(".dirs") || key.endsWith(".path"); + } + + private static void printPropertyValue(PrintStream ostream, + String key, String value) { + ostream.print(INDENT + key + " = "); + if (key.equals("line.separator")) { + byte[] bytes = value.getBytes(); + for (byte b : bytes) { + switch (b) { + case 0xd: + ostream.print("CR "); + break; + case 0xa: + ostream.print("LF "); + break; + default: + ostream.printf("0x%02X", b & 0xff); + break; + } + } + ostream.println(); + return; + } + if (!isPath(key)) { + ostream.println(value); + return; + } + // pretty print the path values as a list + String[] values = value.split(System.getProperty("path.separator")); + int len = values.length; + for (int i = 0 ; i < len ; i++) { + if (i == 0) { // first line treated specially + ostream.println(values[i]); + } else { // following lines prefix with indents + ostream.print(INDENT + INDENT); + ostream.println(values[i]); + } + } + } + + /* + * prints the locale subopt/section + */ + private static void printLocale(PrintStream ostream) { + Locale locale = Locale.getDefault(); + ostream.println(LOCALE_SETTINGS); + ostream.println(INDENT + "default locale = " + locale.getDisplayLanguage()); + printLocales(ostream); + ostream.println(); + } + + private static void printLocales(PrintStream ostream) { + Locale[] locales = Locale.getAvailableLocales(); + final int len = locales == null ? 0 : locales.length; + if (len < 1 ) { + return; + } + ostream.print(INDENT + "available locales = "); + final int last = len - 1 ; + for (int i = 0; i < last ; i++) { + ostream.print(locales[i]); + if (i != last) { + ostream.print(", "); + } + // print columns of 8 + if ((i + 1) % 8 == 0) { + ostream.println(); + ostream.print(INDENT + INDENT); + } + } + ostream.println(locales[last]); + } + /** * A private helper method to get a localized message and also * apply any arguments that we might pass. diff --git a/jdk/src/share/classes/sun/launcher/resources/launcher.properties b/jdk/src/share/classes/sun/launcher/resources/launcher.properties index e89d147a5bb..17ba48a1384 100644 --- a/jdk/src/share/classes/sun/launcher/resources/launcher.properties +++ b/jdk/src/share/classes/sun/launcher/resources/launcher.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2010, 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 @@ -97,7 +97,15 @@ java.launcher.X.usage=\ \ -Xcheck:jni perform additional checks for JNI functions\n\ \ -Xshare:off do not attempt to use shared class data\n\ \ -Xshare:auto use shared class data if possible (default)\n\ -\ -Xshare:on require using shared class data, otherwise fail.\n\n\ +\ -Xshare:on require using shared class data, otherwise fail.\n\ +\ -XshowSettings show all settings and continue\n\ +\ -XshowSettings:all\n\ +\ show all settings and continue\n\ +\ -XshowSettings:vm show all vm related settings and continue\n\ +\ -XshowSettings:properties\n\ +\ show all property settings and continue\n\ +\ -XshowSettings:locale\n\ +\ show all locale related settings and continue\n\n\ The -X options are non-standard and subject to change without notice.\n java.launcher.cls.error1=\ diff --git a/jdk/test/tools/launcher/Settings.java b/jdk/test/tools/launcher/Settings.java new file mode 100644 index 00000000000..b78443acc6b --- /dev/null +++ b/jdk/test/tools/launcher/Settings.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2010, 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. + */ +import java.io.File; +import java.io.IOException; + +/* + * @test + * @bug 6994753 + * @summary tests -XshowSettings options + * @compile -XDignore.symbol.file Settings.java TestHelper.java + * @run main Settings + * @author ksrini + */ +public class Settings { + private static File testJar = null; + + static void init() throws IOException { + if (testJar != null) { + return; + } + testJar = new File("test.jar"); + StringBuilder tsrc = new StringBuilder(); + tsrc.append("public static void main(String... args) {\n"); + tsrc.append(" for (String x : args) {\n"); + tsrc.append(" System.out.println(x);\n"); + tsrc.append(" }\n"); + tsrc.append("}\n"); + TestHelper.createJar(testJar, tsrc.toString()); + } + + static void checkContains(TestHelper.TestResult tr, String str) { + if (!tr.contains(str)) { + System.out.println(tr); + throw new RuntimeException(str + " not found"); + } + } + + static void checkNoContains(TestHelper.TestResult tr, String str) { + if (tr.contains(str)) { + System.out.println(tr.status); + throw new RuntimeException(str + " found"); + } + } + + private static final String VM_SETTINGS = "VM settings:"; + private static final String PROP_SETTINGS = "Property settings:"; + private static final String LOCALE_SETTINGS = "Locale settings:"; + + static void containsAllOptions(TestHelper.TestResult tr) { + checkContains(tr, VM_SETTINGS); + checkContains(tr, PROP_SETTINGS); + checkContains(tr, LOCALE_SETTINGS); + } + + static void runTestOptionDefault() throws IOException { + TestHelper.TestResult tr = null; + tr = TestHelper.doExec(TestHelper.javaCmd, "-Xmx512m", "-Xss128k", + "-XshowSettings", "-jar", testJar.getAbsolutePath()); + containsAllOptions(tr); + if (!tr.isOK()) { + System.out.println(tr.status); + throw new RuntimeException("test fails"); + } + } + + static void runTestOptionAll() throws IOException { + init(); + TestHelper.TestResult tr = null; + tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettings:all"); + containsAllOptions(tr); + } + + static void runTestOptionVM() throws IOException { + TestHelper.TestResult tr = null; + tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettings:vm"); + checkContains(tr, VM_SETTINGS); + checkNoContains(tr, PROP_SETTINGS); + checkNoContains(tr, LOCALE_SETTINGS); + } + + static void runTestOptionProperty() throws IOException { + TestHelper.TestResult tr = null; + tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettings:properties"); + checkNoContains(tr, VM_SETTINGS); + checkContains(tr, PROP_SETTINGS); + checkNoContains(tr, LOCALE_SETTINGS); + } + + static void runTestOptionLocale() throws IOException { + TestHelper.TestResult tr = null; + tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettings:locale"); + checkNoContains(tr, VM_SETTINGS); + checkNoContains(tr, PROP_SETTINGS); + checkContains(tr, LOCALE_SETTINGS); + } + + static void runTestBadOptions() throws IOException { + TestHelper.TestResult tr = null; + tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettingsBadOption"); + checkNoContains(tr, VM_SETTINGS); + checkNoContains(tr, PROP_SETTINGS); + checkNoContains(tr, LOCALE_SETTINGS); + checkContains(tr, "Unrecognized option: -XshowSettingsBadOption"); + } + public static void main(String... args) { + try { + runTestOptionAll(); + runTestOptionDefault(); + runTestOptionVM(); + runTestOptionProperty(); + runTestOptionLocale(); + runTestBadOptions(); + } catch (IOException ioe) { + throw new RuntimeException(ioe); + } + } +} From b6b4b5086c410d7fdf637a34cbda74c204cc9a41 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 24 Nov 2010 09:51:31 +0000 Subject: [PATCH 56/89] 6878369: (ch) AsynchronousSocketChannel read/write methods that specify timeouts should not throw IAE Reviewed-by: forax --- .../channels/AsynchronousSocketChannel.java | 21 ++-- .../nio/ch/AsynchronousSocketChannelImpl.java | 4 - .../AsynchronousSocketChannel/Basic.java | 101 ++++++++++-------- 3 files changed, 65 insertions(+), 61 deletions(-) diff --git a/jdk/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java b/jdk/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java index d37bd2efc46..6d04f4f52a2 100644 --- a/jdk/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java +++ b/jdk/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java @@ -110,7 +110,8 @@ import java.nio.ByteBuffer; * state of the {@link ByteBuffer}, or the sequence of buffers, for the I/O * operation is not defined. Buffers should be discarded or at least care must * be taken to ensure that the buffers are not accessed while the channel remains - * open. + * open. All methods that accept timeout parameters treat values less than or + * equal to zero to mean that the I/O operation does not timeout. * * @since 1.7 */ @@ -367,7 +368,7 @@ public abstract class AsynchronousSocketChannel * @param dst * The buffer into which bytes are to be transferred * @param timeout - * The timeout, or {@code 0L} for no timeout + * The maximum time for the I/O operation to complete * @param unit * The time unit of the {@code timeout} argument * @param attachment @@ -376,8 +377,7 @@ public abstract class AsynchronousSocketChannel * The handler for consuming the result * * @throws IllegalArgumentException - * If the {@code timeout} parameter is negative or the buffer is - * read-only + * If the buffer is read-only * @throws ReadPendingException * If a read operation is already in progress on this channel * @throws NotYetConnectedException @@ -471,7 +471,7 @@ public abstract class AsynchronousSocketChannel * The maximum number of buffers to be accessed; must be non-negative * and no larger than {@code dsts.length - offset} * @param timeout - * The timeout, or {@code 0L} for no timeout + * The maximum time for the I/O operation to complete * @param unit * The time unit of the {@code timeout} argument * @param attachment @@ -483,8 +483,7 @@ public abstract class AsynchronousSocketChannel * If the pre-conditions for the {@code offset} and {@code length} * parameter aren't met * @throws IllegalArgumentException - * If the {@code timeout} parameter is negative, or a buffer is - * read-only + * If the buffer is read-only * @throws ReadPendingException * If a read operation is already in progress on this channel * @throws NotYetConnectedException @@ -524,7 +523,7 @@ public abstract class AsynchronousSocketChannel * @param src * The buffer from which bytes are to be retrieved * @param timeout - * The timeout, or {@code 0L} for no timeout + * The maximum time for the I/O operation to complete * @param unit * The time unit of the {@code timeout} argument * @param attachment @@ -532,8 +531,6 @@ public abstract class AsynchronousSocketChannel * @param handler * The handler for consuming the result * - * @throws IllegalArgumentException - * If the {@code timeout} parameter is negative * @throws WritePendingException * If a write operation is already in progress on this channel * @throws NotYetConnectedException @@ -623,7 +620,7 @@ public abstract class AsynchronousSocketChannel * The maximum number of buffers to be accessed; must be non-negative * and no larger than {@code srcs.length - offset} * @param timeout - * The timeout, or {@code 0L} for no timeout + * The maximum time for the I/O operation to complete * @param unit * The time unit of the {@code timeout} argument * @param attachment @@ -634,8 +631,6 @@ public abstract class AsynchronousSocketChannel * @throws IndexOutOfBoundsException * If the pre-conditions for the {@code offset} and {@code length} * parameter aren't met - * @throws IllegalArgumentException - * If the {@code timeout} parameter is negative * @throws WritePendingException * If a write operation is already in progress on this channel * @throws NotYetConnectedException diff --git a/jdk/src/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java b/jdk/src/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java index 2e06969253c..047bb61e865 100644 --- a/jdk/src/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java +++ b/jdk/src/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java @@ -235,8 +235,6 @@ abstract class AsynchronousSocketChannelImpl if (remoteAddress == null) throw new NotYetConnectedException(); - if (timeout < 0L) - throw new IllegalArgumentException("Negative timeout"); boolean hasSpaceToRead = isScatteringRead || dst.hasRemaining(); boolean shutdown = false; @@ -342,8 +340,6 @@ abstract class AsynchronousSocketChannelImpl if (isOpen()) { if (remoteAddress == null) throw new NotYetConnectedException(); - if (timeout < 0L) - throw new IllegalArgumentException("Negative timeout"); // check and update state synchronized (writeLock) { if (writeKilled) diff --git a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java index e8f23f46866..b38e34efbc0 100644 --- a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java +++ b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 4607272 6842687 + * @bug 4607272 6842687 6878369 * @summary Unit test for AsynchronousSocketChannel * @run main/timeout=600 Basic */ @@ -712,52 +712,57 @@ public class Basic { } static void testTimeout() throws Exception { + System.out.println("-- timeouts --"); + testTimeout(Integer.MIN_VALUE, TimeUnit.SECONDS); + testTimeout(-1L, TimeUnit.SECONDS); + testTimeout(0L, TimeUnit.SECONDS); + testTimeout(2L, TimeUnit.SECONDS); + } + + static void testTimeout(final long timeout, final TimeUnit unit) throws Exception { Server server = new Server(); AsynchronousSocketChannel ch = AsynchronousSocketChannel.open(); ch.connect(server.address()).get(); - System.out.println("-- timeout when reading --"); - ByteBuffer dst = ByteBuffer.allocate(512); final AtomicReference readException = new AtomicReference(); - // this read should timeout - ch.read(dst, 3, TimeUnit.SECONDS, (Void)null, - new CompletionHandler() - { + // this read should timeout if value is > 0 + ch.read(dst, timeout, unit, null, new CompletionHandler() { public void completed(Integer result, Void att) { - throw new RuntimeException("Should not complete"); + readException.set(new RuntimeException("Should not complete")); } public void failed(Throwable exc, Void att) { readException.set(exc); } }); - // wait for exception - while (readException.get() == null) { - Thread.sleep(100); + if (timeout > 0L) { + // wait for exception + while (readException.get() == null) { + Thread.sleep(100); + } + if (!(readException.get() instanceof InterruptedByTimeoutException)) + throw new RuntimeException("InterruptedByTimeoutException expected"); + + // after a timeout then further reading should throw unspecified runtime exception + boolean exceptionThrown = false; + try { + ch.read(dst); + } catch (RuntimeException x) { + exceptionThrown = true; + } + if (!exceptionThrown) + throw new RuntimeException("RuntimeException expected after timeout."); + } else { + Thread.sleep(1000); + Throwable exc = readException.get(); + if (exc != null) + throw new RuntimeException(exc); } - if (!(readException.get() instanceof InterruptedByTimeoutException)) - throw new RuntimeException("InterruptedByTimeoutException expected"); - - // after a timeout then further reading should throw unspecified runtime exception - boolean exceptionThrown = false; - try { - ch.read(dst); - } catch (RuntimeException x) { - exceptionThrown = true; - } - if (!exceptionThrown) - throw new RuntimeException("RuntimeException expected after timeout."); - - - System.out.println("-- timeout when writing --"); final AtomicReference writeException = new AtomicReference(); - final long timeout = 5; - final TimeUnit unit = TimeUnit.SECONDS; - // write bytes to fill socket buffer ch.write(genBuffer(), timeout, unit, ch, new CompletionHandler() @@ -769,24 +774,32 @@ public class Basic { writeException.set(exc); } }); + if (timeout > 0) { + // wait for exception + while (writeException.get() == null) { + Thread.sleep(100); + } + if (!(writeException.get() instanceof InterruptedByTimeoutException)) + throw new RuntimeException("InterruptedByTimeoutException expected"); - // wait for exception - while (writeException.get() == null) { - Thread.sleep(100); + // after a timeout then further writing should throw unspecified runtime exception + boolean exceptionThrown = false; + try { + ch.write(genBuffer()); + } catch (RuntimeException x) { + exceptionThrown = true; + } + if (!exceptionThrown) + throw new RuntimeException("RuntimeException expected after timeout."); + } else { + Thread.sleep(1000); + Throwable exc = writeException.get(); + if (exc != null) + throw new RuntimeException(exc); } - if (!(writeException.get() instanceof InterruptedByTimeoutException)) - throw new RuntimeException("InterruptedByTimeoutException expected"); - - // after a timeout then further writing should throw unspecified runtime exception - exceptionThrown = false; - try { - ch.write(genBuffer()); - } catch (RuntimeException x) { - exceptionThrown = true; - } - if (!exceptionThrown) - throw new RuntimeException("RuntimeException expected after timeout."); + // clean-up + server.accept().close(); ch.close(); server.close(); } From ca74e2b269601178a2bc5b3dc99913721e1d68fe Mon Sep 17 00:00:00 2001 From: Artem Ananiev Date: Thu, 25 Nov 2010 13:23:49 +0300 Subject: [PATCH 57/89] 6993784: Clarification to shaped/translucent windows specification is required Reviewed-by: anthony, dcherepanov --- jdk/src/share/classes/java/awt/Dialog.java | 80 ++++++++++++-- jdk/src/share/classes/java/awt/Frame.java | 80 ++++++++++++-- jdk/src/share/classes/java/awt/Window.java | 116 +++++++++++++-------- 3 files changed, 221 insertions(+), 55 deletions(-) diff --git a/jdk/src/share/classes/java/awt/Dialog.java b/jdk/src/share/classes/java/awt/Dialog.java index 36a3502e3ba..26164ec5675 100644 --- a/jdk/src/share/classes/java/awt/Dialog.java +++ b/jdk/src/share/classes/java/awt/Dialog.java @@ -1248,14 +1248,31 @@ public class Dialog extends Window { /** * Disables or enables decorations for this dialog. - * This method can only be called while the dialog is not displayable. - * @param undecorated true if no dialog decorations are - * to be enabled; - * false if dialog decorations are to be enabled. - * @throws IllegalComponentStateException if the dialog - * is displayable. + *

+ * This method can only be called while the dialog is not displayable. To + * make this dialog decorated, it must be opaque and have the default shape, + * otherwise the {@code IllegalComponentStateException} will be thrown. + * Refer to {@link Window#setShape}, {@link Window#setOpacity} and {@link + * Window#setBackground} for details + * + * @param undecorated {@code true} if no dialog decorations are to be + * enabled; {@code false} if dialog decorations are to be enabled + * + * @throws IllegalComponentStateException if the dialog is displayable + * @throws IllegalComponentStateException if {@code undecorated} is + * {@code false}, and this dialog does not have the default shape + * @throws IllegalComponentStateException if {@code undecorated} is + * {@code false}, and this dialog opacity is less than {@code 1.0f} + * @throws IllegalComponentStateException if {@code undecorated} is + * {@code false}, and the alpha value of this dialog background + * color is less than {@code 1.0f} + * * @see #isUndecorated * @see Component#isDisplayable + * @see Window#getShape + * @see Window#getOpacity + * @see Window#getBackground + * * @since 1.4 */ public void setUndecorated(boolean undecorated) { @@ -1264,6 +1281,18 @@ public class Dialog extends Window { if (isDisplayable()) { throw new IllegalComponentStateException("The dialog is displayable."); } + if (!undecorated) { + if (getOpacity() < 1.0f) { + throw new IllegalComponentStateException("The dialog is not opaque"); + } + if (getShape() != null) { + throw new IllegalComponentStateException("The dialog does not have a default shape"); + } + Color bg = getBackground(); + if ((bg != null) && (bg.getAlpha() < 255)) { + throw new IllegalComponentStateException("The dialog background color is not opaque"); + } + } this.undecorated = undecorated; } } @@ -1280,6 +1309,45 @@ public class Dialog extends Window { return undecorated; } + /** + * {@inheritDoc} + */ + @Override + public void setOpacity(float opacity) { + synchronized (getTreeLock()) { + if ((opacity < 1.0f) && !isUndecorated()) { + throw new IllegalComponentStateException("The dialog is decorated"); + } + super.setOpacity(opacity); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setShape(Shape shape) { + synchronized (getTreeLock()) { + if ((shape != null) && !isUndecorated()) { + throw new IllegalComponentStateException("The dialog is decorated"); + } + super.setShape(shape); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setBackground(Color bgColor) { + synchronized (getTreeLock()) { + if ((bgColor != null) && (bgColor.getAlpha() < 255) && !isUndecorated()) { + throw new IllegalComponentStateException("The dialog is decorated"); + } + super.setBackground(bgColor); + } + } + /** * Returns a string representing the state of this dialog. This * method is intended to be used only for debugging purposes, and the diff --git a/jdk/src/share/classes/java/awt/Frame.java b/jdk/src/share/classes/java/awt/Frame.java index f69e02f5239..211cc3283c0 100644 --- a/jdk/src/share/classes/java/awt/Frame.java +++ b/jdk/src/share/classes/java/awt/Frame.java @@ -879,15 +879,32 @@ public class Frame extends Window implements MenuContainer { /** * Disables or enables decorations for this frame. - * This method can only be called while the frame is not displayable. - * @param undecorated true if no frame decorations are - * to be enabled; - * false if frame decorations are to be enabled. - * @throws IllegalComponentStateException if the frame - * is displayable. + *

+ * This method can only be called while the frame is not displayable. To + * make this frame decorated, it must be opaque and have the default shape, + * otherwise the {@code IllegalComponentStateException} will be thrown. + * Refer to {@link Window#setShape}, {@link Window#setOpacity} and {@link + * Window#setBackground} for details + * + * @param undecorated {@code true} if no frame decorations are to be + * enabled; {@code false} if frame decorations are to be enabled + * + * @throws IllegalComponentStateException if the frame is displayable + * @throws IllegalComponentStateException if {@code undecorated} is + * {@code false}, and this frame does not have the default shape + * @throws IllegalComponentStateException if {@code undecorated} is + * {@code false}, and this frame opacity is less than {@code 1.0f} + * @throws IllegalComponentStateException if {@code undecorated} is + * {@code false}, and the alpha value of this frame background + * color is less than {@code 1.0f} + * * @see #isUndecorated * @see Component#isDisplayable + * @see Window#getShape + * @see Window#getOpacity + * @see Window#getBackground * @see javax.swing.JFrame#setDefaultLookAndFeelDecorated(boolean) + * * @since 1.4 */ public void setUndecorated(boolean undecorated) { @@ -896,6 +913,18 @@ public class Frame extends Window implements MenuContainer { if (isDisplayable()) { throw new IllegalComponentStateException("The frame is displayable."); } + if (!undecorated) { + if (getOpacity() < 1.0f) { + throw new IllegalComponentStateException("The frame is not opaque"); + } + if (getShape() != null) { + throw new IllegalComponentStateException("The frame does not have a default shape"); + } + Color bg = getBackground(); + if ((bg != null) && (bg.getAlpha() < 255)) { + throw new IllegalComponentStateException("The frame background color is not opaque"); + } + } this.undecorated = undecorated; } } @@ -912,6 +941,45 @@ public class Frame extends Window implements MenuContainer { return undecorated; } + /** + * {@inheritDoc} + */ + @Override + public void setOpacity(float opacity) { + synchronized (getTreeLock()) { + if ((opacity < 1.0f) && !isUndecorated()) { + throw new IllegalComponentStateException("The frame is decorated"); + } + super.setOpacity(opacity); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setShape(Shape shape) { + synchronized (getTreeLock()) { + if ((shape != null) && !isUndecorated()) { + throw new IllegalComponentStateException("The frame is decorated"); + } + super.setShape(shape); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setBackground(Color bgColor) { + synchronized (getTreeLock()) { + if ((bgColor != null) && (bgColor.getAlpha() < 255) && !isUndecorated()) { + throw new IllegalComponentStateException("The frame is decorated"); + } + super.setBackground(bgColor); + } + } + /** * Removes the specified menu bar from this frame. * @param m the menu component to remove. diff --git a/jdk/src/share/classes/java/awt/Window.java b/jdk/src/share/classes/java/awt/Window.java index 03dbd535e9f..064c8494f4e 100644 --- a/jdk/src/share/classes/java/awt/Window.java +++ b/jdk/src/share/classes/java/awt/Window.java @@ -3474,14 +3474,20 @@ public class Window extends Container implements Accessible { * level of 0 may or may not disable the mouse event handling on this * window. This is a platform-dependent behavior. *

- * In order for this method to enable the translucency effect, the {@link - * GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)} method must indicate that - * the {@link GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT} - * translucency is supported. + * The following conditions must be met in order to set the opacity value + * less than {@code 1.0f}: + *

    + *
  • The {@link GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT} + * translucency must be supported by the underlying system + *
  • The window must be undecorated (see {@link Frame#setUndecorated} + * and {@link Dialog#setUndecorated}) + *
  • The window must not be in full-screen mode (see {@link + * GraphicsDevice#setFullScreenWindow(Window)}) + *
*

- * Also note that the window must not be in the full-screen mode when - * setting the opacity value < 1.0f. Otherwise the {@code - * IllegalComponentStateException} is thrown. + * If the requested opacity value is less than {@code 1.0f}, and any of the + * above conditions are not met, the window opacity will not change, + * and the {@code IllegalComponentStateException} will be thrown. *

* The translucency levels of individual pixels may also be effected by the * alpha component of their color (see {@link Window#setBackground(Color)}) and the @@ -3491,15 +3497,20 @@ public class Window extends Container implements Accessible { * * @throws IllegalArgumentException if the opacity is out of the range * [0..1] + * @throws IllegalComponentStateException if the window is decorated and + * the opacity is less than {@code 1.0f} * @throws IllegalComponentStateException if the window is in full screen - * mode, and the opacity is less than 1.0f + * mode, and the opacity is less than {@code 1.0f} * @throws UnsupportedOperationException if the {@code * GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT} - * translucency kind is not supported and the opacity is less than 1.0f + * translucency is not supported and the opacity is less than + * {@code 1.0f} * * @see Window#getOpacity * @see Window#setBackground(Color) * @see Window#setShape(Shape) + * @see Frame#isUndecorated + * @see Dialog#isUndecorated * @see GraphicsDevice.WindowTranslucency * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency) * @@ -3557,24 +3568,26 @@ public class Window extends Container implements Accessible { /** * Sets the shape of the window. *

- * Setting a shape enables cutting off some parts of the window, leaving - * visible and clickable only those parts belonging to the given shape - * (see {@link Shape}). If the shape argument is null, this methods - * restores the default shape (making the window rectangular on most - * platforms.) + * Setting a shape cuts off some parts of the window. Only the parts that + * belong to the given {@link Shape} remain visible and clickable. If + * the shape argument is {@code null}, this method restores the default + * shape, making the window rectangular on most platforms. *

- * The following conditions must be met in order to set a non-null shape: + * The following conditions must be met to set a non-null shape: *

    *
  • The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT - * PERPIXEL_TRANSPARENT} translucency kind must be supported by the + * PERPIXEL_TRANSPARENT} translucency must be supported by the * underlying system - * and - *
  • The window must not be in the full-screen mode (see - * {@link GraphicsDevice#setFullScreenWindow(Window)}) + *
  • The window must be undecorated (see {@link Frame#setUndecorated} + * and {@link Dialog#setUndecorated}) + *
  • The window must not be in full-screen mode (see {@link + * GraphicsDevice#setFullScreenWindow(Window)}) *
- * If a certain condition is not met, either the {@code - * UnsupportedOperationException} or {@code IllegalComponentStateException} - * is thrown. + *

+ * If the requested shape is not {@code null}, and any of the above + * conditions are not met, the shape of this window will not change, + * and either the {@code UnsupportedOperationException} or {@code + * IllegalComponentStateException} will be thrown. *

* The tranlucency levels of individual pixels may also be effected by the * alpha component of their color (see {@link Window#setBackground(Color)}) and the @@ -3584,6 +3597,8 @@ public class Window extends Container implements Accessible { * @param shape the shape to set to the window * * @throws IllegalComponentStateException if the shape is not {@code + * null} and the window is decorated + * @throws IllegalComponentStateException if the shape is not {@code * null} and the window is in full-screen mode * @throws UnsupportedOperationException if the shape is not {@code * null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT @@ -3592,6 +3607,8 @@ public class Window extends Container implements Accessible { * @see Window#getShape() * @see Window#setBackground(Color) * @see Window#setOpacity(float) + * @see Frame#isUndecorated + * @see Dialog#isUndecorated * @see GraphicsDevice.WindowTranslucency * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency) * @@ -3645,37 +3662,46 @@ public class Window extends Container implements Accessible { * GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT PERPIXEL_TRANSLUCENT} * tranclucency, the alpha component of the given background color * may effect the mode of operation for this window: it indicates whether - * this window must be opaque (alpha == 1.0f) or per-pixel translucent - * (alpha < 1.0f). All the following conditions must be met in order - * to be able to enable the per-pixel transparency mode for this window: + * this window must be opaque (alpha equals {@code 1.0f}) or per-pixel translucent + * (alpha is less than {@code 1.0f}). If the given background color is + * {@code null}, the window is considered completely opaque. + *

+ * All the following conditions must be met to enable the per-pixel + * transparency mode for this window: *

    *
  • The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT - * PERPIXEL_TRANSLUCENT} translucency must be supported - * by the graphics device where this window is located and - *
  • The window must not be in the full-screen mode (see {@link + * PERPIXEL_TRANSLUCENT} translucency must be supported by the graphics + * device where this window is located + *
  • The window must be undecorated (see {@link Frame#setUndecorated} + * and {@link Dialog#setUndecorated}) + *
  • The window must not be in full-screen mode (see {@link * GraphicsDevice#setFullScreenWindow(Window)}) *
- * If a certain condition is not met at the time of calling this method, - * the alpha component of the given background color will not effect the - * mode of operation for this window. + *

+ * If the alpha component of the requested background color is less than + * {@code 1.0f}, and any of the above conditions are not met, the background + * color of this window will not change, the alpha component of the given + * background color will not affect the mode of operation for this window, + * and either the {@code UnsupportedOperationException} or {@code + * IllegalComponentStateException} will be thrown. *

* When the window is per-pixel translucent, the drawing sub-system * respects the alpha value of each individual pixel. If a pixel gets * painted with the alpha color component equal to zero, it becomes - * visually transparent, if the alpha of the pixel is equal to 1.0f, the + * visually transparent. If the alpha of the pixel is equal to 1.0f, the * pixel is fully opaque. Interim values of the alpha color component make - * the pixel semi-transparent. In this mode the background of the window - * gets painted with the alpha value of the given background color (meaning - * that it is not painted at all if the alpha value of the argument of this - * method is equal to zero.) + * the pixel semi-transparent. In this mode, the background of the window + * gets painted with the alpha value of the given background color. If the + * alpha value of the argument of this method is equal to {@code 0}, the + * background is not painted at all. *

* The actual level of translucency of a given pixel also depends on window * opacity (see {@link #setOpacity(float)}), as well as the current shape of * this window (see {@link #setShape(Shape)}). *

- * Note that painting a pixel with the alpha value of 0 may or may not - * disable the mouse event handling on this pixel. This is a - * platform-dependent behavior. To make sure the mouse clicks do not get + * Note that painting a pixel with the alpha value of {@code 0} may or may + * not disable the mouse event handling on this pixel. This is a + * platform-dependent behavior. To make sure the mouse events do not get * dispatched to a particular pixel, the pixel must be excluded from the * shape of the window. *

@@ -3685,17 +3711,21 @@ public class Window extends Container implements Accessible { * @param bgColor the color to become this window's background color. * * @throws IllegalComponentStateException if the alpha value of the given - * background color is less than 1.0f and the window is in + * background color is less than {@code 1.0f} and the window is decorated + * @throws IllegalComponentStateException if the alpha value of the given + * background color is less than {@code 1.0f} and the window is in * full-screen mode * @throws UnsupportedOperationException if the alpha value of the given - * background color is less than 1.0f and - * {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT + * background color is less than {@code 1.0f} and {@link + * GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT * PERPIXEL_TRANSLUCENT} translucency is not supported * * @see Window#getBackground * @see Window#isOpaque * @see Window#setOpacity(float) * @see Window#setShape(Shape) + * @see Frame#isUndecorated + * @see Dialog#isUndecorated * @see GraphicsDevice.WindowTranslucency * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency) * @see GraphicsConfiguration#isTranslucencyCapable() @@ -3739,7 +3769,7 @@ public class Window extends Container implements Accessible { *

* The method returns {@code false} if the background color of the window * is not {@code null} and the alpha component of the color is less than - * 1.0f. The method returns {@code true} otherwise. + * {@code 1.0f}. The method returns {@code true} otherwise. * * @return {@code true} if the window is opaque, {@code false} otherwise * From 9fdb91625609e3d0a136fbd02d307f6204bad855 Mon Sep 17 00:00:00 2001 From: Andrei Dmitriev Date: Thu, 25 Nov 2010 15:39:39 +0300 Subject: [PATCH 58/89] 6551412: [OpenJDK] Change the 'name=' entry in src/windows/resource/java.manifest XML file Reviewed-by: ohair --- jdk/src/windows/resource/java.manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/windows/resource/java.manifest b/jdk/src/windows/resource/java.manifest index dde8ca07c04..61ec5999e19 100644 --- a/jdk/src/windows/resource/java.manifest +++ b/jdk/src/windows/resource/java.manifest @@ -3,7 +3,7 @@ AWT From a38572f3dedfabf623d620b87d5326c3d3ba5eb9 Mon Sep 17 00:00:00 2001 From: Dmitry Cherepanov Date: Fri, 26 Nov 2010 11:27:00 +0300 Subject: [PATCH 59/89] 6561353: The text for J2SE NervousText demo should be updated to 7.0 Reviewed-by: art --- jdk/src/share/demo/applets/NervousText/example1.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/demo/applets/NervousText/example1.html b/jdk/src/share/demo/applets/NervousText/example1.html index 38e4f840da5..96013da6f45 100644 --- a/jdk/src/share/demo/applets/NervousText/example1.html +++ b/jdk/src/share/demo/applets/NervousText/example1.html @@ -1,7 +1,7 @@ Nervous Text 1.1


- +
The source. From 5ddb1f9a77822e8252e17b828c2b956f01646599 Mon Sep 17 00:00:00 2001 From: Dmitry Cherepanov Date: Fri, 26 Nov 2010 14:36:42 +0300 Subject: [PATCH 60/89] 6699851: setMaximizedbounds not working properly on dual screen environment Reviewed-by: art, anthony --- jdk/src/share/classes/java/awt/Frame.java | 15 +++++-- .../share/classes/sun/awt/AWTAccessor.java | 4 ++ .../classes/sun/awt/windows/WFramePeer.java | 42 ++++++++++++++++++- 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/java/awt/Frame.java b/jdk/src/share/classes/java/awt/Frame.java index 211cc3283c0..bd2539f055b 100644 --- a/jdk/src/share/classes/java/awt/Frame.java +++ b/jdk/src/share/classes/java/awt/Frame.java @@ -828,6 +828,11 @@ public class Frame extends Window implements MenuContainer { return frame.state; } } + public Rectangle getMaximizedBounds(Frame frame) { + synchronized(frame.getObjectLock()) { + return frame.maximizedBounds; + } + } } ); } @@ -855,8 +860,10 @@ public class Frame extends Window implements MenuContainer { * @see #getMaximizedBounds() * @since 1.4 */ - public synchronized void setMaximizedBounds(Rectangle bounds) { - this.maximizedBounds = bounds; + public void setMaximizedBounds(Rectangle bounds) { + synchronized(getObjectLock()) { + this.maximizedBounds = bounds; + } FramePeer peer = (FramePeer)this.peer; if (peer != null) { peer.setMaximizedBounds(bounds); @@ -873,7 +880,9 @@ public class Frame extends Window implements MenuContainer { * @since 1.4 */ public Rectangle getMaximizedBounds() { - return maximizedBounds; + synchronized(getObjectLock()) { + return maximizedBounds; + } } diff --git a/jdk/src/share/classes/sun/awt/AWTAccessor.java b/jdk/src/share/classes/sun/awt/AWTAccessor.java index b9171ce9798..c6ec551baec 100644 --- a/jdk/src/share/classes/sun/awt/AWTAccessor.java +++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java @@ -334,6 +334,10 @@ public final class AWTAccessor { * Gets the state of this frame. */ int getExtendedState(Frame frame); + /* + * Gets the maximized bounds of this frame. + */ + Rectangle getMaximizedBounds(Frame frame); } /* diff --git a/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java b/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java index f5b537c5ae5..78eeaf0147f 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java @@ -79,10 +79,50 @@ class WFramePeer extends WWindowPeer implements FramePeer { if (b == null) { clearMaximizedBounds(); } else { - setMaximizedBounds(b.x, b.y, b.width, b.height); + Rectangle adjBounds = (Rectangle)b.clone(); + adjustMaximizedBounds(adjBounds); + setMaximizedBounds(adjBounds.x, adjBounds.y, adjBounds.width, adjBounds.height); } } + /** + * The incoming bounds describe the maximized size and position of the + * window on the monitor that displays the window. But the window manager + * expects that the bounds are based on the size and position of the + * primary monitor, even if the window ultimately maximizes onto a + * secondary monitor. And the window manager adjusts these values to + * compensate for differences between the primary monitor and the monitor + * that displays the window. + * The method translates the incoming bounds to the values acceptable + * by the window manager. For more details, please refer to 6699851. + */ + private void adjustMaximizedBounds(Rectangle b) { + GraphicsConfiguration currentDevGC = getGraphicsConfiguration(); + + GraphicsDevice primaryDev = GraphicsEnvironment + .getLocalGraphicsEnvironment().getDefaultScreenDevice(); + GraphicsConfiguration primaryDevGC = primaryDev.getDefaultConfiguration(); + + if (currentDevGC != null && currentDevGC != primaryDevGC) { + Rectangle currentDevBounds = currentDevGC.getBounds(); + Rectangle primaryDevBounds = primaryDevGC.getBounds(); + + b.width -= (currentDevBounds.width - primaryDevBounds.width); + b.height -= (currentDevBounds.height - primaryDevBounds.height); + } + } + + @Override + public boolean updateGraphicsData(GraphicsConfiguration gc) { + boolean result = super.updateGraphicsData(gc); + Rectangle bounds = AWTAccessor.getFrameAccessor(). + getMaximizedBounds((Frame)target); + if (bounds != null) { + setMaximizedBounds(bounds); + } + return result; + } + @Override boolean isTargetUndecorated() { return ((Frame)target).isUndecorated(); From 11c66fbbcf1dcbd44f764985e0b42e6acc81943c Mon Sep 17 00:00:00 2001 From: Dmitry Cherepanov Date: Fri, 26 Nov 2010 15:07:53 +0300 Subject: [PATCH 61/89] 6770017: PIT : java/awt/Choice/BlockedWin32Choice/BlockedWin32Choice.java fails on 6u12 b01 pit build Reviewed-by: art --- jdk/src/windows/native/sun/windows/awt_Choice.cpp | 8 +++++--- jdk/src/windows/native/sun/windows/awt_Choice.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/jdk/src/windows/native/sun/windows/awt_Choice.cpp b/jdk/src/windows/native/sun/windows/awt_Choice.cpp index 8c1621afec6..e8296d4c514 100644 --- a/jdk/src/windows/native/sun/windows/awt_Choice.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Choice.cpp @@ -86,6 +86,7 @@ static const UINT MINIMUM_NUMBER_OF_VISIBLE_ITEMS = 8; AwtChoice::AwtChoice() { m_hList = NULL; m_listDefWindowProc = NULL; + m_selectedItem = -1; } LPCTSTR AwtChoice::GetClassName() { @@ -437,9 +438,10 @@ LRESULT CALLBACK AwtChoice::ListWindowProc(HWND hwnd, UINT message, MsgRouting AwtChoice::WmNotify(UINT notifyCode) { if (notifyCode == CBN_SELCHANGE) { - int itemSelect = (int)SendMessage(CB_GETCURSEL); - if (itemSelect != CB_ERR){ - DoCallback("handleAction", "(I)V", itemSelect); + int selectedItem = (int)SendMessage(CB_GETCURSEL); + if (selectedItem != CB_ERR && m_selectedItem != selectedItem){ + m_selectedItem = selectedItem; + DoCallback("handleAction", "(I)V", selectedItem); } } else if (notifyCode == CBN_DROPDOWN) { diff --git a/jdk/src/windows/native/sun/windows/awt_Choice.h b/jdk/src/windows/native/sun/windows/awt_Choice.h index 4852301bb3d..ad0a21d23ae 100644 --- a/jdk/src/windows/native/sun/windows/awt_Choice.h +++ b/jdk/src/windows/native/sun/windows/awt_Choice.h @@ -94,6 +94,7 @@ private: static BOOL sm_isMouseMoveInList; HWND m_hList; WNDPROC m_listDefWindowProc; + int m_selectedItem; static LRESULT CALLBACK ListWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); }; From de54670198e35e5971091bb6beb59144dba42cb0 Mon Sep 17 00:00:00 2001 From: Anthony Petrov Date: Fri, 26 Nov 2010 15:41:16 +0300 Subject: [PATCH 62/89] 7002856: Provide an accessor for Container.validateUnconditionally() Introduce sun.awt.AWTAccessor.getContainerAccessor().validateUnconditionally() Reviewed-by: art --- jdk/src/share/classes/java/awt/Container.java | 8 +++ .../share/classes/sun/awt/AWTAccessor.java | 70 +++++++++---------- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/jdk/src/share/classes/java/awt/Container.java b/jdk/src/share/classes/java/awt/Container.java index a7ee77e16cb..8a463b005e4 100644 --- a/jdk/src/share/classes/java/awt/Container.java +++ b/jdk/src/share/classes/java/awt/Container.java @@ -51,6 +51,7 @@ import javax.accessibility.*; import sun.util.logging.PlatformLogger; import sun.awt.AppContext; +import sun.awt.AWTAccessor; import sun.awt.CausedFocusEvent; import sun.awt.PeerEvent; import sun.awt.SunToolkit; @@ -247,6 +248,13 @@ public class Container extends Component { if (!GraphicsEnvironment.isHeadless()) { initIDs(); } + + AWTAccessor.setContainerAccessor(new AWTAccessor.ContainerAccessor() { + @Override + public void validateUnconditionally(Container cont) { + cont.validateUnconditionally(); + } + }); } /** diff --git a/jdk/src/share/classes/sun/awt/AWTAccessor.java b/jdk/src/share/classes/sun/awt/AWTAccessor.java index c6ec551baec..abef250993d 100644 --- a/jdk/src/share/classes/sun/awt/AWTAccessor.java +++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java @@ -223,6 +223,16 @@ public final class AWTAccessor { void processEvent(Component comp, AWTEvent e); } + /* + * An interface of accessor for the java.awt.Container class. + */ + public interface ContainerAccessor { + /** + * Validates the container unconditionally. + */ + void validateUnconditionally(Container cont); + } + /* * An interface of accessor for java.awt.Window class. */ @@ -444,53 +454,19 @@ public final class AWTAccessor { } /* - * The java.awt.Component class accessor object. + * Accessor instances are initialized in the static initializers of + * corresponding AWT classes by using setters defined below. */ private static ComponentAccessor componentAccessor; - - /* - * The java.awt.Window class accessor object. - */ + private static ContainerAccessor containerAccessor; private static WindowAccessor windowAccessor; - - /* - * The java.awt.AWTEvent class accessor object. - */ private static AWTEventAccessor awtEventAccessor; - - /* - * The java.awt.event.InputEvent class accessor object. - */ private static InputEventAccessor inputEventAccessor; - - /* - * The java.awt.Frame class accessor object. - */ private static FrameAccessor frameAccessor; - - /* - * The java.awt.KeyboardFocusManager class accessor object. - */ private static KeyboardFocusManagerAccessor kfmAccessor; - - /* - * The java.awt.MenuComponent class accessor object. - */ private static MenuComponentAccessor menuComponentAccessor; - - /* - * The java.awt.EventQueue class accessor object. - */ private static EventQueueAccessor eventQueueAccessor; - - /* - * The java.awt.PopupMenu class accessor object. - */ private static PopupMenuAccessor popupMenuAccessor; - - /* - * The java.awt.FileDialog class accessor object. - */ private static FileDialogAccessor fileDialogAccessor; /* @@ -501,7 +477,7 @@ public final class AWTAccessor { } /* - * Retrieve the accessor object for the java.awt.Window class. + * Retrieve the accessor object for the java.awt.Component class. */ public static ComponentAccessor getComponentAccessor() { if (componentAccessor == null) { @@ -511,6 +487,24 @@ public final class AWTAccessor { return componentAccessor; } + /* + * Set an accessor object for the java.awt.Container class. + */ + public static void setContainerAccessor(ContainerAccessor ca) { + containerAccessor = ca; + } + + /* + * Retrieve the accessor object for the java.awt.Container class. + */ + public static ContainerAccessor getContainerAccessor() { + if (containerAccessor == null) { + unsafe.ensureClassInitialized(Container.class); + } + + return containerAccessor; + } + /* * Set an accessor object for the java.awt.Window class. */ From 968c2304895715ed830ffafd042120968c7f93e9 Mon Sep 17 00:00:00 2001 From: Dmitry Cherepanov Date: Fri, 26 Nov 2010 15:52:55 +0300 Subject: [PATCH 63/89] 6953894: docs build reports warning in java.awt.FileDialog Reviewed-by: art --- jdk/src/share/classes/java/awt/FileDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/java/awt/FileDialog.java b/jdk/src/share/classes/java/awt/FileDialog.java index 033b7660d0e..5e35bfe2ea9 100644 --- a/jdk/src/share/classes/java/awt/FileDialog.java +++ b/jdk/src/share/classes/java/awt/FileDialog.java @@ -99,7 +99,7 @@ public class FileDialog extends Dialog { * Contains the File instances for all the files that the user selects. * * @serial - * @see getFiles + * @see #getFiles * @since 1.7 */ private File[] files; From b38c70ff49276ee9e9b3950687b0a07fd3cb44a5 Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Sat, 27 Nov 2010 07:46:05 -0800 Subject: [PATCH 64/89] 7002986: (pack200) intermittent failures compiling pack200 Reviewed-by: jjg --- .../java/util/jar/pack/AdaptiveCoding.java | 6 ++-- .../com/sun/java/util/jar/pack/Attribute.java | 14 +++++++-- .../sun/java/util/jar/pack/BandStructure.java | 30 ++++++++++++++----- .../sun/java/util/jar/pack/ClassReader.java | 14 +++++++-- .../sun/java/util/jar/pack/ClassWriter.java | 14 +++++++-- .../com/sun/java/util/jar/pack/Code.java | 4 +-- .../com/sun/java/util/jar/pack/Coding.java | 6 ++-- .../sun/java/util/jar/pack/CodingChooser.java | 14 +++++++-- .../sun/java/util/jar/pack/CodingMethod.java | 4 ++- .../sun/java/util/jar/pack/ConstantPool.java | 9 +++++- .../com/sun/java/util/jar/pack/Constants.java | 3 +- .../com/sun/java/util/jar/pack/Driver.java | 29 +++++++++++++++--- .../com/sun/java/util/jar/pack/Fixups.java | 8 +++-- .../com/sun/java/util/jar/pack/Histogram.java | 6 ++-- .../sun/java/util/jar/pack/NativeUnpack.java | 16 +++++++--- .../com/sun/java/util/jar/pack/Package.java | 29 +++++++++++++++--- .../sun/java/util/jar/pack/PackageReader.java | 8 ++++- .../sun/java/util/jar/pack/PackageWriter.java | 24 +++++++++++++-- .../sun/java/util/jar/pack/PackerImpl.java | 23 ++++++++++++-- .../java/util/jar/pack/PopulationCoding.java | 8 +++-- .../com/sun/java/util/jar/pack/PropMap.java | 21 +++++++++---- .../sun/java/util/jar/pack/UnpackerImpl.java | 22 +++++++++++--- .../com/sun/java/util/jar/pack/Utils.java | 21 +++++++++---- 23 files changed, 264 insertions(+), 69 deletions(-) diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java index 477806bd912..a782e8631e5 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java @@ -25,8 +25,10 @@ package com.sun.java.util.jar.pack; -import java.util.*; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; /** * Adaptive coding. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Attribute.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Attribute.java index b662ebb9683..7b838f26d02 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Attribute.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Attribute.java @@ -25,9 +25,17 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; -import com.sun.java.util.jar.pack.ConstantPool.*; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * Represents an attribute in a class-file. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java index 1c8266cd69f..7af5e38019d 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java @@ -25,12 +25,28 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; -import java.util.jar.*; -import com.sun.java.util.jar.pack.Package.Class; -import com.sun.java.util.jar.pack.Package.InnerClass; -import com.sun.java.util.jar.pack.ConstantPool.*; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import com.sun.java.util.jar.pack.Package.Class.Field; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.EOFException; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FilterInputStream; +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.jar.Pack200; /** * Define the structure and ordering of "bands" in a packed file. @@ -1629,7 +1645,7 @@ class BandStructure implements Constants { } } - protected void setConstantValueIndex(Class.Field f) { + protected void setConstantValueIndex(com.sun.java.util.jar.pack.Package.Class.Field f) { Index ix = null; if (f != null) { byte tag = f.getLiteralTag(); diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java index 356be128b45..a1bce52a5e2 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java @@ -25,11 +25,19 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; +import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; +import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry; +import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry; import com.sun.java.util.jar.pack.Package.Class; import com.sun.java.util.jar.pack.Package.InnerClass; -import com.sun.java.util.jar.pack.ConstantPool.*; +import java.io.DataInputStream; +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Map; /** * Reader for a class file that is being incorporated into a package. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java index 516954c937a..a4ceff57686 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java @@ -25,11 +25,19 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; + +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import com.sun.java.util.jar.pack.ConstantPool.NumberEntry; import com.sun.java.util.jar.pack.Package.Class; import com.sun.java.util.jar.pack.Package.InnerClass; -import com.sun.java.util.jar.pack.ConstantPool.*; +import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Iterator; +import java.util.List; /** * Writer for a class file that is incorporated into a package. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Code.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Code.java index 3461d44293c..e6272f57a5b 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Code.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Code.java @@ -25,10 +25,10 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; import com.sun.java.util.jar.pack.Package.Class; import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.Collection; /** * Represents a chunk of bytecodes. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Coding.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Coding.java index 6e72d1baae8..a35261f5db9 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Coding.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Coding.java @@ -25,8 +25,10 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.HashMap; /** * Define the conversions between sequences of small integers and raw bytes. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java index 2f1f3e1b839..61a6710a6f6 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java @@ -25,9 +25,17 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; -import java.util.zip.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.zip.Deflater; +import java.util.zip.DeflaterOutputStream; /** * Heuristic chooser of basic encodings. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingMethod.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingMethod.java index 75f32a86118..d0b1d9d9604 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingMethod.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingMethod.java @@ -25,7 +25,9 @@ package com.sun.java.util.jar.pack; -import java.io.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; /** * Interface for encoding and decoding int arrays using bytewise codes. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java index ac6199abe25..abafbd92b40 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java @@ -25,7 +25,14 @@ package com.sun.java.util.jar.pack; -import java.util.*; +import java.util.AbstractList; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; /** * Representation of constant pool entries and indexes. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Constants.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Constants.java index 19ce04cf559..512dac7972f 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Constants.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Constants.java @@ -25,7 +25,8 @@ package com.sun.java.util.jar.pack; -import java.util.*; +import java.util.Arrays; +import java.util.List; /** * Shared constants diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Driver.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Driver.java index 2630febb7c3..a7c47a8a8cc 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Driver.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Driver.java @@ -25,11 +25,32 @@ package com.sun.java.util.jar.pack; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintStream; import java.text.MessageFormat; -import java.util.*; -import java.util.jar.*; -import java.util.zip.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.SortedMap; +import java.util.TreeMap; +import java.util.jar.JarFile; +import java.util.jar.JarOutputStream; +import java.util.jar.Pack200; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; /** Command line interface for Pack200. */ diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Fixups.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Fixups.java index 3cb47069c8f..77815b43b22 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Fixups.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Fixups.java @@ -25,9 +25,11 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; -import com.sun.java.util.jar.pack.ConstantPool.*; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import java.util.AbstractCollection; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; /** * Collection of relocatable constant pool references. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Histogram.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Histogram.java index 1c03e592b02..92cf6e4e918 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Histogram.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Histogram.java @@ -25,8 +25,10 @@ package com.sun.java.util.jar.pack; -import java.util.*; -import java.io.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.util.Arrays; /** * Histogram derived from an integer array of events (int[]). diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java index c6d96085180..2ea9f4d4721 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java @@ -26,10 +26,18 @@ package com.sun.java.util.jar.pack; -import java.nio.*; -import java.io.*; -import java.util.jar.*; -import java.util.zip.*; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.util.jar.JarOutputStream; +import java.util.jar.Pack200; +import java.util.zip.CRC32; +import java.util.zip.Deflater; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; class NativeUnpack { // Pointer to the native unpacker obj diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Package.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Package.java index 29d217687c4..981bd53b75c 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Package.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Package.java @@ -26,11 +26,32 @@ package com.sun.java.util.jar.pack; import com.sun.java.util.jar.pack.Attribute.Layout; +import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; +import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import com.sun.java.util.jar.pack.ConstantPool.LiteralEntry; +import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.SequenceInputStream; import java.lang.reflect.Modifier; -import java.util.*; -import java.util.jar.*; -import java.io.*; -import com.sun.java.util.jar.pack.ConstantPool.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; +import java.util.jar.JarFile; /** * Define the main data structure transmitted by pack/unpack. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java index 73efca5ca85..be8ba0d008b 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java @@ -25,12 +25,18 @@ package com.sun.java.util.jar.pack; +import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; +import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import com.sun.java.util.jar.pack.ConstantPool.MemberEntry; +import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry; +import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry; import java.io.*; import java.util.*; import com.sun.java.util.jar.pack.Package.Class; import com.sun.java.util.jar.pack.Package.File; import com.sun.java.util.jar.pack.Package.InnerClass; -import com.sun.java.util.jar.pack.ConstantPool.*; /** * Reader for a package file. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java index 55b64cce5e8..cbfcb8aacfd 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java @@ -25,12 +25,30 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; +import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; +import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import com.sun.java.util.jar.pack.ConstantPool.IndexGroup; +import com.sun.java.util.jar.pack.ConstantPool.MemberEntry; +import com.sun.java.util.jar.pack.ConstantPool.NumberEntry; +import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry; +import com.sun.java.util.jar.pack.ConstantPool.StringEntry; import com.sun.java.util.jar.pack.Package.Class; import com.sun.java.util.jar.pack.Package.File; import com.sun.java.util.jar.pack.Package.InnerClass; -import com.sun.java.util.jar.pack.ConstantPool.*; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; /** * Writer for a package file. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java index f4840709997..7e2f6a27c02 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java @@ -26,10 +26,27 @@ package com.sun.java.util.jar.pack; import com.sun.java.util.jar.pack.Attribute.Layout; -import java.util.*; -import java.util.jar.*; -import java.io.*; import java.beans.PropertyChangeListener; +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.SortedMap; +import java.util.TimeZone; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarInputStream; +import java.util.jar.Pack200; /* diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java index 599d86fa6b2..3e5ecf170c3 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java @@ -25,8 +25,12 @@ package com.sun.java.util.jar.pack; -import java.util.*; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Arrays; +import java.util.HashSet; /** * Population-based coding. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java index 78c709f343d..3072ef394eb 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java @@ -25,13 +25,24 @@ package com.sun.java.util.jar.pack; -import java.util.*; -import java.util.jar.*; -import java.util.jar.Pack200; -import java.util.zip.*; -import java.io.*; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; +import java.util.jar.Pack200; /** * Control block for publishing Pack200 options to the other classes. */ diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java index 5b9f8ec61f6..a0c1e4d26ef 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java @@ -25,11 +25,25 @@ package com.sun.java.util.jar.pack; -import java.util.*; -import java.util.jar.*; -import java.util.zip.*; -import java.io.*; import java.beans.PropertyChangeListener; +import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.HashSet; +import java.util.Iterator; +import java.util.SortedMap; +import java.util.TimeZone; +import java.util.jar.JarEntry; +import java.util.jar.JarInputStream; +import java.util.jar.JarOutputStream; +import java.util.jar.Pack200; +import java.util.zip.CRC32; +import java.util.zip.CheckedOutputStream; +import java.util.zip.ZipEntry; /* * Implementation of the Pack provider. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Utils.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Utils.java index 84f65ac2ccf..d14d59926ca 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Utils.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Utils.java @@ -25,18 +25,27 @@ package com.sun.java.util.jar.pack; -import com.sun.java.util.jar.pack.Attribute.Layout; import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; import com.sun.java.util.jar.pack.ConstantPool.LiteralEntry; import com.sun.java.util.jar.pack.ConstantPool.MemberEntry; import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry; import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry; -import java.util.*; -import java.util.jar.*; -import java.util.zip.*; -import java.io.*; - +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Date; +import java.util.Enumeration; +import java.util.Map; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarInputStream; +import java.util.jar.JarOutputStream; +import java.util.zip.ZipEntry; import sun.util.logging.PlatformLogger; class Utils { From 68ea64e30f6cc6e1f55c2b2e521cc7b153b6dd11 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Mon, 29 Nov 2010 10:09:48 -0800 Subject: [PATCH 65/89] 7003006: add option to list directory in deterministic order Reviewed-by: mcimadamore --- .../tools/javac/file/JavacFileManager.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java b/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java index 5fec67baecc..6f97aec679e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java +++ b/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java @@ -25,6 +25,7 @@ package com.sun.tools.javac.file; +import java.util.Comparator; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; @@ -110,6 +111,20 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil protected boolean mmappedIO; protected boolean ignoreSymbolFile; + protected enum SortFiles implements Comparator { + FORWARD { + public int compare(File f1, File f2) { + return f1.getName().compareTo(f2.getName()); + } + }, + REVERSE { + public int compare(File f1, File f2) { + return -f1.getName().compareTo(f2.getName()); + } + }; + }; + protected SortFiles sortFiles; + /** * Register a Context.Factory to create a JavacFileManager. */ @@ -152,6 +167,11 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil mmappedIO = options.isSet("mmappedIO"); ignoreSymbolFile = options.isSet("ignore.symbol.file"); + + String sf = options.get("sortFiles"); + if (sf != null) { + sortFiles = (sf.equals("reverse") ? SortFiles.REVERSE : SortFiles.FORWARD); + } } public JavaFileObject getFileForInput(String name) { @@ -293,6 +313,9 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil if (files == null) return; + if (sortFiles != null) + Arrays.sort(files, sortFiles); + for (File f: files) { String fname = f.getName(); if (f.isDirectory()) { From 7da94e3872d3aea7dfa20976f36646f02c8eaf63 Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Mon, 29 Nov 2010 10:37:44 -0800 Subject: [PATCH 66/89] 6998016: Incorrect ifdef nesting in sane-gcc-compiler rule 6998014: Use /etc/lsb-release, when available, to detect linux variant and version Reviewed-by: dholmes, ohair --- jdk/make/common/shared/Defs-linux.gmk | 2 +- jdk/make/common/shared/Sanity.gmk | 97 ++++++++++++++------------- 2 files changed, 53 insertions(+), 46 deletions(-) diff --git a/jdk/make/common/shared/Defs-linux.gmk b/jdk/make/common/shared/Defs-linux.gmk index fbc059c1da6..71272540c05 100644 --- a/jdk/make/common/shared/Defs-linux.gmk +++ b/jdk/make/common/shared/Defs-linux.gmk @@ -123,7 +123,7 @@ LIBM=-lm # GCC29_COMPILER_PATH: is the path to where the gcc 2.9 compiler is installed # NOTE: Must end with / so that it could be empty, allowing PATH usage. -ifneq "$(origin ALT_GCC29_COMPILER_PATH)" "undefined" +ifdef ALT_GCC29_COMPILER_PATH GCC29_COMPILER_PATH :=$(call PrefixPath,$(ALT_GCC29_COMPILER_PATH)) else GCC29_COMPILER_PATH = $(JDK_DEVTOOLS_DIR)/$(PLATFORM)/gcc29/usr/ diff --git a/jdk/make/common/shared/Sanity.gmk b/jdk/make/common/shared/Sanity.gmk index 39f99ae7c17..aac7d039c59 100644 --- a/jdk/make/common/shared/Sanity.gmk +++ b/jdk/make/common/shared/Sanity.gmk @@ -99,12 +99,16 @@ ifeq ($(PLATFORM), linux) echo "RedHat"; \ elif [ -f /etc/SuSE-release ] ; then \ echo "SuSE"; \ + elif [ -f /etc/lsb-release ] ; then \ + $(EGREP) DISTRIB_ID /etc/lsb-release | $(SED) -e 's@.*DISTRIB_ID=\(.*\)@\1@'; \ else \ echo "Unknown"; \ fi) OS_VARIANT_VERSION := $(shell \ if [ "$(OS_VARIANT_NAME)" = "Fedora" ] ; then \ $(CAT) /etc/fedora-release | $(HEAD) -1 | $(NAWK) '{ print $$3; }' ; \ + elif [ -f /etc/lsb-release ] ; then \ + $(EGREP) DISTRIB_RELEASE /etc/lsb-release | $(SED) -e 's@.*DISTRIB_RELEASE=\(.*\)@\1@'; \ fi) ALSA_INCLUDE=/usr/include/alsa/version.h ALSA_LIBRARY=/usr/lib/libasound.so @@ -279,7 +283,7 @@ sane-arch_data_model: fi ###################################################### -# Check the OS version (windows and linus have release name checks) +# Check the OS version (windows and linux have release name checks) # NOTE: OPENJDK explicitly does not check for OS release information. # Unless we know for sure that it will not build somewhere, we cannot # generate a fatal sanity error, and a warning about the official @@ -1476,60 +1480,63 @@ ifeq ($(PLATFORM), windows) endif ###################################################### -# Check the Solaris GNU c++ compiler for solaris plugin +# Check the GNU C++ compiler for OJI plugin ###################################################### sane-gcc-compiler: -ifeq ($(PLATFORM), solaris) - ifndef OPENJDK - @if [ -r $(GCC_COMPILER_PATH) ]; then \ - if [ ! "$(GCC_VER)" = $(REQUIRED_GCC_VERSION) ]; then \ - $(ECHO) "ERROR: The Solaris GCC compiler version must be $(REQUIRED_GCC_VERSION). \n" \ - " You are using the following compiler version: $(GCC_VER) \n" \ - " The compiler was obtained from the following location: \n" \ - " $(GCC_COMPILER_PATH) \n" \ - " Please change your compiler. \n" \ - "" >> $(ERROR_FILE) ; \ - fi \ +ifndef OPENJDK + ifeq ($(PLATFORM), solaris) + @if [ -r $(GCC_COMPILER_PATH) ]; then \ + if [ ! "$(GCC_VER)" = $(REQUIRED_GCC_VERSION) ]; then \ + $(ECHO) "ERROR: The Solaris GCC compiler version must be $(REQUIRED_GCC_VERSION). \n" \ + " You are using the following compiler version: $(GCC_VER) \n" \ + " The compiler was obtained from the following location: \n" \ + " $(GCC_COMPILER_PATH) \n" \ + " Please change your compiler. \n" \ + "" >> $(ERROR_FILE) ; \ + fi \ else \ - $(ECHO) "ERROR: You do not have a valid GCC_COMPILER_PATH setting. \n" \ - " Please check your access to \n" \ - " $(GCC_COMPILER_PATH) \n" \ - " and/or check your value of ALT_GCC_COMPILER_PATH. \n" \ - " This will affect you if you build the plugin target. \n" \ - "" >> $(ERROR_FILE) ; \ + $(ECHO) "ERROR: You do not have a valid GCC_COMPILER_PATH setting. \n" \ + " Please check your access to \n" \ + " $(GCC_COMPILER_PATH) \n" \ + " and/or check your value of ALT_GCC_COMPILER_PATH. \n" \ + " This will affect you if you build the plugin target. \n" \ + "" >> $(ERROR_FILE) ; \ fi endif ifeq ($(PLATFORM), linux) - ifdef ALT_GCC29_COMPILER_PATH + ifeq ($(ARCH_DATA_MODEL), 32) + ifdef ALT_GCC29_COMPILER_PATH @if [ ! -x $(ALT_GCC29_COMPILER_PATH)/bin/gcc ]; then \ - $(ECHO) "ERROR: You do not have a valid ALT_GCC29_COMPILER_PATH setting. \n" \ - " Please check your access to \n" \ - " $(ALT_GCC29_COMPILER_PATH)/bin/gcc \n" \ - " This will affect you if you build the plugin target. \n" \ - "" >> $(ERROR_FILE) ; \ - fi - endif - ifdef ALT_GCC29_PLUGIN_LIB_PATH - @if [ ! -r $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so ]; then \ + $(ECHO) "ERROR: You do not have a valid ALT_GCC29_COMPILER_PATH setting. \n" \ + " Please check your access to \n" \ + " $(ALT_GCC29_COMPILER_PATH)/bin/gcc \n" \ + " This will affect you if you build the plugin target. \n" \ + "" >> $(ERROR_FILE) ; \ + fi + else + ifdef ALT_GCC29_PLUGIN_LIB_PATH + @if [ ! -r $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so ]; then \ $(ECHO) "Error: You do not have a valid ALT_GCC29_PLUGIN_LIB_PATH setting. \n" \ - " Please check your access to \n" \ - " $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so \n" \ - " This will affect you if you build the plugin target, specifically for gcc 2.9 version of OJI plugin library. \n" \ - "" >> $(ERROR_FILE) ; \ - fi - else - @if [ ! -r $(GCC29_COMPILER_PATH) ]; then \ + " Please check your access to \n" \ + " $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so \n" \ + " This will affect you if you build the plugin target, specifically for gcc 2.9 version of OJI plugin library. \n" \ + "" >> $(ERROR_FILE) ; \ + fi + else + @if [ ! -r $(GCC29_COMPILER_PATH) ]; then \ $(ECHO) "ERROR: You do not have a valid GCC29_COMPILER_PATH setting. \n" \ - " Please check your access to \n" \ - " $(GCC29_COMPILER_PATH) \n" \ - " and/or check your value of ALT_GCC29_COMPILER_PATH. \n" \ - " This will affect you if you build the plugin target. \n" \ - "" >> $(ERROR_FILE) ; \ - fi - endif - endif -endif + " Please check your access to \n" \ + " $(GCC29_COMPILER_PATH) \n" \ + " and/or check your value of ALT_GCC29_COMPILER_PATH or ALT_GCC29_PLUGIN_LIB_PATH \n" \ + " This will affect you if you build the plugin target. \n" \ + "" >> $(ERROR_FILE) ; \ + fi + endif # ALT_GCC29_PLUGIN_LIB_PATH + endif # ALT_GCC29_COMPILER_PATH + endif # ARCH_DATA_MODEL, 32 + endif # LINUX +endif # OPEN_JDK ###################################################### From acdfc13f597e05d8c049771d5c2d6b289d9f486a Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Mon, 29 Nov 2010 13:38:12 -0800 Subject: [PATCH 67/89] 7003227: (pack200) intermittent failures compiling pack200 Reviewed-by: jjg --- .../java/util/jar/pack/AdaptiveCoding.java | 6 ++-- .../com/sun/java/util/jar/pack/Attribute.java | 14 +++++++-- .../sun/java/util/jar/pack/BandStructure.java | 30 ++++++++++++++----- .../sun/java/util/jar/pack/ClassReader.java | 14 +++++++-- .../sun/java/util/jar/pack/ClassWriter.java | 14 +++++++-- .../com/sun/java/util/jar/pack/Code.java | 4 +-- .../com/sun/java/util/jar/pack/Coding.java | 6 ++-- .../sun/java/util/jar/pack/CodingChooser.java | 14 +++++++-- .../sun/java/util/jar/pack/CodingMethod.java | 4 ++- .../sun/java/util/jar/pack/ConstantPool.java | 9 +++++- .../com/sun/java/util/jar/pack/Constants.java | 3 +- .../com/sun/java/util/jar/pack/Driver.java | 29 +++++++++++++++--- .../com/sun/java/util/jar/pack/Fixups.java | 8 +++-- .../com/sun/java/util/jar/pack/Histogram.java | 6 ++-- .../sun/java/util/jar/pack/NativeUnpack.java | 16 +++++++--- .../com/sun/java/util/jar/pack/Package.java | 29 +++++++++++++++--- .../sun/java/util/jar/pack/PackageReader.java | 8 ++++- .../sun/java/util/jar/pack/PackageWriter.java | 24 +++++++++++++-- .../sun/java/util/jar/pack/PackerImpl.java | 23 ++++++++++++-- .../java/util/jar/pack/PopulationCoding.java | 8 +++-- .../com/sun/java/util/jar/pack/PropMap.java | 21 +++++++++---- .../sun/java/util/jar/pack/UnpackerImpl.java | 22 +++++++++++--- .../com/sun/java/util/jar/pack/Utils.java | 21 +++++++++---- 23 files changed, 264 insertions(+), 69 deletions(-) diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java index 477806bd912..a782e8631e5 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java @@ -25,8 +25,10 @@ package com.sun.java.util.jar.pack; -import java.util.*; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; /** * Adaptive coding. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Attribute.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Attribute.java index b662ebb9683..7b838f26d02 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Attribute.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Attribute.java @@ -25,9 +25,17 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; -import com.sun.java.util.jar.pack.ConstantPool.*; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * Represents an attribute in a class-file. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java index 1c8266cd69f..7af5e38019d 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java @@ -25,12 +25,28 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; -import java.util.jar.*; -import com.sun.java.util.jar.pack.Package.Class; -import com.sun.java.util.jar.pack.Package.InnerClass; -import com.sun.java.util.jar.pack.ConstantPool.*; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import com.sun.java.util.jar.pack.Package.Class.Field; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.EOFException; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FilterInputStream; +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.jar.Pack200; /** * Define the structure and ordering of "bands" in a packed file. @@ -1629,7 +1645,7 @@ class BandStructure implements Constants { } } - protected void setConstantValueIndex(Class.Field f) { + protected void setConstantValueIndex(com.sun.java.util.jar.pack.Package.Class.Field f) { Index ix = null; if (f != null) { byte tag = f.getLiteralTag(); diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java index 356be128b45..a1bce52a5e2 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java @@ -25,11 +25,19 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; +import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; +import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry; +import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry; import com.sun.java.util.jar.pack.Package.Class; import com.sun.java.util.jar.pack.Package.InnerClass; -import com.sun.java.util.jar.pack.ConstantPool.*; +import java.io.DataInputStream; +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Map; /** * Reader for a class file that is being incorporated into a package. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java index 516954c937a..a4ceff57686 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java @@ -25,11 +25,19 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; + +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import com.sun.java.util.jar.pack.ConstantPool.NumberEntry; import com.sun.java.util.jar.pack.Package.Class; import com.sun.java.util.jar.pack.Package.InnerClass; -import com.sun.java.util.jar.pack.ConstantPool.*; +import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Iterator; +import java.util.List; /** * Writer for a class file that is incorporated into a package. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Code.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Code.java index 3461d44293c..e6272f57a5b 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Code.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Code.java @@ -25,10 +25,10 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; import com.sun.java.util.jar.pack.Package.Class; import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.Collection; /** * Represents a chunk of bytecodes. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Coding.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Coding.java index 6e72d1baae8..a35261f5db9 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Coding.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Coding.java @@ -25,8 +25,10 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.HashMap; /** * Define the conversions between sequences of small integers and raw bytes. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java index 2f1f3e1b839..61a6710a6f6 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java @@ -25,9 +25,17 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; -import java.util.zip.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.zip.Deflater; +import java.util.zip.DeflaterOutputStream; /** * Heuristic chooser of basic encodings. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingMethod.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingMethod.java index 75f32a86118..d0b1d9d9604 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingMethod.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingMethod.java @@ -25,7 +25,9 @@ package com.sun.java.util.jar.pack; -import java.io.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; /** * Interface for encoding and decoding int arrays using bytewise codes. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java index ac6199abe25..abafbd92b40 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java @@ -25,7 +25,14 @@ package com.sun.java.util.jar.pack; -import java.util.*; +import java.util.AbstractList; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; /** * Representation of constant pool entries and indexes. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Constants.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Constants.java index 19ce04cf559..512dac7972f 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Constants.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Constants.java @@ -25,7 +25,8 @@ package com.sun.java.util.jar.pack; -import java.util.*; +import java.util.Arrays; +import java.util.List; /** * Shared constants diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Driver.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Driver.java index 2630febb7c3..a7c47a8a8cc 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Driver.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Driver.java @@ -25,11 +25,32 @@ package com.sun.java.util.jar.pack; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintStream; import java.text.MessageFormat; -import java.util.*; -import java.util.jar.*; -import java.util.zip.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.SortedMap; +import java.util.TreeMap; +import java.util.jar.JarFile; +import java.util.jar.JarOutputStream; +import java.util.jar.Pack200; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; /** Command line interface for Pack200. */ diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Fixups.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Fixups.java index 3cb47069c8f..77815b43b22 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Fixups.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Fixups.java @@ -25,9 +25,11 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; -import com.sun.java.util.jar.pack.ConstantPool.*; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import java.util.AbstractCollection; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; /** * Collection of relocatable constant pool references. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Histogram.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Histogram.java index 1c03e592b02..92cf6e4e918 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Histogram.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Histogram.java @@ -25,8 +25,10 @@ package com.sun.java.util.jar.pack; -import java.util.*; -import java.io.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.util.Arrays; /** * Histogram derived from an integer array of events (int[]). diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java index c6d96085180..2ea9f4d4721 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java @@ -26,10 +26,18 @@ package com.sun.java.util.jar.pack; -import java.nio.*; -import java.io.*; -import java.util.jar.*; -import java.util.zip.*; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.util.jar.JarOutputStream; +import java.util.jar.Pack200; +import java.util.zip.CRC32; +import java.util.zip.Deflater; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; class NativeUnpack { // Pointer to the native unpacker obj diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Package.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Package.java index 29d217687c4..981bd53b75c 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Package.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Package.java @@ -26,11 +26,32 @@ package com.sun.java.util.jar.pack; import com.sun.java.util.jar.pack.Attribute.Layout; +import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; +import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import com.sun.java.util.jar.pack.ConstantPool.LiteralEntry; +import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.SequenceInputStream; import java.lang.reflect.Modifier; -import java.util.*; -import java.util.jar.*; -import java.io.*; -import com.sun.java.util.jar.pack.ConstantPool.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; +import java.util.jar.JarFile; /** * Define the main data structure transmitted by pack/unpack. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java index 73efca5ca85..be8ba0d008b 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java @@ -25,12 +25,18 @@ package com.sun.java.util.jar.pack; +import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; +import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import com.sun.java.util.jar.pack.ConstantPool.MemberEntry; +import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry; +import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry; import java.io.*; import java.util.*; import com.sun.java.util.jar.pack.Package.Class; import com.sun.java.util.jar.pack.Package.File; import com.sun.java.util.jar.pack.Package.InnerClass; -import com.sun.java.util.jar.pack.ConstantPool.*; /** * Reader for a package file. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java index 55b64cce5e8..cbfcb8aacfd 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java @@ -25,12 +25,30 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; +import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; +import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import com.sun.java.util.jar.pack.ConstantPool.IndexGroup; +import com.sun.java.util.jar.pack.ConstantPool.MemberEntry; +import com.sun.java.util.jar.pack.ConstantPool.NumberEntry; +import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry; +import com.sun.java.util.jar.pack.ConstantPool.StringEntry; import com.sun.java.util.jar.pack.Package.Class; import com.sun.java.util.jar.pack.Package.File; import com.sun.java.util.jar.pack.Package.InnerClass; -import com.sun.java.util.jar.pack.ConstantPool.*; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; /** * Writer for a package file. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java index f4840709997..7e2f6a27c02 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java @@ -26,10 +26,27 @@ package com.sun.java.util.jar.pack; import com.sun.java.util.jar.pack.Attribute.Layout; -import java.util.*; -import java.util.jar.*; -import java.io.*; import java.beans.PropertyChangeListener; +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.SortedMap; +import java.util.TimeZone; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarInputStream; +import java.util.jar.Pack200; /* diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java index 599d86fa6b2..3e5ecf170c3 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java @@ -25,8 +25,12 @@ package com.sun.java.util.jar.pack; -import java.util.*; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Arrays; +import java.util.HashSet; /** * Population-based coding. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java index 78c709f343d..3072ef394eb 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java @@ -25,13 +25,24 @@ package com.sun.java.util.jar.pack; -import java.util.*; -import java.util.jar.*; -import java.util.jar.Pack200; -import java.util.zip.*; -import java.io.*; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; +import java.util.jar.Pack200; /** * Control block for publishing Pack200 options to the other classes. */ diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java index 5b9f8ec61f6..a0c1e4d26ef 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java @@ -25,11 +25,25 @@ package com.sun.java.util.jar.pack; -import java.util.*; -import java.util.jar.*; -import java.util.zip.*; -import java.io.*; import java.beans.PropertyChangeListener; +import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.HashSet; +import java.util.Iterator; +import java.util.SortedMap; +import java.util.TimeZone; +import java.util.jar.JarEntry; +import java.util.jar.JarInputStream; +import java.util.jar.JarOutputStream; +import java.util.jar.Pack200; +import java.util.zip.CRC32; +import java.util.zip.CheckedOutputStream; +import java.util.zip.ZipEntry; /* * Implementation of the Pack provider. diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/Utils.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/Utils.java index 84f65ac2ccf..d14d59926ca 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Utils.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Utils.java @@ -25,18 +25,27 @@ package com.sun.java.util.jar.pack; -import com.sun.java.util.jar.pack.Attribute.Layout; import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; import com.sun.java.util.jar.pack.ConstantPool.LiteralEntry; import com.sun.java.util.jar.pack.ConstantPool.MemberEntry; import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry; import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry; -import java.util.*; -import java.util.jar.*; -import java.util.zip.*; -import java.io.*; - +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Date; +import java.util.Enumeration; +import java.util.Map; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarInputStream; +import java.util.jar.JarOutputStream; +import java.util.zip.ZipEntry; import sun.util.logging.PlatformLogger; class Utils { From be8a607fef4c40a9c2217d206aacb498b052d70a Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Mon, 29 Nov 2010 14:15:36 -0800 Subject: [PATCH 68/89] 6900037: javac should warn if earlier -source is used and bootclasspath not set Reviewed-by: darcy --- .../com/sun/tools/javac/code/Lint.java | 35 ++++++++------- .../tools/javac/file/JavacFileManager.java | 5 +++ .../com/sun/tools/javac/file/Paths.java | 45 ++++++++++++++----- .../sun/tools/javac/main/JavaCompiler.java | 15 ++++++- .../com/sun/tools/javac/main/Main.java | 5 ++- .../tools/javac/nio/JavacPathFileManager.java | 5 +++ .../tools/javac/resources/compiler.properties | 3 ++ .../sun/tools/javac/util/BaseFileManager.java | 5 ++- .../test/tools/javac/6341866/T6341866.java | 2 +- .../ClassFileModifiers/MemberModifiers.java | 2 +- langtools/test/tools/javac/T6900037.java | 34 ++++++++++++++ langtools/test/tools/javac/T6900037.out | 4 ++ .../javac/TryWithResources/PlainTry.java | 4 +- .../test/tools/javac/annotations/neg/Dep.java | 6 +-- .../examples/AnnotationsNotSupported.java | 2 +- .../diags/examples/AssertAsIdentifier.java | 2 +- .../diags/examples/DiamondNotSupported.java | 2 +- .../diags/examples/EnumAsIdentifier.java | 2 +- .../diags/examples/EnumsNotSupported.java | 2 +- .../tools/javac/diags/examples/Expected2.java | 2 +- .../diags/examples/ForeachNotSupported.java | 2 +- .../diags/examples/GenericsNotSupported.java | 2 +- .../examples/MulticatchNotSupported.java | 2 +- .../examples/NeitherConditionalSubtype.java | 2 +- .../diags/examples/SourceNoBootclasspath.java | 27 +++++++++++ .../examples/StaticImportNotSupported.java | 2 +- .../examples/StringSwitchNotSupported.java | 2 +- .../examples/TryResourceNotSupported.java | 2 +- .../examples/TryWithoutCatchOrFinally.java | 2 +- .../examples/UnsupportedBinaryLiteral.java | 2 +- .../diags/examples/UnsupportedFpLit.java | 2 +- .../UnsupportedUnderscoreLiteral.java | 2 +- .../diags/examples/VarargsNotSupported.java | 2 +- .../tools/javac/enum/6384542/T6384542.java | 4 +- .../tools/javac/enum/6384542/T6384542a.java | 4 +- .../javac/literals/BadBinaryLiterals.java | 2 +- .../javac/literals/BadUnderscoreLiterals.java | 2 +- .../warnings/TestSourceVersionWarnings.java | 18 ++++---- .../tools/javac/varargs/warning/Warn1.java | 2 +- 39 files changed, 193 insertions(+), 72 deletions(-) create mode 100644 langtools/test/tools/javac/T6900037.java create mode 100644 langtools/test/tools/javac/T6900037.out create mode 100644 langtools/test/tools/javac/diags/examples/SourceNoBootclasspath.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java b/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java index 5145ca2a4c4..06d25c26419 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java @@ -164,6 +164,11 @@ public class Lint */ FINALLY("finally"), + /** + * Warn about issues relating to use of command line options + */ + OPTIONS("options"), + /** * Warn about issues regarding method overrides. */ @@ -181,25 +186,15 @@ public class Lint */ PROCESSING("processing"), - /** - * Warn about Serializable classes that do not provide a serial version ID. - */ - SERIAL("serial"), - - /** - * Warn about unchecked operations on raw types. - */ - UNCHECKED("unchecked"), - /** * Warn about unchecked operations on raw types. */ RAW("rawtypes"), /** - * Warn about proprietary API that may be removed in a future release. + * Warn about Serializable classes that do not provide a serial version ID. */ - SUNAPI("sunapi", true), + SERIAL("serial"), /** * Warn about issues relating to use of statics @@ -207,14 +202,24 @@ public class Lint STATIC("static"), /** - * Warn about potentially unsafe vararg methods + * Warn about proprietary API that may be removed in a future release. */ - VARARGS("varargs"), + SUNAPI("sunapi", true), /** * Warn about issues relating to use of try blocks (i.e. try-with-resources) */ - TRY("try"); + TRY("try"), + + /** + * Warn about unchecked operations on raw types. + */ + UNCHECKED("unchecked"), + + /** + * Warn about potentially unsafe vararg methods + */ + VARARGS("varargs"); LintCategory(String option) { this(option, false); diff --git a/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java b/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java index 6f97aec679e..f57579e9f0d 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java +++ b/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java @@ -174,6 +174,11 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil } } + @Override + public boolean isDefaultBootClassPath() { + return paths.isDefaultBootClassPath(); + } + public JavaFileObject getFileForInput(String name) { return getRegularFile(new File(name)); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java b/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java index 67b21614e20..28387af1be1 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java +++ b/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java @@ -114,6 +114,11 @@ public class Paths { */ private File bootClassPathRtJar = null; + /** + * Is bootclasspath the default? + */ + private boolean isDefaultBootClassPath; + Path getPathForLocation(Location location) { Path path = pathsForLocation.get(location); if (path == null) @@ -129,7 +134,7 @@ public class Paths { if (location == CLASS_PATH) p = computeUserClassPath(); else if (location == PLATFORM_CLASS_PATH) - p = computeBootClassPath(); + p = computeBootClassPath(); // sets isDefaultBootClassPath else if (location == ANNOTATION_PROCESSOR_PATH) p = computeAnnotationProcessorPath(); else if (location == SOURCE_PATH) @@ -138,6 +143,8 @@ public class Paths { // no defaults for other paths p = null; } else { + if (location == PLATFORM_CLASS_PATH) + isDefaultBootClassPath = false; p = new Path(); for (File f: path) p.addFile(f, warn); // TODO: is use of warn appropriate? @@ -145,6 +152,11 @@ public class Paths { pathsForLocation.put(location, p); } + boolean isDefaultBootClassPath() { + lazy(); + return isDefaultBootClassPath; + } + protected void lazy() { if (!inited) { warn = lint.isEnabled(Lint.LintCategory.PATH); @@ -262,9 +274,10 @@ public class Paths { } public Path addFiles(String files, boolean warn) { - if (files != null) + if (files != null) { for (File file : getPathEntries(files, emptyPathDefault)) addFile(file, warn); + } return this; } @@ -334,18 +347,23 @@ public class Paths { private Path computeBootClassPath() { bootClassPathRtJar = null; - String optionValue; Path path = new Path(); - path.addFiles(options.get(XBOOTCLASSPATH_PREPEND)); + String bootclasspathOpt = options.get(BOOTCLASSPATH); + String endorseddirsOpt = options.get(ENDORSEDDIRS); + String extdirsOpt = options.get(EXTDIRS); + String xbootclasspathPrependOpt = options.get(XBOOTCLASSPATH_PREPEND); + String xbootclasspathAppendOpt = options.get(XBOOTCLASSPATH_APPEND); - if ((optionValue = options.get(ENDORSEDDIRS)) != null) - path.addDirectories(optionValue); + path.addFiles(xbootclasspathPrependOpt); + + if (endorseddirsOpt != null) + path.addDirectories(endorseddirsOpt); else path.addDirectories(System.getProperty("java.endorsed.dirs"), false); - if ((optionValue = options.get(BOOTCLASSPATH)) != null) { - path.addFiles(optionValue); + if (bootclasspathOpt != null) { + path.addFiles(bootclasspathOpt); } else { // Standard system classes for this compiler's release. String files = System.getProperty("sun.boot.class.path"); @@ -357,16 +375,21 @@ public class Paths { } } - path.addFiles(options.get(XBOOTCLASSPATH_APPEND)); + path.addFiles(xbootclasspathAppendOpt); // Strictly speaking, standard extensions are not bootstrap // classes, but we treat them identically, so we'll pretend // that they are. - if ((optionValue = options.get(EXTDIRS)) != null) - path.addDirectories(optionValue); + if (extdirsOpt != null) + path.addDirectories(extdirsOpt); else path.addDirectories(System.getProperty("java.ext.dirs"), false); + isDefaultBootClassPath = + (xbootclasspathPrependOpt == null) && + (bootclasspathOpt == null) && + (xbootclasspathAppendOpt == null); + return path; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java index 03996018d58..4e190e8a5f8 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -51,6 +51,7 @@ import com.sun.source.util.TaskListener; import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.util.*; import com.sun.tools.javac.code.*; +import com.sun.tools.javac.code.Lint.LintCategory; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.tree.JCTree.*; @@ -370,6 +371,15 @@ public class JavaCompiler implements ClassReader.SourceCompleter { processPcks = options.isSet("process.packages"); werror = options.isSet(WERROR); + if (source.compareTo(Source.DEFAULT) < 0) { + if (options.isUnset(XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option)) { + if (fileManager instanceof BaseFileManager) { + if (((BaseFileManager) fileManager).isDefaultBootClassPath()) + log.warning(LintCategory.OPTIONS, "source.no.bootclasspath", source.name); + } + } + } + verboseCompilePolicy = options.isSet("verboseCompilePolicy"); if (attrParseOnly) @@ -783,6 +793,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { hasBeenUsed = true; start_msec = now(); + try { initProcessAnnotations(processors); @@ -797,7 +808,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { elapsed_msec = delegateCompiler.elapsed_msec; } catch (Abort ex) { if (devVerbose) - ex.printStackTrace(); + ex.printStackTrace(System.err); } finally { if (procEnvImpl != null) procEnvImpl.close(); @@ -841,7 +852,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { } } catch (Abort ex) { if (devVerbose) - ex.printStackTrace(); + ex.printStackTrace(System.err); } if (verbose) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java index e5e53dc1ad3..85a50238538 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java @@ -420,7 +420,7 @@ public class Main { processors); if (log.expectDiagKeys != null) { - if (log.expectDiagKeys.size() == 0) { + if (log.expectDiagKeys.isEmpty()) { Log.printLines(log.noticeWriter, "all expected diagnostics found"); return EXIT_OK; } else { @@ -506,7 +506,7 @@ public class Main { void apMessage(AnnotationProcessingError ex) { Log.printLines(out, getLocalizedString("msg.proc.annotation.uncaught.exception")); - ex.getCause().printStackTrace(); + ex.getCause().printStackTrace(out); } /** Display the location and checksum of a class. */ @@ -563,6 +563,7 @@ public class Main { public static void useRawMessages(boolean enable) { if (enable) { messages = new JavacMessages(javacBundleName) { + @Override public String getLocalizedString(String key, Object... args) { return key; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java b/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java index 1181c274e71..52672f8185a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java +++ b/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java @@ -172,6 +172,11 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan return getClassLoader(lb.toArray(new URL[lb.size()])); } + @Override + public boolean isDefaultBootClassPath() { + return searchPaths.isDefaultBootClassPath(); + } + // public boolean hasLocation(Location location) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties index 58c1f660ef3..27c8ba2622f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -764,6 +764,9 @@ compiler.warn.big.major.version=\ compiler.warn.static.not.qualified.by.type=\ static {0} should be qualified by type name, {1}, instead of by an expression +compiler.warn.source.no.bootclasspath=\ + bootstrap class path not set in conjunction with -source {0} + # Warnings related to annotation processing compiler.warn.proc.package.does.not.exist=\ package {0} does not exist diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java b/langtools/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java index b5e1d53306e..9328bde0613 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java @@ -59,7 +59,7 @@ import javax.tools.JavaFileObject.Kind; * There are no references here to file-system specific objects such as * java.io.File or java.nio.file.Path. */ -public class BaseFileManager { +public abstract class BaseFileManager { protected BaseFileManager(Charset charset) { this.charset = charset; byteBufferCache = new ByteBufferCache(); @@ -163,6 +163,9 @@ public class BaseFileManager { } return -1; } + + public abstract boolean isDefaultBootClassPath(); + // // diff --git a/langtools/test/tools/javac/6341866/T6341866.java b/langtools/test/tools/javac/6341866/T6341866.java index 7a62987a4b6..6fe0258b0b5 100644 --- a/langtools/test/tools/javac/6341866/T6341866.java +++ b/langtools/test/tools/javac/6341866/T6341866.java @@ -97,7 +97,7 @@ public class T6341866 { processorServices.delete(); List opts = new ArrayList(); - opts.addAll(Arrays.asList("-d", ".", "-sourcepath", testSrc, "-classpath", testClasses, "-source", "1.6")); + opts.addAll(Arrays.asList("-d", ".", "-sourcepath", testSrc, "-classpath", testClasses, "-source", "1.6", "-Xlint:-options")); if (implicitType.opt != null) opts.add(implicitType.opt); diff --git a/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java b/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java index 8eec7c1e276..55c7633c01c 100644 --- a/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java +++ b/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java @@ -26,7 +26,7 @@ * @bug 4249112 4785453 * @summary Verify that implicit member modifiers are set correctly. * - * @compile/ref=MemberModifiers.out -source 1.4 -target 1.4.2 -XDdumpmodifiers=cfm MemberModifiers.java + * @compile/ref=MemberModifiers.out -source 1.4 -target 1.4.2 -Xlint:-options -XDdumpmodifiers=cfm MemberModifiers.java */ // Currently, we check only that members of final classes are not final. diff --git a/langtools/test/tools/javac/T6900037.java b/langtools/test/tools/javac/T6900037.java new file mode 100644 index 00000000000..c5002e02e20 --- /dev/null +++ b/langtools/test/tools/javac/T6900037.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2010, 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 6900037 + * @summary javac should warn if earlier -source is used and bootclasspath not set + * @compile T6900037.java + * @compile -source 1.6 T6900037.java + * @compile/fail/ref=T6900037.out -XDrawDiagnostics -Werror -source 1.6 T6900037.java + * @compile -Werror -source 1.6 -Xlint:-options T6900037.java + */ + +class T6900037 { } diff --git a/langtools/test/tools/javac/T6900037.out b/langtools/test/tools/javac/T6900037.out new file mode 100644 index 00000000000..f98225f4ecf --- /dev/null +++ b/langtools/test/tools/javac/T6900037.out @@ -0,0 +1,4 @@ +- compiler.warn.source.no.bootclasspath: 1.6 +- compiler.err.warnings.and.werror +1 error +1 warning diff --git a/langtools/test/tools/javac/TryWithResources/PlainTry.java b/langtools/test/tools/javac/TryWithResources/PlainTry.java index fad4ca8c054..294012f8b83 100644 --- a/langtools/test/tools/javac/TryWithResources/PlainTry.java +++ b/langtools/test/tools/javac/TryWithResources/PlainTry.java @@ -3,8 +3,8 @@ * @bug 6911256 6964740 * @author Joseph D. Darcy * @summary Test error messages for an unadorned try - * @compile/fail/ref=PlainTry6.out -XDrawDiagnostics -source 6 PlainTry.java - * @compile/fail/ref=PlainTry.out -XDrawDiagnostics PlainTry.java + * @compile/fail/ref=PlainTry6.out -XDrawDiagnostics -source 6 -Xlint:-options PlainTry.java + * @compile/fail/ref=PlainTry.out -XDrawDiagnostics PlainTry.java */ public class PlainTry { public static void main(String... args) { diff --git a/langtools/test/tools/javac/annotations/neg/Dep.java b/langtools/test/tools/javac/annotations/neg/Dep.java index 4ffbe3f3ef0..58ac9622b60 100644 --- a/langtools/test/tools/javac/annotations/neg/Dep.java +++ b/langtools/test/tools/javac/annotations/neg/Dep.java @@ -27,9 +27,9 @@ * @summary Please add annotation Deprecated to supplant the javadoc tag * @author gafter * - * @compile -source 1.4 -Xlint:dep-ann -Werror Dep.java - * @compile/fail -Xlint:dep-ann -Werror Dep.java - * @compile -Xlint:dep-ann Dep.java + * @compile -source 1.4 -Xlint:-options -Xlint:dep-ann -Werror Dep.java + * @compile/fail -Xlint:dep-ann -Werror Dep.java + * @compile -Xlint:dep-ann Dep.java */ /** @deprecated */ diff --git a/langtools/test/tools/javac/diags/examples/AnnotationsNotSupported.java b/langtools/test/tools/javac/diags/examples/AnnotationsNotSupported.java index 9ab2747c522..e318d70d6e3 100644 --- a/langtools/test/tools/javac/diags/examples/AnnotationsNotSupported.java +++ b/langtools/test/tools/javac/diags/examples/AnnotationsNotSupported.java @@ -22,7 +22,7 @@ */ // key: compiler.err.annotations.not.supported.in.source -// options: -source 1.4 +// options: -source 1.4 -Xlint:-options @Deprecated class AnnotationsNotSupported { } diff --git a/langtools/test/tools/javac/diags/examples/AssertAsIdentifier.java b/langtools/test/tools/javac/diags/examples/AssertAsIdentifier.java index 9c09276c158..5a4e5a258f3 100644 --- a/langtools/test/tools/javac/diags/examples/AssertAsIdentifier.java +++ b/langtools/test/tools/javac/diags/examples/AssertAsIdentifier.java @@ -22,7 +22,7 @@ */ // key: compiler.warn.assert.as.identifier -// options: -source 1.3 +// options: -source 1.3 -Xlint:-options class AssertAsIdentifier { int assert; diff --git a/langtools/test/tools/javac/diags/examples/DiamondNotSupported.java b/langtools/test/tools/javac/diags/examples/DiamondNotSupported.java index d4c2a13b201..82b38f1975b 100644 --- a/langtools/test/tools/javac/diags/examples/DiamondNotSupported.java +++ b/langtools/test/tools/javac/diags/examples/DiamondNotSupported.java @@ -22,7 +22,7 @@ */ // key: compiler.err.diamond.not.supported.in.source -// options: -source 6 +// options: -source 6 -Xlint:-options import java.util.*; diff --git a/langtools/test/tools/javac/diags/examples/EnumAsIdentifier.java b/langtools/test/tools/javac/diags/examples/EnumAsIdentifier.java index 00ec5f712ea..bfa3d211ad3 100644 --- a/langtools/test/tools/javac/diags/examples/EnumAsIdentifier.java +++ b/langtools/test/tools/javac/diags/examples/EnumAsIdentifier.java @@ -22,7 +22,7 @@ */ // key: compiler.warn.enum.as.identifier -// options: -source 1.3 +// options: -source 1.3 -Xlint:-options class EnumAsIdentifier { int enum; diff --git a/langtools/test/tools/javac/diags/examples/EnumsNotSupported.java b/langtools/test/tools/javac/diags/examples/EnumsNotSupported.java index 6f288ca1057..5b90eec64b4 100644 --- a/langtools/test/tools/javac/diags/examples/EnumsNotSupported.java +++ b/langtools/test/tools/javac/diags/examples/EnumsNotSupported.java @@ -22,6 +22,6 @@ */ // key: compiler.err.enums.not.supported.in.source -// options: -source 1.4 +// options: -source 1.4 -Xlint:-options enum EnumsNotSupported { A, B, C } diff --git a/langtools/test/tools/javac/diags/examples/Expected2.java b/langtools/test/tools/javac/diags/examples/Expected2.java index 008146a0341..0eee97aff20 100644 --- a/langtools/test/tools/javac/diags/examples/Expected2.java +++ b/langtools/test/tools/javac/diags/examples/Expected2.java @@ -22,6 +22,6 @@ */ // key: compiler.err.expected2 -// options: -source 1.4 +// options: -source 1.4 -Xlint:-options int Expected2; diff --git a/langtools/test/tools/javac/diags/examples/ForeachNotSupported.java b/langtools/test/tools/javac/diags/examples/ForeachNotSupported.java index a8ec5b943a0..2590cb3c721 100644 --- a/langtools/test/tools/javac/diags/examples/ForeachNotSupported.java +++ b/langtools/test/tools/javac/diags/examples/ForeachNotSupported.java @@ -22,7 +22,7 @@ */ // key: compiler.err.foreach.not.supported.in.source -// options: -source 1.4 +// options: -source 1.4 -Xlint:-options class ForeachNotSupported { void m(String[] args) { diff --git a/langtools/test/tools/javac/diags/examples/GenericsNotSupported.java b/langtools/test/tools/javac/diags/examples/GenericsNotSupported.java index 374fe29a2fe..d64f74cb824 100644 --- a/langtools/test/tools/javac/diags/examples/GenericsNotSupported.java +++ b/langtools/test/tools/javac/diags/examples/GenericsNotSupported.java @@ -22,6 +22,6 @@ */ // key: compiler.err.generics.not.supported.in.source -// options: -source 1.4 +// options: -source 1.4 -Xlint:-options class GenericsNotSupported { } diff --git a/langtools/test/tools/javac/diags/examples/MulticatchNotSupported.java b/langtools/test/tools/javac/diags/examples/MulticatchNotSupported.java index 76efa83f592..9159a609fc1 100644 --- a/langtools/test/tools/javac/diags/examples/MulticatchNotSupported.java +++ b/langtools/test/tools/javac/diags/examples/MulticatchNotSupported.java @@ -22,7 +22,7 @@ */ // key: compiler.err.multicatch.not.supported.in.source -// options: -source 1.6 +// options: -source 1.6 -Xlint:-options class MulticatchNotSupported { class E1 extends Exception { } diff --git a/langtools/test/tools/javac/diags/examples/NeitherConditionalSubtype.java b/langtools/test/tools/javac/diags/examples/NeitherConditionalSubtype.java index 647487c450b..ac766332aad 100644 --- a/langtools/test/tools/javac/diags/examples/NeitherConditionalSubtype.java +++ b/langtools/test/tools/javac/diags/examples/NeitherConditionalSubtype.java @@ -22,7 +22,7 @@ */ // key: compiler.err.neither.conditional.subtype -// options: -source 1.4 +// options: -source 1.4 -Xlint:-options class X { Object m(boolean b) { diff --git a/langtools/test/tools/javac/diags/examples/SourceNoBootclasspath.java b/langtools/test/tools/javac/diags/examples/SourceNoBootclasspath.java new file mode 100644 index 00000000000..6cc20165cef --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/SourceNoBootclasspath.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2010, 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. + */ + +// key: compiler.warn.source.no.bootclasspath +// options: -source 6 + +class SourceNoBootclasspath { } diff --git a/langtools/test/tools/javac/diags/examples/StaticImportNotSupported.java b/langtools/test/tools/javac/diags/examples/StaticImportNotSupported.java index ee151a25057..c545c19cd06 100644 --- a/langtools/test/tools/javac/diags/examples/StaticImportNotSupported.java +++ b/langtools/test/tools/javac/diags/examples/StaticImportNotSupported.java @@ -22,7 +22,7 @@ */ // key: compiler.err.static.import.not.supported.in.source -// options: -source 1.4 +// options: -source 1.4 -Xlint:-options import static java.util.regex.Pattern.*; diff --git a/langtools/test/tools/javac/diags/examples/StringSwitchNotSupported.java b/langtools/test/tools/javac/diags/examples/StringSwitchNotSupported.java index b6169d1c09c..3df19d6ee5f 100644 --- a/langtools/test/tools/javac/diags/examples/StringSwitchNotSupported.java +++ b/langtools/test/tools/javac/diags/examples/StringSwitchNotSupported.java @@ -22,7 +22,7 @@ */ // key: compiler.err.string.switch.not.supported.in.source -// options: -source 6 +// options: -source 6 -Xlint:-options class StringSwitchNotSupported { int m(String s) { diff --git a/langtools/test/tools/javac/diags/examples/TryResourceNotSupported.java b/langtools/test/tools/javac/diags/examples/TryResourceNotSupported.java index 9063dc9651e..bd3a04bb947 100644 --- a/langtools/test/tools/javac/diags/examples/TryResourceNotSupported.java +++ b/langtools/test/tools/javac/diags/examples/TryResourceNotSupported.java @@ -22,7 +22,7 @@ */ // key: compiler.err.try.with.resources.not.supported.in.source -// options: -source 1.6 +// options: -source 1.6 -Xlint:-options import java.io.*; diff --git a/langtools/test/tools/javac/diags/examples/TryWithoutCatchOrFinally.java b/langtools/test/tools/javac/diags/examples/TryWithoutCatchOrFinally.java index 78511219056..bd23aad855b 100644 --- a/langtools/test/tools/javac/diags/examples/TryWithoutCatchOrFinally.java +++ b/langtools/test/tools/javac/diags/examples/TryWithoutCatchOrFinally.java @@ -22,7 +22,7 @@ */ // key: compiler.err.try.without.catch.or.finally -// options: -source 1.6 +// options: -source 1.6 -Xlint:-options class TryWithoutCatchOrFinally { void m() { diff --git a/langtools/test/tools/javac/diags/examples/UnsupportedBinaryLiteral.java b/langtools/test/tools/javac/diags/examples/UnsupportedBinaryLiteral.java index 6d620c94244..7a311b25f3c 100644 --- a/langtools/test/tools/javac/diags/examples/UnsupportedBinaryLiteral.java +++ b/langtools/test/tools/javac/diags/examples/UnsupportedBinaryLiteral.java @@ -22,7 +22,7 @@ */ // key: compiler.err.unsupported.binary.lit -// options: -source 6 +// options: -source 6 -Xlint:-options class UnsupportedBinaryLiteral { int i = 0b01000010; diff --git a/langtools/test/tools/javac/diags/examples/UnsupportedFpLit.java b/langtools/test/tools/javac/diags/examples/UnsupportedFpLit.java index c2ced724d6b..8f70b6e88d8 100644 --- a/langtools/test/tools/javac/diags/examples/UnsupportedFpLit.java +++ b/langtools/test/tools/javac/diags/examples/UnsupportedFpLit.java @@ -22,7 +22,7 @@ */ // key: compiler.err.unsupported.fp.lit -// options: -source 1.4 +// options: -source 1.4 -Xlint:-options class UnsupportedFpLit { float f = 0xCafe.BabeP1; diff --git a/langtools/test/tools/javac/diags/examples/UnsupportedUnderscoreLiteral.java b/langtools/test/tools/javac/diags/examples/UnsupportedUnderscoreLiteral.java index 233f93f880a..3ae8cc9ba37 100644 --- a/langtools/test/tools/javac/diags/examples/UnsupportedUnderscoreLiteral.java +++ b/langtools/test/tools/javac/diags/examples/UnsupportedUnderscoreLiteral.java @@ -22,7 +22,7 @@ */ // key: compiler.err.unsupported.underscore.lit -// options: -source 6 +// options: -source 6 -Xlint:-options class UnsupportedUnderscoreLiteral { int i = 123_456_789; diff --git a/langtools/test/tools/javac/diags/examples/VarargsNotSupported.java b/langtools/test/tools/javac/diags/examples/VarargsNotSupported.java index 559340352c8..110b71af421 100644 --- a/langtools/test/tools/javac/diags/examples/VarargsNotSupported.java +++ b/langtools/test/tools/javac/diags/examples/VarargsNotSupported.java @@ -22,7 +22,7 @@ */ // key: compiler.err.varargs.not.supported.in.source -// options: -source 1.4 +// options: -source 1.4 -Xlint:-options class VarargsNotSupported { void m(String... args) { } diff --git a/langtools/test/tools/javac/enum/6384542/T6384542.java b/langtools/test/tools/javac/enum/6384542/T6384542.java index 06b15b71069..234ba485864 100644 --- a/langtools/test/tools/javac/enum/6384542/T6384542.java +++ b/langtools/test/tools/javac/enum/6384542/T6384542.java @@ -3,8 +3,8 @@ * @bug 6384542 * @summary crash: test/tools/javac/versions/check.sh * @author Peter von der Ah\u00e9 - * @compile/fail -source 1.4 T6384542.java - * @compile/fail/ref=T6384542.out -source 1.4 -XDrawDiagnostics T6384542.java + * @compile/fail -source 1.4 -Xlint:-options T6384542.java + * @compile/fail/ref=T6384542.out -source 1.4 -Xlint:-options -XDrawDiagnostics T6384542.java */ import static java.lang.Math.sin; diff --git a/langtools/test/tools/javac/enum/6384542/T6384542a.java b/langtools/test/tools/javac/enum/6384542/T6384542a.java index cb95a527e6c..f313b73f167 100644 --- a/langtools/test/tools/javac/enum/6384542/T6384542a.java +++ b/langtools/test/tools/javac/enum/6384542/T6384542a.java @@ -5,8 +5,8 @@ * @author Peter von der Ah\u00e9 * @compile/fail -source 5 T6384542a.java * @compile -source 1.4 T6384542a.java - * @compile/fail/ref=T6384542a_5.out -source 5 -XDrawDiagnostics T6384542a.java - * @compile/ref=T6384542a_1_4.out -source 1.4 -XDrawDiagnostics T6384542a.java + * @compile/fail/ref=T6384542a_5.out -source 5 -Xlint:-options -XDrawDiagnostics T6384542a.java + * @compile/ref=T6384542a_1_4.out -source 1.4 -Xlint:-options -XDrawDiagnostics T6384542a.java */ public class T6384542a { diff --git a/langtools/test/tools/javac/literals/BadBinaryLiterals.java b/langtools/test/tools/javac/literals/BadBinaryLiterals.java index 8a8f5ea5568..034d1f6d6f2 100644 --- a/langtools/test/tools/javac/literals/BadBinaryLiterals.java +++ b/langtools/test/tools/javac/literals/BadBinaryLiterals.java @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 6860965 * @summary Project Coin: binary literals - * @compile/fail/ref=BadBinaryLiterals.6.out -XDrawDiagnostics -source 6 BadBinaryLiterals.java + * @compile/fail/ref=BadBinaryLiterals.6.out -XDrawDiagnostics -source 6 -Xlint:-options BadBinaryLiterals.java * @compile/fail/ref=BadBinaryLiterals.7.out -XDrawDiagnostics BadBinaryLiterals.java */ diff --git a/langtools/test/tools/javac/literals/BadUnderscoreLiterals.java b/langtools/test/tools/javac/literals/BadUnderscoreLiterals.java index 26debae019b..2254596192b 100644 --- a/langtools/test/tools/javac/literals/BadUnderscoreLiterals.java +++ b/langtools/test/tools/javac/literals/BadUnderscoreLiterals.java @@ -7,7 +7,7 @@ * @compile/fail/ref=BadUnderscoreLiterals.7.out -XDrawDiagnostics BadUnderscoreLiterals.java * * @compile/fail -source 6 BadUnderscoreLiterals.java - * @compile/fail/ref=BadUnderscoreLiterals.6.out -XDrawDiagnostics -source 6 BadUnderscoreLiterals.java + * @compile/fail/ref=BadUnderscoreLiterals.6.out -XDrawDiagnostics -source 6 -Xlint:-options BadUnderscoreLiterals.java */ public class BadUnderscoreLiterals { diff --git a/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java b/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java index bba89985c57..a5c0c2f3058 100644 --- a/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java +++ b/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java @@ -27,15 +27,15 @@ * @summary Test that warnings about source versions are output as expected. * @author Joseph D. Darcy * @compile TestSourceVersionWarnings.java - * @compile/ref=gold_0.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -source 1.5 HelloWorld.java - * @compile/ref=gold_sv_warn_0_2.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_0 -source 1.2 HelloWorld.java - * @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_2 -source 1.2 HelloWorld.java - * @compile/ref=gold_sv_warn_2_3.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_2 -source 1.3 HelloWorld.java - * @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_5 -source 1.5 HelloWorld.java - * @compile/ref=gold_sv_warn_5_6.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_5 -source 1.6 HelloWorld.java - * @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 HelloWorld.java - * @compile/ref=gold_unsp_warn.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 -Aunsupported HelloWorld.java - * @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_7 -source 1.7 HelloWorld.java + * @compile/ref=gold_0.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -source 1.5 -Xlint:-options HelloWorld.java + * @compile/ref=gold_sv_warn_0_2.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_0 -source 1.2 -Xlint:-options HelloWorld.java + * @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_2 -source 1.2 -Xlint:-options HelloWorld.java + * @compile/ref=gold_sv_warn_2_3.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_2 -source 1.3 -Xlint:-options HelloWorld.java + * @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_5 -source 1.5 -Xlint:-options HelloWorld.java + * @compile/ref=gold_sv_warn_5_6.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_5 -source 1.6 -Xlint:-options HelloWorld.java + * @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 -Xlint:-options HelloWorld.java + * @compile/ref=gold_unsp_warn.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 -Xlint:-options -Aunsupported HelloWorld.java + * @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_7 -source 1.7 HelloWorld.java */ import java.util.Set; diff --git a/langtools/test/tools/javac/varargs/warning/Warn1.java b/langtools/test/tools/javac/varargs/warning/Warn1.java index 05f68446434..bbafe7dd117 100644 --- a/langtools/test/tools/javac/varargs/warning/Warn1.java +++ b/langtools/test/tools/javac/varargs/warning/Warn1.java @@ -27,7 +27,7 @@ * @summary fixed-arity warning given too often * @author gafter * - * @compile -Werror -source 1.4 Warn1.java + * @compile -Werror -source 1.4 -Xlint:-options Warn1.java */ package varargs.warning.warn1; From cf15a10d325341be22096c522fbfd62d1d2569be Mon Sep 17 00:00:00 2001 From: Anthony Petrov Date: Tue, 30 Nov 2010 17:36:56 +0300 Subject: [PATCH 69/89] 6998592: FileDialog tests crashed on solaris Override GtkFileDialogPeer.toFront() Reviewed-by: art, dcherepanov --- jdk/make/sun/xawt/mapfile-vers | 1 + .../sun/awt/X11/GtkFileDialogPeer.java | 5 ++++- .../solaris/native/sun/awt/gtk2_interface.c | 1 + .../solaris/native/sun/awt/gtk2_interface.h | 1 + .../sun/awt/sun_awt_X11_GtkFileDialogPeer.c | 22 +++++++++++++++++++ .../sun/awt/sun_awt_X11_GtkFileDialogPeer.h | 8 +++++++ 6 files changed, 37 insertions(+), 1 deletion(-) diff --git a/jdk/make/sun/xawt/mapfile-vers b/jdk/make/sun/xawt/mapfile-vers index 0d951efff1d..920d829fc93 100644 --- a/jdk/make/sun/xawt/mapfile-vers +++ b/jdk/make/sun/xawt/mapfile-vers @@ -432,6 +432,7 @@ SUNWprivate_1.1 { Java_sun_awt_X11_GtkFileDialogPeer_initIDs; Java_sun_awt_X11_GtkFileDialogPeer_run; Java_sun_awt_X11_GtkFileDialogPeer_quit; + Java_sun_awt_X11_GtkFileDialogPeer_toFront; Java_sun_print_CUPSPrinter_initIDs; Java_sun_print_CUPSPrinter_getCupsServer; diff --git a/jdk/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java b/jdk/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java index f67efb57fb6..572a9200064 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java @@ -57,9 +57,12 @@ class GtkFileDialogPeer extends XDialogPeer implements FileDialogPeer { private native void run(String title, int mode, String dir, String file, FilenameFilter filter, boolean isMultipleMode); - private native void quit(); + @Override + public native void toFront(); + + /** * Called exclusively by the native C code. */ diff --git a/jdk/src/solaris/native/sun/awt/gtk2_interface.c b/jdk/src/solaris/native/sun/awt/gtk2_interface.c index a26a839d120..767fe47cf07 100644 --- a/jdk/src/solaris/native/sun/awt/gtk2_interface.c +++ b/jdk/src/solaris/native/sun/awt/gtk2_interface.c @@ -607,6 +607,7 @@ gboolean gtk2_load() fp_gtk_tree_view_new = dl_symbol("gtk_tree_view_new"); fp_gtk_viewport_new = dl_symbol("gtk_viewport_new"); fp_gtk_window_new = dl_symbol("gtk_window_new"); + fp_gtk_window_present = dl_symbol("gtk_window_present"); fp_gtk_dialog_new = dl_symbol("gtk_dialog_new"); fp_gtk_frame_new = dl_symbol("gtk_frame_new"); diff --git a/jdk/src/solaris/native/sun/awt/gtk2_interface.h b/jdk/src/solaris/native/sun/awt/gtk2_interface.h index 3ecaf94af20..c7265bff4a7 100644 --- a/jdk/src/solaris/native/sun/awt/gtk2_interface.h +++ b/jdk/src/solaris/native/sun/awt/gtk2_interface.h @@ -749,6 +749,7 @@ int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf); int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf); GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error); void (*fp_gtk_widget_destroy)(GtkWidget *widget); +void (*fp_gtk_window_present)(GtkWindow *window); /** diff --git a/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c b/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c index 890284e570e..1832401e4fb 100644 --- a/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c +++ b/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c @@ -80,6 +80,28 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_quit quit(env, jpeer, FALSE); } +/* + * Class: sun_awt_X11_GtkFileDialogPeer + * Method: toFront + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_toFront +(JNIEnv * env, jobject jpeer) +{ + GtkWidget * dialog; + + fp_gdk_threads_enter(); + + dialog = (GtkWidget*)jlong_to_ptr( + (*env)->GetLongField(env, jpeer, widgetFieldID)); + + if (dialog != NULL) { + fp_gtk_window_present((GtkWindow*)dialog); + } + + fp_gdk_threads_leave(); +} + /** * Convert a GSList to an array of filenames (without the parent folder) */ diff --git a/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.h b/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.h index 7c3c2338d10..81ed11ae555 100644 --- a/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.h +++ b/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.h @@ -33,6 +33,14 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_run JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_quit (JNIEnv *, jobject); +/* + * Class: sun_awt_X11_GtkFileDialogPeer + * Method: toFront + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_toFront +(JNIEnv *, jobject); + #ifdef __cplusplus } #endif From 6edf2ff9a30e23b3ac3a2b643267cd6d331ae9c3 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 30 Nov 2010 09:38:48 -0800 Subject: [PATCH 70/89] 7003477: Paths.isDefaultBootClassPath needs to be public Reviewed-by: mcimadamore --- langtools/src/share/classes/com/sun/tools/javac/file/Paths.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java b/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java index 28387af1be1..4f69b27d013 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java +++ b/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java @@ -152,7 +152,7 @@ public class Paths { pathsForLocation.put(location, p); } - boolean isDefaultBootClassPath() { + public boolean isDefaultBootClassPath() { lazy(); return isDefaultBootClassPath; } From efca767f8273fa9b990eff2a2bf73811cc911e0f Mon Sep 17 00:00:00 2001 From: Andrei Dmitriev Date: Tue, 30 Nov 2010 21:54:55 +0300 Subject: [PATCH 71/89] 6783910: (dav) java.awt.Color.brighter()/darker() methods make color opaque Reviewed-by: art, yan --- jdk/src/share/classes/java/awt/Color.java | 23 +++++--- .../Color/OpacityChange/OpacityChange.java | 54 +++++++++++++++++++ 2 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 jdk/test/java/awt/Color/OpacityChange/OpacityChange.java diff --git a/jdk/src/share/classes/java/awt/Color.java b/jdk/src/share/classes/java/awt/Color.java index 8cbe667ca00..2ff9a6d5e1b 100644 --- a/jdk/src/share/classes/java/awt/Color.java +++ b/jdk/src/share/classes/java/awt/Color.java @@ -611,12 +611,15 @@ public class Color implements Paint, java.io.Serializable { *

* This method applies an arbitrary scale factor to each of the three RGB * components of this Color to create a brighter version - * of this Color. Although brighter and + * of this Color. + * The {@code alpha} value is preserved. + * Although brighter and * darker are inverse operations, the results of a * series of invocations of these two methods might be inconsistent * because of rounding errors. * @return a new Color object that is - * a brighter version of this Color. + * a brighter version of this Color + * with the same {@code alpha} value. * @see java.awt.Color#darker * @since JDK1.0 */ @@ -624,6 +627,7 @@ public class Color implements Paint, java.io.Serializable { int r = getRed(); int g = getGreen(); int b = getBlue(); + int alpha = getAlpha(); /* From 2D group: * 1. black.brighter() should return grey @@ -632,7 +636,7 @@ public class Color implements Paint, java.io.Serializable { */ int i = (int)(1.0/(1.0-FACTOR)); if ( r == 0 && g == 0 && b == 0) { - return new Color(i, i, i); + return new Color(i, i, i, alpha); } if ( r > 0 && r < i ) r = i; if ( g > 0 && g < i ) g = i; @@ -640,7 +644,8 @@ public class Color implements Paint, java.io.Serializable { return new Color(Math.min((int)(r/FACTOR), 255), Math.min((int)(g/FACTOR), 255), - Math.min((int)(b/FACTOR), 255)); + Math.min((int)(b/FACTOR), 255), + alpha); } /** @@ -649,19 +654,23 @@ public class Color implements Paint, java.io.Serializable { *

* This method applies an arbitrary scale factor to each of the three RGB * components of this Color to create a darker version of - * this Color. Although brighter and + * this Color. + * The {@code alpha} value is preserved. + * Although brighter and * darker are inverse operations, the results of a series * of invocations of these two methods might be inconsistent because * of rounding errors. * @return a new Color object that is - * a darker version of this Color. + * a darker version of this Color + * with the same {@code alpha} value. * @see java.awt.Color#brighter * @since JDK1.0 */ public Color darker() { return new Color(Math.max((int)(getRed() *FACTOR), 0), Math.max((int)(getGreen()*FACTOR), 0), - Math.max((int)(getBlue() *FACTOR), 0)); + Math.max((int)(getBlue() *FACTOR), 0), + getAlpha()); } /** diff --git a/jdk/test/java/awt/Color/OpacityChange/OpacityChange.java b/jdk/test/java/awt/Color/OpacityChange/OpacityChange.java new file mode 100644 index 00000000000..d3317eb922d --- /dev/null +++ b/jdk/test/java/awt/Color/OpacityChange/OpacityChange.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2010, 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 6783910 + @summary java.awt.Color.brighter()/darker() methods make color opaque + @author Andrei Dmitriev: area=awt-color + @run main OpacityChange +*/ + +import java.awt.*; + +public class OpacityChange { + private final static int INITIAL_ALPHA = 125; + + public static void main(String argv[]) { + Color color = new Color(20, 20, 20, INITIAL_ALPHA); + System.out.println("Initial alpha: " + color.getAlpha()); + Color colorBrighter = color.brighter(); + System.out.println("New alpha (after brighter): " + colorBrighter.getAlpha()); + + Color colorDarker = color.darker(); + System.out.println("New alpha (after darker): " + colorDarker.getAlpha()); + + + if (INITIAL_ALPHA != colorBrighter.getAlpha()) { + throw new RuntimeException("Brighter color alpha has changed from : " +INITIAL_ALPHA + " to " + colorBrighter.getAlpha()); + } + if (INITIAL_ALPHA != colorDarker.getAlpha()) { + throw new RuntimeException("Darker color alpha has changed from : " +INITIAL_ALPHA + " to " + colorDarker.getAlpha()); + } + } +} From 338c085a7f775a41dce99e0eff84dd9bf5b9f300 Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Tue, 30 Nov 2010 13:53:06 -0800 Subject: [PATCH 72/89] 7003544: backout of openjdk changeset 6a391a0ed0da Reviewed-by: ohair --- jdk/make/common/shared/Defs-linux.gmk | 2 +- jdk/make/common/shared/Sanity.gmk | 97 +++++++++++++-------------- 2 files changed, 46 insertions(+), 53 deletions(-) diff --git a/jdk/make/common/shared/Defs-linux.gmk b/jdk/make/common/shared/Defs-linux.gmk index 71272540c05..fbc059c1da6 100644 --- a/jdk/make/common/shared/Defs-linux.gmk +++ b/jdk/make/common/shared/Defs-linux.gmk @@ -123,7 +123,7 @@ LIBM=-lm # GCC29_COMPILER_PATH: is the path to where the gcc 2.9 compiler is installed # NOTE: Must end with / so that it could be empty, allowing PATH usage. -ifdef ALT_GCC29_COMPILER_PATH +ifneq "$(origin ALT_GCC29_COMPILER_PATH)" "undefined" GCC29_COMPILER_PATH :=$(call PrefixPath,$(ALT_GCC29_COMPILER_PATH)) else GCC29_COMPILER_PATH = $(JDK_DEVTOOLS_DIR)/$(PLATFORM)/gcc29/usr/ diff --git a/jdk/make/common/shared/Sanity.gmk b/jdk/make/common/shared/Sanity.gmk index aac7d039c59..39f99ae7c17 100644 --- a/jdk/make/common/shared/Sanity.gmk +++ b/jdk/make/common/shared/Sanity.gmk @@ -99,16 +99,12 @@ ifeq ($(PLATFORM), linux) echo "RedHat"; \ elif [ -f /etc/SuSE-release ] ; then \ echo "SuSE"; \ - elif [ -f /etc/lsb-release ] ; then \ - $(EGREP) DISTRIB_ID /etc/lsb-release | $(SED) -e 's@.*DISTRIB_ID=\(.*\)@\1@'; \ else \ echo "Unknown"; \ fi) OS_VARIANT_VERSION := $(shell \ if [ "$(OS_VARIANT_NAME)" = "Fedora" ] ; then \ $(CAT) /etc/fedora-release | $(HEAD) -1 | $(NAWK) '{ print $$3; }' ; \ - elif [ -f /etc/lsb-release ] ; then \ - $(EGREP) DISTRIB_RELEASE /etc/lsb-release | $(SED) -e 's@.*DISTRIB_RELEASE=\(.*\)@\1@'; \ fi) ALSA_INCLUDE=/usr/include/alsa/version.h ALSA_LIBRARY=/usr/lib/libasound.so @@ -283,7 +279,7 @@ sane-arch_data_model: fi ###################################################### -# Check the OS version (windows and linux have release name checks) +# Check the OS version (windows and linus have release name checks) # NOTE: OPENJDK explicitly does not check for OS release information. # Unless we know for sure that it will not build somewhere, we cannot # generate a fatal sanity error, and a warning about the official @@ -1480,63 +1476,60 @@ ifeq ($(PLATFORM), windows) endif ###################################################### -# Check the GNU C++ compiler for OJI plugin +# Check the Solaris GNU c++ compiler for solaris plugin ###################################################### sane-gcc-compiler: -ifndef OPENJDK - ifeq ($(PLATFORM), solaris) - @if [ -r $(GCC_COMPILER_PATH) ]; then \ - if [ ! "$(GCC_VER)" = $(REQUIRED_GCC_VERSION) ]; then \ - $(ECHO) "ERROR: The Solaris GCC compiler version must be $(REQUIRED_GCC_VERSION). \n" \ - " You are using the following compiler version: $(GCC_VER) \n" \ - " The compiler was obtained from the following location: \n" \ - " $(GCC_COMPILER_PATH) \n" \ - " Please change your compiler. \n" \ - "" >> $(ERROR_FILE) ; \ - fi \ +ifeq ($(PLATFORM), solaris) + ifndef OPENJDK + @if [ -r $(GCC_COMPILER_PATH) ]; then \ + if [ ! "$(GCC_VER)" = $(REQUIRED_GCC_VERSION) ]; then \ + $(ECHO) "ERROR: The Solaris GCC compiler version must be $(REQUIRED_GCC_VERSION). \n" \ + " You are using the following compiler version: $(GCC_VER) \n" \ + " The compiler was obtained from the following location: \n" \ + " $(GCC_COMPILER_PATH) \n" \ + " Please change your compiler. \n" \ + "" >> $(ERROR_FILE) ; \ + fi \ else \ - $(ECHO) "ERROR: You do not have a valid GCC_COMPILER_PATH setting. \n" \ - " Please check your access to \n" \ - " $(GCC_COMPILER_PATH) \n" \ - " and/or check your value of ALT_GCC_COMPILER_PATH. \n" \ - " This will affect you if you build the plugin target. \n" \ - "" >> $(ERROR_FILE) ; \ + $(ECHO) "ERROR: You do not have a valid GCC_COMPILER_PATH setting. \n" \ + " Please check your access to \n" \ + " $(GCC_COMPILER_PATH) \n" \ + " and/or check your value of ALT_GCC_COMPILER_PATH. \n" \ + " This will affect you if you build the plugin target. \n" \ + "" >> $(ERROR_FILE) ; \ fi endif ifeq ($(PLATFORM), linux) - ifeq ($(ARCH_DATA_MODEL), 32) - ifdef ALT_GCC29_COMPILER_PATH + ifdef ALT_GCC29_COMPILER_PATH @if [ ! -x $(ALT_GCC29_COMPILER_PATH)/bin/gcc ]; then \ - $(ECHO) "ERROR: You do not have a valid ALT_GCC29_COMPILER_PATH setting. \n" \ - " Please check your access to \n" \ - " $(ALT_GCC29_COMPILER_PATH)/bin/gcc \n" \ - " This will affect you if you build the plugin target. \n" \ - "" >> $(ERROR_FILE) ; \ - fi - else - ifdef ALT_GCC29_PLUGIN_LIB_PATH - @if [ ! -r $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so ]; then \ + $(ECHO) "ERROR: You do not have a valid ALT_GCC29_COMPILER_PATH setting. \n" \ + " Please check your access to \n" \ + " $(ALT_GCC29_COMPILER_PATH)/bin/gcc \n" \ + " This will affect you if you build the plugin target. \n" \ + "" >> $(ERROR_FILE) ; \ + fi + endif + ifdef ALT_GCC29_PLUGIN_LIB_PATH + @if [ ! -r $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so ]; then \ $(ECHO) "Error: You do not have a valid ALT_GCC29_PLUGIN_LIB_PATH setting. \n" \ - " Please check your access to \n" \ - " $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so \n" \ - " This will affect you if you build the plugin target, specifically for gcc 2.9 version of OJI plugin library. \n" \ - "" >> $(ERROR_FILE) ; \ - fi - else - @if [ ! -r $(GCC29_COMPILER_PATH) ]; then \ + " Please check your access to \n" \ + " $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so \n" \ + " This will affect you if you build the plugin target, specifically for gcc 2.9 version of OJI plugin library. \n" \ + "" >> $(ERROR_FILE) ; \ + fi + else + @if [ ! -r $(GCC29_COMPILER_PATH) ]; then \ $(ECHO) "ERROR: You do not have a valid GCC29_COMPILER_PATH setting. \n" \ - " Please check your access to \n" \ - " $(GCC29_COMPILER_PATH) \n" \ - " and/or check your value of ALT_GCC29_COMPILER_PATH or ALT_GCC29_PLUGIN_LIB_PATH \n" \ - " This will affect you if you build the plugin target. \n" \ - "" >> $(ERROR_FILE) ; \ - fi - endif # ALT_GCC29_PLUGIN_LIB_PATH - endif # ALT_GCC29_COMPILER_PATH - endif # ARCH_DATA_MODEL, 32 - endif # LINUX -endif # OPEN_JDK + " Please check your access to \n" \ + " $(GCC29_COMPILER_PATH) \n" \ + " and/or check your value of ALT_GCC29_COMPILER_PATH. \n" \ + " This will affect you if you build the plugin target. \n" \ + "" >> $(ERROR_FILE) ; \ + fi + endif + endif +endif ###################################################### From 5d80d9aad5af4969f53f6cca95643e3aa2e20e8e Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Thu, 2 Dec 2010 19:03:54 -0800 Subject: [PATCH 73/89] Added tag jdk7-b120 for changeset a841cb10e4ea --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 35f1f600c87..77da515c6e4 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -94,3 +94,4 @@ e8ebdf41b9c01a26642848f4134f5504e8fb3233 jdk7-b115 7220e60b097fa027e922f1aeecdd330f3e37409f jdk7-b117 a12a9e78df8a9d534da0b4a244ed68f0de0bd58e jdk7-b118 661360bef6ccad6c119f067f5829b207de80c936 jdk7-b119 +366ff0b6d2151595629806b033e2e1497e3a55d4 jdk7-b120 From 41f96b787207de43f73973d3d4236eaf156888d2 Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Thu, 2 Dec 2010 19:03:55 -0800 Subject: [PATCH 74/89] Added tag jdk7-b120 for changeset a3c4c326e934 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 4245e3a1d43..76c35c677d5 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -93,3 +93,4 @@ da7561d479e0ddaa4650d8023ac0fc7294e014e3 jdk7-b115 98c028de4301106f2285ac0e128a1bb9b4c24f5c jdk7-b116 fa502e4834dac2176499cc1f44794d5dc32a11b9 jdk7-b117 42e77836fded7c2a3080d27316b96634ea9e33c6 jdk7-b118 +cff5a173ec1e89013359e804a3e31736ef6fb462 jdk7-b120 From 636b550f8cc73dbb03f682e41dbca3d1e4bbd2da Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Thu, 2 Dec 2010 19:04:00 -0800 Subject: [PATCH 75/89] Added tag jdk7-b120 for changeset 6df7c2b3dbea --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 3708e167562..6d9274748c8 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -131,3 +131,4 @@ bdbc48857210a509b3c50a3291ecb9dd6a72e016 jdk7-b115 806d0c037e6bbb88dac0699673f4ba55ee8c02da jdk7-b117 698b7b727e12de44139d8cca6ab9a494ead13253 jdk7-b118 3ef7426b4deac5dcfd4afb35cabe9ab3d666df91 hs20-b02 +f5603a6e50422046ebc0d2f1671d55cb8f1bf1e9 jdk7-b120 From 9efe7286dd7adf85163cba288eea7cec0c09a287 Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Thu, 2 Dec 2010 19:04:05 -0800 Subject: [PATCH 76/89] Added tag jdk7-b120 for changeset e9aad21cf42e --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index f8033c1011a..d8a2ab98578 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -94,3 +94,4 @@ f8d4e6c6cfce1cda23fcbd144628a9791a9e1a63 jdk7-b116 9ee4d96e893436a48607924227dadd2d93b9b00d jdk7-b117 b2f6d9c4f12ffd307a5de40455b2b61b31a5cb79 jdk7-b118 9ee900f01c5872551c06f33ae909662ffd8463ac jdk7-b119 +4821de0908defe647fcdaab4485f98873e24dea0 jdk7-b120 From 609788c8270484f9cc35272ff5549539942c674d Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Thu, 2 Dec 2010 19:04:06 -0800 Subject: [PATCH 77/89] Added tag jdk7-b120 for changeset 0165dcd8285f --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index db1808eed9f..acd63f0520b 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -94,3 +94,4 @@ d35c94fd22362f478f75b4bfcd2bef6a83cb9b3f jdk7-b113 1320fb3bb588298c79716bd2d10b5b4afacb9370 jdk7-b117 19a2fab3f91a275f90791c15d1c21a24e820ff2d jdk7-b118 41fa02b3663795ddf529690df7aa6714210093ec jdk7-b119 +a4f2e1ca67163ef79555082809d7cd719893c338 jdk7-b120 From e92f8ce76462fe5946e29ead5ee2f8bdfc16208a Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Thu, 2 Dec 2010 19:04:13 -0800 Subject: [PATCH 78/89] Added tag jdk7-b120 for changeset 445c518364c4 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 24dc9213f13..3b04251d136 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -93,3 +93,4 @@ e250cef36ea05e627e7e6f7d75e5e19f529e2ba3 jdk7-b114 1657ed4e1d86c8aa2028ab5a41f9da1ac4a369f8 jdk7-b116 3e6726bbf80a4254ecd01051c8ed77ee19325e46 jdk7-b117 b357910aa04aead2a16b6d6ff395a8df4b51d1dd jdk7-b118 +37d74e29687cf07c2bf9411af58c7e42440855c3 jdk7-b120 From 7579c0a24d42ef13b903dcf0c5cec958663bec08 Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Thu, 2 Dec 2010 19:04:25 -0800 Subject: [PATCH 79/89] Added tag jdk7-b120 for changeset 49e5caf5b854 --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 3e96fb4dfbe..79381e63275 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -93,3 +93,4 @@ e4e7408cdc5b3d91d39161e1e94aad576ecc2dcd jdk7-b114 857bfcea3f30cb5f4ae96f46a53ae1c772f9b0e5 jdk7-b116 2129a046f117547fc8a5cb3397a767e6d528f5b6 jdk7-b117 c491eec0acc73fa41b77e1619ed03e56d8a75b83 jdk7-b118 +1dd813a529cfa06d850ee7dc42da42efb8f6af0e jdk7-b120 From b95088ea8c63b97731b25a3a0519910570a3a349 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 9 Dec 2010 21:25:18 -0800 Subject: [PATCH 80/89] Added tag jdk7-b121 for changeset 0961b69bacc0 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 77da515c6e4..9180b32f19c 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -95,3 +95,4 @@ e8ebdf41b9c01a26642848f4134f5504e8fb3233 jdk7-b115 a12a9e78df8a9d534da0b4a244ed68f0de0bd58e jdk7-b118 661360bef6ccad6c119f067f5829b207de80c936 jdk7-b119 366ff0b6d2151595629806b033e2e1497e3a55d4 jdk7-b120 +2c2d4f88637b488014c37e1a2eb401f68bca8838 jdk7-b121 From 9494f0dc4b8564d2e68e5a723736059d77ce977d Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 9 Dec 2010 21:25:22 -0800 Subject: [PATCH 81/89] Added tag jdk7-b121 for changeset 5a27cf522774 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 5a4c52c0d68..de24085cb76 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -95,3 +95,4 @@ fa502e4834dac2176499cc1f44794d5dc32a11b9 jdk7-b117 42e77836fded7c2a3080d27316b96634ea9e33c6 jdk7-b118 39829414ae31a0080578a49b751899edd518cd7d jdk7-b119 cff5a173ec1e89013359e804a3e31736ef6fb462 jdk7-b120 +2cc9f32992101732b23730b737740e64ebc5fa89 jdk7-b121 From 06759914a2763319949e74e3fe3d3b4fb38f3f63 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 9 Dec 2010 21:25:25 -0800 Subject: [PATCH 82/89] Added tag jdk7-b121 for changeset 355804dc2e5e --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 524e71794ff..bb184649761 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -133,3 +133,4 @@ bdbc48857210a509b3c50a3291ecb9dd6a72e016 jdk7-b115 3ef7426b4deac5dcfd4afb35cabe9ab3d666df91 hs20-b02 5484e7c53fa7da5e869902437ee08a9ae10c1c69 jdk7-b119 f5603a6e50422046ebc0d2f1671d55cb8f1bf1e9 jdk7-b120 +3f3653ab7af8dc1ddb9fa75dad56bf94f89e81a8 jdk7-b121 From 49604555648b7d1454b5aabfbe3f2f2044ec9e70 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 9 Dec 2010 21:25:29 -0800 Subject: [PATCH 83/89] Added tag jdk7-b121 for changeset 75d78f95b8eb --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index d8a2ab98578..8d387c4063f 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -95,3 +95,4 @@ f8d4e6c6cfce1cda23fcbd144628a9791a9e1a63 jdk7-b116 b2f6d9c4f12ffd307a5de40455b2b61b31a5cb79 jdk7-b118 9ee900f01c5872551c06f33ae909662ffd8463ac jdk7-b119 4821de0908defe647fcdaab4485f98873e24dea0 jdk7-b120 +63dae40fa19fd3bf4689ea2f3c1d9d690e1abcee jdk7-b121 From 3dd432bce0a3947148c6a5cabcc5bd500d321d80 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 9 Dec 2010 21:25:29 -0800 Subject: [PATCH 84/89] Added tag jdk7-b121 for changeset 1813eb437117 --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index acd63f0520b..5564a74d072 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -95,3 +95,4 @@ d35c94fd22362f478f75b4bfcd2bef6a83cb9b3f jdk7-b113 19a2fab3f91a275f90791c15d1c21a24e820ff2d jdk7-b118 41fa02b3663795ddf529690df7aa6714210093ec jdk7-b119 a4f2e1ca67163ef79555082809d7cd719893c338 jdk7-b120 +0fa950117faac7bdbc94e6c46b88f6f892031c17 jdk7-b121 From 98e6656b3cd86b10d83d8d6610713aa96ca8c0aa Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 9 Dec 2010 21:25:32 -0800 Subject: [PATCH 85/89] Added tag jdk7-b121 for changeset 4a42e58ee6c3 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 5ca82e2575b..8bd85bbd69d 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -95,3 +95,4 @@ e250cef36ea05e627e7e6f7d75e5e19f529e2ba3 jdk7-b114 b357910aa04aead2a16b6d6ff395a8df4b51d1dd jdk7-b118 ecab7eefb8f2326fd90fb632f47f1b6f81e928f8 jdk7-b119 37d74e29687cf07c2bf9411af58c7e42440855c3 jdk7-b120 +a661d8587b5d8986aacae086f5df66af9e1a96b1 jdk7-b121 From 90141befa83b0811c85888602e46e17a0f4ca952 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 9 Dec 2010 21:25:38 -0800 Subject: [PATCH 86/89] Added tag jdk7-b121 for changeset 89ced394b320 --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index b66829fe16a..5e41fdda4d2 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -95,3 +95,4 @@ e4e7408cdc5b3d91d39161e1e94aad576ecc2dcd jdk7-b114 c491eec0acc73fa41b77e1619ed03e56d8a75b83 jdk7-b118 814561077c448292f78de461b6de5d78d57c2089 jdk7-b119 1dd813a529cfa06d850ee7dc42da42efb8f6af0e jdk7-b120 +1bf969e9792f977a8593496681539840a54fe644 jdk7-b121 From dbf4b1d8c3630b1870f7f42a536f1da0a55b1c0a Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 17:27:30 +0200 Subject: [PATCH 87/89] Added tag jdk7-b119 for changeset 4951967a61b4 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 47f9f75fafa..c7c5b24ee64 100644 --- a/.hgtags +++ b/.hgtags @@ -93,3 +93,4 @@ f960f117f1623629f64203e2b09a92a8f6f14ff5 jdk7-b112 a4e6aa1f45ad23a6f083ed98d970b5006ea4d292 jdk7-b116 228e73f288c543a8c34e2a54227103ae5649e6af jdk7-b117 2e876e59938a853934aa738c811b26c452bd9fe8 jdk7-b118 +4951967a61b4dbbf514828879f57bd1a0d4b420b jdk7-b119 From 9ff9b05487d241c17a8150c1bf6fcdd22132ae68 Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 17:28:08 +0200 Subject: [PATCH 88/89] Added tag jdk7-b120 for changeset 8c840d3ab24f --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index c7c5b24ee64..a3f7d59f57a 100644 --- a/.hgtags +++ b/.hgtags @@ -94,3 +94,4 @@ a4e6aa1f45ad23a6f083ed98d970b5006ea4d292 jdk7-b116 228e73f288c543a8c34e2a54227103ae5649e6af jdk7-b117 2e876e59938a853934aa738c811b26c452bd9fe8 jdk7-b118 4951967a61b4dbbf514828879f57bd1a0d4b420b jdk7-b119 +8c840d3ab24f8d0f422b991638acb44b6ab1d98c jdk7-b120 From 5fee9a54ad753bdfe9381f48696dc6e32a403388 Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 17:28:51 +0200 Subject: [PATCH 89/89] Added tag jdk7-b121 for changeset 0ce0a2c3a692 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index a3f7d59f57a..7e5d08a0b80 100644 --- a/.hgtags +++ b/.hgtags @@ -95,3 +95,4 @@ a4e6aa1f45ad23a6f083ed98d970b5006ea4d292 jdk7-b116 2e876e59938a853934aa738c811b26c452bd9fe8 jdk7-b118 4951967a61b4dbbf514828879f57bd1a0d4b420b jdk7-b119 8c840d3ab24f8d0f422b991638acb44b6ab1d98c jdk7-b120 +0ce0a2c3a6926677dc507839a820ab6625541e5a jdk7-b121