From 70ec72585d401c8dbb1eeca0310935bdba3d3974 Mon Sep 17 00:00:00 2001 From: Xiomara Jayasena Date: Tue, 4 Dec 2007 16:28:05 -0800 Subject: [PATCH 01/54] Added tag jdk7-b24 for changeset fd16c54261b3 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) create mode 100644 .hgtags-top-repo diff --git a/.hgtags-top-repo b/.hgtags-top-repo new file mode 100644 index 00000000000..ff06c88a2bf --- /dev/null +++ b/.hgtags-top-repo @@ -0,0 +1 @@ +cfeea66a3fa8ca3686a7cfa2d0ce8ab0169f168d jdk7-b24 From 7828a7dee6d967804cb355a8a7c9a0fad3dcc920 Mon Sep 17 00:00:00 2001 From: Xiomara Jayasena Date: Tue, 4 Dec 2007 16:28:13 -0800 Subject: [PATCH 02/54] Added tag jdk7-b24 for changeset 02bb8761fcce --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) create mode 100644 corba/.hgtags diff --git a/corba/.hgtags b/corba/.hgtags new file mode 100644 index 00000000000..f50e5065b96 --- /dev/null +++ b/corba/.hgtags @@ -0,0 +1 @@ +55540e827aef970ecc010b7e06b912d991c8e3ce jdk7-b24 From dcbf4ea9ee880b926385c29053519e4bb9a41a89 Mon Sep 17 00:00:00 2001 From: Xiomara Jayasena Date: Tue, 4 Dec 2007 16:28:18 -0800 Subject: [PATCH 03/54] Added tag jdk7-b24 for changeset 489c9b5090e2 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) create mode 100644 hotspot/.hgtags diff --git a/hotspot/.hgtags b/hotspot/.hgtags new file mode 100644 index 00000000000..c3230a6f10b --- /dev/null +++ b/hotspot/.hgtags @@ -0,0 +1 @@ +a61af66fc99eb5ec9d50c05b0c599757b1289ceb jdk7-b24 From 3dde8f95e5834baac1eca32582026d2a35dc1721 Mon Sep 17 00:00:00 2001 From: Xiomara Jayasena Date: Tue, 4 Dec 2007 16:28:22 -0800 Subject: [PATCH 04/54] Added tag jdk7-b24 for changeset 7f561c08de6b --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) create mode 100644 jaxp/.hgtags diff --git a/jaxp/.hgtags b/jaxp/.hgtags new file mode 100644 index 00000000000..0c27eee3f67 --- /dev/null +++ b/jaxp/.hgtags @@ -0,0 +1 @@ +6ce5f4757bde08f7470cbb9f0b46da8f2f3d4f56 jdk7-b24 From fcc15c26e24ffb7ff91d99084fca13eb9f644e8a Mon Sep 17 00:00:00 2001 From: Xiomara Jayasena Date: Tue, 4 Dec 2007 16:28:24 -0800 Subject: [PATCH 05/54] Added tag jdk7-b24 for changeset 474761f14bca --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) create mode 100644 jaxws/.hgtags diff --git a/jaxws/.hgtags b/jaxws/.hgtags new file mode 100644 index 00000000000..f96f9279308 --- /dev/null +++ b/jaxws/.hgtags @@ -0,0 +1 @@ +0961a4a211765fea071b8dac419003ee0c3d5973 jdk7-b24 From 3d9467a9486cab0f73713adb21b7feaade00997e Mon Sep 17 00:00:00 2001 From: Xiomara Jayasena Date: Tue, 4 Dec 2007 16:28:45 -0800 Subject: [PATCH 06/54] Added tag jdk7-b24 for changeset 06bc494ca11e --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) create mode 100644 langtools/.hgtags diff --git a/langtools/.hgtags b/langtools/.hgtags new file mode 100644 index 00000000000..92efaa97332 --- /dev/null +++ b/langtools/.hgtags @@ -0,0 +1 @@ +9a66ca7c79fab293c1bb0534e0d208c7e4f58b01 jdk7-b24 From fde483bc31506313b228b55c163dc7cd3716ea04 Mon Sep 17 00:00:00 2001 From: Mark Reinhold Date: Fri, 29 Feb 2008 20:03:57 -0800 Subject: [PATCH 07/54] 6669216: Add jcheck configuration directories Reviewed-by: ohair, xdono --- .jcheck/conf | 1 + 1 file changed, 1 insertion(+) create mode 100644 .jcheck/conf diff --git a/.jcheck/conf b/.jcheck/conf new file mode 100644 index 00000000000..d8227cd90e3 --- /dev/null +++ b/.jcheck/conf @@ -0,0 +1 @@ +project=jdk7 From 5529465023ff79b998cc7ebc248db4eaa3953cc1 Mon Sep 17 00:00:00 2001 From: Mark Reinhold Date: Fri, 29 Feb 2008 20:03:57 -0800 Subject: [PATCH 08/54] 6669216: Add jcheck configuration directories Reviewed-by: ohair, xdono --- corba/.jcheck/conf | 1 + 1 file changed, 1 insertion(+) create mode 100644 corba/.jcheck/conf diff --git a/corba/.jcheck/conf b/corba/.jcheck/conf new file mode 100644 index 00000000000..d8227cd90e3 --- /dev/null +++ b/corba/.jcheck/conf @@ -0,0 +1 @@ +project=jdk7 From 1559ee2a70904af7e487f9bbfece5ff8c41737d4 Mon Sep 17 00:00:00 2001 From: Mark Reinhold Date: Fri, 29 Feb 2008 20:03:58 -0800 Subject: [PATCH 09/54] 6669216: Add jcheck configuration directories Reviewed-by: ohair, xdono --- hotspot/.jcheck/conf | 1 + 1 file changed, 1 insertion(+) create mode 100644 hotspot/.jcheck/conf diff --git a/hotspot/.jcheck/conf b/hotspot/.jcheck/conf new file mode 100644 index 00000000000..d8227cd90e3 --- /dev/null +++ b/hotspot/.jcheck/conf @@ -0,0 +1 @@ +project=jdk7 From c5ef8d3eaf301ae73e33cfc9080904b3f5cd2c5f Mon Sep 17 00:00:00 2001 From: Mark Reinhold Date: Fri, 29 Feb 2008 20:03:59 -0800 Subject: [PATCH 10/54] 6669216: Add jcheck configuration directories Reviewed-by: ohair, xdono --- jaxp/.jcheck/conf | 1 + 1 file changed, 1 insertion(+) create mode 100644 jaxp/.jcheck/conf diff --git a/jaxp/.jcheck/conf b/jaxp/.jcheck/conf new file mode 100644 index 00000000000..d8227cd90e3 --- /dev/null +++ b/jaxp/.jcheck/conf @@ -0,0 +1 @@ +project=jdk7 From f7a57b1ea2cf7cb235282ea20d8a1193f4192361 Mon Sep 17 00:00:00 2001 From: Mark Reinhold Date: Fri, 29 Feb 2008 20:03:59 -0800 Subject: [PATCH 11/54] 6669216: Add jcheck configuration directories Reviewed-by: ohair, xdono --- jaxws/.jcheck/conf | 1 + 1 file changed, 1 insertion(+) create mode 100644 jaxws/.jcheck/conf diff --git a/jaxws/.jcheck/conf b/jaxws/.jcheck/conf new file mode 100644 index 00000000000..d8227cd90e3 --- /dev/null +++ b/jaxws/.jcheck/conf @@ -0,0 +1 @@ +project=jdk7 From c426bbd074ccdb23e2bf6ffcb8429ead32898adc Mon Sep 17 00:00:00 2001 From: Mark Reinhold Date: Fri, 29 Feb 2008 20:04:03 -0800 Subject: [PATCH 12/54] 6669216: Add jcheck configuration directories Reviewed-by: ohair, xdono --- langtools/.jcheck/conf | 1 + 1 file changed, 1 insertion(+) create mode 100644 langtools/.jcheck/conf diff --git a/langtools/.jcheck/conf b/langtools/.jcheck/conf new file mode 100644 index 00000000000..d8227cd90e3 --- /dev/null +++ b/langtools/.jcheck/conf @@ -0,0 +1 @@ +project=jdk7 From 702926ba5566303ca2b0ba36937c900af22a06d0 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Mon, 3 Mar 2008 16:03:53 +0000 Subject: [PATCH 13/54] 6614974: javac successfully compiles code that throws java.lang.VerifyError when run Synthetic cast missing when translating autoboxing expressions Reviewed-by: jjg --- .../com/sun/tools/javac/comp/Lower.java | 1 + .../test/tools/javac/boxing/T6614974.java | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 langtools/test/tools/javac/boxing/T6614974.java 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 0fdbbd40c26..6dc06546ed5 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 @@ -1835,6 +1835,7 @@ public class Lower extends TreeTranslator { + "" + rval.hashCode()), type, currentMethodSym); + rval = convert(rval,type); JCVariableDecl def = make.VarDef(var, (JCExpression)rval); // XXX cast JCTree built = builder.build(make.Ident(var)); JCTree res = make.LetExpr(def, built); diff --git a/langtools/test/tools/javac/boxing/T6614974.java b/langtools/test/tools/javac/boxing/T6614974.java new file mode 100644 index 00000000000..a2da7c88fb6 --- /dev/null +++ b/langtools/test/tools/javac/boxing/T6614974.java @@ -0,0 +1,43 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6614974 + * @summary javac successfully compiles code that throws java.lang.VerifyError when run + * @author mcimadamore + */ +public class T6614974 { + + private T n; + + public void error() { + T6614974 val = new T6614974(); + val.n = 0; + Integer.toString(val.n++); + } + + public static void main(String[] args) { + T6614974.class.getMethods(); + } +} From 9e5259f79285521737e67792da587460f5e8f4b9 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 4 Mar 2008 12:14:13 +0000 Subject: [PATCH 14/54] 6611449: Internal Error thrown during generic method/constructor invocation Type-inference should fail since lub is not defined for primitive types Reviewed-by: jjg --- .../com/sun/tools/javac/code/Types.java | 2 +- .../com/sun/tools/javac/comp/Infer.java | 6 +-- .../generics/inference/6611449/T6611449.java | 46 +++++++++++++++++++ .../generics/inference/6611449/T6611449.out | 5 ++ 4 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 langtools/test/tools/javac/generics/inference/6611449/T6611449.java create mode 100644 langtools/test/tools/javac/generics/inference/6611449/T6611449.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 7a6498c7884..070bf9d541f 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 @@ -2483,7 +2483,7 @@ public class Types { break; default: if (t.isPrimitive()) - return syms.botType; + return syms.errType; } } switch (boundkind) { 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 54c3714783d..071d2fc60f2 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 @@ -194,14 +194,14 @@ public class Infer { if (that.lobounds.isEmpty()) that.inst = syms.botType; else if (that.lobounds.tail.isEmpty()) - that.inst = that.lobounds.head; + that.inst = that.lobounds.head.isPrimitive() ? syms.errType : that.lobounds.head; else { that.inst = types.lub(that.lobounds); - if (that.inst == null) + } + if (that.inst == null || that.inst == syms.errType) throw ambiguousNoInstanceException .setMessage("no.unique.minimal.instance.exists", that.qtype, that.lobounds); - } // VGJ: sort of inlined maximizeInst() below. Adding // bounds can cause lobounds that are above hibounds. if (that.hibounds.isEmpty()) diff --git a/langtools/test/tools/javac/generics/inference/6611449/T6611449.java b/langtools/test/tools/javac/generics/inference/6611449/T6611449.java new file mode 100644 index 00000000000..8f2378e1d5b --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/6611449/T6611449.java @@ -0,0 +1,46 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6611449 + * @summary Internal Error thrown during generic method/constructor invocation + * @compile/fail/ref=T6611449.out -XDstdout -XDrawDiagnostics T6611449.java + */ +public class T6611449 { + + T6611449() {this(1);} + + T6611449(T t1) {this(t1, 1);} + + T6611449(T t1, T t2) {} + + void m(T t1) {} + + void m(T t1, T t2) {} + + void test() { + m1(1); + m2(1, 1); + } +} diff --git a/langtools/test/tools/javac/generics/inference/6611449/T6611449.out b/langtools/test/tools/javac/generics/inference/6611449/T6611449.out new file mode 100644 index 00000000000..ed501cb48d6 --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/6611449/T6611449.out @@ -0,0 +1,5 @@ +T6611449.java:32:17: compiler.err.cant.resolve.location: (- compiler.misc.kindname.constructor), T6611449, (int), , (- compiler.misc.kindname.class), T6611449 +T6611449.java:34:35: compiler.err.cant.resolve.location: (- compiler.misc.kindname.constructor), T6611449, (T,int), , (- compiler.misc.kindname.class), T6611449 +T6611449.java:43:9: compiler.err.cant.resolve.location: (- compiler.misc.kindname.method), m1, (int), , (- compiler.misc.kindname.class), T6611449 +T6611449.java:44:9: compiler.err.cant.resolve.location: (- compiler.misc.kindname.method), m2, (int,int), , (- compiler.misc.kindname.class), T6611449 +4 errors From 00c56207401b2c408ac63b1d6b7f8b52102f62c1 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 4 Mar 2008 13:00:08 +0000 Subject: [PATCH 15/54] 6660289: declared bound in inner class referring a type variable of the outer class NPE caused by a defect in type-variable attribution Reviewed-by: jjg --- .../com/sun/tools/javac/comp/Attr.java | 10 +++--- .../test/tools/javac/generics/T6660289.java | 34 +++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 langtools/test/tools/javac/generics/T6660289.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 385ce3c6d6e..b754ae11511 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 @@ -465,12 +465,12 @@ public class Attr extends JCTree.Visitor { types.setBounds(a, List.of(syms.objectType)); } } + } + + void attribBounds(List typarams, Env env) { for (JCTypeParameter tvar : typarams) chk.checkNonCyclic(tvar.pos(), (TypeVar)tvar.type); attribStats(typarams, env); - } - - void attribBounds(List typarams) { for (JCTypeParameter typaram : typarams) { Type bound = typaram.type.getUpperBound(); if (bound != null && bound.tsym instanceof ClassSymbol) { @@ -581,7 +581,7 @@ public class Attr extends JCTree.Visitor { try { chk.checkDeprecatedAnnotation(tree.pos(), m); - attribBounds(tree.typarams); + attribBounds(tree.typarams, env); // If we override any other methods, check that we do so properly. // JLS ??? @@ -2687,7 +2687,7 @@ public class Attr extends JCTree.Visitor { chk.validateAnnotations(tree.mods.annotations, c); // Validate type parameters, supertype and interfaces. - attribBounds(tree.typarams); + attribBounds(tree.typarams, env); chk.validateTypeParams(tree.typarams); chk.validate(tree.extending); chk.validate(tree.implementing); diff --git a/langtools/test/tools/javac/generics/T6660289.java b/langtools/test/tools/javac/generics/T6660289.java new file mode 100644 index 00000000000..3b948bedcde --- /dev/null +++ b/langtools/test/tools/javac/generics/T6660289.java @@ -0,0 +1,34 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6660289 + * @summary declared bound in inner class referring a type variable of the outer class + * @author Maurizio Cimadamore + * @compile T6660289.java + */ + +public class T6660289 { + class Inner {} +} From 6350088352fd9e39f4e37f92a24c499a1472c113 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 4 Mar 2008 15:19:06 +0000 Subject: [PATCH 16/54] 6608214: Exception throw while analysing a file with error Bad error-recovery after bad type-variable bound is detected Reviewed-by: jjg --- .../com/sun/tools/javac/comp/Attr.java | 1 + .../tools/javac/api/6608214/T6608214.java | 56 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 langtools/test/tools/javac/api/6608214/T6608214.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 b754ae11511..bf06b95c51c 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 @@ -2514,6 +2514,7 @@ public class Attr extends JCTree.Visitor { log.error(tree.bounds.tail.head.pos(), "type.var.may.not.be.followed.by.other.bounds"); tree.bounds = List.of(tree.bounds.head); + a.bound = bs.head; } } else { // if first bound was a class or interface, accept only interfaces diff --git a/langtools/test/tools/javac/api/6608214/T6608214.java b/langtools/test/tools/javac/api/6608214/T6608214.java new file mode 100644 index 00000000000..a1e5ceaed6e --- /dev/null +++ b/langtools/test/tools/javac/api/6608214/T6608214.java @@ -0,0 +1,56 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6608214 + * @summary Exception throw while analysing a file with error + * @author Maurizio Cimadamore + */ + +import com.sun.source.util.JavacTask; +import java.io.IOException; +import java.net.URI; +import java.util.Arrays; +import java.util.List; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; +import static javax.tools.JavaFileObject.Kind; + +public class T6608214 { + public static void main(String[] args) throws IOException { + JavaFileObject sfo = new SimpleJavaFileObject(URI.create(""),Kind.SOURCE) { + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return "class Test { void test(){}}"; + } + }; + List files = Arrays.asList(sfo); + String bootPath = System.getProperty("sun.boot.class.path"); + List opts = Arrays.asList("-bootclasspath", bootPath, "-Xjcov"); + JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); + JavacTask ct = (JavacTask)tool.getTask(null, null, null,opts,null,files); + ct.analyze(); + } +} From e82f62558354b1366e6ad061d88d5ce1fb240007 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 4 Mar 2008 15:45:20 +0000 Subject: [PATCH 17/54] 6663588: Compiler goes into infinite loop for Cyclic Inheritance test case Interplay between cyclic inheritance and tvar bounds hangs javac Reviewed-by: jjg --- .../com/sun/tools/javac/comp/MemberEnter.java | 4 +-- langtools/test/tools/javac/T6663588.java | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 langtools/test/tools/javac/T6663588.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java index 5a2f188b5bc..5c698ac16a7 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java @@ -901,10 +901,10 @@ public class MemberEnter extends JCTree.Visitor implements Completer { c.flags_field |= DEPRECATED; annotateLater(tree.mods.annotations, baseEnv, c); - attr.attribTypeVariables(tree.typarams, baseEnv); - chk.checkNonCyclic(tree.pos(), c.type); + attr.attribTypeVariables(tree.typarams, baseEnv); + // Add default constructor if needed. if ((c.flags() & INTERFACE) == 0 && !TreeInfo.hasConstructors(tree.defs)) { diff --git a/langtools/test/tools/javac/T6663588.java b/langtools/test/tools/javac/T6663588.java new file mode 100644 index 00000000000..9c1dfa9202e --- /dev/null +++ b/langtools/test/tools/javac/T6663588.java @@ -0,0 +1,34 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6663588 + * @summary Compiler goes into infinite loop for Cyclic Inheritance test case + * @author Maurizio Cimadamore + * @compile/fail T6663588.java + */ + +public class T6663588 extends T6663588 { + class Inner extends T6663588.Inner {} +} From 12028b6de1242f5e8f0c58c51099fd178559fd47 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Tue, 4 Mar 2008 10:58:04 -0800 Subject: [PATCH 18/54] 6652588: Fix broken JPRT makefile target, no bundle saved Jprt make rules missing the bundle up of the output Reviewed-by: xdono --- jaxp/make/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jaxp/make/Makefile b/jaxp/make/Makefile index 9e72148a928..6de97e7e673 100644 --- a/jaxp/make/Makefile +++ b/jaxp/make/Makefile @@ -90,7 +90,6 @@ ifdef ALT_OUTPUTDIR else OUTPUTDIR = .. endif -ABS_OUTPUTDIR = $(call FullPath,$(OUTPUTDIR)) ifdef ALT_LANGTOOLS_DIST ANT_OPTIONS += -Dbootstrap.dir=$(ALT_LANGTOOLS_DIST)/bootstrap @@ -127,7 +126,11 @@ $(ANT_TARGETS): $(ANT_JAVA_HOME) $(ANT) $(ANT_OPTIONS) $@ # Targets for Sun's internal JPRT build system +JPRT_ARCHIVE_BUNDLE=$(OUTPUTDIR)/jprt.zip jprt_build_product jprt_build_debug jprt_build_fastdebug: all + $(RM) $(JPRT_ARCHIVE_BUNDLE) + ( cd $(OUTPUTDIR)/dist && \ + zip -q -r $(JPRT_ARCHIVE_BUNDLE) . ) # Declare these phony (not filenames) .PHONY: $(ANT_TARGETS) all clobber \ From fc9ffa52c48ef8cf8549262cf92bf348f2389dde Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Tue, 4 Mar 2008 10:58:50 -0800 Subject: [PATCH 19/54] 6652588: Fix broken JPRT makefile target, no bundle saved Jprt make rules were missing the bundle logic Reviewed-by: xdono --- jaxws/make/Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jaxws/make/Makefile b/jaxws/make/Makefile index 3dab62bec74..3dc17bfa39f 100644 --- a/jaxws/make/Makefile +++ b/jaxws/make/Makefile @@ -69,7 +69,7 @@ else endif endif -# Note: j2se/make/common/Defs.gmk uses LANGUAGE_VERSION (-source NN) +# Note: jdk/make/common/Defs.gmk uses LANGUAGE_VERSION (-source NN) # and the somewhat misnamed CLASS_VERSION (-target NN) ifdef TARGET_CLASS_VERSION ANT_OPTIONS += -Djavac.target=$(TARGET_CLASS_VERSION) @@ -90,7 +90,6 @@ ifdef ALT_OUTPUTDIR else OUTPUTDIR = .. endif -ABS_OUTPUTDIR = $(call FullPath,$(OUTPUTDIR)) ifdef ALT_LANGTOOLS_DIST ANT_OPTIONS += -Dbootstrap.dir=$(ALT_LANGTOOLS_DIST)/bootstrap @@ -127,7 +126,11 @@ $(ANT_TARGETS): $(ANT_JAVA_HOME) $(ANT) $(ANT_OPTIONS) $@ # Targets for Sun's internal JPRT build system +JPRT_ARCHIVE_BUNDLE=$(OUTPUTDIR)/jprt.zip jprt_build_product jprt_build_debug jprt_build_fastdebug: all + $(RM) $(JPRT_ARCHIVE_BUNDLE) + ( cd $(OUTPUTDIR)/dist && \ + zip -q -r $(JPRT_ARCHIVE_BUNDLE) . ) # Declare these phony (not filenames) .PHONY: $(ANT_TARGETS) all clobber \ From d8e9d2232314cb96314b3c22405a73b0e08c7583 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Wed, 5 Mar 2008 18:56:03 -0800 Subject: [PATCH 20/54] 6662830: OpenJDK build testing results Small corrections in the README. Reviewed-by: xdono --- README-builds.html | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/README-builds.html b/README-builds.html index 6530865db54..096d192e2b9 100644 --- a/README-builds.html +++ b/README-builds.html @@ -342,32 +342,29 @@

- The source code for the - OpenJDK is - delivered in 3 sibling directories: + The source code for the OpenJDK is delivered in a set of + directories: hotspot, langtools, corba, jaxws, jaxp, - jdk and + jdk. The hotspot directory contains the source code and make - files for - building the - OpenJDK - Hotspot Virtual Machine. - The jdk - directory contains the source code and make files for - building the - OpenJDK - runtime libraries, tools and demos. - The top level Makefile is used to build the complete OpenJDK - release including building the hotspot - VM, staging the VM binaries, and building the - OpenJDK - runtime libraries, - tools and demos. + files for building the OpenJDK Hotspot Virtual Machine. + The langtools directory contains the source code and make + files for building the OpenJDK javac and language tools. + The corba directory contains the source code and make + files for building the OpenJDK Corba files. + The jaxws directory contains the source code and make + files for building the OpenJDK JAXWS files. + The jaxp directory contains the source code and make + files for building the OpenJDK JAXP files. + The jdk directory contains the source code and make files for + building the OpenJDK runtime libraries and misc files. + The top level Makefile + is used to build the entire OpenJDK.

@@ -730,17 +727,15 @@ under an open-source license. In order to build an OpenJDK binary from source code, you must first download and install the appropriate - binary plug bundles from the OpenJDK Download area. + binary plug bundles from the OpenJDK, go to the + OpenJDK site and select + the "Bundles(7)" link. During the OpenJDK build process these "binary plugs" for the encumbered components will be copied into your resulting OpenJDK binary build image. These binary plug files are only for the purpose of building an OpenJDK binary. - Download the Binary Plugs by selecting the Downloads - link at - the OpenJDK site, - install the bundle, - and make sure you set + Make sure you set ALT_BINARY_PLUGS_PATH to the root of this installation. From 7c8027dacea0711ae7264b02e4ea9e40a8da947c Mon Sep 17 00:00:00 2001 From: Michael Bailey Date: Thu, 6 Mar 2008 10:07:25 -0800 Subject: [PATCH 21/54] 4741726: allow Object += String Remove code in line with restriction removed from JLS Reviewed-by: mcimadamore --- .../com/sun/tools/javac/comp/Attr.java | 15 ++++-------- ...jectAppend.java => StringConversion2.java} | 23 +++++++++++-------- 2 files changed, 17 insertions(+), 21 deletions(-) rename langtools/test/tools/javac/{expression/ObjectAppend.java => StringConversion2.java} (73%) 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 bf06b95c51c..f597bc7f3e6 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 @@ -1609,17 +1609,10 @@ public class Attr extends JCTree.Visitor { tree.getTag() - JCTree.ASGOffset, owntype, operand); - if (types.isSameType(operator.type.getReturnType(), syms.stringType)) { - // String assignment; make sure the lhs is a string - chk.checkType(tree.lhs.pos(), - owntype, - syms.stringType); - } else { - chk.checkDivZero(tree.rhs.pos(), operator, operand); - chk.checkCastable(tree.rhs.pos(), - operator.type.getReturnType(), - owntype); - } + chk.checkDivZero(tree.rhs.pos(), operator, operand); + chk.checkCastable(tree.rhs.pos(), + operator.type.getReturnType(), + owntype); } result = check(tree, owntype, VAL, pkind, pt); } diff --git a/langtools/test/tools/javac/expression/ObjectAppend.java b/langtools/test/tools/javac/StringConversion2.java similarity index 73% rename from langtools/test/tools/javac/expression/ObjectAppend.java rename to langtools/test/tools/javac/StringConversion2.java index b92575f0d84..6e8db13e22d 100644 --- a/langtools/test/tools/javac/expression/ObjectAppend.java +++ b/langtools/test/tools/javac/StringConversion2.java @@ -1,5 +1,5 @@ /* - * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,14 +23,17 @@ /* * @test - * @bug 4642850 - * @summary compiler allows Object += String - * @author gafter - * - * @compile/fail ObjectAppend.java + * @bug 4741726 + * @summary allow Object += String */ -class ObjectAppend {{ - Object o = null; - o += "string"; -}} +public class StringConversion2 +{ + public static void main(String[] args) { + Object o = "Hello "; + String s = "World!"; + o += s; + if (!o.equals("Hello World!")) + throw new Error("test failed"); + } +} From a7ed75b36aa3173289a61721c991e666c09531a9 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 6 Mar 2008 10:25:04 -0800 Subject: [PATCH 22/54] 6668802: javac handles diagnostics for last line badly, if line not terminated by newline Use CharBuffer.limit(), not the length of the backing array Reviewed-by: mcimadamore --- .../classes/com/sun/tools/javac/util/Log.java | 26 +++--- langtools/test/tools/javac/T6668802.java | 79 +++++++++++++++++++ 2 files changed, 96 insertions(+), 9 deletions(-) create mode 100644 langtools/test/tools/javac/T6668802.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java index 7ceb7d98660..33c3144cb75 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java @@ -203,6 +203,10 @@ public class Log { */ private char[] buf = null; + /** The length of useful data in buf + */ + private int bufLen = 0; + /** The position in the buffer at which last error was reported */ private int bp; @@ -256,6 +260,7 @@ public class Log { */ protected void setBuf(char[] newBuf) { buf = newBuf; + bufLen = buf.length; bp = 0; lineStart = 0; line = 1; @@ -324,7 +329,7 @@ public class Log { return; int lineEnd = lineStart; - while (lineEnd < buf.length && buf[lineEnd] != CR && buf[lineEnd] != LF) + while (lineEnd < bufLen && buf[lineEnd] != CR && buf[lineEnd] != LF) lineEnd++; if (lineEnd - lineStart == 0) return; @@ -336,12 +341,15 @@ public class Log { writer.flush(); } - protected static char[] getCharContent(JavaFileObject fileObject) throws IOException { + protected void initBuf(JavaFileObject fileObject) throws IOException { CharSequence cs = fileObject.getCharContent(true); if (cs instanceof CharBuffer) { - return JavacFileManager.toArray((CharBuffer)cs); + CharBuffer cb = (CharBuffer) cs; + buf = JavacFileManager.toArray(cb); + bufLen = cb.limit(); } else { - return cs.toString().toCharArray(); + buf = cs.toString().toCharArray(); + bufLen = buf.length; } } @@ -353,7 +361,7 @@ public class Log { return false; try { if (buf == null) { - buf = getCharContent(currentSource()); + initBuf(currentSource()); lineStart = 0; line = 1; } else if (lineStart > pos) { // messages don't come in order @@ -361,10 +369,10 @@ public class Log { line = 1; } bp = lineStart; - while (bp < buf.length && bp < pos) { + while (bp < bufLen && bp < pos) { switch (buf[bp++]) { case CR: - if (bp < buf.length && buf[bp] == LF) bp++; + if (bp < bufLen && buf[bp] == LF) bp++; line++; lineStart = bp; break; @@ -374,7 +382,7 @@ public class Log { break; } } - return bp <= buf.length; + return bp <= bufLen; } catch (IOException e) { //e.printStackTrace(); // FIXME: include e.getLocalizedMessage() in error message @@ -704,7 +712,7 @@ public class Log { if (findLine(pos)) { int column = 0; for (bp = lineStart; bp < pos; bp++) { - if (bp >= buf.length) + if (bp >= bufLen) return 0; if (buf[bp] == '\t') column = (column / TabInc * TabInc) + TabInc; diff --git a/langtools/test/tools/javac/T6668802.java b/langtools/test/tools/javac/T6668802.java new file mode 100644 index 00000000000..d357e2b39e7 --- /dev/null +++ b/langtools/test/tools/javac/T6668802.java @@ -0,0 +1,79 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6668802 + * @summary javac handles diagnostics for last line badly, if line not terminated by newline + */ + +import java.io.*; +import java.util.*; + +public class T6668802 +{ + public static void main(String[] args) throws Exception { + new T6668802().run(); + } + + void run() throws Exception { + String test = "public class Test {"; + File f = writeTestFile("Test.java", test); + String[] out = compileBadFile(f); + for (String line: out) + System.err.println(">>>" + line + "<<<"); + if (!out[1].equals(test)) { + show("expected", test); + show(" actual", out[1]); + throw new Error("test failed"); + } + } + + File writeTestFile(String path, String contents) throws IOException { + File f = new File(path); + FileWriter out = new FileWriter(f); + out.write(contents); + out.close(); + return f; + } + + String[] compileBadFile(File file) throws IOException { + List options = new ArrayList(); + options.add(file.getPath()); + System.err.println("compile: " + options); + String[] opts = options.toArray(new String[options.size()]); + StringWriter sw = new StringWriter(); + PrintWriter out = new PrintWriter(sw); + int rc = com.sun.tools.javac.Main.compile(opts, out); + if (rc == 0) + throw new Error("compilation succeeded unexpectedly"); + out.close(); + return sw.toString().split("[\n\r]+"); + } + + void show(String prefix, String text) { + System.err.println(prefix + ": (" + text.length() + ") " + text); + } +} From 2dae31e47ce2c9c4ee6e424881894bcbb647b771 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Thu, 6 Mar 2008 13:56:47 -0800 Subject: [PATCH 23/54] 6624808: corba makefiles not using langtools compiler If supplied, the langtools javac should be used. Reviewed-by: xdono --- corba/make/common/shared/Defs.gmk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/corba/make/common/shared/Defs.gmk b/corba/make/common/shared/Defs.gmk index 8cd237fed51..c7832863e34 100644 --- a/corba/make/common/shared/Defs.gmk +++ b/corba/make/common/shared/Defs.gmk @@ -281,6 +281,13 @@ endif # Get platform specific settings include $(BUILDDIR)/common/shared/Defs-$(PLATFORM).gmk +# Components +ifdef ALT_LANGTOOLS_DIST + LANGTOOLS_DIST :=$(call FullPath,$(ALT_LANGTOOLS_DIST)) +else + LANGTOOLS_DIST = +endif + # These are the same on all platforms but require the above platform include 1st # BOOTDIR: Bootstrap JDK, previous released JDK. From 6b9d629f069faeb157e3594dd0754cca466a6a98 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Sun, 9 Mar 2008 13:11:51 -0700 Subject: [PATCH 24/54] 6649270: Change by-default openjdk building in control/make/makefile to use open source tree Change build rules to allow for openjdk builds by default when building the closed or production build. Reviewed-by: xdono --- Makefile | 115 ++++++++++++++++++++++++++++------------- make/Defs-internal.gmk | 2 - 2 files changed, 80 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index 5e06900266b..3ced65f0e31 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,17 @@ ifndef CONTROL_TOPDIR fi) endif +# Openjdk sources (only used if SKIP_OPENJDK_BUILD!=true) +OPENJDK_SOURCETREE=$(TOPDIR)/openjdk +OPENJDK_BUILDDIR:=$(shell \ + if [ -r $(OPENJDK_SOURCETREE)/control/make/Makefile ]; then \ + echo "$(OPENJDK_SOURCETREE)/control/make"; \ + elif [ -r $(OPENJDK_SOURCETREE)/Makefile ]; then \ + echo "$(OPENJDK_SOURCETREE)"; \ + else \ + echo "."; \ + fi) + ifndef JDK_TOPDIR JDK_TOPDIR=$(TOPDIR)/jdk endif @@ -81,12 +92,28 @@ include ./make/deploy-rules.gmk all:: setup build -setup: +setup: openjdk_check $(MKDIR) -p $(OUTPUTDIR)/j2sdk-image $(MKDIR) -p $(ABS_OUTPUTDIR)/j2sdk-image $(MKDIR) -p $(OUTPUTDIR)-fastdebug/j2sdk-image $(MKDIR) -p $(ABS_OUTPUTDIR)-fastdebug/j2sdk-image +# Check on whether we really can build the openjdk, need source etc. +openjdk_check: +ifneq ($(SKIP_OPENJDK_BUILD), true) + @$(ECHO) " " + @$(ECHO) "=================================================" + @if [ ! -r $(OPENJDK_BUILDDIR)/Makefile ] ; then \ + $(ECHO) "ERROR: No openjdk source tree available at: $(OPENJDK_BUILDDIR)"; \ + exit 1; \ + else \ + $(ECHO) "OpenJDK will be built after JDK is built"; \ + $(ECHO) " OPENJDK_BUILDDIR=$(OPENJDK_BUILDDIR)"; \ + fi + @$(ECHO) "=================================================" + @$(ECHO) " " +endif + build:: sanity clobber:: @@ -190,46 +217,64 @@ ifneq ($(SKIP_COMPARE_IMAGES), true) all :: compare-image endif -ifeq ($(SKIP_OPENJDK_BUILD), false) +ifneq ($(SKIP_OPENJDK_BUILD), true) + all :: openjdk_build +endif + +# If we have bundle rules, we have a chance here to do a complete cycle +# build, of production and open build. +# FIXUP: We should create the openjdk source bundle and build that? +# But how do we reliable create or get at a formal openjdk source tree? +# The one we have needs to be trimmed of built bits and closed dirs. +# The repositories might not be available. +# The openjdk source bundle is probably not available. + +ifneq ($(SKIP_OPENJDK_BUILD), true) ifeq ($(BUILD_JDK), true) ifeq ($(BUNDLE_RULES_AVAILABLE), true) - # If we have bundle rules, we have a chance here to do a complete cycle - # build, of closed and open build. - # FIXUP: We should create the openjdk source bundle and build that? - ABS_OPENJDK_PLUGS=$(ABS_OUTPUTDIR)/$(OPENJDK_BINARY_PLUGS_INAME) - ABS_OPENJDK_OUTPUTDIR=$(ABS_OUTPUTDIR)/openjdk - OPENJDK_BUILD_NAME_PREFIX \ - = $(J2SDK_NAME)-$(JDK_MKTG_UNDERSCORE_VERSION)-$(MILESTONE) - OPENJDK_BUILD_NAME_SUFFIX \ - = $(BUILD_NUMBER)-$(PLATFORM)-$(ARCH)-$(BUNDLE_DATE) - OPENJDK_BUILD_NAME \ - = $(OPENJDK_BUILD_NAME_PREFIX)-openjdk-$(OPENJDK_BUILD_NAME_SUFFIX) - OPENJDK_BUILD_BINARY_ZIP \ - = $(ABS_BIN_BUNDLEDIR)/$(OPENJDK_BUILD_NAME).zip - all :: openjdk-build - openjdk-build: + +OPENJDK_PLUGS=$(ABS_OUTPUTDIR)/$(OPENJDK_BINARY_PLUGS_INAME) +OPENJDK_OUTPUTDIR=$(ABS_OUTPUTDIR)/open-output +OPENJDK_BUILD_NAME \ + = openjdk-$(JDK_MINOR_VERSION)-$(BUILD_NUMBER)-$(PLATFORM)-$(ARCH)-$(BUNDLE_DATE) +OPENJDK_BUILD_BINARY_ZIP=$(ABS_BIN_BUNDLEDIR)/$(OPENJDK_BUILD_NAME).zip +BUILT_IMAGE=$(ABS_OUTPUTDIR)/j2sdk-image +ifeq ($(PLATFORM)$(ARCH_DATA_MODEL),solaris64) + OPENJDK_BOOTDIR=$(BOOTDIR) + OPENJDK_IMPORTJDK=$(JDK_IMPORT_PATH) +else + OPENJDK_BOOTDIR=$(BUILT_IMAGE) + OPENJDK_IMPORTJDK=$(BUILT_IMAGE) +endif + +openjdk_build: @$(ECHO) " " @$(ECHO) "=================================================" @$(ECHO) "Starting openjdk build" + @$(ECHO) " Using: ALT_JDK_DEVTOOLS_DIR=$(JDK_DEVTOOLS_DIR)" @$(ECHO) "=================================================" @$(ECHO) " " - $(RM) -r $(ABS_OPENJDK_OUTPUTDIR) - $(MKDIR) -p $(ABS_OPENJDK_OUTPUTDIR) - $(MAKE) OPENJDK=true \ - BUILD_LANGTOOLS=$(BUILD_LANGTOOLS) \ - BUILD_CORBA=$(BUILD_CORBA) \ - BUILD_JAXP=$(BUILD_JAXP) \ - BUILD_JAXWS=$(BUILD_JAXWS) \ - BUILD_HOTSPOT=$(BUILD_HOTSPOT) \ - ALT_OUTPUTDIR=$(ABS_OPENJDK_OUTPUTDIR) \ - ALT_BINARY_PLUGS_PATH=$(ABS_OUTPUTDIR)/$(OPENJDK_BINARY_PLUGS_INAME) \ - ALT_BOOTDIR=$(ABS_OUTPUTDIR)/j2sdk-image \ - ALT_JDK_IMPORT_PATH=$(ABS_OUTPUTDIR)/j2sdk-image \ - product_build + $(RM) -r $(OPENJDK_OUTPUTDIR) + $(MKDIR) -p $(OPENJDK_OUTPUTDIR) + ($(CD) $(OPENJDK_BUILDDIR) && $(MAKE) \ + OPENJDK=true \ + ALT_JDK_DEVTOOLS_DIR=$(JDK_DEVTOOLS_DIR) \ + ALT_OUTPUTDIR=$(OPENJDK_OUTPUTDIR) \ + ALT_BINARY_PLUGS_PATH=$(OPENJDK_PLUGS) \ + ALT_BOOTDIR=$(OPENJDK_BOOTDIR) \ + ALT_JDK_IMPORT_PATH=$(OPENJDK_IMPORTJDK) \ + product_build ) $(RM) $(OPENJDK_BUILD_BINARY_ZIP) - ( $(CD) $(ABS_OPENJDK_OUTPUTDIR)/j2sdk-image && \ + ( $(CD) $(OPENJDK_OUTPUTDIR)/j2sdk-image && \ $(ZIPEXE) -q -r $(OPENJDK_BUILD_BINARY_ZIP) .) - $(RM) -r $(ABS_OPENJDK_OUTPUTDIR) + $(RM) -r $(OPENJDK_OUTPUTDIR) + @$(ECHO) " " + @$(ECHO) "=================================================" + @$(ECHO) "Finished openjdk build" + @$(ECHO) " Binary Bundle: $(OPENJDK_BUILD_BINARY_ZIP)" + @$(ECHO) "=================================================" + @$(ECHO) " " + endif endif endif @@ -432,11 +477,11 @@ endif # Cycle build. Build the jdk, use it to build the jdk again. ################################################################ -ABS_BOOTJDK_OUTPUTDIR=$(ABS_OUTPUTDIR)/bootjdk +ABS_BOOTDIR_OUTPUTDIR=$(ABS_OUTPUTDIR)/bootjdk boot_cycle: - $(MAKE) ALT_OUTPUTDIR=$(ABS_BOOTJDK_OUTPUTDIR) product_build - $(MAKE) ALT_BOOTDIR=$(ABS_BOOTJDK_OUTPUTDIR)/j2sdk-image product_build + $(MAKE) ALT_OUTPUTDIR=$(ABS_BOOTDIR_OUTPUTDIR) product_build + $(MAKE) ALT_BOOTDIR=$(ABS_BOOTDIR_OUTPUTDIR)/j2sdk-image product_build ################################################################ # JPRT rule to build diff --git a/make/Defs-internal.gmk b/make/Defs-internal.gmk index 6d4c81ca6ff..7343049c61b 100644 --- a/make/Defs-internal.gmk +++ b/make/Defs-internal.gmk @@ -151,8 +151,6 @@ ifdef OPENJDK else ifndef SKIP_OPENJDK_BUILD SKIP_OPENJDK_BUILD = false - # FIXUP: until freetype fixed on linux and solaris rmi build fixed - SKIP_OPENJDK_BUILD = true endif endif From 6377bd6f3ab4a4a540f611cfd9149dd5fe2b1ffc Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Sun, 9 Mar 2008 15:47:58 -0700 Subject: [PATCH 25/54] 6649672: Adjustments to OUTPUTDIR default and mkdirs to avoid empty directory clutter Cleanup of OUTPUTDIR handling Reviewed-by: xdono --- Makefile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 3ced65f0e31..43b36254335 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,8 @@ # have any questions. # +BUILD_PARENT_DIRECTORY=. + ifndef TOPDIR TOPDIR:=$(shell \ if [ -r ./j2se/make/Makefile -o -r ./jdk/make/Makefile ]; then \ @@ -66,6 +68,7 @@ include ./make/Defs-internal.gmk all:: @$(ECHO) $(PLATFORM) $(ARCH) $(RELEASE) build started: `$(DATE) '+%y-%m-%d %H:%M'` + $(MKDIR) -p $(OUTPUTDIR) # Rules for sanity checks include ./make/sanity-rules.gmk @@ -94,12 +97,9 @@ all:: setup build setup: openjdk_check $(MKDIR) -p $(OUTPUTDIR)/j2sdk-image - $(MKDIR) -p $(ABS_OUTPUTDIR)/j2sdk-image - $(MKDIR) -p $(OUTPUTDIR)-fastdebug/j2sdk-image - $(MKDIR) -p $(ABS_OUTPUTDIR)-fastdebug/j2sdk-image # Check on whether we really can build the openjdk, need source etc. -openjdk_check: +openjdk_check: FRC ifneq ($(SKIP_OPENJDK_BUILD), true) @$(ECHO) " " @$(ECHO) "=================================================" @@ -170,7 +170,7 @@ endif COMMON_DEBUG_FLAGS= \ DEBUG_NAME=$(DEBUG_NAME) \ - ALT_OUTPUTDIR=$(_OUTPUTDIR)-$(DEBUG_NAME) \ + ALT_OUTPUTDIR=$(ABS_OUTPUTDIR)-$(DEBUG_NAME) \ NO_DOCS=true product_build: setup @@ -501,3 +501,6 @@ include ./make/jprt.gmk j2se_fastdebug_only: jdk_fastdebug_only j2se_only: jdk_only +# Force target +FRC: + From 4cd40a47ff918c57cb296c8cd7f4f6e52fb16e15 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 11 Mar 2008 13:14:55 -0700 Subject: [PATCH 26/54] 6307187: clean up code for -Xlint:options Introduce common code for handling one-of and any-of options Reviewed-by: mcimadamore --- .../com/sun/tools/javac/code/Lint.java | 2 +- .../com/sun/tools/javac/main/JavacOption.java | 136 ++++++++++-- .../com/sun/tools/javac/main/OptionName.java | 14 +- .../tools/javac/main/RecognizedOptions.java | 201 ++++++++---------- .../test/tools/javac/6341866/T6341866.java | 2 +- 5 files changed, 218 insertions(+), 137 deletions(-) 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 78474bbaa9c..1d43d5faddc 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 @@ -194,7 +194,7 @@ public class Lint return map.get(option); } - private final String option; + public final String option; }; /** diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/JavacOption.java b/langtools/src/share/classes/com/sun/tools/javac/main/JavacOption.java index de724c58060..d607b433553 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/JavacOption.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavacOption.java @@ -28,6 +28,8 @@ package com.sun.tools.javac.main; import com.sun.tools.javac.util.Log; import com.sun.tools.javac.util.Options; import java.io.PrintWriter; +import java.util.Arrays; +import java.util.Collection; /** * TODO: describe com.sun.tools.javac.main.JavacOption @@ -41,19 +43,29 @@ public interface JavacOption { OptionKind getKind(); - /** Does this option take a (separate) operand? */ + /** Does this option take a (separate) operand? + * @return true if this option takes a separate operand + */ boolean hasArg(); /** Does argument string match option pattern? - * @param arg The command line argument string. + * @param arg the command line argument string + * @return true if {@code arg} matches this option */ boolean matches(String arg); - /** Process the option (with arg). Return true if error detected. + /** Process an option with an argument. + * @param options the accumulated set of analyzed options + * @param option the option to be processed + * @param arg the arg for the option to be processed + * @return true if an error was detected */ boolean process(Options options, String option, String arg); - /** Process the option (without arg). Return true if error detected. + /** Process the option with no argument. + * @param options the accumulated set of analyzed options + * @param option the option to be processed + * @return true if an error was detected */ boolean process(Options options, String option); @@ -65,6 +77,11 @@ public interface JavacOption { HIDDEN, } + enum ChoiceKind { + ONEOF, + ANYOF + } + /** This class represents an option recognized by the main program */ static class Option implements JavacOption { @@ -85,6 +102,14 @@ public interface JavacOption { */ boolean hasSuffix; + /** The kind of choices for this option, if any. + */ + ChoiceKind choiceKind; + + /** The choices for this option, if any. + */ + Collection choices; + Option(OptionName name, String argsNameKey, String descrKey) { this.name = name; this.argsNameKey = argsNameKey; @@ -92,51 +117,116 @@ public interface JavacOption { char lastChar = name.optionName.charAt(name.optionName.length()-1); hasSuffix = lastChar == ':' || lastChar == '='; } + Option(OptionName name, String descrKey) { this(name, null, descrKey); } + Option(OptionName name, String descrKey, ChoiceKind choiceKind, String... choices) { + this(name, descrKey, choiceKind, Arrays.asList(choices)); + } + + Option(OptionName name, String descrKey, ChoiceKind choiceKind, Collection choices) { + this(name, null, descrKey); + if (choiceKind == null || choices == null) + throw new NullPointerException(); + this.choiceKind = choiceKind; + this.choices = choices; + } + + @Override public String toString() { return name.optionName; } - /** Does this option take a (separate) operand? - */ public boolean hasArg() { return argsNameKey != null && !hasSuffix; } - /** Does argument string match option pattern? - * @param arg The command line argument string. - */ - public boolean matches(String arg) { - return hasSuffix ? arg.startsWith(name.optionName) : arg.equals(name.optionName); + public boolean matches(String option) { + if (!hasSuffix) + return option.equals(name.optionName); + + if (!option.startsWith(name.optionName)) + return false; + + if (choices != null) { + String arg = option.substring(name.optionName.length()); + if (choiceKind == ChoiceKind.ONEOF) + return choices.contains(arg); + else { + for (String a: arg.split(",+")) { + if (!choices.contains(a)) + return false; + } + } + } + + return true; } /** Print a line of documentation describing this option, if standard. + * @param out the stream to which to write the documentation */ void help(PrintWriter out) { String s = " " + helpSynopsis(); out.print(s); - for (int j = s.length(); j < 29; j++) out.print(" "); + for (int j = Math.min(s.length(), 28); j < 29; j++) out.print(" "); Log.printLines(out, Main.getLocalizedString(descrKey)); } + String helpSynopsis() { - return name + - (argsNameKey == null ? "" : - ((hasSuffix ? "" : " ") + - Main.getLocalizedString(argsNameKey))); + StringBuilder sb = new StringBuilder(); + sb.append(name); + if (argsNameKey == null) { + if (choices != null) { + String sep = "{"; + for (String c: choices) { + sb.append(sep); + sb.append(c); + sep = ","; + } + sb.append("}"); + } + } else { + if (!hasSuffix) + sb.append(" "); + sb.append(Main.getLocalizedString(argsNameKey)); + } + + return sb.toString(); } /** Print a line of documentation describing this option, if non-standard. + * @param out the stream to which to write the documentation */ void xhelp(PrintWriter out) {} /** Process the option (with arg). Return true if error detected. */ public boolean process(Options options, String option, String arg) { - if (options != null) + if (options != null) { + if (choices != null) { + if (choiceKind == ChoiceKind.ONEOF) { + // some clients like to see just one of option+choice set + for (String c: choices) + options.remove(option + c); + String opt = option + arg; + options.put(opt, opt); + // some clients like to see option (without trailing ":") + // set to arg + String nm = option.substring(0, option.length() - 1); + options.put(nm, arg); + } else { + // set option+word for each word in arg + for (String a: arg.split(",+")) { + String opt = option + a; + options.put(opt, opt); + } + } + } options.put(option, arg); + } return false; } @@ -163,8 +253,17 @@ public interface JavacOption { XOption(OptionName name, String descrKey) { this(name, null, descrKey); } + XOption(OptionName name, String descrKey, ChoiceKind kind, String... choices) { + super(name, descrKey, kind, choices); + } + XOption(OptionName name, String descrKey, ChoiceKind kind, Collection choices) { + super(name, descrKey, kind, choices); + } + @Override void help(PrintWriter out) {} + @Override void xhelp(PrintWriter out) { super.help(out); } + @Override public OptionKind getKind() { return OptionKind.EXTENDED; } }; @@ -177,8 +276,11 @@ public interface JavacOption { HiddenOption(OptionName name, String argsNameKey) { super(name, argsNameKey, null); } + @Override void help(PrintWriter out) {} + @Override void xhelp(PrintWriter out) {} + @Override public OptionKind getKind() { return OptionKind.HIDDEN; } }; diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/OptionName.java b/langtools/src/share/classes/com/sun/tools/javac/main/OptionName.java index e3cec6f714b..81d20f5b4cf 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/OptionName.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/OptionName.java @@ -37,13 +37,9 @@ package com.sun.tools.javac.main; public enum OptionName { G("-g"), G_NONE("-g:none"), - G_CUSTOM("-g:{lines,vars,source}"), + G_CUSTOM("-g:"), XLINT("-Xlint"), - XLINT_CUSTOM("-Xlint:{" - + "all," - + "cast,deprecation,divzero,empty,unchecked,fallthrough,path,serial,finally,overrides," - + "-cast,-deprecation,-divzero,-empty,-unchecked,-fallthrough,-path,-serial,-finally,-overrides," - + "none}"), + XLINT_CUSTOM("-Xlint:"), NOWARN("-nowarn"), VERBOSE("-verbose"), DEPRECATION("-deprecation"), @@ -58,12 +54,12 @@ public enum OptionName { DJAVA_EXT_DIRS("-Djava.ext.dirs="), ENDORSEDDIRS("-endorseddirs"), DJAVA_ENDORSED_DIRS("-Djava.endorsed.dirs="), - PROC_CUSTOM("-proc:{none,only}"), + PROC("-proc:"), PROCESSOR("-processor"), PROCESSORPATH("-processorpath"), D("-d"), S("-s"), - IMPLICIT("-implicit:{none,class}"), + IMPLICIT("-implicit:"), ENCODING("-encoding"), SOURCE("-source"), TARGET("-target"), @@ -86,7 +82,7 @@ public enum OptionName { XPRINT("-Xprint"), XPRINTROUNDS("-XprintRounds"), XPRINTPROCESSORINFO("-XprintProcessorInfo"), - XPREFER("-Xprefer:{source,newer}"), + XPREFER("-Xprefer:"), O("-O"), XJCOV("-Xjcov"), XD("-XD"), diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java b/langtools/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java index b205472f61f..688459011b1 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java @@ -25,21 +25,23 @@ package com.sun.tools.javac.main; +import com.sun.tools.javac.code.Lint; import com.sun.tools.javac.code.Source; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.jvm.Target; import com.sun.tools.javac.main.JavacOption.HiddenOption; import com.sun.tools.javac.main.JavacOption.Option; import com.sun.tools.javac.main.JavacOption.XOption; -import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; -import com.sun.tools.javac.util.Log; import com.sun.tools.javac.util.Options; import com.sun.tools.javac.processing.JavacProcessingEnvironment; import java.io.File; import java.io.FileWriter; import java.io.PrintWriter; +import java.util.Arrays; +import java.util.Collection; import java.util.EnumSet; +import java.util.LinkedHashSet; import java.util.Set; import java.util.StringTokenizer; import javax.lang.model.SourceVersion; @@ -134,7 +136,7 @@ public class RecognizedOptions { DJAVA_EXT_DIRS, ENDORSEDDIRS, DJAVA_ENDORSED_DIRS, - PROC_CUSTOM, + PROC, PROCESSOR, PROCESSORPATH, D, @@ -195,7 +197,7 @@ public class RecognizedOptions { NOWARN, VERBOSE, DEPRECATION, - PROC_CUSTOM, + PROC, PROCESSOR, IMPLICIT, SOURCE, @@ -245,79 +247,58 @@ public class RecognizedOptions { } /** - * @param out the writer to use for diagnostic output + * Get all the recognized options. + * @param helper an {@code OptionHelper} to help when processing options + * @return an array of options */ public static Option[] getAll(final OptionHelper helper) { - return new Option[]{ + return new Option[] { new Option(G, "opt.g"), new Option(G_NONE, "opt.g.none") { + @Override public boolean process(Options options, String option) { options.put("-g:", "none"); return false; } }, - new Option(G_CUSTOM, "opt.g.lines.vars.source") { - public boolean matches(String s) { - return s.startsWith("-g:"); - } - public boolean process(Options options, String option) { - String suboptions = option.substring(3); - options.put("-g:", suboptions); - // enter all the -g suboptions as "-g:suboption" - for (StringTokenizer t = new StringTokenizer(suboptions, ","); t.hasMoreTokens(); ) { - String tok = t.nextToken(); - String opt = "-g:" + tok; - options.put(opt, opt); - } - return false; - } - }, + new Option(G_CUSTOM, "opt.g.lines.vars.source", + Option.ChoiceKind.ANYOF, "lines", "vars", "source"), new XOption(XLINT, "opt.Xlint"), - new XOption(XLINT_CUSTOM, "opt.Xlint.suboptlist") { - public boolean matches(String s) { - return s.startsWith("-Xlint:"); - } - public boolean process(Options options, String option) { - String suboptions = option.substring(7); - options.put("-Xlint:", suboptions); - // enter all the -Xlint suboptions as "-Xlint:suboption" - for (StringTokenizer t = new StringTokenizer(suboptions, ","); t.hasMoreTokens(); ) { - String tok = t.nextToken(); - String opt = "-Xlint:" + tok; - options.put(opt, opt); - } - return false; - } - }, + new XOption(XLINT_CUSTOM, "opt.Xlint.suboptlist", + Option.ChoiceKind.ANYOF, getXLintChoices()), // -nowarn is retained for command-line backward compatibility new Option(NOWARN, "opt.nowarn") { - public boolean process(Options options, String option) { - options.put("-Xlint:none", option); - return false; - } - }, + @Override + public boolean process(Options options, String option) { + options.put("-Xlint:none", option); + return false; + } + }, new Option(VERBOSE, "opt.verbose"), // -deprecation is retained for command-line backward compatibility new Option(DEPRECATION, "opt.deprecation") { - public boolean process(Options options, String option) { - options.put("-Xlint:deprecation", option); - return false; - } - }, + @Override + public boolean process(Options options, String option) { + options.put("-Xlint:deprecation", option); + return false; + } + }, new Option(CLASSPATH, "opt.arg.path", "opt.classpath"), new Option(CP, "opt.arg.path", "opt.classpath") { + @Override public boolean process(Options options, String option, String arg) { return super.process(options, "-classpath", arg); } }, new Option(SOURCEPATH, "opt.arg.path", "opt.sourcepath"), new Option(BOOTCLASSPATH, "opt.arg.path", "opt.bootclasspath") { + @Override public boolean process(Options options, String option, String arg) { options.remove("-Xbootclasspath/p:"); options.remove("-Xbootclasspath/a:"); @@ -327,6 +308,7 @@ public class RecognizedOptions { new XOption(XBOOTCLASSPATH_PREPEND,"opt.arg.path", "opt.Xbootclasspath.p"), new XOption(XBOOTCLASSPATH_APPEND, "opt.arg.path", "opt.Xbootclasspath.a"), new XOption(XBOOTCLASSPATH, "opt.arg.path", "opt.bootclasspath") { + @Override public boolean process(Options options, String option, String arg) { options.remove("-Xbootclasspath/p:"); options.remove("-Xbootclasspath/a:"); @@ -335,48 +317,29 @@ public class RecognizedOptions { }, new Option(EXTDIRS, "opt.arg.dirs", "opt.extdirs"), new XOption(DJAVA_EXT_DIRS, "opt.arg.dirs", "opt.extdirs") { + @Override public boolean process(Options options, String option, String arg) { return super.process(options, "-extdirs", arg); } }, new Option(ENDORSEDDIRS, "opt.arg.dirs", "opt.endorseddirs"), new XOption(DJAVA_ENDORSED_DIRS, "opt.arg.dirs", "opt.endorseddirs") { + @Override public boolean process(Options options, String option, String arg) { return super.process(options, "-endorseddirs", arg); } }, - new Option(PROC_CUSTOM, "opt.proc.none.only") { - public boolean matches(String s) { - return s.equals("-proc:none") || s.equals("-proc:only"); - } - - public boolean process(Options options, String option) { - if (option.equals("-proc:none")) { - options.remove("-proc:only"); - } else { - options.remove("-proc:none"); - } - options.put(option, option); - return false; - } - }, + new Option(PROC, "opt.proc.none.only", + Option.ChoiceKind.ONEOF, "none", "only"), new Option(PROCESSOR, "opt.arg.class.list", "opt.processor"), new Option(PROCESSORPATH, "opt.arg.path", "opt.processorpath"), new Option(D, "opt.arg.directory", "opt.d"), new Option(S, "opt.arg.directory", "opt.sourceDest"), - new Option(IMPLICIT, "opt.implicit") { - public boolean matches(String s) { - return s.equals("-implicit:none") || s.equals("-implicit:class"); - } - public boolean process(Options options, String option, String operand) { - int sep = option.indexOf(":"); - options.put(option.substring(0, sep), option.substring(sep+1)); - options.put(option,option); - return false; - } - }, + new Option(IMPLICIT, "opt.implicit", + Option.ChoiceKind.ONEOF, "none", "class"), new Option(ENCODING, "opt.arg.encoding", "opt.encoding"), new Option(SOURCE, "opt.arg.release", "opt.source") { + @Override public boolean process(Options options, String option, String operand) { Source source = Source.lookup(operand); if (source == null) { @@ -387,6 +350,7 @@ public class RecognizedOptions { } }, new Option(TARGET, "opt.arg.release", "opt.target") { + @Override public boolean process(Options options, String option, String operand) { Target target = Target.lookup(operand); if (target == null) { @@ -397,54 +361,62 @@ public class RecognizedOptions { } }, new Option(VERSION, "opt.version") { + @Override public boolean process(Options options, String option) { helper.printVersion(); return super.process(options, option); } }, new HiddenOption(FULLVERSION) { + @Override public boolean process(Options options, String option) { helper.printFullVersion(); return super.process(options, option); } }, new Option(HELP, "opt.help") { + @Override public boolean process(Options options, String option) { helper.printHelp(); return super.process(options, option); } }, new Option(A, "opt.arg.key.equals.value","opt.A") { - String helpSynopsis() { - hasSuffix = true; - return super.helpSynopsis(); - } + @Override + String helpSynopsis() { + hasSuffix = true; + return super.helpSynopsis(); + } - public boolean matches(String arg) { - return arg.startsWith("-A"); - } + @Override + public boolean matches(String arg) { + return arg.startsWith("-A"); + } - public boolean hasArg() { - return false; + @Override + public boolean hasArg() { + return false; + } + // Mapping for processor options created in + // JavacProcessingEnvironment + @Override + public boolean process(Options options, String option) { + int argLength = option.length(); + if (argLength == 2) { + helper.error("err.empty.A.argument"); + return true; } - // Mapping for processor options created in - // JavacProcessingEnvironment - public boolean process(Options options, String option) { - int argLength = option.length(); - if (argLength == 2) { - helper.error("err.empty.A.argument"); - return true; - } - int sepIndex = option.indexOf('='); - String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) ); - if (!JavacProcessingEnvironment.isValidOptionName(key)) { - helper.error("err.invalid.A.key", option); - return true; - } - return process(options, option, option); + int sepIndex = option.indexOf('='); + String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) ); + if (!JavacProcessingEnvironment.isValidOptionName(key)) { + helper.error("err.invalid.A.key", option); + return true; } + return process(options, option, option); + } }, new Option(X, "opt.X") { + @Override public boolean process(Options options, String option) { helper.printXhelp(); return super.process(options, option); @@ -454,10 +426,12 @@ public class RecognizedOptions { // This option exists only for the purpose of documenting itself. // It's actually implemented by the launcher. new Option(J, "opt.arg.flag", "opt.J") { + @Override String helpSynopsis() { hasSuffix = true; return super.helpSynopsis(); } + @Override public boolean process(Options options, String option) { throw new AssertionError ("the -J flag should be caught by the launcher."); @@ -469,6 +443,7 @@ public class RecognizedOptions { // new Option("-moreinfo", "opt.moreinfo") { new HiddenOption(MOREINFO) { + @Override public boolean process(Options options, String option) { Type.moreInfo = true; return super.process(options, option); @@ -512,6 +487,7 @@ public class RecognizedOptions { // display warnings for generic unchecked operations new HiddenOption(WARNUNCHECKED) { + @Override public boolean process(Options options, String option) { options.put("-Xlint:unchecked", option); return false; @@ -521,6 +497,7 @@ public class RecognizedOptions { new XOption(XMAXERRS, "opt.arg.number", "opt.maxerrs"), new XOption(XMAXWARNS, "opt.arg.number", "opt.maxwarns"), new XOption(XSTDOUT, "opt.arg.file", "opt.Xstdout") { + @Override public boolean process(Options options, String option, String arg) { try { helper.setOut(new PrintWriter(new FileWriter(arg), true)); @@ -538,17 +515,8 @@ public class RecognizedOptions { new XOption(XPRINTPROCESSORINFO, "opt.printProcessorInfo"), - new XOption(XPREFER, "opt.prefer") { - public boolean matches(String s) { - return s.equals("-Xprefer:source") || s.equals("-Xprefer:newer"); - } - public boolean process(Options options, String option, String operand) { - int sep = option.indexOf(":"); - options.put(option.substring(0, sep), option.substring(sep+1)); - options.put(option,option); - return false; - } - }, + new XOption(XPREFER, "opt.prefer", + Option.ChoiceKind.ONEOF, "source", "newer"), /* -O is a no-op, accepted for backward compatibility. */ new HiddenOption(O), @@ -562,10 +530,12 @@ public class RecognizedOptions { */ new HiddenOption(XD) { String s; + @Override public boolean matches(String s) { this.s = s; return s.startsWith(name.optionName); } + @Override public boolean process(Options options, String option) { s = s.substring(name.optionName.length()); int eq = s.indexOf('='); @@ -586,11 +556,13 @@ public class RecognizedOptions { */ new HiddenOption(SOURCEFILE) { String s; + @Override public boolean matches(String s) { this.s = s; return s.endsWith(".java") // Java source file || SourceVersion.isName(s); // Legal type name } + @Override public boolean process(Options options, String option) { if (s.endsWith(".java") ) { File f = new File(s); @@ -612,4 +584,15 @@ public class RecognizedOptions { }; } + private static Collection getXLintChoices() { + Collection choices = new LinkedHashSet(); + choices.add("all"); + for (Lint.LintCategory c : Lint.LintCategory.values()) + choices.add(c.option); + for (Lint.LintCategory c : Lint.LintCategory.values()) + choices.add("-" + c.option); + choices.add("none"); + return choices; + } + } diff --git a/langtools/test/tools/javac/6341866/T6341866.java b/langtools/test/tools/javac/6341866/T6341866.java index 5590566d6be..4c7eafca8f8 100644 --- a/langtools/test/tools/javac/6341866/T6341866.java +++ b/langtools/test/tools/javac/6341866/T6341866.java @@ -186,7 +186,7 @@ public class T6341866 { } static void error(String msg) { - System.err.println(msg); + System.err.println("ERROR: " + msg); } static File services(Class service) { From 7dbe0828dec2e6c38f9e9b6d68dd5e65d6d2aa83 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 12 Mar 2008 13:06:00 -0700 Subject: [PATCH 27/54] 6668794: javac puts localized text in raw diagnostics 6668796: bad diagnostic "bad class file" given for source files Replace internal use of localized text with JCDiagnostic fragments; fix diagnostic for bad source file Reviewed-by: mcimadamore --- .../com/sun/tools/javac/code/Symbol.java | 32 +++++-- .../com/sun/tools/javac/comp/Check.java | 2 +- .../com/sun/tools/javac/jvm/ClassReader.java | 40 +++++---- .../sun/tools/javac/main/JavaCompiler.java | 23 +++-- .../JavacProcessingEnvironment.java | 2 +- .../tools/javac/resources/compiler.properties | 4 + .../test/tools/javac/6668794/badClass/A.java | 28 ++++++ .../test/tools/javac/6668794/badClass/B.java | 7 ++ .../tools/javac/6668794/badClass/Test.java | 88 +++++++++++++++++++ .../tools/javac/6668794/badSource/Test.java | 11 +++ .../tools/javac/6668794/badSource/Test.out | 1 + .../tools/javac/6668794/badSource/p/A.java | 28 ++++++ 12 files changed, 233 insertions(+), 33 deletions(-) create mode 100644 langtools/test/tools/javac/6668794/badClass/A.java create mode 100644 langtools/test/tools/javac/6668794/badClass/B.java create mode 100644 langtools/test/tools/javac/6668794/badClass/Test.java create mode 100644 langtools/test/tools/javac/6668794/badSource/Test.java create mode 100644 langtools/test/tools/javac/6668794/badSource/Test.out create mode 100644 langtools/test/tools/javac/6668794/badSource/p/A.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java index 86f0e5f1f2c..51823389f9f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java @@ -25,13 +25,9 @@ package com.sun.tools.javac.code; -import java.util.ArrayList; -import java.util.Collections; import java.util.Set; import java.util.concurrent.Callable; import javax.lang.model.element.*; -import javax.lang.model.type.ReferenceType; -import javax.lang.model.type.TypeMirror; import javax.tools.JavaFileObject; import com.sun.tools.javac.util.*; @@ -1272,8 +1268,14 @@ public abstract class Symbol implements Element { private static final long serialVersionUID = 0; public Symbol sym; - /** A localized string describing the failure. + /** A diagnostic object describing the failure */ + public JCDiagnostic diag; + + /** A localized string describing the failure. + * @deprecated Use {@code getDetail()} or {@code getMessage()} + */ + @Deprecated public String errmsg; public CompletionFailure(Symbol sym, String errmsg) { @@ -1282,8 +1284,26 @@ public abstract class Symbol implements Element { // this.printStackTrace();//DEBUG } + public CompletionFailure(Symbol sym, JCDiagnostic diag) { + this.sym = sym; + this.diag = diag; +// this.printStackTrace();//DEBUG + } + + public JCDiagnostic getDiagnostic() { + return diag; + } + + @Override public String getMessage() { - return errmsg; + if (diag != null) + return diag.getMessage(null); + else + return errmsg; + } + + public Object getDetailValue() { + return (diag != null ? diag : errmsg); } @Override 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 6b01fce3471..342696ceed8 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 @@ -173,7 +173,7 @@ public class Check { * @param ex The failure to report. */ public Type completionError(DiagnosticPosition pos, CompletionFailure ex) { - log.error(pos, "cant.access", ex.sym, ex.errmsg); + log.error(pos, "cant.access", ex.sym, ex.getDetailValue()); if (ex instanceof ClassReader.BadClassFile) throw new Abort(); else return syms.errType; } 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 da75150e8cc..96729791774 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 @@ -131,6 +131,10 @@ public class ClassReader extends ClassFile implements Completer { */ private final JavaFileManager fileManager; + /** Factory for diagnostics + */ + JCDiagnostic.Factory diagFactory; + /** Can be reassigned from outside: * the completer to be used for ".java" files. If this remains unassigned * ".java" files will not be loaded. @@ -221,6 +225,7 @@ public class ClassReader extends ClassFile implements Completer { fileManager = context.get(JavaFileManager.class); if (fileManager == null) throw new AssertionError("FileManager initialization error"); + diagFactory = JCDiagnostic.Factory.instance(context); init(syms, definitive); log = Log.instance(context); @@ -256,23 +261,26 @@ public class ClassReader extends ClassFile implements Completer { * Error Diagnoses ***********************************************************************/ - public static class BadClassFile extends CompletionFailure { + + public class BadClassFile extends CompletionFailure { private static final long serialVersionUID = 0; - /** - * @param msg A localized message. - */ - public BadClassFile(ClassSymbol c, Object cname, Object msg) { - super(c, Log.getLocalizedString("bad.class.file.header", - cname, msg)); + public BadClassFile(TypeSymbol sym, JavaFileObject file, JCDiagnostic diag) { + super(sym, createBadClassFileDiagnostic(file, diag)); } } + // where + private JCDiagnostic createBadClassFileDiagnostic(JavaFileObject file, JCDiagnostic diag) { + String key = (file.getKind() == JavaFileObject.Kind.SOURCE + ? "bad.source.file.header" : "bad.class.file.header"); + return diagFactory.fragment(key, file, diag); + } public BadClassFile badClassFile(String key, Object... args) { return new BadClassFile ( currentOwner.enclClass(), currentClassFile, - Log.getLocalizedString(key, args)); + diagFactory.fragment(key, args)); } /************************************************************************ @@ -1893,10 +1901,10 @@ public class ClassReader extends ClassFile implements Completer { currentClassFile = previousClassFile; } } else { + JCDiagnostic diag = + diagFactory.fragment("class.file.not.found", c.flatname); throw - newCompletionFailure(c, - Log.getLocalizedString("class.file.not.found", - c.flatname)); + newCompletionFailure(c, diag); } } // where @@ -1934,22 +1942,22 @@ public class ClassReader extends ClassFile implements Completer { * In practice, only one can be used at a time, so we share one * to reduce the expense of allocating new exception objects. */ - private CompletionFailure newCompletionFailure(ClassSymbol c, - String localized) { + private CompletionFailure newCompletionFailure(TypeSymbol c, + JCDiagnostic diag) { if (!cacheCompletionFailure) { // log.warning("proc.messager", // Log.getLocalizedString("class.file.not.found", c.flatname)); // c.debug.printStackTrace(); - return new CompletionFailure(c, localized); + return new CompletionFailure(c, diag); } else { CompletionFailure result = cachedCompletionFailure; result.sym = c; - result.errmsg = localized; + result.diag = diag; return result; } } private CompletionFailure cachedCompletionFailure = - new CompletionFailure(null, null); + new CompletionFailure(null, (JCDiagnostic) null); { cachedCompletionFailure.setStackTrace(new StackTraceElement[0]); } 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 af97c6e022e..5bcccd35b7c 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 @@ -198,6 +198,10 @@ public class JavaCompiler implements ClassReader.SourceCompleter { */ public Log log; + /** Factory for creating diagnostic objects + */ + JCDiagnostic.Factory diagFactory; + /** The tree factory module. */ protected TreeMaker make; @@ -304,6 +308,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { names = Name.Table.instance(context); log = Log.instance(context); + diagFactory = JCDiagnostic.Factory.instance(context); reader = ClassReader.instance(context); make = TreeMaker.instance(context); writer = ClassWriter.instance(context); @@ -318,7 +323,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { syms = Symtab.instance(context); } catch (CompletionFailure ex) { // inlined Check.completionError as it is not initialized yet - log.error("cant.access", ex.sym, ex.errmsg); + log.error("cant.access", ex.sym, ex.getDetailValue()); if (ex instanceof ClassReader.BadClassFile) throw new Abort(); } @@ -683,16 +688,16 @@ public class JavaCompiler implements ClassReader.SourceCompleter { JavaFileObject.Kind.SOURCE); if (isPkgInfo) { if (enter.getEnv(tree.packge) == null) { - String msg - = log.getLocalizedString("file.does.not.contain.package", + JCDiagnostic diag = + diagFactory.fragment("file.does.not.contain.package", c.location()); - throw new ClassReader.BadClassFile(c, filename, msg); + throw reader.new BadClassFile(c, filename, diag); } } else { - throw new - ClassReader.BadClassFile(c, filename, log. - getLocalizedString("file.doesnt.contain.class", - c.fullname)); + JCDiagnostic diag = + diagFactory.fragment("file.doesnt.contain.class", + c.getQualifiedName()); + throw reader.new BadClassFile(c, filename, diag); } } @@ -997,7 +1002,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { annotationProcessingOccurred = c.annotationProcessingOccurred = true; return c; } catch (CompletionFailure ex) { - log.error("cant.access", ex.sym, ex.errmsg); + log.error("cant.access", ex.sym, ex.getDetailValue()); return this; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java index 4e7dfa99f26..684d28a2193 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java +++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java @@ -734,7 +734,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea } catch (CompletionFailure ex) { StringWriter out = new StringWriter(); ex.printStackTrace(new PrintWriter(out)); - log.error("proc.cant.access", ex.sym, ex.errmsg, out.toString()); + log.error("proc.cant.access", ex.sym, ex.getDetailValue(), out.toString()); return false; } catch (Throwable t) { throw new AnnotationProcessingError(t); 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 1dcbe45759f..abedc2db9b1 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 @@ -827,6 +827,10 @@ compiler.misc.bad.class.file.header=\ bad class file: {0}\n\ {1}\n\ Please remove or make sure it appears in the correct subdirectory of the classpath. +compiler.misc.bad.source.file.header=\ +bad source file: {0}\n\ +{1}\n\ +Please remove or make sure it appears in the correct subdirectory of the sourcepath. ## The following are all possible strings for the second argument ({1}) of the ## above strings. diff --git a/langtools/test/tools/javac/6668794/badClass/A.java b/langtools/test/tools/javac/6668794/badClass/A.java new file mode 100644 index 00000000000..404039d2255 --- /dev/null +++ b/langtools/test/tools/javac/6668794/badClass/A.java @@ -0,0 +1,28 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package q; + +class A { } diff --git a/langtools/test/tools/javac/6668794/badClass/B.java b/langtools/test/tools/javac/6668794/badClass/B.java new file mode 100644 index 00000000000..4ba00da6b45 --- /dev/null +++ b/langtools/test/tools/javac/6668794/badClass/B.java @@ -0,0 +1,7 @@ +/* + * /nodynamiccopyright/ + */ + +class B { + p.A a; +} diff --git a/langtools/test/tools/javac/6668794/badClass/Test.java b/langtools/test/tools/javac/6668794/badClass/Test.java new file mode 100644 index 00000000000..40e514f89a5 --- /dev/null +++ b/langtools/test/tools/javac/6668794/badClass/Test.java @@ -0,0 +1,88 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6668794 6668796 + * @summary javac puts localized text in raw diagnostics + * bad diagnostic "bad class file" given for source files + */ + +import java.io.*; +import java.util.*; +import javax.tools.*; + +public class Test { + public static void main(String[] args) throws Exception { + new Test().run(); + } + + void run() throws Exception { + + // compile q.A then move it to p.A + compile("A.java"); + + File p = new File("p"); + p.mkdirs(); + new File("q/A.class").renameTo(new File("p/A.class")); + + // compile B against p.A + String[] out = compile("B.java"); + if (out.length == 0) + throw new Error("no diagnostics generated"); + + String expected = "B.java:6:6: compiler.err.cant.access: p.A, " + + "(- compiler.misc.bad.class.file.header: A.class, " + + "(- compiler.misc.class.file.wrong.class: q.A))"; + + if (!out[0].equals(expected)) { + System.err.println("expected: " + expected); + System.err.println(" found: " + out[0]); + throw new Error("test failed"); + } + } + + String[] compile(String file) { + String[] options = { + "-XDrawDiagnostics", + "-d", ".", + "-classpath", ".", + new File(testSrc, file).getPath() + }; + + System.err.println("compile: " + Arrays.asList(options)); + StringWriter sw = new StringWriter(); + PrintWriter out = new PrintWriter(sw); + int rc = com.sun.tools.javac.Main.compile(options, out); + out.close(); + + String outText = sw.toString(); + System.err.println(outText); + + return sw.toString().split("[\\r\\n]+"); + } + + File testSrc = new File(System.getProperty("test.src", ".")); +} diff --git a/langtools/test/tools/javac/6668794/badSource/Test.java b/langtools/test/tools/javac/6668794/badSource/Test.java new file mode 100644 index 00000000000..162493e5ab1 --- /dev/null +++ b/langtools/test/tools/javac/6668794/badSource/Test.java @@ -0,0 +1,11 @@ +/* + * @test /nodynamiccopyight/ + * @bug 6668794 6668796 + * @summary javac puts localized text in raw diagnostics + * bad diagnostic "bad class file" given for source files + * @compile/fail/ref=Test.out -XDrawDiagnostics Test.java + */ + +class Test { + p.A a; +} diff --git a/langtools/test/tools/javac/6668794/badSource/Test.out b/langtools/test/tools/javac/6668794/badSource/Test.out new file mode 100644 index 00000000000..e9fbdf99bda --- /dev/null +++ b/langtools/test/tools/javac/6668794/badSource/Test.out @@ -0,0 +1 @@ +Test.java:10:6: compiler.err.cant.access: p.A, (- compiler.misc.bad.source.file.header: A.java, (- compiler.misc.file.doesnt.contain.class: p.A)) diff --git a/langtools/test/tools/javac/6668794/badSource/p/A.java b/langtools/test/tools/javac/6668794/badSource/p/A.java new file mode 100644 index 00000000000..404039d2255 --- /dev/null +++ b/langtools/test/tools/javac/6668794/badSource/p/A.java @@ -0,0 +1,28 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package q; + +class A { } From d3dcc1c11528e4fefebe2c333debbbc4ce929ad0 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 13 Mar 2008 13:42:38 -0700 Subject: [PATCH 28/54] 6559315: Inconsistent non-standard Sun copyright in src/share/opensource/javac/doc/document.css Remove obsolete files Reviewed-by: mcimadamore --- langtools/src/share/opensource/javac/Makefile | 275 --------------- .../opensource/javac/README-template.html | 330 ------------------ .../share/opensource/javac/build.properties | 13 - .../src/share/opensource/javac/build.xml | 163 --------- .../share/opensource/javac/doc/document.css | 59 ---- .../javac/doc/javac_lifecycle/Context.html | 107 ------ .../javac/doc/javac_lifecycle/Enter.html | 90 ----- .../doc/javac_lifecycle/JavaCompiler.html | 79 ----- .../javac/doc/javac_lifecycle/Main.html | 69 ---- .../javac/doc/javac_lifecycle/ToDo.html | 167 --------- .../javac/doc/javac_lifecycle/contents.html | 43 --- .../javac/doc/javac_lifecycle/index.html | 40 --- .../javac/doc/javac_lifecycle/packages.html | 91 ----- .../javac/doc/javac_lifecycle/style.css | 33 -- .../opensource/javac/nbproject/project.xml | 88 ----- .../share/opensource/javac/src/bin/javac.sh | 30 -- 16 files changed, 1677 deletions(-) delete mode 100644 langtools/src/share/opensource/javac/Makefile delete mode 100644 langtools/src/share/opensource/javac/README-template.html delete mode 100644 langtools/src/share/opensource/javac/build.properties delete mode 100644 langtools/src/share/opensource/javac/build.xml delete mode 100644 langtools/src/share/opensource/javac/doc/document.css delete mode 100644 langtools/src/share/opensource/javac/doc/javac_lifecycle/Context.html delete mode 100644 langtools/src/share/opensource/javac/doc/javac_lifecycle/Enter.html delete mode 100644 langtools/src/share/opensource/javac/doc/javac_lifecycle/JavaCompiler.html delete mode 100644 langtools/src/share/opensource/javac/doc/javac_lifecycle/Main.html delete mode 100644 langtools/src/share/opensource/javac/doc/javac_lifecycle/ToDo.html delete mode 100644 langtools/src/share/opensource/javac/doc/javac_lifecycle/contents.html delete mode 100644 langtools/src/share/opensource/javac/doc/javac_lifecycle/index.html delete mode 100644 langtools/src/share/opensource/javac/doc/javac_lifecycle/packages.html delete mode 100644 langtools/src/share/opensource/javac/doc/javac_lifecycle/style.css delete mode 100644 langtools/src/share/opensource/javac/nbproject/project.xml delete mode 100644 langtools/src/share/opensource/javac/src/bin/javac.sh diff --git a/langtools/src/share/opensource/javac/Makefile b/langtools/src/share/opensource/javac/Makefile deleted file mode 100644 index 6dedb18e44d..00000000000 --- a/langtools/src/share/opensource/javac/Makefile +++ /dev/null @@ -1,275 +0,0 @@ -# -# Copyright 2006-2007 Sun Microsystems, Inc. All Rights Reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Sun designates this -# particular file as subject to the "Classpath" exception as provided -# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - -# Simple Makefile for javac - -BUILD = build -BUILD_BOOTCLASSES = $(BUILD)/bootclasses -BUILD_CLASSES = $(BUILD)/classes -BUILD_JAVAC_SRCFILES = $(BUILD)/javac.srcfiles -GENSRCDIR = $(BUILD)/gensrc -DIST = dist -DIST_JAVAC = $(DIST) -ABS_DIST_JAVAC = $(shell cd $(DIST_JAVAC) ; pwd) -SRC_BIN = src/bin -SRC_CLASSES = src/share/classes - -#-------------------------------------------------------------------------------- -# -# version info for generated compiler - -JDK_VERSION = 1.7.0 -RELEASE=$(JDK_VERSION)-opensource -BUILD_NUMBER = b00 -USER_RELEASE_SUFFIX := $(shell echo $(USER)_`date '+%d_%b_%Y_%H_%M' | tr "A-Z" "a-z"`) -FULL_VERSION = $(RELEASE)-$(USER_RELEASE_SUFFIX)-$(BUILD_NUMBER) - -#-------------------------------------------------------------------------------- - -CAT = /bin/cat -CHMOD = /bin/chmod -CP = /bin/cp -MKDIR = /bin/mkdir -RM = /bin/rm -SED = /bin/sed - - -SYSTEM_UNAME := $(shell uname) - -# Platform settings specific to Solaris -ifeq ($(SYSTEM_UNAME), SunOS) - # Intrinsic unix command, with backslash-escaped character interpretation - # (not using -e will cause build failure when using /bin/bash) - # (using -e breaks something else) - ECHO = /usr/bin/echo - PLATFORM = solaris -endif - -# Platform settings specific to Linux -ifeq ($(SYSTEM_UNAME), Linux) - # Intrinsic unix command, with backslash-escaped character interpretation - ECHO = echo -e - PLATFORM = linux -endif - - -# Set BOOTDIR to specify the JDK used to build the compiler -ifdef BOOTDIR -JAR = $(BOOTDIR)/bin/jar -JAVA = $(BOOTDIR)/bin/java -JAVAC = $(BOOTDIR)/bin/javac -JAVADOC = $(BOOTDIR)/bin/javadoc -else -JAR = jar -JAVA = java -JAVAC = javac -JAVADOC = javadoc -endif - -ifndef JTREG -ifdef JTREG_HOME -JTREG = $(JTREG_HOME)/$(PLATFORM)/bin/jtreg -else -JTREG = jtreg -endif -endif - -ifndef JTREG_OPTS -JTREG_OPTS = -s -verbose:summary -endif - -ifndef JTREG_TESTS -JTREG_TESTS = test/tools/javac -endif - -# Set this to the baseline version of JDK used for the tests -# TESTJDKHOME = - -COMPILER_SOURCE_LEVEL = 1.5 - -#-------------------------------------------------------------------------------- -SCM_DIRS = -name .hg -o -name .svn -o -name CVS -o -name RCS -o -name SCCS -JAVAC_SRCS = $(shell find \ - $(SRC_CLASSES)/javax/annotation/processing \ - $(SRC_CLASSES)/javax/lang/model \ - $(SRC_CLASSES)/javax/tools \ - $(SRC_CLASSES)/com/sun/source \ - $(SRC_CLASSES)/com/sun/tools/javac \ - \( $(SCM_DIRS) -o -name \*-template.\* \) -prune -o -name \*.java -print ) - -JAVAC_RESOURCES = $(shell ls $(SRC_CLASSES)/com/sun/tools/javac/resources/*.properties | $(SED) -e 's/-template//' ) - - -#-------------------------------------------------------------------------------- - -default: build - -all: build docs - -clean: - $(RM) -rf $(BUILD) $(DIST) - -build: sanity $(DIST_JAVAC)/lib/javac.jar $(DIST_JAVAC)/bin/javac - - -# javac.jar - -$(DIST_JAVAC)/lib/javac.jar: \ - $(JAVAC_SRCS) \ - $(patsubst $(SRC_CLASSES)/%,$(BUILD_BOOTCLASSES)/%,$(JAVAC_RESOURCES)) \ - $(patsubst $(SRC_CLASSES)/%,$(BUILD_CLASSES)/%,$(JAVAC_RESOURCES)) - @$(ECHO) $(JAVAC_SRCS) > $(BUILD_JAVAC_SRCFILES) - $(JAVAC) -d $(BUILD_BOOTCLASSES) -source $(COMPILER_SOURCE_LEVEL) -g:source,lines @$(BUILD_JAVAC_SRCFILES) - $(JAVA) -cp $(BUILD_BOOTCLASSES) com.sun.tools.javac.Main \ - -d $(BUILD_CLASSES) -g:source,lines @$(BUILD_JAVAC_SRCFILES) - ( $(ECHO) "Main-Class: com.sun.tools.javac.Main" ; \ - $(ECHO) "Built-By: $$USER" ; \ - $(ECHO) "Built-At: `date`" ) > $(BUILD)/javac.MF - $(MKDIR) -p $(DIST_JAVAC)/lib - $(JAR) -cmf $(BUILD)/javac.MF $(DIST_JAVAC)/lib/javac.jar -C ${BUILD_CLASSES} . - - -# javac resources - -$(BUILD_BOOTCLASSES)/com/sun/tools/javac/resources/version.properties \ -$(BUILD_CLASSES)/com/sun/tools/javac/resources/version.properties: \ - $(SRC_CLASSES)/com/sun/tools/javac/resources/version-template.properties - $(MKDIR) -p $(@D) - $(SED) -e 's/$$(JDK_VERSION)/$(JDK_VERSION)/' \ - -e 's/$$(FULL_VERSION)/$(FULL_VERSION)/' \ - -e 's/$$(RELEASE)/$(RELEASE)/' \ - < $< > $@ - -$(BUILD_BOOTCLASSES)/com/sun/tools/javac/resources/%.properties: \ - $(SRC_CLASSES)/com/sun/tools/javac/resources/%.properties - $(MKDIR) -p $(@D) - $(CP) $^ $@ - -$(BUILD_CLASSES)/com/sun/tools/javac/resources/%.properties: \ - $(SRC_CLASSES)/com/sun/tools/javac/resources/%.properties - $(MKDIR) -p $(@D) - $(CP) $^ $@ - - -# javac wrapper script - -$(DIST_JAVAC)/bin/javac: $(SRC_BIN)/javac.sh - $(MKDIR) -p $(@D) - $(CP) $^ $@ - $(CHMOD) +x $@ - -# javadoc - -JLS3_URL = http://java.sun.com/docs/books/jls/ -JLS3_CITE = \ - The Java Language Specification, Third Edition -TAG_JLS3 = -tag 'jls3:a:See $(JLS3_CITE):' - -TAGS = $(IGNORED_TAGS:%=-tag %:X) $(TAG_JLS3) - -docs: - $(JAVADOC) -sourcepath $(SRC_CLASSES) -d $(DIST_JAVAC)/doc/api \ - $(TAGS) \ - -subpackages javax.annotation.processing:javax.lang.model:javax.tools:com.sun.source:com.sun.tools.javac - -#-------------------------------------------------------------------------------- - -test: test-sanity $(DIST_JAVAC)/lib/javac.jar - $(JTREG) $(JTREG_OPTS) -noshell \ - -jdk:$(TESTJDKHOME) \ - -Xbootclasspath/p:$(ABS_DIST_JAVAC)/lib/javac.jar \ - -w:$(BUILD)/jtreg/work \ - -r:$(BUILD)/jtreg/report \ - $(JTREG_TESTS) - -#-------------------------------------------------------------------------------- - -ifndef ERROR_FILE - ERROR_FILE = $(BUILD)/sanityCheckErrors.txt -endif - -presanity: - @$(RM) -f $(ERROR_FILE) - @$(MKDIR) -p `dirname $(ERROR_FILE)` - -###################################################### -# CLASSPATH cannot be set, unless you are insane. -###################################################### -sane-classpath: -ifdef CLASSPATH - @$(ECHO) "ERROR: Your CLASSPATH environment variable is set. This will \n" \ - " most likely cause the build to fail. Please unset it \n" \ - " and start your build again. \n" \ - "" >> $(ERROR_FILE) -endif - -###################################################### -# JAVA_HOME cannot be set, unless you are insane. -###################################################### -sane-java_home: -ifdef JAVA_HOME - @$(ECHO) "ERROR: Your JAVA_HOME environment variable is set. This will \n" \ - " most likely cause the build to fail. Please unset it \n" \ - " and start your build again. \n" \ - "" >> $(ERROR_FILE) -endif - - -###################################################### -# TESTJDKHOME needs to be set to run tests -###################################################### -sane-testjdk: -ifndef TESTJDKHOME - @$(ECHO) "ERROR: TESTJDKHOME needs to be set to the baseline version \n" \ - " version of JDK used to run the compiler tests.\n" \ - "" >> $(ERROR_FILE) -endif - - -sane-lastrule: - @if [ -r $(ERROR_FILE) ]; then \ - if [ "x$(INSANE)" = x ]; then \ - $(ECHO) "Exiting because of the above error(s). \n" \ - "">> $(ERROR_FILE); \ - fi ; \ - $(CAT) $(ERROR_FILE) ; \ - if [ "x$(INSANE)" = x ]; then \ - exit 1 ; \ - fi ; \ - fi - -sanity \ -build-sanity: presanity sane-classpath sane-java_home sane-lastrule - -test-sanity: presanity sane-classpath sane-java_home sane-testjdk sane-lastrule - - - - -#-------------------------------------------------------------------------------- - -.PHONY: all build clean default docs prep test \ - presanity sanity build-sanity test-sanity \ - sane-classpath sane-java_home sane-testjdk sane-lastrule diff --git a/langtools/src/share/opensource/javac/README-template.html b/langtools/src/share/opensource/javac/README-template.html deleted file mode 100644 index 32d210165f1..00000000000 --- a/langtools/src/share/opensource/javac/README-template.html +++ /dev/null @@ -1,330 +0,0 @@ - - - - - - - - - - - OpenJDK: javac -- README - - - - - - - - - - - - - -
 
-

README

- -

Open JDK™ Java programming language compiler (javac)
- Version $(RELEASE) -

-

$(BUILD_DATE)

-
 
- - - - - -

Table of Contents

- - - -

Introduction

-

This bundle contains the source code for javac, a compiler for - the Java™ programming language. - Build files are provided for use with - NetBeans, - Apache Ant or - GNU make. - The bundle also contains a set of compiler tests, for use with the - jtreg test harness. - - -

Files and Directories

- When you install the compiler bundle, a directory named - compiler will be created, containing the following: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameDescription -
README.htmlThis file.
nbproject/project.xmlA NetBeans project file. -
src/share/classes/The source files for the compiler.
build.xmlA build file for building the compiler, suitable for - use with NetBeans and Apache Ant.
build.propertiesBuild properties, used by build.xml.
MakefileA Makefile for building the compiler, suitable for use - with GNU make.
test/tools/javac/Regression tests for the compiler, for use with the JDK regression - test harness, jtreg.
doc/Additional notes about the compiler.
- -

Specifications

-

The compiler is a program for compiling source code written in the Java - programming language into class files suitable for execution on a Java - virtual machine. It also provides API for annotation processing, - and invoking the compiler programmatically. -

These behaviors are governed by the following specifications: -

    -
  • Java Language Specification (JLS)
  • -
  • Java Virtual Machine Specification (JVMS)
  • -
  • Java Compiler API (JSR 199)
  • -
  • Pluggable Annotation Processing API (JSR 269)
  • -
-

For more details on these specifications, see the - javac Guide. -

- -

These specifications are controlled by the Java Community Process - (JCP.) All implementations of these specifications - must pass the appropriate test suites.

- -

Notice regarding JSR 199 and JSR 269: - This is an implementation of an early-draft - specification developed under the Java Community Process (JCP) - and is made available for testing and evaluation purposes only. - The code is not compatible with any specification of the JCP. - -

Building the compiler

- -

System Requirements

-

javac is written in the Java programming language. - As a general rule, it can normally be compiled using tools in the - latest released version of the JDK. - (That is, a development version of javac version 7 - can be built with JDK version 6, etc.) - To bootstrap the compiler, you should also have - a copy of the target JDK.

- -

You can build javac using - NetBeans, - Apache Ant, - or GNU make. -

- -

To run the compiler tests, you will need the - jtreg test harness. - -

Bootstrapping the compiler

- -

The source for the compiler is such that it can be compiled using the latest - publicly released version of the JDK.In practice, it is typically desirable - to compile it first using the latest publicly released version of the JDK, - and then again using itself, and the target platform on which it will be run. - This not only provides a good initial test of the newly built compiler, it - also means the compiler is built with the latest compiler sources, against - the target libraries. - -

Building with NetBeans

-

The installation directory for the compiler is set up as a free-form NetBeans project, - so to build the compiler using NetBeans, you just have to open the - project and build it in the normal way, for example, by using the operations - on the Build menu. -

To run the tests, you will have to edit properties in the - build.properties file, to specify where you have installed - the jtreg harness and, possibly, a different version of - JDK to use when running the tests. - -

Building with Apache Ant

-

To build the compiler, go to the compiler installation directory, and run "ant".

-
-        % cd install-dir
-        % ant       
-        
-

To run the tests, you will have to edit properties in the - build.properties file, to specify where you have installed - the jtreg harness and, possibly, a different version of - JDK to use when running the tests. Then, you can run the tests using the - "test" target. - -

Building with GNU make

-

To build the compiler, go to the compiler installation directory, and type "make".

- You should not have CLASSPATH and JAVAHOME environment variables set when you - do this. -
-        % cd install-dir
-        % make      
-        
-

To run the tests, you will have to specify where you have installed - the jtreg harness and, possibly, a different version of - JDK to use when running the tests. Then, you can run the tests using the - "test" target. You can specify the values by giving them on the command - line when you run make or by editing the values into the Makefile. - -

What gets built?

-

Whichever build tool you use, the results are put in the dist - subdirectory of your installation directory. The following files will be built. - - - - - - - - - - - - - -
NameDescription -
dist/lib/javac.jarThis is an executable jar file containing the compiler.
dist/bin/javacThis is a simple shell script to invoke the compiler.
- -

Notes

- -

Property files: - It is possible to compile the resource property files into equivalent - class files, for a minor performance improvement. For simplicity, that - feature is not included here.

- -

The launcher: - JDK uses a program informally called "the launcher" which is used as - a wrapper for all JDK tools, including java, - javac, javadoc, and so on. The program is a deployed - as a platform-dependent binary, thus obviating the need for a shell - script to invoke the tools. Again for simplicity, and because that program - is not normally considered part of javac, that program is - not included here.

Running the compiler -

Once you have built the compiler, you can run it in a number of ways. -

    -
  • -

    Use the generated script, perhaps by putting it on your shell's - command execution path.

    -
        % install-dir/dist/bin/javac HelloWorld.java
    -

    or

    -
        % javac HelloWorld.java
    -
  • -
  • Execute javac.jar with the java command.

    -
        % java -jar install-dir/dist/lib/javac.jar HelloWorld.java
    -
  • -
  • Execute javac.jar directly. Depending on your operating system, - you may be able to execute the jar file directly.

    -
        % install-dir/dist/lib/javac.jar HelloWorld.java
    -

    See the - Jar File Overview - for details.

    -
  • -
- -

Testing the compiler with jtreg

-

This bundle contains a large test suite of unit and regression tests - used to test javac. They are part of the JDK Regression Test - Suite, which uses the - jtreg test harness. - This harness is - designed to run both API-style tests, and command-line tests, such as - found in the tests for javac.

- -

The simplest way to run the tests is to prepend the newly created - copy of javac.jar to the bootstrap class path of a - compatible version of JDK (meaning, it must accept the class file - versions of newly compiled classes.) To do this, you can use - the -Xbootclasspath/p:<path> option - for jtreg. This option is similar to the equivalent - option for the java command. - -

Note:Some of the tests, written as shell tests, do not yet - support this mode of operation. You should use the - -noshell to disable these tests for the time being. - This restriction will be lifted in the near future. - -

Note:Four additional tests are ignored, using the jtreg - @ignore tag, because of problems caused by bugs that have not yet - been addressed. - -

You can run the compiler tests with a command such as the following:

- -
    % jtreg -jdk:jdk -Xbootclasspath/p:my-javac.jar -verbose -noshell test/tools/javac
- -

Depending on the verbose options used, some amount of detail of the result - of each test is written to the console. In addition, an HTML report about the - entire test run is written to a report directory, and a results file is written for - each test, in a "work" directory. The location of these directories can be - specified on the jtreg command line; the actual locations used - are reported to the console at the conclusion of the test run. - -

For more information on jtreg, use the - the -help option for command-line help, or - the -onlineHelp option for the built-in online help. - Both of these options may optionally be followed by search - keywords

- -

jtreg can also be run from Ant. See - jtreg -onlineHelp ant for details.

- -

Both build.xml and Makefile contain "test" targets for running the tests. - - - diff --git a/langtools/src/share/opensource/javac/build.properties b/langtools/src/share/opensource/javac/build.properties deleted file mode 100644 index e42d827508f..00000000000 --- a/langtools/src/share/opensource/javac/build.properties +++ /dev/null @@ -1,13 +0,0 @@ -build.jdk.version = 1.7.0 -build.release = ${build.jdk.version}-opensource -build.number = b00 -build.user.release.suffix = ${user.name}_${build.fullversion.time} -build.full.version = ${build.release}-${build.user.release.suffix}-${build.number} - -# Set jtreg.home to jtreg installation directory -# jtreg.home = - -# Set test.jdk.home to baseline JDK used to run the tests -# test.jdk.home = - -compiler.source.level = 1.5 diff --git a/langtools/src/share/opensource/javac/build.xml b/langtools/src/share/opensource/javac/build.xml deleted file mode 100644 index 028221f576f..00000000000 --- a/langtools/src/share/opensource/javac/build.xml +++ /dev/null @@ -1,163 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/langtools/src/share/opensource/javac/doc/document.css b/langtools/src/share/opensource/javac/doc/document.css deleted file mode 100644 index 7d6104aaaf6..00000000000 --- a/langtools/src/share/opensource/javac/doc/document.css +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -/* - * Copyright � 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * - */ - -body { background-color: #FFFFFF; font-family: Arial, Helvetica, sans-serif; - border-top-width: 0px; border-right-width: 0px; - border-bottom-width: 0px; border-left-width: 0px} -h1 { font-family: Arial, Helvetica, sans-serif} -h2 { font-family: Arial, Helvetica, sans-serif; padding-top: 25px} -h3 { font-family: Arial, Helvetica, sans-serif} -h4 { font-family: Arial, Helvetica, sans-serif} -li { font-family: Arial, Helvetica, sans-serif} -table { font-family: Arial, Helvetica, sans-serif; - background-color: #FFFFFF; - margin-top: 0px; padding-top: 0px; - border-top-width: 0px; border-right-width: 0px; - border-bottom-width: 0px; border-left-width: 0px; - margin-bottom: 10px; margin-left: 0px; - padding-bottom: 5px; padding-left: 5px} -td { vertical-align: top; font-family: Arial, Helvetica, sans-serif} -td h1 { text-align: center} -td h2 { text-align: center; padding-top: 0px} -td h4 { text-align: center} -th { font-family: Arial, Helvetica, sans-serif; text-align: left; - padding-top: 10px; padding-right: 10px; padding-bottom: 0px; - padding-left: 10px; white-space: nowrap} - -.sun-darkblue { font-family: Arial, Helvetica, sans-serif ; - color: #FFFFFF; background-color: #666699} -.sun-lightblue { background-color: #9999CC} -.nav-link { font-family: Arial, Helvetica, sans-serif; font-size: x-small} -code { font-family: Courier, serif} diff --git a/langtools/src/share/opensource/javac/doc/javac_lifecycle/Context.html b/langtools/src/share/opensource/javac/doc/javac_lifecycle/Context.html deleted file mode 100644 index 289a593236e..00000000000 --- a/langtools/src/share/opensource/javac/doc/javac_lifecycle/Context.html +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - com.sun.tools.javac.comp.Enter - - - -

com.sun.tools.javac.util.Context

- -

Contexts provides a way to share data between the different parts of - the compiler.

- -

They provide support for an abstract context, modelled loosely after - ThreadLocal but using a user-provided context instead of the current - thread.

- -

Within the compiler, a single Context is used for each - invocation of the compiler. The context is then used to ensure a - single copy of each compiler phase exists per compiler invocation.

- -

The context can be used to assist in extending the compiler by - extending its components. To do that, the extended component must - be registered before the base component. We break initialization - cycles by (1) registering a factory for the component rather than - the component itself, and (2) a convention for a pattern of usage - in which each base component registers itself by calling an - instance method that is overridden in extended components. A base - phase supporting extension would look something like this:

- -
-   public class Phase {
-       protected static final Context.Key<Phase> phaseKey =
- 	   new Context.Key<Phase>();
- 
-       public static Phase instance(Context context) {
- 	   Phase instance = context.get(phaseKey);
- 	   if (instance == null)
- 	       // the phase has not been overridden
- 	       instance = new Phase(context);
- 	   return instance;
-       }
- 
-       protected Phase(Context context) {
- 	   context.put(phaseKey, this);
- 	   // other intitialization follows...
-       }
-   }
-        
- -

In the compiler, we simply use Phase.instance(context) to get - the reference to the phase. But in extensions of the compiler, we - must register extensions of the phases to replace the base phase, - and this must be done before any reference to the phase is accessed - using Phase.instance(). An extended phase might be declared thus:

- -
-   public class NewPhase extends Phase {
-       protected NewPhase(Context context) {
- 	   super(context);
-       }
-       public static void preRegister(final Context context) {
-           context.put(phaseKey, new Context.Factory<Phase>() {
- 	       public Phase make() {
- 		   return new NewPhase(context);
- 	       }
-           });
-       }
-   }
-        
- -

And is registered early in the extended compiler like this:

- -
-       NewPhase.preRegister(context);
-        
- - - - diff --git a/langtools/src/share/opensource/javac/doc/javac_lifecycle/Enter.html b/langtools/src/share/opensource/javac/doc/javac_lifecycle/Enter.html deleted file mode 100644 index 19f1a0785b1..00000000000 --- a/langtools/src/share/opensource/javac/doc/javac_lifecycle/Enter.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - com.sun.tools.javac.comp.Enter - - - -

com.sun.tools.javac.comp.Enter

- - This enters symbols for all encountered definitions into - the symbol table. The pass consists of two phases, organized as - follows: - -
    -
  1. In the first phase, all class symbols are entered into their - enclosing scope, descending recursively down the tree for classes - which are members of other classes. The class symbols are given a - MemberEnter object as completer.

  2. - -

    In addition, - if any package-info.java files are found, - containing package annotations, then the TopLevel tree node for - the package-info.java file is put on the "to do" as well. -

    - -
  3. In the second phase, classes are completed using - MemberEnter.complete(). Completion might occur on demand, but - any classes that are not completed that way will be eventually - completed by processing the `uncompleted' queue. Completion - entails -

    • (1) determination of a class's parameters, supertype and - interfaces, as well as
    • (2) entering all symbols defined in the - class into its scope, with the exception of class symbols which - have been entered in phase 1.
    • -
    - (2) depends on (1) having been - completed for a class and all its superclasses and enclosing - classes. That's why, after doing (1), we put classes in a - `halfcompleted' queue. Only when we have performed (1) for a class - and all it's superclasses and enclosing classes, we proceed to - (2).

  4. -
- -

Whereas the first phase is organized as a sweep through all - compiled syntax trees, the second phase is demand. Members of a - class are entered when the contents of a class are first - accessed. This is accomplished by installing completer objects in - class symbols for compiled classes which invoke the member-enter - phase for the corresponding class tree.

- -

Classes migrate from one phase to the next via queues:

- -
-    class enter -> (Enter.uncompleted)         --> member enter (1)
- 		-> (MemberEnter.halfcompleted) --> member enter (2)
- 		-> (Todo)	               --> attribute
- 						(only for toplevel classes)
-        
- - - - diff --git a/langtools/src/share/opensource/javac/doc/javac_lifecycle/JavaCompiler.html b/langtools/src/share/opensource/javac/doc/javac_lifecycle/JavaCompiler.html deleted file mode 100644 index 4ee6f0fe0f2..00000000000 --- a/langtools/src/share/opensource/javac/doc/javac_lifecycle/JavaCompiler.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - JavaCompiler - - - -

com.sun.tools.javac.main.JavaCompiler

-

- JavaCompiler provides (and enforces) a use-once method to compile a list of source files. - It invokes the various phases of the compiler to cause those source files to be compiled. -

-
    -
  • All the files given on the command line are parsed, to build a - list of parse trees. Lexing and parsing are done with - Scanner and - Parser. - Lexical and syntax errors will be detected here. -

    - Note: Additional files may be parsed later, if they are found on the class/source path, and if they are newer than their matching class file. -

    -
  • - -
  • For each of the parse trees, their symbols are "entered", using - Enter. This will also set up a "to do" list of additional work to be done to compile those parse trees. - (more...) -
  • - -
  • If source code or stub code will be generated, a list is made - (in rootClasses) of all the top level classes defined in the parse trees. This will be used later, to check whether a class being processed was directly provided on the command line or not. -
  • - -
  • Then, for as long as there is work on the "to do" list, - JavaCompiler processes entries from the "to do" list. - In so doing, the compiler might find additional classes that need to be - processed, which may result in additional entries being added to the - "to do" list. (more...) -
  • - -
  • Print final messages.
  • - -
  • Return a list of class symbols, perhaps just those from - final lower (may not include top level classes) -
  • -
- - - - - - diff --git a/langtools/src/share/opensource/javac/doc/javac_lifecycle/Main.html b/langtools/src/share/opensource/javac/doc/javac_lifecycle/Main.html deleted file mode 100644 index b434883b295..00000000000 --- a/langtools/src/share/opensource/javac/doc/javac_lifecycle/Main.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - Main - - - -

com.sun.tools.javac.main.Main

- -

- The normal main entry point is - com.sun.tools.javac.main.Main, - with a public API entry point at - com.sun.tools.javac.Main which just calls down to com.sun.tools.javac.main.Main. -

- -

The various parts of the compiler share common information by means of a - Context. - Every invocation of the compiler must have its own Context. - -

- com.sun.tools.javac.main.Main does command line processing to determine the list of files to be compiled, and any applicable options. There are four types of options: -

    -
  • standard public options, e.g. -classpath -
  • extended public options, beginning -X, e.g. -Xlint -
  • hidden options -- not public or documented, e.g. -fullversion -
  • even more hidden options -- typically for debugging the compiler, beginning -XD, e.g. -XDrawDiagnostics -
- - If there are files to be compiled, Main invokes - JavaCompiler (more...) - After JavaCompiler completes, the list of class symbols that was returned is discarded. -

- -

- Any and all exceptions are caught and handled, and a return code is - determined. Finally, the compiler exits. -

- - - diff --git a/langtools/src/share/opensource/javac/doc/javac_lifecycle/ToDo.html b/langtools/src/share/opensource/javac/doc/javac_lifecycle/ToDo.html deleted file mode 100644 index 3d56e846636..00000000000 --- a/langtools/src/share/opensource/javac/doc/javac_lifecycle/ToDo.html +++ /dev/null @@ -1,167 +0,0 @@ - - - - - - - - - JavaCompiler's "to do" list - - - -

com.sun.tools.javac.main.JavaCompiler's "to do" list

- -

- After the source files have been parsed, and their symbols entered - in the symbol table, the top level classes and some other items end - up on JavaCompiler's "to do" list. -

- -

- For each entry on the "to do" list, JavaCompiler - processes it as follows: -

- -
    -
  • Some parts of the compilation involve modifying the parse tree, - so a copy of the root of the tree is kept prior to such manipulation. -

    -

    - Note: this copy is just used to check whether the class is one of those - found in a compilation unit on the command line (i.e. in rootClasses). -

    - -
  • The top level classes are "attributed", using - Attr, - meaning that names and other elements within the parse tree are resolved - and associated with the corresponding types and symbols. Many semantic - errors may be detected here, either by Attr, or by - Check. -

    -

    While attributing the tree, class files will be read as necessary. - In addition, if a class is required, and a source file for the class is found - that is newer than the class file, the source file will be automatically parsed - and put on the "to do" list. This is done by registering JavaCompiler as an - implementation of - Attr.SourceCompleter. -

    -

    - Note: there is a hidden option -attrparseonly which can be used to skip - the rest of the processing for this file. In so doing, it "breaks" the - protocol use to save and restore the source file used to report error - messages (Log.useSource). There is a "try finally" block which - could reasonably be used/extended to restore the source file correctly. -

    -
  • - -
  • If there are no errors so far, flow analysis will be done for the class, using - Flow. - Flow analysis is used to check for definite assignment to variables, - and unreachable statements, which may result in additional errors. -

    -

    Note: flow analysis can be suppressed with the hidden - option -relax. -

    -
  • - -
  • If the "to do" item is a TopLevel tree, it will be the contents of a - package-info.java file, containing annotations for a package. - (See notes for Enter.) -
      -
    • Syntactic sugar is processed, using - Lower. - Lower is defined to return a list of trees for the translated classes - and all the translated inner classes.
    • -
    • If Lower returns a non-empty list, there is an assertion that - the list has a single element, in which case, code is generated, using - Gen, - and the resulting code is written out using - ClassWriter. -
    • -
    • No further processing is done on this "to do" item.
      -
    • -
    -

    Note that Enter will have processed all other TopLevel - putting the individual classes that it finds there on the "to do" - (and not the TopLevel node itself.) -

    - -
  • If stub outputs have been requested, with the hidden -stubs option, -
      -
    • If the class was one of those mentioned on the command line and is in - java.lang, - pretty print the source with no method bodies.
    • -
    • No further processing is done on this "to do" item.
    • -
    - -
  • Code involving generic types is translated to code without generic types, using - TransTypes. -
  • - -
  • If source output has been requested, with the hidden -s option -
      -
    • If the original tree was from command line, pretty print the source code -
    • -
    • No further processing is done on this "to do" item.
    • -
    - -
  • Syntactic sugar is processed, using - Lower. - This takes care of inner classes, class literals, assertions, foreach - loops, etc. - Lower is defined to return a list of trees for the translated classes - and all the translated inner classes.
  • - -

    - Note: see also the use of Lower earlier in the loop, when processing - TopLevel trees.

    - -
  • For each class returned by Lower
    -
      -
    • If source has been requestion with the hidden -printflat - option, the source of the class is printed. -
    • Otherwise, code for the class is generated, using - Gen, - and the resulting code is written out using - ClassWriter. -
    - -
- -

Issues

- The "to do" list is mostly organized by top level classes, and not by - compilation units. This means that if a compilation unit contains several - classes, it is possible for code to be generated for some of the classes - in the file, at which point at error may be detected for one of the - remaining classes, preventing code from being generated for that and any - subsequent classes. This means that the compilation unit will be partially - compiled, with some but not all of the class files being generated. - (Bug 5011101) - - - - diff --git a/langtools/src/share/opensource/javac/doc/javac_lifecycle/contents.html b/langtools/src/share/opensource/javac/doc/javac_lifecycle/contents.html deleted file mode 100644 index c936c5561f3..00000000000 --- a/langtools/src/share/opensource/javac/doc/javac_lifecycle/contents.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - com.sun.tools.javac.comp.Enter - - - Packages
-
- Classes
- Context
- Enter
- JavaCompiler
- Main
- ToDo
- diff --git a/langtools/src/share/opensource/javac/doc/javac_lifecycle/index.html b/langtools/src/share/opensource/javac/doc/javac_lifecycle/index.html deleted file mode 100644 index fa75dca7adf..00000000000 --- a/langtools/src/share/opensource/javac/doc/javac_lifecycle/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - javac life cycle - - - - - - <body> - <p>This page uses frames, but your browser doesn't support them.</p> - </body> - - - diff --git a/langtools/src/share/opensource/javac/doc/javac_lifecycle/packages.html b/langtools/src/share/opensource/javac/doc/javac_lifecycle/packages.html deleted file mode 100644 index 33d3e7a0cf4..00000000000 --- a/langtools/src/share/opensource/javac/doc/javac_lifecycle/packages.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - Packages - - - - -

javac Packages

- -

With the exception of a publicly supported entry point at - com.sun.tools.javac.Main, - javac is organized as a set of packages under - com.sun.tools.javac. -

- - - - - - - - - - -
Sub-packageDescription -
code - Classes to represent the internal semantics of a Java program -- - types, symbols, etc. - -
comp - Classes that analyse and annotate the parse tree with semantic - details, such as determining the types and symbols referred to by identifiers. - -
jvm - Back end classes to read and write class files. - -
main - Top-level driver classes. The standard entry point to the compiler is - com.sun.tools.javac.main.Main (more...) - -
parser - Classes to read a Java source file and create a corresponding parse tree. - -
resources - Resource classes for messages generated by the compiler. Two of the - three classes are automagically generated by a "property file compiler" - from a property source file; the third is automagically generated during - the build to contain build version information. - -
tree - Classes representing an annotated syntax tree for a Java program. - The top level node, representing the contents of a source file is - Tree.TopLevel. - -
util - Utility classes used throughout the compiler, providing support for - diagnostics, access to the file system, and javac's collection classes. - - - diff --git a/langtools/src/share/opensource/javac/doc/javac_lifecycle/style.css b/langtools/src/share/opensource/javac/doc/javac_lifecycle/style.css deleted file mode 100644 index 473824b665e..00000000000 --- a/langtools/src/share/opensource/javac/doc/javac_lifecycle/style.css +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -body { color: black; background-color: #eeffee } -body.contents { background-color: #ddffdd } - -li { margin-top:10px } -p.note { font-size:smaller } - -.code { font-family:monospace } - diff --git a/langtools/src/share/opensource/javac/nbproject/project.xml b/langtools/src/share/opensource/javac/nbproject/project.xml deleted file mode 100644 index 45e3ea949a1..00000000000 --- a/langtools/src/share/opensource/javac/nbproject/project.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - org.netbeans.modules.ant.freeform - - - - openjdk-javac - - - - - java - src/share/classes - - - - - build - - - clean - - - docs - - - clean - build - - - xtest - - - - - - - src/share/classes - - - build.properties - - - build.xml - - - - - - - - - - - - - src/share/classes - 1.5 - - - - diff --git a/langtools/src/share/opensource/javac/src/bin/javac.sh b/langtools/src/share/opensource/javac/src/bin/javac.sh deleted file mode 100644 index 0c971b93308..00000000000 --- a/langtools/src/share/opensource/javac/src/bin/javac.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh - -# -# Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Sun designates this -# particular file as subject to the "Classpath" exception as provided -# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - -mydir="`dirname $0`" - -java -jar "${mydir}"/../lib/javac.jar "$@" From db98b5b071aa3dac5c92c0d77c7631a52a38c9cc Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Thu, 13 Mar 2008 16:12:15 -0700 Subject: [PATCH 29/54] 6675289: Make default production build NOT include an openjdk build SKIP_OPENJDK_BUILD now set to true. Reviewed-by: xdono --- make/Defs-internal.gmk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/make/Defs-internal.gmk b/make/Defs-internal.gmk index 7343049c61b..97c9395f068 100644 --- a/make/Defs-internal.gmk +++ b/make/Defs-internal.gmk @@ -150,7 +150,9 @@ ifdef OPENJDK SKIP_OPENJDK_BUILD = true else ifndef SKIP_OPENJDK_BUILD - SKIP_OPENJDK_BUILD = false + #SKIP_OPENJDK_BUILD = false + # Until 6675289 is resolved, or this feature is removed. + SKIP_OPENJDK_BUILD = true endif endif From 2f36d025cab284c2e4e5ed35c35756065de60aaf Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 14 Mar 2008 16:09:30 -0700 Subject: [PATCH 30/54] 6638501: Regression with Javac in JDK6 U4 b03? Replace some String paths with File paths in Paths.java Reviewed-by: ksrini --- .../com/sun/tools/javac/util/Paths.java | 22 +- .../6638501/HelloLib/test/HelloImpl.java | 32 +++ .../Paths/6638501/JarFromManifestFailure.java | 169 ++++++++++++++++ .../javac/Paths/6638501/WsCompileExample.java | 189 ++++++++++++++++++ .../javac/Paths/6638501/test/SayHello.java | 31 +++ .../Paths/6638501/test1/SayHelloToo.java | 31 +++ 6 files changed, 462 insertions(+), 12 deletions(-) create mode 100644 langtools/test/tools/javac/Paths/6638501/HelloLib/test/HelloImpl.java create mode 100644 langtools/test/tools/javac/Paths/6638501/JarFromManifestFailure.java create mode 100644 langtools/test/tools/javac/Paths/6638501/WsCompileExample.java create mode 100644 langtools/test/tools/javac/Paths/6638501/test/SayHello.java create mode 100644 langtools/test/tools/javac/Paths/6638501/test1/SayHelloToo.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/Paths.java b/langtools/src/share/classes/com/sun/tools/javac/util/Paths.java index 073ce5bd6a9..a28bfa26582 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/Paths.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/Paths.java @@ -38,13 +38,8 @@ import java.util.Collections; import java.util.LinkedHashSet; import java.util.Iterator; import java.util.StringTokenizer; -import java.util.zip.ZipException; import java.util.zip.ZipFile; import com.sun.tools.javac.code.Lint; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Log; -import com.sun.tools.javac.util.Options; -import com.sun.tools.javac.util.Position; import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.Lock; @@ -70,7 +65,10 @@ public class Paths { protected static final Context.Key pathsKey = new Context.Key(); - /** Get the Paths instance for this context. */ + /** Get the Paths instance for this context. + * @param context the context + * @return the Paths instance for this context + */ public static Paths instance(Context context) { Paths instance = context.get(pathsKey); if (instance == null) @@ -89,7 +87,7 @@ public class Paths { private static boolean NON_BATCH_MODE = System.getProperty("nonBatchMode") != null;// TODO: Use -XD compiler switch for this. private static Map pathExistanceCache = new ConcurrentHashMap(); - private static Map> manifestEntries = new ConcurrentHashMap>(); + private static Map> manifestEntries = new ConcurrentHashMap>(); private static Map isDirectory = new ConcurrentHashMap(); private static Lock lock = new ReentrantLock(); @@ -369,13 +367,13 @@ public class Paths { // filenames, but if we do, we should redo all path-related code. private void addJarClassPath(File jarFile, boolean warn) { try { - java.util.List manifestsList = manifestEntries.get(jarFile); + java.util.List manifestsList = manifestEntries.get(jarFile); if (!NON_BATCH_MODE) { lock.lock(); try { if (manifestsList != null) { - for (String entr : manifestsList) { - addFile(new File(entr), warn); + for (File entr : manifestsList) { + addFile(entr, warn); } return; } @@ -386,7 +384,7 @@ public class Paths { } if (!NON_BATCH_MODE) { - manifestsList = new ArrayList(); + manifestsList = new ArrayList(); manifestEntries.put(jarFile, manifestsList); } @@ -412,7 +410,7 @@ public class Paths { if (!NON_BATCH_MODE) { lock.lock(); try { - manifestsList.add(elt); + manifestsList.add(f); } finally { lock.unlock(); diff --git a/langtools/test/tools/javac/Paths/6638501/HelloLib/test/HelloImpl.java b/langtools/test/tools/javac/Paths/6638501/HelloLib/test/HelloImpl.java new file mode 100644 index 00000000000..7f5a934e601 --- /dev/null +++ b/langtools/test/tools/javac/Paths/6638501/HelloLib/test/HelloImpl.java @@ -0,0 +1,32 @@ +/* + * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package test; + +public class HelloImpl { + + public void Hello() { + java.lang.System.out.println("Hello"); + } + +} diff --git a/langtools/test/tools/javac/Paths/6638501/JarFromManifestFailure.java b/langtools/test/tools/javac/Paths/6638501/JarFromManifestFailure.java new file mode 100644 index 00000000000..a82cbb017ab --- /dev/null +++ b/langtools/test/tools/javac/Paths/6638501/JarFromManifestFailure.java @@ -0,0 +1,169 @@ +/* + * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6638501 + * @summary REGRESSION: Java Compiler cannot find jar files referenced by other + * @run main JarFromManifestFailure + */ + +import java.io.*; +import java.nio.*; +import java.util.*; +import java.util.jar.*; +import javax.tools.*; +import javax.tools.StandardJavaFileManager.*; + +public class JarFromManifestFailure { + static File testSrc = new File(System.getProperty("test.src", ".")); + static File testClasses = new File(System.getProperty("test.classes", ".")); + + public static void main(String... args) throws Exception { + compile(testClasses, null, new File(testSrc, "HelloLib/test/HelloImpl.java"), new File(testSrc, "WsCompileExample.java")); + File libFile = new File(testClasses, "lib"); + libFile.mkdir(); + jar(new File(libFile, "HelloLib.jar"), new ArrayList(), testClasses, new File("test")); + + ArrayList arList = new ArrayList(); + arList.add(new File("HelloLib.jar")); + jar(new File(libFile, "JarPointer.jar"), arList, testClasses); + + String[] args1 = { + "-d", ".", + "-cp", new File(libFile, "JarPointer.jar").getPath().replace('\\', '/'), + new File(testSrc, "test/SayHello.java").getPath().replace('\\', '/') + }; + System.err.println("First compile!!!"); + if (com.sun.tools.javac.Main.compile(args1) != 0) { + throw new AssertionError("Failure in first compile!"); + } + + System.err.println("Second compile!!!"); + + args1 = new String[] { + "-d", ".", + "-cp", new File(libFile, "JarPointer.jar").getPath().replace('\\', '/'), + new File(testSrc, "test1/SayHelloToo.java").getPath().replace('\\', '/') + }; + if (com.sun.tools.javac.Main.compile(args1) != 0) { + throw new AssertionError("Failure in second compile!"); + } + } + + static void compile(File classOutDir, Iterable classPath, File... files) { + System.err.println("compile..."); + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null); + Iterable fileObjects = + fm.getJavaFileObjectsFromFiles(Arrays.asList(files)); + + List options = new ArrayList(); + if (classOutDir != null) { + options.add("-d"); + options.add(classOutDir.getPath()); + } + if (classPath != null) { + options.add("-classpath"); + options.add(join(classPath, File.pathSeparator)); + } + options.add("-verbose"); + + JavaCompiler.CompilationTask task = + compiler.getTask(null, fm, null, options, null, fileObjects); + if (!task.call()) + throw new AssertionError("compilation failed"); + } + + static void jar(File jar, Iterable classPath, File base, File... files) + throws IOException { + System.err.println("jar..."); + Manifest m = new Manifest(); + if (classPath != null) { + Attributes mainAttrs = m.getMainAttributes(); + mainAttrs.put(Attributes.Name.MANIFEST_VERSION, "1.0"); + mainAttrs.put(Attributes.Name.CLASS_PATH, join(classPath, " ")); + } + OutputStream out = new BufferedOutputStream(new FileOutputStream(jar)); + JarOutputStream j = new JarOutputStream(out, m); + add(j, base, files); + j.close(); + } + + static void add(JarOutputStream j, File base, File... files) throws IOException { + if (files == null) + return; + + for (File f: files) + add(j, base, f); + } + + static void add(JarOutputStream j, File base, File file) throws IOException { + File f = new File(base, file.getPath()); + if (f.isDirectory()) { + JarEntry e = new JarEntry(new String(file.getPath() + File.separator).replace('\\', '/')); + e.setSize(file.length()); + j.putNextEntry(e); + String[] children = f.list(); + if (children != null) { + for (String c: children) { + add(j, base, new File(file, c)); + } + } + } else { + JarEntry e = new JarEntry(file.getPath().replace('\\', '/')); + e.setSize(f.length()); + j.putNextEntry(e); + j.write(read(f)); + j.closeEntry(); + } + + } + + static byte[] read(File f) throws IOException { + byte[] buf = new byte[(int) f.length()]; + BufferedInputStream in = new BufferedInputStream(new FileInputStream(f)); + int offset = 0; + while (offset < buf.length) { + int n = in.read(buf, offset, buf.length - offset); + if (n < 0) + throw new EOFException(); + offset += n; + } + return buf; + } + + static Iterable iterable(T single) { + return Collections.singleton(single); + } + + static String join(Iterable iter, String sep) { + StringBuilder p = new StringBuilder(); + for (T t: iter) { + if (p.length() > 0) + p.append(' '); + p.append(t); + } + return p.toString(); + } +} diff --git a/langtools/test/tools/javac/Paths/6638501/WsCompileExample.java b/langtools/test/tools/javac/Paths/6638501/WsCompileExample.java new file mode 100644 index 00000000000..3884af9588c --- /dev/null +++ b/langtools/test/tools/javac/Paths/6638501/WsCompileExample.java @@ -0,0 +1,189 @@ +/* + * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.util.List; +import java.util.ArrayList; +import java.io.File; +//for CompilerHelper +import java.io.OutputStream; +import java.io.PrintWriter; +import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; + + + +public class WsCompileExample { + File destDir; + File srcDir; + protected boolean compilerDebug = false; + protected boolean compilerOptimize = false; + protected String userClasspath = null; + + public static void main(String[] args) { + new WsCompileExample().do_main(args); + } + + public void do_main(String[] args) { + if(!args[0].equals("-s")) { + throw new RuntimeException("specify -s for src"); + } + + //run it once + srcDir = new File(args[1]); + if(!args[2].equals("-d")) { + throw new RuntimeException("specify -d for dest"); + } + destDir = new File(args[3]); + if(!destDir.exists()) + destDir.mkdirs(); + System.out.println("----test compile 1-----"); + compileGeneratedClasses(); + + //run it twice + srcDir = new File(args[1]+"1"); + destDir = new File(args[3]+"1"); + if(!destDir.exists()) + destDir.mkdirs(); + System.out.println("----test compile 2-----"); + compileGeneratedClasses(); + + } + protected void compileGeneratedClasses() { + List sourceFiles = new ArrayList(); + + for (File f: srcDir.listFiles()) { + if (f.getName().endsWith(".java")) { + sourceFiles.add(f.getAbsolutePath()); + } + } + + if (sourceFiles.size() > 0) { + String classDir = destDir.getAbsolutePath(); + String classpathString = createClasspathString(); + System.out.println("classpathString: " + classpathString); + + String[] args = new String[4 + (compilerDebug == true ? 1 : 0) + + (compilerOptimize == true ? 1 : 0) + + sourceFiles.size()]; + args[0] = "-d"; + args[1] = classDir; + args[2] = "-classpath"; + args[3] = classpathString; +// args[4]="-DnonBatchMode"; + int baseIndex = 4; + if (compilerDebug) { + args[baseIndex++] = "-g"; + } + if (compilerOptimize) { + args[baseIndex++] = "-O"; + } + for (int i = 0; i < sourceFiles.size(); ++i) { + args[baseIndex + i] = (String)sourceFiles.get(i); + } + + // ByteArrayOutputStream javacOutput = new ByteArrayOutputStream(); + JavaCompilerHelper compilerHelper = new JavaCompilerHelper(System.out); + boolean result = compilerHelper.compile(args); + if (!result) { + System.out.println("wscompile.compilation Failed"); + } + } + } + + protected String createClasspathString() { + if (userClasspath == null) { + userClasspath = ""; + } + String jcp = userClasspath + File.pathSeparator + System.getProperty("java.class.path"); + return jcp; + } +} +/////////////////////////////////////////////////////////////////// +class JavaCompilerHelper { + public JavaCompilerHelper(OutputStream out) { + this.out = out; + } + + public boolean compile(String[] args) { + return internalCompile(args); + } + + protected boolean internalCompile(String[] args) { + + System.out.println("Args: "); + for(String arg : args){ + System.out.print(arg+" "); + } + System.out.println(); + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + Class comSunToolsJavacMainClass = null; + try { + /* try to use the new compiler */ + comSunToolsJavacMainClass = + cl.loadClass("com.sun.tools.javac.Main"); + try { + Method compileMethod = + comSunToolsJavacMainClass.getMethod( + "compile", + compile141MethodSignature); + try { + Object result = + compileMethod.invoke( + null, + new Object[] { args, new PrintWriter(out)}); + if (!(result instanceof Integer)) { + return false; + } + return ((Integer) result).intValue() == 0; + } catch (IllegalAccessException e3) { + return false; + } catch (IllegalArgumentException e3) { + return false; + } catch (InvocationTargetException e3) { + return false; + } + } catch (NoSuchMethodException e2) { + System.out.println("ERROR: Compile failed with error:" + e2.toString() ); + } + } catch (ClassNotFoundException e) { + e.printStackTrace(); + return false; + } catch (SecurityException e) { + return false; + } + return true; + } + + protected String getGenericErrorMessage() {return "javacompiler.error"; } + protected void run() { } + protected boolean parseArguments(String[] args) {return false;} + protected OutputStream out; + + protected static final Class[] compile141MethodSignature; + static + { + compile141MethodSignature = new Class[2]; + compile141MethodSignature[0] = (new String[0]).getClass(); + compile141MethodSignature[1] = PrintWriter.class; + } +} diff --git a/langtools/test/tools/javac/Paths/6638501/test/SayHello.java b/langtools/test/tools/javac/Paths/6638501/test/SayHello.java new file mode 100644 index 00000000000..fa008b9db6d --- /dev/null +++ b/langtools/test/tools/javac/Paths/6638501/test/SayHello.java @@ -0,0 +1,31 @@ +/* + * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import test.HelloImpl; + +public class SayHello extends HelloImpl { + public static void main(String... args) { + new SayHello().Hello(); +} + +} diff --git a/langtools/test/tools/javac/Paths/6638501/test1/SayHelloToo.java b/langtools/test/tools/javac/Paths/6638501/test1/SayHelloToo.java new file mode 100644 index 00000000000..08fa024f550 --- /dev/null +++ b/langtools/test/tools/javac/Paths/6638501/test1/SayHelloToo.java @@ -0,0 +1,31 @@ +/* + * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import test.HelloImpl; + +public class SayHelloToo extends HelloImpl { + public static void main(String... args) { + new SayHelloToo().Hello(); +} + +} From 3bcb13882070a40f0e26e1014144820a205481a3 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Tue, 18 Mar 2008 11:01:40 -0700 Subject: [PATCH 31/54] 6674232: OPENJDK=false is same as OPENJDK=true If OPENJDK has a value, that value must be "true", empty value == undefined with GNU make. Reviewed-by: tbell --- make/Defs-internal.gmk | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/make/Defs-internal.gmk b/make/Defs-internal.gmk index 97c9395f068..5d5e7491b34 100644 --- a/make/Defs-internal.gmk +++ b/make/Defs-internal.gmk @@ -28,6 +28,12 @@ # not contain rules. # +ifdef OPENJDK + ifneq ($(OPENJDK),true) + x:=$(error "OPENJDK (if defined) can only be set to true") + endif +endif + # Define absolute paths to TOPDIRs ABS_CONTROL_TOPDIR:=$(call OptFullPath,"$(CONTROL_TOPDIR)") ABS_LANGTOOLS_TOPDIR:=$(call OptFullPath,"$(LANGTOOLS_TOPDIR)") @@ -96,10 +102,8 @@ ifndef BUILD_JDK endif ifeq ($(JDK_SRC_AVAILABLE),true) JDK_CLOSED_SRC_AVAILABLE := $(call MkExists,$(JDK_TOPDIR)/src/closed) - ifndef OPENJDK - ifeq ($(JDK_CLOSED_SRC_AVAILABLE),false) - OPENJDK = true - endif + ifeq ($(JDK_CLOSED_SRC_AVAILABLE),false) + OPENJDK = true endif endif From 65cbc8719faa021c1e3656f8612cfda2c9d03c5d Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Tue, 18 Mar 2008 11:03:27 -0700 Subject: [PATCH 32/54] 6674226: Warning errors in freetypecheck Just corrected some C code to remove warning errors from gcc. Reviewed-by: tbell --- jdk/make/tools/freetypecheck/freetypecheck.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jdk/make/tools/freetypecheck/freetypecheck.c b/jdk/make/tools/freetypecheck/freetypecheck.c index 00f460d7dc1..12b26f7e88b 100644 --- a/jdk/make/tools/freetypecheck/freetypecheck.c +++ b/jdk/make/tools/freetypecheck/freetypecheck.c @@ -26,13 +26,16 @@ /* Test program for freetype sanity check. Prints "Failed" messages to STDOUT if check fails. */ +#include +#include + #include "ft2build.h" #include FT_FREETYPE_H #define QUOTEMACRO(x) QUOTEME(x) #define QUOTEME(x) #x -int main(char** argv, int argc) { +int main(int argc, char** argv) { char v[50]; FT_Int major, minor, patch; FT_Library library; From 0dbfd8d9bf60b6c73df06a94315f4c2211104e50 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Tue, 18 Mar 2008 11:04:42 -0700 Subject: [PATCH 33/54] 6611788: chmod a+x bin/winver.exe in make/tools/winver/Makefile fails on a read only file system Tell Mercurial this file has execute permission. Reviewed-by: tbell --- jdk/make/tools/winver/bin/winver.exe | Bin 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 jdk/make/tools/winver/bin/winver.exe diff --git a/jdk/make/tools/winver/bin/winver.exe b/jdk/make/tools/winver/bin/winver.exe old mode 100644 new mode 100755 From 42919ee3bb762481b1824225ffc545c966031f7a Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Tue, 18 Mar 2008 11:06:34 -0700 Subject: [PATCH 34/54] 6674232: OPENJDK=false is same as OPENJDK=true OPENJDK should be empty (undefined) or "true". Reviewed-by: tbell --- jdk/make/common/Defs.gmk | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/jdk/make/common/Defs.gmk b/jdk/make/common/Defs.gmk index 6fe53ebeced..268533ba608 100644 --- a/jdk/make/common/Defs.gmk +++ b/jdk/make/common/Defs.gmk @@ -32,6 +32,13 @@ # So when it includes other files, it must use JDK_TOPDIR. # +# Check for strange explicit settings (change to empty or true) +ifdef OPENJDK + ifneq ($(OPENJDK),true) + x:=$(error "OPENJDK (if defined) can only be set to true") + endif +endif + # # On Solaris, the 'make' utility from Sun will not work with these makefiles. # This little rule is only understood by Sun's make, and is harmless @@ -87,19 +94,6 @@ ifeq ($(CLOSED_SRC_DIR_EXISTS), false) OPENJDK = true endif -# Check for strange explicit settings (change to empty or true) -ifdef OPENJDK - ifeq ($(OPENJDK),false) - # Silently treat as not defined - OPENJDK = - else - ifneq ($(OPENJDK),true) - dummy := $(warning "WARNING: OPENKJDK=$(OPENJDK) being treated as true") - OPENJDK = true - endif - endif -endif - # Define where closed directories are ifdef OPENJDK CLOSED_SRC = From e35b18e39bd50fb93dc8e9dd45aae9791d37e6c0 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Tue, 18 Mar 2008 11:08:09 -0700 Subject: [PATCH 35/54] 6654458: /java/devtools findbugs doesn't work on windows Changes to both ant and findbugs version checking. Reviewed-by: tbell --- jdk/make/common/shared/Defs-utils.gmk | 10 ---------- jdk/make/common/shared/Defs.gmk | 18 ++++++++++++++++++ jdk/make/common/shared/Sanity.gmk | 20 ++++++++++++++------ 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/jdk/make/common/shared/Defs-utils.gmk b/jdk/make/common/shared/Defs-utils.gmk index dc84d795b76..3886ee65ce4 100644 --- a/jdk/make/common/shared/Defs-utils.gmk +++ b/jdk/make/common/shared/Defs-utils.gmk @@ -67,16 +67,6 @@ ifeq ($(PLATFORM),windows) UTILS_DEVTOOL_PATH=$(DEVTOOLS_PATH) endif -# Utilities ant and findbugs -ifndef ANT_HOME - ANT_HOME = $(JDK_DEVTOOLS_DIR)/share/ant/latest -endif -ANT = $(ANT_HOME)/bin/ant -ifndef FINDBUGS_HOME - FINDBUGS_HOME = $(JDK_DEVTOOLS_DIR)/share/findbugs/latest -endif -FINDBUGS = $(FINDBUGS_HOME)/bin/findbugs - # Utilities ADB = $(UTILS_COMMAND_PATH)adb AR = $(UTILS_CCS_BIN_PATH)ar diff --git a/jdk/make/common/shared/Defs.gmk b/jdk/make/common/shared/Defs.gmk index 0eb8c729a96..6b0adfcb533 100644 --- a/jdk/make/common/shared/Defs.gmk +++ b/jdk/make/common/shared/Defs.gmk @@ -503,6 +503,24 @@ JDK_CUPS_HEADERS_PATH=$(JDK_DEVTOOLS_DIR)/share/cups/include endif endif +# Utilities ant and findbugs +ifeq ($(ANT_HOME),) + ANT_HOME := $(call DirExists,/usr/share/ant,$(JDK_DEVTOOLS_DIR)/share/ant/latest,) +endif +ifeq ($(ANT_HOME),) + ANT = ant +else + ANT = $(ANT_HOME)/bin/ant +endif +ifeq ($(FINDBUGS_HOME),) + FINDBUGS_HOME := $(call DirExists,/usr/share/findbugs,$(JDK_DEVTOOLS_DIR)/share/findbugs/latest,) +endif +ifeq ($(FINDBUGS_HOME),) + FINDBUGS = findbugs +else + FINDBUGS = $(FINDBUGS_HOME)/bin/findbugs +endif + ifdef ALT_COPYRIGHT_YEAR COPYRIGHT_YEAR = $(ALT_COPYRIGHT_YEAR) else diff --git a/jdk/make/common/shared/Sanity.gmk b/jdk/make/common/shared/Sanity.gmk index a97ddddd534..8809842608f 100644 --- a/jdk/make/common/shared/Sanity.gmk +++ b/jdk/make/common/shared/Sanity.gmk @@ -105,13 +105,21 @@ ZIP_VER :=$(call GetVersion,"$(_ZIP_VER)") UNZIP_VER :=$(call GetVersion,"$(_UNZIP_VER)") BOOT_VER :=$(call GetVersion,"$(_BOOT_VER)") -REQUIRED_ANT_VER := 1.6.3 -_ANT_VER :=$(shell $(ANT) -version 2>&1 ) -ANT_VER :=$(call GetVersion,"$(_ANT_VER)") +REQUIRED_ANT_VER := 1.6.3 +ifeq ($(ANT_HOME),) + _ANT_VER:=$(shell JAVACMD="$(BOOTDIR)/bin/java" $(ANT) -version 2>&1 ) +else + _ANT_VER:=$(shell JAVACMD="$(BOOTDIR)/bin/java" ANT_HOME="$(ANT_HOME)" $(ANT) -version 2>&1 ) +endif +ANT_VER:=$(call GetVersion,"$(_ANT_VER)") -REQUIRED_FINDBUGS_VER := 1.1 -_FINDBUGS_VER :=$(shell $(FINDBUGS) -version 2>&1 ) -FINDBUGS_VER :=$(call GetVersion,"$(_FINDBUGS_VER)") +REQUIRED_FINDBUGS_VER := 1.2 +ifeq ($(FINDBUGS_HOME),) + _FINDBUGS_VER:=$(shell $(FINDBUGS) -javahome "$(BOOTDIR)" -textui -version 2>&1 ) +else + _FINDBUGS_VER:=$(shell FINDBUGS_HOME="$(FINDBUGS_HOME)" $(FINDBUGS) -javahome "$(BOOTDIR)" -textui -version 2>&1 ) +endif +FINDBUGS_VER:=$(call GetVersion,"$(_FINDBUGS_VER)") ifdef ALT_BINDIR ALT_BINDIR_VERSION := $(shell $(ALT_BINDIR)/java$(EXE_SUFFIX) -version 2>&1 | $(NAWK) -F'"' '{ print $$2 }') From cd2e0b7e918927050a4f416e8637b36ef62669bc Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Wed, 19 Mar 2008 13:26:29 -0700 Subject: [PATCH 36/54] 6611629: Avoid hardcoded cygwin paths for memory detection Use free with sygwin, mem or systeminfo otherwise, to get MB_OF_MEMORY on windows. Reviewed-by: tbell --- jdk/make/common/shared/Platform.gmk | 101 +++++++++++++++++----------- 1 file changed, 61 insertions(+), 40 deletions(-) diff --git a/jdk/make/common/shared/Platform.gmk b/jdk/make/common/shared/Platform.gmk index 648dcbeb7d6..32cb08e3473 100644 --- a/jdk/make/common/shared/Platform.gmk +++ b/jdk/make/common/shared/Platform.gmk @@ -270,7 +270,7 @@ ifeq ($(SYSTEM_UNAME), Linux) REQUIRED_ALSA_VERSION = ^((0[.]9[.][1-9])|(1[.]0[.][0-9]))[0-9]* endif # How much RAM does this machine have: - MB_OF_MEMORY := $(shell free -m | fgrep Mem: | sed -e 's@\ \ *@ @g' | cut -d' ' -f2) + MB_OF_MEMORY := $(shell free -m | fgrep Mem: | awk '{print $$2;}' ) endif # Windows with and without CYGWIN will be slightly different @@ -374,45 +374,35 @@ ifeq ($(PLATFORM), windows) REQUIRED_DXSDK_VER = 0x0700 OS_VENDOR = Microsoft # How much RAM does this machine have: - MB_OF_MEMORY := $(shell \ - if [ -f "C:/cygwin/bin/free.exe" ] ; then \ - ( C:/cygwin/bin/bash.exe -c "C:/cygwin/bin/free.exe -m" ) | \ - grep Mem: | \ - sed -e 's@\ \ *@ @g' | cut -d' ' -f2 ; \ - else \ - echo "512"; \ - fi) -endif - -# Machines with 512Mb or less of real memory are considered low memory -# build machines and adjustments will be made to prevent excessing -# system swapping during the build. -# If we don't know, assume 512. Subtract 128 from MB for VM MAX. -# Don't set VM max over 1024-128=896. -ifneq ($(MB_OF_MEMORY),) - LOW_MEMORY_MACHINE := $(shell \ - if [ $(MB_OF_MEMORY) -le 512 ] ; then \ - echo "true"; \ - else \ - echo "false"; \ - fi) - MAX_VM_MEMORY := $(shell \ - if [ $(MB_OF_MEMORY) -le 1024 ] ; then \ - expr $(MB_OF_MEMORY) '-' 128 ; \ - else \ - echo "896"; \ - fi) - MIN_VM_MEMORY := $(shell \ - if [ $(MAX_VM_MEMORY) -le 128 ] ; then \ - expr $(MAX_VM_MEMORY) '-' 8 ; \ - else \ - echo "128"; \ - fi) -else - MB_OF_MEMORY := unknown - LOW_MEMORY_MACHINE := true - MAX_VM_MEMORY := 384 - MIN_VM_MEMORY := 128 + ifeq ($(USING_CYGWIN),true) + # CYGWIN has the 'free' utility + _MB_OF_MEMORY := \ + $(shell free -m | grep Mem: | awk '{print $$2;}' ) + else + # Windows 2000 has the mem utility, but two memory areas + # extended memory is what is beyond 1024M + _B_OF_EXT_MEMORY := \ + $(shell mem 2> $(DEV_NULL) | grep 'total contiguous extended memory' | awk '{print $$1;}') + ifeq ($(_B_OF_EXT_MEMORY),) + _B_OF_MEMORY := \ + $(shell mem 2> $(DEV_NULL) | grep 'total conventional memory' | awk '{print $$1;}') + else + _B_OF_MEMORY := \ + $(shell expr 1048576 '+' $(_B_OF_EXT_MEMORY) 2> $(DEV_NULL)) + endif + ifeq ($(_B_OF_MEMORY),) + # Windows 2003 has the systeminfo utility use it if mem doesn't work + _MB_OF_MEMORY := \ + $(shell systeminfo 2> $(DEV_NULL) | grep 'Total Physical Memory:' | awk '{print $$4;}' | sed -e 's@,@@') + else + _MB_OF_MEMORY := $(shell expr $(_B_OF_MEMORY) '/' 1024 2> $(DEV_NULL)) + endif + endif + ifeq ($(shell expr $(_MB_OF_MEMORY) '+' 0 2> $(DEV_NULL)), $(_MB_OF_MEMORY)) + MB_OF_MEMORY := $(_MB_OF_MEMORY) + else + MB_OF_MEMORY := 512 + endif endif REQUIRED_ZIP_VER = 2.2 @@ -452,6 +442,37 @@ ifneq ($(PLATFORM), windows) ARCH_VM_SUBDIR=jre/lib/$(LIBARCH) endif +# Machines with 512Mb or less of real memory are considered low memory +# build machines and adjustments will be made to prevent excessing +# system swapping during the build. +# If we don't know, assume 512. Subtract 128 from MB for VM MAX. +# Don't set VM max over 1024-128=896. +ifneq ($(MB_OF_MEMORY),) + LOW_MEMORY_MACHINE := $(shell \ + if [ $(MB_OF_MEMORY) -le 512 ] ; then \ + echo "true"; \ + else \ + echo "false"; \ + fi) + MAX_VM_MEMORY := $(shell \ + if [ $(MB_OF_MEMORY) -le 1024 ] ; then \ + expr $(MB_OF_MEMORY) '-' 128 2> $(DEV_NULL) ; \ + else \ + echo "896"; \ + fi) + MIN_VM_MEMORY := $(shell \ + if [ $(MAX_VM_MEMORY) -le 128 ] ; then \ + expr $(MAX_VM_MEMORY) '-' 8 2> $(DEV_NULL) ; \ + else \ + echo "128"; \ + fi) +else + MB_OF_MEMORY := unknown + LOW_MEMORY_MACHINE := true + MAX_VM_MEMORY := 384 + MIN_VM_MEMORY := 128 +endif + # If blanks in the username, use the first 4 words and pack them together _USER1:=$(subst ', ,$(_USER)) _USER2:=$(subst ", ,$(_USER1)) From fb56a9a49f38cc6d4329e5ed575738e666126e10 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Tue, 25 Mar 2008 14:38:56 -0700 Subject: [PATCH 37/54] 6623832: Cleanup old j2se makefile targets Just removing unneeded makefile rules and 'control' logic. Reviewed-by: xdono --- Makefile | 23 +++-------------------- make/jdk-rules.gmk | 8 -------- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 43b36254335..d5b3ebac73a 100644 --- a/Makefile +++ b/Makefile @@ -26,30 +26,17 @@ BUILD_PARENT_DIRECTORY=. ifndef TOPDIR - TOPDIR:=$(shell \ - if [ -r ./j2se/make/Makefile -o -r ./jdk/make/Makefile ]; then \ - echo "."; \ - else \ - echo "../.."; \ - fi) + TOPDIR:=. endif ifndef CONTROL_TOPDIR - CONTROL_TOPDIR=$(TOPDIR)/control - CONTROL_TOPDIR:=$(shell \ - if [ -r $(TOPDIR)/control/make/Makefile ]; then \ - echo "$(TOPDIR)/control"; \ - else \ - echo "$(TOPDIR)"; \ - fi) + CONTROL_TOPDIR=$(TOPDIR) endif # Openjdk sources (only used if SKIP_OPENJDK_BUILD!=true) OPENJDK_SOURCETREE=$(TOPDIR)/openjdk OPENJDK_BUILDDIR:=$(shell \ - if [ -r $(OPENJDK_SOURCETREE)/control/make/Makefile ]; then \ - echo "$(OPENJDK_SOURCETREE)/control/make"; \ - elif [ -r $(OPENJDK_SOURCETREE)/Makefile ]; then \ + if [ -r $(OPENJDK_SOURCETREE)/Makefile ]; then \ echo "$(OPENJDK_SOURCETREE)"; \ else \ echo "."; \ @@ -497,10 +484,6 @@ include ./make/jprt.gmk fastdebug_build debug_build product_build setup \ dev dev-build dev-sanity dev-clobber -# FIXUP: Old j2se targets -j2se_fastdebug_only: jdk_fastdebug_only -j2se_only: jdk_only - # Force target FRC: diff --git a/make/jdk-rules.gmk b/make/jdk-rules.gmk index da97562b591..f5e4533cd07 100644 --- a/make/jdk-rules.gmk +++ b/make/jdk-rules.gmk @@ -121,11 +121,3 @@ compare-image-clobber: .PHONY: jdk jdk-build jdk-clobber jdk-sanity -# FIXUP: Old j2se target names -j2se-build: jdk-build -j2se-clobber:: jdk-clobber -j2se-sanity:: jdk-sanity -j2se: jdk - -.PHONY: j2se j2se-build j2se-clobber j2se-sanity - From ba11a6a5e623ef18cad3aa17003f58f2aeea1010 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Tue, 25 Mar 2008 14:40:43 -0700 Subject: [PATCH 38/54] 6627817: Remove ^M characters in all files (Makefiles too) Some files included the use of the ^M character, which has been deleted. Reviewed-by: xdono --- jdk/make/common/shared/Sanity.gmk | 50 +- jdk/make/docs/CORE_PKGS.gmk | 18 +- .../indicim/resources/DisplayNames.properties | 11 +- .../thaiim/resources/DisplayNames.properties | 11 +- .../xml/internal/security/resource/config.dtd | 146 ++-- .../xml/internal/security/resource/config.xml | 760 +++++++++--------- .../security/resource/schema/etsi.xsd | 694 ++++++++-------- .../resource/xmlsecurity_en.properties | 246 +++--- .../swing/plaf/synth/doc-files/synth.dtd | 2 +- .../javax/swing/plaf/synth/package.html | 300 +++---- .../jfc/Notepad/resources/Notepad.properties | 152 ++-- jdk/src/share/sample/vm/clr-jvm/Makefile | 26 +- jdk/src/share/sample/vm/clr-jvm/README.txt | 108 +-- jdk/src/share/sample/vm/clr-jvm/invoker.cs | 58 +- jdk/src/share/sample/vm/jvm-clr/README.txt | 14 +- jdk/src/share/sample/vm/jvm-clr/invoked.cs | 12 +- 16 files changed, 1305 insertions(+), 1303 deletions(-) diff --git a/jdk/make/common/shared/Sanity.gmk b/jdk/make/common/shared/Sanity.gmk index 8809842608f..9f6bd2a55ab 100644 --- a/jdk/make/common/shared/Sanity.gmk +++ b/jdk/make/common/shared/Sanity.gmk @@ -1572,31 +1572,31 @@ ifeq ($(ARCH_DATA_MODEL), 32) endif -###################################################### -# SECURITY_BASELINE_142 test -###################################################### -security_baseline_142: -ifeq ($(PLATFORM), windows) - @if [ -z "$(SECURITY_BASELINE_142)" ]; then \ - $(ECHO) "WARNING: Your SECURITY_BASELINE_142 setting is empty.\n" \ - " Setting it to the default value of 1.4.2_10.\n" \ - " It is recommended to set SECURITY_BASELINE_142.\n" \ - "" >> $(WARNING_FILE) ; \ - fi -endif - -###################################################### -# SECURITY_BASELINE_150 test -###################################################### -security_baseline_150: -ifeq ($(PLATFORM), windows) - @if [ -z "$(SECURITY_BASELINE_150)" ]; then \ - $(ECHO) "WARNING: Your SECURITY_BASELINE_150 setting is empty.\n" \ - " Setting it to the default value of 1.5.0_07.\n" \ - " It is recommended to set SECURITY_BASELINE_150.\n" \ - "" >> $(WARNING_FILE) ; \ - fi -endif +###################################################### +# SECURITY_BASELINE_142 test +###################################################### +security_baseline_142: +ifeq ($(PLATFORM), windows) + @if [ -z "$(SECURITY_BASELINE_142)" ]; then \ + $(ECHO) "WARNING: Your SECURITY_BASELINE_142 setting is empty.\n" \ + " Setting it to the default value of 1.4.2_10.\n" \ + " It is recommended to set SECURITY_BASELINE_142.\n" \ + "" >> $(WARNING_FILE) ; \ + fi +endif + +###################################################### +# SECURITY_BASELINE_150 test +###################################################### +security_baseline_150: +ifeq ($(PLATFORM), windows) + @if [ -z "$(SECURITY_BASELINE_150)" ]; then \ + $(ECHO) "WARNING: Your SECURITY_BASELINE_150 setting is empty.\n" \ + " Setting it to the default value of 1.5.0_07.\n" \ + " It is recommended to set SECURITY_BASELINE_150.\n" \ + "" >> $(WARNING_FILE) ; \ + fi +endif ###################################################### diff --git a/jdk/make/docs/CORE_PKGS.gmk b/jdk/make/docs/CORE_PKGS.gmk index dce55eea756..03d95a606aa 100644 --- a/jdk/make/docs/CORE_PKGS.gmk +++ b/jdk/make/docs/CORE_PKGS.gmk @@ -49,8 +49,8 @@ EXCLUDE_PKGS = \ # ACTIVE_JSR_PKGS are packages that are part of an active JSR process-- # one that is doing its own review. These packages are not included when # creating diff pages for the platform's JCP process. -# -# (see /java/pubs/apisrc/jdk/6.0/beta/make/docs/active_jsr_pkgs) +# +# (see /java/pubs/apisrc/jdk/6.0/beta/make/docs/active_jsr_pkgs) # Note: # This is a list of regular expressions. So foo.* matches "foo" and "foo.bar". # @@ -72,13 +72,13 @@ ACTIVE_JSR_PKGS= \ # CORE_PKGS is the list of packages that form the # Java API Specification. # -### ***IMPORTANT NOTE*** -### There is also a "REGEXP" variable in the docs/makefile that -### determines which table the packages go in on the main page. -### Currently, there is only table ("Platform Packages") and -### everything goes in it, so REGEXP is "*". But if that policy -### changes, packages added will need to be reflected in that -### list of wildcard expressions, as well. +### ***IMPORTANT NOTE*** +### There is also a "REGEXP" variable in the docs/makefile that +### determines which table the packages go in on the main page. +### Currently, there is only table ("Platform Packages") and +### everything goes in it, so REGEXP is "*". But if that policy +### changes, packages added will need to be reflected in that +### list of wildcard expressions, as well. ### CORE_PKGS = \ java.applet \ diff --git a/jdk/src/share/classes/com/sun/inputmethods/internal/indicim/resources/DisplayNames.properties b/jdk/src/share/classes/com/sun/inputmethods/internal/indicim/resources/DisplayNames.properties index e592c36caba..f0feb6395c0 100644 --- a/jdk/src/share/classes/com/sun/inputmethods/internal/indicim/resources/DisplayNames.properties +++ b/jdk/src/share/classes/com/sun/inputmethods/internal/indicim/resources/DisplayNames.properties @@ -1,5 +1,6 @@ -# -# Default Input method display names for Indic input methods -# - -DisplayName.Devanagari = Devanagari Input Method +# +# Default Input method display names for Indic input methods +# + +DisplayName.Devanagari = Devanagari Input Method + diff --git a/jdk/src/share/classes/com/sun/inputmethods/internal/thaiim/resources/DisplayNames.properties b/jdk/src/share/classes/com/sun/inputmethods/internal/thaiim/resources/DisplayNames.properties index f88a4bf2dca..e4528a49a53 100644 --- a/jdk/src/share/classes/com/sun/inputmethods/internal/thaiim/resources/DisplayNames.properties +++ b/jdk/src/share/classes/com/sun/inputmethods/internal/thaiim/resources/DisplayNames.properties @@ -1,5 +1,6 @@ -# -# Default Input method display names for Thai input methods -# - -DisplayName.Thai = Thai Input Method +# +# Default Input method display names for Thai input methods +# + +DisplayName.Thai = Thai Input Method + diff --git a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/config.dtd b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/config.dtd index f57b9fabe4d..1e886bf1776 100644 --- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/config.dtd +++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/config.dtd @@ -1,73 +1,73 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/config.xml b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/config.xml index e6881361512..d0d6edcee69 100644 --- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/config.xml +++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/config.xml @@ -1,380 +1,380 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/etsi.xsd b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/etsi.xsd index d69852ff842..3a08c64f4b6 100644 --- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/etsi.xsd +++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/etsi.xsd @@ -1,347 +1,347 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_en.properties b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_en.properties index 1b8e97bfd63..8c8b2ab1f8d 100644 --- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_en.properties +++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_en.properties @@ -1,123 +1,123 @@ -algorithm.alreadyRegistered = URI {0} already assigned to class {1} -algorithm.classDoesNotExist = Cannot register URI {0} to class {1} because this class does not exist in CLASSPATH -algorithm.ClassDoesNotExist = Class {0} does not exist -algorithm.extendsWrongClass = Cannot register URI {0} to class {1} because it does not extend {2} -algorithms.CannotUseAlgorithmParameterSpecOnDSA = Sorry, but you cannot use a AlgorithmParameterSpec object for creating DSA signatures. -algorithms.CannotUseAlgorithmParameterSpecOnRSA = Sorry, but you cannot use a AlgorithmParameterSpec object for creating RSA signatures. -algorithms.CannotUseSecureRandomOnMAC = Sorry, but you cannot use a SecureRandom object for creating MACs. -algorithms.HMACOutputLengthOnlyForHMAC = A HMACOutputLength can only be specified for HMAC integrity algorithms -algorithms.NoSuchAlgorithm = The requested algorithm {0} does not exist. Original Message was: {1} -algorithms.NoSuchMap = The algorithm URI "{0}" could not be mapped to a JCE algorithm -algorithms.NoSuchProvider = The specified Provider {0} does not exist. Original Message was: {1} -algorithms.operationOnlyVerification = A public key can only used for verification of a signature. -algorithms.WrongKeyForThisOperation = Sorry, you supplied the wrong key type for this operation! You supplied a {0} but a {1} is needed. -attributeValueIllegal = The attribute {0} has value {1} but must be {2} -c14n.Canonicalizer.Exception = Exception during Canonicalization: Original Message was {0} -c14n.Canonicalizer.IllegalNode = Illegal node type {0}, node name was {1} -c14n.Canonicalizer.NoSuchCanonicalizer = No canonicalizer found with URI {0} -c14n.Canonicalizer.ParserConfigurationException = ParserConfigurationException during Canonicalization: Original Message was {0} -c14n.Canonicalizer.RelativeNamespace = Element {0} has a relative namespace: {1}="{2}" -c14n.Canonicalizer.SAXException = SAXException during Canonicalization: Original Message was {0} -c14n.Canonicalizer.TraversalNotSupported = This DOM document does not support Traversal {0} -c14n.Canonicalizer.UnsupportedEncoding = Unsupported encoding {0} -c14n.Canonicalizer.UnsupportedOperation = This canonicalizer does not support this operation -c14n.XMLUtils.circumventBug2650forgotten = The tree has not been prepared for canonicalization using XMLUtils#circumventBug2650(Document) -certificate.noSki.lowVersion = Certificate cannot contain a SubjectKeyIdentifier because it is only X509v{0} -certificate.noSki.notOctetString = Certificates SubjectKeyIdentifier is not a OctetString -certificate.noSki.null = Certificate does not contain a SubjectKeyIdentifier -defaultNamespaceCannotBeSetHere = Default namespace cannot be set here -ElementProxy.nullElement = Cannot create an ElementProxy from a null argument -empty = {0} -encryption.algorithmCannotBeUsedForEncryptedData = encryption.algorithmCannotBeUsedForEncryptedData {0} -encryption.algorithmCannotEatInitParams = encryption.algorithmCannotEatInitParams -encryption.algorithmCannotEncryptDecrypt = encryption.algorithmCannotEncryptDecrypt -encryption.algorithmCannotWrapUnWrap = encryption.algorithmCannotWrapUnWrap -encryption.ExplicitKeySizeMismatch = The xenc:KeySize element requests a key size of {0} bit but the algorithm implements {1} bit -encryption.nonceLongerThanDecryptedPlaintext = The given nonce is longer than the available plaintext. I Cannot strip away this. -encryption.RSAOAEP.dataHashWrong = data hash wrong -encryption.RSAOAEP.dataStartWrong = data wrong start {0} -encryption.RSAOAEP.dataTooShort = data too short -encryption.RSAPKCS15.blockTruncated = block truncated -encryption.RSAPKCS15.noDataInBlock = no data in block -encryption.RSAPKCS15.unknownBlockType = unknown block type -encryption.nokey = No Key Encryption Key loaded and cannot determine using key resolvers -endorsed.jdk1.4.0 = Since it seems that nobody reads our installation notes, we must do it in the exception messages. Hope you read them. You did NOT use the endorsed mechanism from JDK 1.4 properly; look at how to solve this problem. -errorMessages.InvalidDigestValueException = INVALID signature -- check reference resolution. -errorMessages.InvalidSignatureValueException = INVALID signature -- core validation failed. -errorMessages.IOException = Other file I/O and similar exceptions. -errorMessages.MissingKeyFailureException = Cannot verify because of missing public key. Provide it via addResource and try again. -errorMessages.MissingResourceFailureException = Cannot verify because of unresolved references. Provide it via addResource and try again. -errorMessages.NoSuchAlgorithmException = Unknown Algorithm {0} -errorMessages.NotYetImplementedException = Functionality not yet there. -errorMessages.XMLSignatureException = Verification failed for some other reason. -decoding.divisible.four = It should be divisible by four -decoding.general = Error while decoding -FileKeyStorageImpl.addToDefaultFromRemoteNotImplemented = Method addToDefaultFromRemote() not yet implemented. -FileKeyStorageImpl.NoCert.Context = Not found such a X509Certificate including context {0} -FileKeyStorageImpl.NoCert.IssNameSerNo = Not found such a X509Certificate with IssuerName {0} and serial number {1} -FileKeyStorageImpl.NoCert.SubjName = Not found such a X509Certificate including SubjectName {0} -generic.dontHaveConstructionElement = I do not have a construction Element -generic.EmptyMessage = {0} -generic.NotYetImplemented = {0} Not YET implemented ;-(( -java.security.InvalidKeyException = Invalid key -java.security.NoSuchProviderException = Unknown or unsupported provider -java.security.UnknownKeyType = Unknown or unsupported key type {0} -KeyInfo.needKeyResolver = More than one keyResovler have to be registered -KeyInfo.nokey = Cannot get key from {0} -KeyInfo.noKey = Cannot get the public key -KeyInfo.wrongNumberOfObject = Need {0} keyObjects -KeyInfo.wrongUse = This object was made for getting {0} -keyResolver.alreadyRegistered = {1} class has already been registered for {0} -KeyResolver.needStorageResolver = Need a StorageResolver to retrieve a Certificate from a {0} -KeyResoverSpiImpl.cannotGetCert = Cannot get the Certificate that include or in {1} in implement class {0} -KeyResoverSpiImpl.elementGeneration = Cannot make {1} element in implement class {0} -KeyResoverSpiImpl.getPoublicKey = Cannot get the public key from implement class {0} -KeyResoverSpiImpl.InvalidElement = Cannot set (2) Element in implement class {0} -KeyResoverSpiImpl.keyStore = KeyStorage error in implement class {0} -KeyResoverSpiImpl.need.Element = {1} type of Element is needed in implement class {0} -KeyResoverSpiImpl.wrongCRLElement = Cannot make CRL from {1} in implement class {0} -KeyResoverSpiImpl.wrongKeyObject = Need {1} type of KeyObject for generation Element in implement class{0} -KeyResoverSpiImpl.wrongNumberOfObject = Need {1} keyObject in implement class {0} -KeyStore.alreadyRegistered = {0} Class has already been registered for {1} -KeyStore.register = {1} type class register error in class {0} -KeyStore.registerStore.register = Registeration error for type {0} -KeyValue.IllegalArgument = Cannot create a {0} from {1} -namespacePrefixAlreadyUsedByOtherURI = Namespace prefix {0} already used by other URI {1} -notYetInitialized = The module {0} is not yet initialized -prefix.AlreadyAssigned = You want to assign {0} as prefix for namespace {1} but it is already assigned for {2} -signature.Canonicalizer.UnknownCanonicalizer = Unknown canonicalizer. No handler installed for URI {0} -signature.DSA.invalidFormat = Invalid ASN.1 encoding of the DSA signature -signature.Generation.signBeforeGetValue = You have to XMLSignature.sign(java.security.PrivateKey) first -signature.signaturePropertyHasNoTarget = The Target attribute of the SignatureProperty must be set -signature.Transform.ErrorDuringTransform = A {1} was thrown during the {0} transform -signature.Transform.NotYetImplemented = Transform {0} not yet implemented -signature.Transform.NullPointerTransform = Null pointer as URI. Programming bug? -signature.Transform.UnknownTransform = Unknown transformation. No handler installed for URI {0} -signature.Transform.node = Current Node: {0} -signature.Transform.nodeAndType = Current Node: {0}, type: {1} -signature.Util.BignumNonPositive = bigInteger.signum() must be positive -signature.Util.NonTextNode = Not a text node -signature.Util.TooManyChilds = Too many childs of Type {0} in {1} -signature.Verification.certificateError = Certificate error -signature.Verification.IndexOutOfBounds = Index {0} illegal. We only have {1} References -signature.Verification.internalError = Internal error -signature.Verification.InvalidDigestOrReference = Invalid digest of reference {0} -signature.Verification.keyStore = KeyStore error -signature.Verification.MissingID = Cannot resolve element with ID {0} -signature.Verification.MissingResources = Cannot resolve external resource {0} -signature.Verification.NoSignatureElement = Input document contains no {0} Element in namespace {1} -signature.Verification.Reference.NoInput = The Reference for URI {0} has no XMLSignatureInput -signature.Verification.SignatureError = Signature error -signature.XMLSignatureInput.MissingConstuctor = Cannot construct a XMLSignatureInput from class {0} -signature.XMLSignatureInput.SerializeDOM = Input initialized with DOM Element. Use Canonicalization to serialize it -signature.XMLSignatureInput.nodesetReference = Unable to convert to nodeset the reference -transform.Init.IllegalContextArgument = Invalid context argument of class {0}. Must be String, org.w3c.dom.NodeList or java.io.InputStream. -transform.init.NotInitialized = -transform.init.wrongURI = Initialized with wrong URI. How could this happen? We implement {0} but {1} was used during initialization -utils.Base64.IllegalBitlength = Illegal byte length; Data to be decoded must be a multiple of 4 -Base64Decoding = Error while decoding -utils.resolver.noClass = Could not find a resolver for URI {0} and Base {1} -xml.WrongContent = Cannot find {0} in {1} -xml.WrongElement = Cannot create a {0} from a {1} element -xpath.funcHere.documentsDiffer = The XPath is not in the same document as the context node -xpath.funcHere.noXPathContext = Try to evaluate an XPath which uses the here() function but XPath is not inside an ds:XPath Element. XPath was : {0} +algorithm.alreadyRegistered = URI {0} already assigned to class {1} +algorithm.classDoesNotExist = Cannot register URI {0} to class {1} because this class does not exist in CLASSPATH +algorithm.ClassDoesNotExist = Class {0} does not exist +algorithm.extendsWrongClass = Cannot register URI {0} to class {1} because it does not extend {2} +algorithms.CannotUseAlgorithmParameterSpecOnDSA = Sorry, but you cannot use a AlgorithmParameterSpec object for creating DSA signatures. +algorithms.CannotUseAlgorithmParameterSpecOnRSA = Sorry, but you cannot use a AlgorithmParameterSpec object for creating RSA signatures. +algorithms.CannotUseSecureRandomOnMAC = Sorry, but you cannot use a SecureRandom object for creating MACs. +algorithms.HMACOutputLengthOnlyForHMAC = A HMACOutputLength can only be specified for HMAC integrity algorithms +algorithms.NoSuchAlgorithm = The requested algorithm {0} does not exist. Original Message was: {1} +algorithms.NoSuchMap = The algorithm URI "{0}" could not be mapped to a JCE algorithm +algorithms.NoSuchProvider = The specified Provider {0} does not exist. Original Message was: {1} +algorithms.operationOnlyVerification = A public key can only used for verification of a signature. +algorithms.WrongKeyForThisOperation = Sorry, you supplied the wrong key type for this operation! You supplied a {0} but a {1} is needed. +attributeValueIllegal = The attribute {0} has value {1} but must be {2} +c14n.Canonicalizer.Exception = Exception during Canonicalization: Original Message was {0} +c14n.Canonicalizer.IllegalNode = Illegal node type {0}, node name was {1} +c14n.Canonicalizer.NoSuchCanonicalizer = No canonicalizer found with URI {0} +c14n.Canonicalizer.ParserConfigurationException = ParserConfigurationException during Canonicalization: Original Message was {0} +c14n.Canonicalizer.RelativeNamespace = Element {0} has a relative namespace: {1}="{2}" +c14n.Canonicalizer.SAXException = SAXException during Canonicalization: Original Message was {0} +c14n.Canonicalizer.TraversalNotSupported = This DOM document does not support Traversal {0} +c14n.Canonicalizer.UnsupportedEncoding = Unsupported encoding {0} +c14n.Canonicalizer.UnsupportedOperation = This canonicalizer does not support this operation +c14n.XMLUtils.circumventBug2650forgotten = The tree has not been prepared for canonicalization using XMLUtils#circumventBug2650(Document) +certificate.noSki.lowVersion = Certificate cannot contain a SubjectKeyIdentifier because it is only X509v{0} +certificate.noSki.notOctetString = Certificates SubjectKeyIdentifier is not a OctetString +certificate.noSki.null = Certificate does not contain a SubjectKeyIdentifier +defaultNamespaceCannotBeSetHere = Default namespace cannot be set here +ElementProxy.nullElement = Cannot create an ElementProxy from a null argument +empty = {0} +encryption.algorithmCannotBeUsedForEncryptedData = encryption.algorithmCannotBeUsedForEncryptedData {0} +encryption.algorithmCannotEatInitParams = encryption.algorithmCannotEatInitParams +encryption.algorithmCannotEncryptDecrypt = encryption.algorithmCannotEncryptDecrypt +encryption.algorithmCannotWrapUnWrap = encryption.algorithmCannotWrapUnWrap +encryption.ExplicitKeySizeMismatch = The xenc:KeySize element requests a key size of {0} bit but the algorithm implements {1} bit +encryption.nonceLongerThanDecryptedPlaintext = The given nonce is longer than the available plaintext. I Cannot strip away this. +encryption.RSAOAEP.dataHashWrong = data hash wrong +encryption.RSAOAEP.dataStartWrong = data wrong start {0} +encryption.RSAOAEP.dataTooShort = data too short +encryption.RSAPKCS15.blockTruncated = block truncated +encryption.RSAPKCS15.noDataInBlock = no data in block +encryption.RSAPKCS15.unknownBlockType = unknown block type +encryption.nokey = No Key Encryption Key loaded and cannot determine using key resolvers +endorsed.jdk1.4.0 = Since it seems that nobody reads our installation notes, we must do it in the exception messages. Hope you read them. You did NOT use the endorsed mechanism from JDK 1.4 properly; look at how to solve this problem. +errorMessages.InvalidDigestValueException = INVALID signature -- check reference resolution. +errorMessages.InvalidSignatureValueException = INVALID signature -- core validation failed. +errorMessages.IOException = Other file I/O and similar exceptions. +errorMessages.MissingKeyFailureException = Cannot verify because of missing public key. Provide it via addResource and try again. +errorMessages.MissingResourceFailureException = Cannot verify because of unresolved references. Provide it via addResource and try again. +errorMessages.NoSuchAlgorithmException = Unknown Algorithm {0} +errorMessages.NotYetImplementedException = Functionality not yet there. +errorMessages.XMLSignatureException = Verification failed for some other reason. +decoding.divisible.four = It should be divisible by four +decoding.general = Error while decoding +FileKeyStorageImpl.addToDefaultFromRemoteNotImplemented = Method addToDefaultFromRemote() not yet implemented. +FileKeyStorageImpl.NoCert.Context = Not found such a X509Certificate including context {0} +FileKeyStorageImpl.NoCert.IssNameSerNo = Not found such a X509Certificate with IssuerName {0} and serial number {1} +FileKeyStorageImpl.NoCert.SubjName = Not found such a X509Certificate including SubjectName {0} +generic.dontHaveConstructionElement = I do not have a construction Element +generic.EmptyMessage = {0} +generic.NotYetImplemented = {0} Not YET implemented ;-(( +java.security.InvalidKeyException = Invalid key +java.security.NoSuchProviderException = Unknown or unsupported provider +java.security.UnknownKeyType = Unknown or unsupported key type {0} +KeyInfo.needKeyResolver = More than one keyResovler have to be registered +KeyInfo.nokey = Cannot get key from {0} +KeyInfo.noKey = Cannot get the public key +KeyInfo.wrongNumberOfObject = Need {0} keyObjects +KeyInfo.wrongUse = This object was made for getting {0} +keyResolver.alreadyRegistered = {1} class has already been registered for {0} +KeyResolver.needStorageResolver = Need a StorageResolver to retrieve a Certificate from a {0} +KeyResoverSpiImpl.cannotGetCert = Cannot get the Certificate that include or in {1} in implement class {0} +KeyResoverSpiImpl.elementGeneration = Cannot make {1} element in implement class {0} +KeyResoverSpiImpl.getPoublicKey = Cannot get the public key from implement class {0} +KeyResoverSpiImpl.InvalidElement = Cannot set (2) Element in implement class {0} +KeyResoverSpiImpl.keyStore = KeyStorage error in implement class {0} +KeyResoverSpiImpl.need.Element = {1} type of Element is needed in implement class {0} +KeyResoverSpiImpl.wrongCRLElement = Cannot make CRL from {1} in implement class {0} +KeyResoverSpiImpl.wrongKeyObject = Need {1} type of KeyObject for generation Element in implement class{0} +KeyResoverSpiImpl.wrongNumberOfObject = Need {1} keyObject in implement class {0} +KeyStore.alreadyRegistered = {0} Class has already been registered for {1} +KeyStore.register = {1} type class register error in class {0} +KeyStore.registerStore.register = Registeration error for type {0} +KeyValue.IllegalArgument = Cannot create a {0} from {1} +namespacePrefixAlreadyUsedByOtherURI = Namespace prefix {0} already used by other URI {1} +notYetInitialized = The module {0} is not yet initialized +prefix.AlreadyAssigned = You want to assign {0} as prefix for namespace {1} but it is already assigned for {2} +signature.Canonicalizer.UnknownCanonicalizer = Unknown canonicalizer. No handler installed for URI {0} +signature.DSA.invalidFormat = Invalid ASN.1 encoding of the DSA signature +signature.Generation.signBeforeGetValue = You have to XMLSignature.sign(java.security.PrivateKey) first +signature.signaturePropertyHasNoTarget = The Target attribute of the SignatureProperty must be set +signature.Transform.ErrorDuringTransform = A {1} was thrown during the {0} transform +signature.Transform.NotYetImplemented = Transform {0} not yet implemented +signature.Transform.NullPointerTransform = Null pointer as URI. Programming bug? +signature.Transform.UnknownTransform = Unknown transformation. No handler installed for URI {0} +signature.Transform.node = Current Node: {0} +signature.Transform.nodeAndType = Current Node: {0}, type: {1} +signature.Util.BignumNonPositive = bigInteger.signum() must be positive +signature.Util.NonTextNode = Not a text node +signature.Util.TooManyChilds = Too many childs of Type {0} in {1} +signature.Verification.certificateError = Certificate error +signature.Verification.IndexOutOfBounds = Index {0} illegal. We only have {1} References +signature.Verification.internalError = Internal error +signature.Verification.InvalidDigestOrReference = Invalid digest of reference {0} +signature.Verification.keyStore = KeyStore error +signature.Verification.MissingID = Cannot resolve element with ID {0} +signature.Verification.MissingResources = Cannot resolve external resource {0} +signature.Verification.NoSignatureElement = Input document contains no {0} Element in namespace {1} +signature.Verification.Reference.NoInput = The Reference for URI {0} has no XMLSignatureInput +signature.Verification.SignatureError = Signature error +signature.XMLSignatureInput.MissingConstuctor = Cannot construct a XMLSignatureInput from class {0} +signature.XMLSignatureInput.SerializeDOM = Input initialized with DOM Element. Use Canonicalization to serialize it +signature.XMLSignatureInput.nodesetReference = Unable to convert to nodeset the reference +transform.Init.IllegalContextArgument = Invalid context argument of class {0}. Must be String, org.w3c.dom.NodeList or java.io.InputStream. +transform.init.NotInitialized = +transform.init.wrongURI = Initialized with wrong URI. How could this happen? We implement {0} but {1} was used during initialization +utils.Base64.IllegalBitlength = Illegal byte length; Data to be decoded must be a multiple of 4 +Base64Decoding = Error while decoding +utils.resolver.noClass = Could not find a resolver for URI {0} and Base {1} +xml.WrongContent = Cannot find {0} in {1} +xml.WrongElement = Cannot create a {0} from a {1} element +xpath.funcHere.documentsDiffer = The XPath is not in the same document as the context node +xpath.funcHere.noXPathContext = Try to evaluate an XPath which uses the here() function but XPath is not inside an ds:XPath Element. XPath was : {0} diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/doc-files/synth.dtd b/jdk/src/share/classes/javax/swing/plaf/synth/doc-files/synth.dtd index 5ac5a61f100..9188d43e2d4 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/doc-files/synth.dtd +++ b/jdk/src/share/classes/javax/swing/plaf/synth/doc-files/synth.dtd @@ -73,7 +73,7 @@ type (idref|boolean|dimension|insets|integer|string) "idref" value CDATA #REQUIRED > - + - - + + + - - -

- Synth is a skinnable look and feel in which all painting is - delegated. Synth does not provide a default look. In - order to use Synth you need to specify a - file, or - provide a {@link - javax.swing.plaf.synth.SynthStyleFactory}. Both - configuration options require an - understanding of the synth architecture, which is described - below, as well as an understanding of Swing's architecture. -

-

- Unless otherwise specified null is not a legal value to any of - the methods defined in the synth package and if passed in will - result in a NullPointerException. - - -

Synth

-

- Each {@link javax.swing.plaf.ComponentUI} implementation in Synth associates - itself with one {@link - javax.swing.plaf.synth.SynthStyle} per {@link - javax.swing.plaf.synth.Region}, most - Components only have one Region and - therefor only one SynthStyle. - SynthStyle - is used to access all style related properties: fonts, colors - and other Component properties. In addition - SynthStyles are used to obtain - {@link javax.swing.plaf.synth.SynthPainter}s for painting the background, border, - focus and other portions of a Component. The ComponentUIs obtain - SynthStyles from a - {@link javax.swing.plaf.synth.SynthStyleFactory}. - A SynthStyleFactory - can be provided directly by way of - {@link javax.swing.plaf.synth.SynthLookAndFeel#setStyleFactory(javax.swing.plaf.synth.SynthStyleFactory)}, - or indirectly by way of - {@link javax.swing.plaf.synth.SynthLookAndFeel#load}. The - following example uses the SynthLookAndFeel.load() - method to configure a SynthLookAndFeel and sets it - as the current look and feel: -

-
-
-  SynthLookAndFeel laf = new SynthLookAndFeel();
+
+
+    

+ Synth is a skinnable look and feel in which all painting is + delegated. Synth does not provide a default look. In + order to use Synth you need to specify a + file, or + provide a {@link + javax.swing.plaf.synth.SynthStyleFactory}. Both + configuration options require an + understanding of the synth architecture, which is described + below, as well as an understanding of Swing's architecture. +

+

+ Unless otherwise specified null is not a legal value to any of + the methods defined in the synth package and if passed in will + result in a NullPointerException. + + +

Synth

+

+ Each {@link javax.swing.plaf.ComponentUI} implementation in Synth associates + itself with one {@link + javax.swing.plaf.synth.SynthStyle} per {@link + javax.swing.plaf.synth.Region}, most + Components only have one Region and + therefor only one SynthStyle. + SynthStyle + is used to access all style related properties: fonts, colors + and other Component properties. In addition + SynthStyles are used to obtain + {@link javax.swing.plaf.synth.SynthPainter}s for painting the background, border, + focus and other portions of a Component. The ComponentUIs obtain + SynthStyles from a + {@link javax.swing.plaf.synth.SynthStyleFactory}. + A SynthStyleFactory + can be provided directly by way of + {@link javax.swing.plaf.synth.SynthLookAndFeel#setStyleFactory(javax.swing.plaf.synth.SynthStyleFactory)}, + or indirectly by way of + {@link javax.swing.plaf.synth.SynthLookAndFeel#load}. The + following example uses the SynthLookAndFeel.load() + method to configure a SynthLookAndFeel and sets it + as the current look and feel: +

+
+
+  SynthLookAndFeel laf = new SynthLookAndFeel();
   laf.load(MyClass.class.getResourceAsStream("laf.xml"), MyClass.class);
-  UIManager.setLookAndFeel(laf);
-      
-
-

- Many JComponents are broken down into smaller - pieces and identified by the type safe enumeration in - {@link javax.swing.plaf.synth.Region}. For example, a JTabbedPane - consists of a Region for the - JTabbedPane ({@link - javax.swing.plaf.synth.Region#TABBED_PANE}), the content - area ({@link - javax.swing.plaf.synth.Region#TABBED_PANE_CONTENT}), the - area behind the tabs ({@link - javax.swing.plaf.synth.Region#TABBED_PANE_TAB_AREA}), and the - tabs ({@link - javax.swing.plaf.synth.Region#TABBED_PANE_TAB}). Each - Region of each - JComponent will have a - SynthStyle. This allows - you to customize individual pieces of each region of each - JComponent. -

- Many of the Synth methods take a {@link javax.swing.plaf.synth.SynthContext}. This - is used to provide information about the current - Component and includes: the - {@link javax.swing.plaf.synth.SynthStyle} associated with the current - {@link javax.swing.plaf.synth.Region}, the state of the Component - as a bitmask (refer to {@link - javax.swing.plaf.synth.SynthConstants} for the valid - states), and a {@link javax.swing.plaf.synth.Region} identifying the portion of - the Component being painted. -

- All text rendering by non-JTextComponents is - delegated to a {@link - javax.swing.plaf.synth.SynthGraphicsUtils}, which is - obtained using the {@link javax.swing.plaf.synth.SynthStyle} method - {@link javax.swing.plaf.synth.SynthStyle#getGraphicsUtils}. You can - customize text rendering - by supplying your own {@link javax.swing.plaf.synth.SynthGraphicsUtils}. - -

- -

Notes on specific components

- -

JTree

-

- Synth provides a region for the cells of a tree: - Region.TREE_CELL. To specify the colors of the - renderer you'll want to provide a style for the - TREE_CELL region. The following illustrates this: -

-  <style id="treeCellStyle">
-    <opaque value="TRUE"/>
-    <state>
-      <color value="WHITE" type="TEXT_FOREGROUND"/>
-      <color value="RED" type="TEXT_BACKGROUND"/>
-    </state>
-    <state value="SELECTED">
-      <color value="RED" type="TEXT_FOREGROUND"/>
-      <color value="WHITE" type="BACKGROUND"/>
-    </state>
-  </style>
-  <bind style="treeCellStyle" type="region" key="TreeCell"/>
-
-

- This specifies a color combination of red on white, when - selected, and white on red when not selected. To see the - background you need to specify that labels are not opaque. The - following XML fragment does that: -

-  <style id="labelStyle">
-    <opaque value="FALSE"/>
-  </style>
-  <bind style="labelStyle" type="region" key="Label"/>
-
- -

JList and JTable

-

- The colors that the renderers for JList and JTable use are - specified by way of the list and table Regions. The following - XML fragment illustrates how to specify red on white, when - selected, and white on red when not selected: -

-  <style id="style">
-    <opaque value="TRUE"/>
-    <state>
-      <color value="WHITE" type="TEXT_FOREGROUND"/>
-      <color value="RED" type="TEXT_BACKGROUND"/>
-      <color value="RED" type="BACKGROUND"/>
-    </state>
-    <state value="SELECTED">
-      <color value="RED" type="TEXT_FOREGROUND"/>
-      <color value="WHITE" type="TEXT_BACKGROUND"/>
-    </state>
-  </style>
-  <bind style="style" type="region" key="Table"/>
-  <bind style="style" type="region" key="List"/>
-
- - + UIManager.setLookAndFeel(laf); +
+
+

+ Many JComponents are broken down into smaller + pieces and identified by the type safe enumeration in + {@link javax.swing.plaf.synth.Region}. For example, a JTabbedPane + consists of a Region for the + JTabbedPane ({@link + javax.swing.plaf.synth.Region#TABBED_PANE}), the content + area ({@link + javax.swing.plaf.synth.Region#TABBED_PANE_CONTENT}), the + area behind the tabs ({@link + javax.swing.plaf.synth.Region#TABBED_PANE_TAB_AREA}), and the + tabs ({@link + javax.swing.plaf.synth.Region#TABBED_PANE_TAB}). Each + Region of each + JComponent will have a + SynthStyle. This allows + you to customize individual pieces of each region of each + JComponent. +

+ Many of the Synth methods take a {@link javax.swing.plaf.synth.SynthContext}. This + is used to provide information about the current + Component and includes: the + {@link javax.swing.plaf.synth.SynthStyle} associated with the current + {@link javax.swing.plaf.synth.Region}, the state of the Component + as a bitmask (refer to {@link + javax.swing.plaf.synth.SynthConstants} for the valid + states), and a {@link javax.swing.plaf.synth.Region} identifying the portion of + the Component being painted. +

+ All text rendering by non-JTextComponents is + delegated to a {@link + javax.swing.plaf.synth.SynthGraphicsUtils}, which is + obtained using the {@link javax.swing.plaf.synth.SynthStyle} method + {@link javax.swing.plaf.synth.SynthStyle#getGraphicsUtils}. You can + customize text rendering + by supplying your own {@link javax.swing.plaf.synth.SynthGraphicsUtils}. + +

+ +

Notes on specific components

+ +

JTree

+

+ Synth provides a region for the cells of a tree: + Region.TREE_CELL. To specify the colors of the + renderer you'll want to provide a style for the + TREE_CELL region. The following illustrates this: +

+  <style id="treeCellStyle">
+    <opaque value="TRUE"/>
+    <state>
+      <color value="WHITE" type="TEXT_FOREGROUND"/>
+      <color value="RED" type="TEXT_BACKGROUND"/>
+    </state>
+    <state value="SELECTED">
+      <color value="RED" type="TEXT_FOREGROUND"/>
+      <color value="WHITE" type="BACKGROUND"/>
+    </state>
+  </style>
+  <bind style="treeCellStyle" type="region" key="TreeCell"/>
+
+

+ This specifies a color combination of red on white, when + selected, and white on red when not selected. To see the + background you need to specify that labels are not opaque. The + following XML fragment does that: +

+  <style id="labelStyle">
+    <opaque value="FALSE"/>
+  </style>
+  <bind style="labelStyle" type="region" key="Label"/>
+
+ +

JList and JTable

+

+ The colors that the renderers for JList and JTable use are + specified by way of the list and table Regions. The following + XML fragment illustrates how to specify red on white, when + selected, and white on red when not selected: +

+  <style id="style">
+    <opaque value="TRUE"/>
+    <state>
+      <color value="WHITE" type="TEXT_FOREGROUND"/>
+      <color value="RED" type="TEXT_BACKGROUND"/>
+      <color value="RED" type="BACKGROUND"/>
+    </state>
+    <state value="SELECTED">
+      <color value="RED" type="TEXT_FOREGROUND"/>
+      <color value="WHITE" type="TEXT_BACKGROUND"/>
+    </state>
+  </style>
+  <bind style="style" type="region" key="Table"/>
+  <bind style="style" type="region" key="List"/>
+
+ + diff --git a/jdk/src/share/demo/jfc/Notepad/resources/Notepad.properties b/jdk/src/share/demo/jfc/Notepad/resources/Notepad.properties index 9f9ec3a7531..fdd5c5a2246 100644 --- a/jdk/src/share/demo/jfc/Notepad/resources/Notepad.properties +++ b/jdk/src/share/demo/jfc/Notepad/resources/Notepad.properties @@ -1,76 +1,76 @@ -# -# Resource strings for Notepad example - -Title=Notepad -ElementTreeFrameTitle=Elements -ViewportBackingStore=false - -# menubar definition -# -# Each of the strings that follow form a key to be -# used to the actual menu definition. -menubar=file edit debug - -# file Menu definition -# -# Each of the strings that follow form a key to be -# used as the basis of a menu item definition. -# -# open -> Notepad.openAction -# new -> Notepad.newAction -# save -> Notepad.saveAction -# exit -> Notepad.exitAction -file=new open save - exit -fileLabel=File -openLabel=Open -openImage=resources/open.gif -newLabel=New -newImage=resources/new.gif -saveLabel=Save -saveImage=resources/save.gif -exitLabel=Exit - -# -# edit Menu definition -# -# cut -> JTextComponent.cutAction -# copy -> JTextComponent.copyAction -# paste -> JTextComponent.pasteAction -edit=cut copy paste - undo redo -editLabel=Edit -cutLabel=Cut -cutAction=cut-to-clipboard -cutImage=resources/cut.gif -copyLabel=Copy -copyAction=copy-to-clipboard -copyImage=resources/copy.gif -pasteLabel=Paste -pasteAction=paste-from-clipboard -pasteImage=resources/paste.gif -undoLabel=Undo -undoAction=Undo -redoLabel=Redo -redoAction=Redo - -# -# debug Menu definition -# -debug=dump showElementTree -debugLabel=Debug -dumpLabel=Dump model to System.err -dumpAction=dump-model -showElementTreeLabel=Show Elements - -# toolbar definition -# -# Each of the strings that follow form a key to be -# used as the basis of the tool definition. Actions -# are of course sharable, and in this case are shared -# with the menu items. -toolbar=new open save - cut copy paste -newTooltip=Create a new file -openTooltip=Open a file -saveTooltip=Save to a file -cutTooltip=Move selection to clipboard -copyTooltip=Copy selection to clipboard -pasteTooltip=Paste clipboard to selection +# +# Resource strings for Notepad example + +Title=Notepad +ElementTreeFrameTitle=Elements +ViewportBackingStore=false + +# menubar definition +# +# Each of the strings that follow form a key to be +# used to the actual menu definition. +menubar=file edit debug + +# file Menu definition +# +# Each of the strings that follow form a key to be +# used as the basis of a menu item definition. +# +# open -> Notepad.openAction +# new -> Notepad.newAction +# save -> Notepad.saveAction +# exit -> Notepad.exitAction +file=new open save - exit +fileLabel=File +openLabel=Open +openImage=resources/open.gif +newLabel=New +newImage=resources/new.gif +saveLabel=Save +saveImage=resources/save.gif +exitLabel=Exit + +# +# edit Menu definition +# +# cut -> JTextComponent.cutAction +# copy -> JTextComponent.copyAction +# paste -> JTextComponent.pasteAction +edit=cut copy paste - undo redo +editLabel=Edit +cutLabel=Cut +cutAction=cut-to-clipboard +cutImage=resources/cut.gif +copyLabel=Copy +copyAction=copy-to-clipboard +copyImage=resources/copy.gif +pasteLabel=Paste +pasteAction=paste-from-clipboard +pasteImage=resources/paste.gif +undoLabel=Undo +undoAction=Undo +redoLabel=Redo +redoAction=Redo + +# +# debug Menu definition +# +debug=dump showElementTree +debugLabel=Debug +dumpLabel=Dump model to System.err +dumpAction=dump-model +showElementTreeLabel=Show Elements + +# toolbar definition +# +# Each of the strings that follow form a key to be +# used as the basis of the tool definition. Actions +# are of course sharable, and in this case are shared +# with the menu items. +toolbar=new open save - cut copy paste +newTooltip=Create a new file +openTooltip=Open a file +saveTooltip=Save to a file +cutTooltip=Move selection to clipboard +copyTooltip=Copy selection to clipboard +pasteTooltip=Paste clipboard to selection diff --git a/jdk/src/share/sample/vm/clr-jvm/Makefile b/jdk/src/share/sample/vm/clr-jvm/Makefile index 2515650d1d5..5b8e6f3b6fa 100644 --- a/jdk/src/share/sample/vm/clr-jvm/Makefile +++ b/jdk/src/share/sample/vm/clr-jvm/Makefile @@ -29,16 +29,16 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -all: jinvoker.dll invoked.class invoker.exe - -jinvoker.dll: jinvoker.obj Makefile - cl /LD /o jinvoker.dll jinvoker.obj - -jinvoker.obj: jinvoker.cpp jinvokerExp.h Makefile - cl /Fojinvoker.obj /DJINVOKEREEXPORT /c jinvoker.cpp - -invoked.class: invoked.java Makefile - javac invoked.java - -invoker.exe: invoker.cs Makefile - csc /unsafe invoker.cs +all: jinvoker.dll invoked.class invoker.exe + +jinvoker.dll: jinvoker.obj Makefile + cl /LD /o jinvoker.dll jinvoker.obj + +jinvoker.obj: jinvoker.cpp jinvokerExp.h Makefile + cl /Fojinvoker.obj /DJINVOKEREEXPORT /c jinvoker.cpp + +invoked.class: invoked.java Makefile + javac invoked.java + +invoker.exe: invoker.cs Makefile + csc /unsafe invoker.cs diff --git a/jdk/src/share/sample/vm/clr-jvm/README.txt b/jdk/src/share/sample/vm/clr-jvm/README.txt index a081c878c94..52ed44e6d82 100644 --- a/jdk/src/share/sample/vm/clr-jvm/README.txt +++ b/jdk/src/share/sample/vm/clr-jvm/README.txt @@ -1,54 +1,54 @@ -This sample provides Java "Hello World" program that is invoked -from C# application in the same process. - -The problem of direct call of the JVM API from CLR applications -by PInvoke interface is the JVM API functions do not have static -adresses, they need to be got by JNI_CreateJavaVM() call. -The sample contains C++ libraty that wraps JVM API calls by the -static functions that are called from the C# application by -PInvoke interface. - -The sample contains the following files: - -Makefile - make file -README.txt - this readme -invoked.java - the invoked HelloWorld Java program -invoker.cs - C# invoker application -jinvoker.cpp - C++ wrapper -jinvokerExp.h - wrapper library exports - -After the success making the following files are produced: - -invoked.class - the compiled HelloWorld class -invoker.exe - the executable .NET program that invokes Java -jinvoker.dll - the wrapper library - -The following environment needs to be set for the correct sample -build and execution: - -INCLUDE must contain the paths to: - 1. MS Visual C++ standard include - 2. .NET SDK include - 3. Java includes - Example: %MSDEV%/VC98/Include;%DOTNET%/Include;%JAVA_HOME%/include;%JAVA_HOME%/include/win32 - -LIB must contain the paths to: - 1. MS Visual C++ standard libraries - 2. .NET SDK libraries - 3. jvm.dll - Example: %MSDEV%/VC98/Lib;%DOTNET%/Lib;%JAVA_HOME%/jre/bin/client - -PATH must contain the paths to: - 1. MS Visual C++ standard bin - 2. MS Dev common bin - 3. .NET SDK libraries - 4. Java bin - 5. jvm.dll - Example: %MSDEV%/VC98/Bin;%MSDEV%/Common/MSDev98/Bin;%DOTNET%/Lib;%JAVA_HOME%/bin;%JAVA_HOME%/jre/bin/client;%PATH% - -To run the sample please do: - - invoker.exe invoked - - ---Dmitry Ryashchentsev +This sample provides Java "Hello World" program that is invoked +from C# application in the same process. + +The problem of direct call of the JVM API from CLR applications +by PInvoke interface is the JVM API functions do not have static +adresses, they need to be got by JNI_CreateJavaVM() call. +The sample contains C++ libraty that wraps JVM API calls by the +static functions that are called from the C# application by +PInvoke interface. + +The sample contains the following files: + +Makefile - make file +README.txt - this readme +invoked.java - the invoked HelloWorld Java program +invoker.cs - C# invoker application +jinvoker.cpp - C++ wrapper +jinvokerExp.h - wrapper library exports + +After the success making the following files are produced: + +invoked.class - the compiled HelloWorld class +invoker.exe - the executable .NET program that invokes Java +jinvoker.dll - the wrapper library + +The following environment needs to be set for the correct sample +build and execution: + +INCLUDE must contain the paths to: + 1. MS Visual C++ standard include + 2. .NET SDK include + 3. Java includes + Example: %MSDEV%/VC98/Include;%DOTNET%/Include;%JAVA_HOME%/include;%JAVA_HOME%/include/win32 + +LIB must contain the paths to: + 1. MS Visual C++ standard libraries + 2. .NET SDK libraries + 3. jvm.dll + Example: %MSDEV%/VC98/Lib;%DOTNET%/Lib;%JAVA_HOME%/jre/bin/client + +PATH must contain the paths to: + 1. MS Visual C++ standard bin + 2. MS Dev common bin + 3. .NET SDK libraries + 4. Java bin + 5. jvm.dll + Example: %MSDEV%/VC98/Bin;%MSDEV%/Common/MSDev98/Bin;%DOTNET%/Lib;%JAVA_HOME%/bin;%JAVA_HOME%/jre/bin/client;%PATH% + +To run the sample please do: + + invoker.exe invoked + + +--Dmitry Ryashchentsev diff --git a/jdk/src/share/sample/vm/clr-jvm/invoker.cs b/jdk/src/share/sample/vm/clr-jvm/invoker.cs index 7e5646230bf..b4ae1bb3d0a 100644 --- a/jdk/src/share/sample/vm/clr-jvm/invoker.cs +++ b/jdk/src/share/sample/vm/clr-jvm/invoker.cs @@ -29,30 +29,30 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* -*/ - +/* +*/ + using System; using System.Runtime.InteropServices; class jinvoker{ public static int Main(string[] aArgs){ - - // Print Hello to show we are in CLR - Console.WriteLine("Hello from C#"); - if(aArgs.Length > 0) - // invoke JVM - return InvokeMain(aArgs[0]); - else - return -1; + + // Print Hello to show we are in CLR + Console.WriteLine("Hello from C#"); + if(aArgs.Length > 0) + // invoke JVM + return InvokeMain(aArgs[0]); + else + return -1; } // Link the JVM API functions and the wrappers [DllImport("jvm.dll")] public unsafe static extern int JNI_CreateJavaVM(void** ppVm, void** ppEnv, void* pArgs); [DllImport("jinvoker.dll")] public unsafe static extern int MakeJavaVMInitArgs( void** ppArgs ); - [DllImport("jinvoker.dll")] public unsafe static extern void FreeJavaVMInitArgs( void* pArgs ); + [DllImport("jinvoker.dll")] public unsafe static extern void FreeJavaVMInitArgs( void* pArgs ); [DllImport("jinvoker.dll")] public unsafe static extern int FindClass( void* pEnv, String sClass, void** ppClass ); [DllImport("jinvoker.dll")] public unsafe static extern int GetStaticMethodID( void* pEnv, void* pClass, @@ -73,7 +73,7 @@ class jinvoker{ [DllImport("jinvoker.dll")] public unsafe static extern int DestroyJavaVM( void* pJVM ); public unsafe static int InvokeMain( String sClass ){ - + void* pJVM; // JVM struct void* pEnv; // JVM environment void* pVMArgs; // VM args @@ -81,23 +81,23 @@ class jinvoker{ void* pMethod; // The executed method struct void* pArgs; // The executed method arguments struct - // Fill the pVMArgs structs + // Fill the pVMArgs structs MakeJavaVMInitArgs( &pVMArgs ); - // Create JVM + // Create JVM int nRes = JNI_CreateJavaVM( &pJVM, &pEnv, pVMArgs ); if( nRes == 0 ){ - - // Find the executed method class + + // Find the executed method class if(FindClass( pEnv, sClass, &pClass) == 0 ) - - // Find the executed method + + // Find the executed method if( GetStaticMethodID( pEnv, pClass, "main", "([Ljava/lang/String;)V", &pMethod ) == 0 ) - - // Create empty String[] array to pass to the main() + + // Create empty String[] array to pass to the main() if( NewObjectArray( pEnv, 0, "java/lang/String", &pArgs ) == 0 ){ - - // Call main() + + // Call main() nRes = CallStaticVoidMethod( pEnv, pClass, pMethod, pArgs ); if( nRes != -1 ) Console.WriteLine("Result:"+nRes); @@ -116,16 +116,16 @@ class jinvoker{ Console.WriteLine("can not find class:"+sClass); nRes = -102; } - - // Destroy the JVM + + // Destroy the JVM DestroyJavaVM( pJVM ); }else - Console.WriteLine("Can not create Java VM"); - - // Free the JVM args structs + Console.WriteLine("Can not create Java VM"); + + // Free the JVM args structs FreeJavaVMInitArgs(pVMArgs); - + return nRes; } } diff --git a/jdk/src/share/sample/vm/jvm-clr/README.txt b/jdk/src/share/sample/vm/jvm-clr/README.txt index a8fe79db343..1d1c2f4bb12 100644 --- a/jdk/src/share/sample/vm/jvm-clr/README.txt +++ b/jdk/src/share/sample/vm/jvm-clr/README.txt @@ -42,10 +42,10 @@ PATH must contain the paths to: 3. .NET SDK libraries 4. Java bin Example: %MSDEV%/VC98/Bin;%MSDEV%/Common/MSDev98/Bin;%DOTNET%/Lib;%JAVA_HOME%/bin;%PATH% - -To run the sample please do: - -java invoker invoked.exe - - ---Dmitry Ryashchentsev + +To run the sample please do: + +java invoker invoked.exe + + +--Dmitry Ryashchentsev diff --git a/jdk/src/share/sample/vm/jvm-clr/invoked.cs b/jdk/src/share/sample/vm/jvm-clr/invoked.cs index 1904bb7191b..e5eead480af 100644 --- a/jdk/src/share/sample/vm/jvm-clr/invoked.cs +++ b/jdk/src/share/sample/vm/jvm-clr/invoked.cs @@ -29,17 +29,17 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* -*/ - - +/* +*/ + + using System; class App{ public static int Main(){ - - // Print Hello to show we are in CLR + + // Print Hello to show we are in CLR Console.WriteLine("Hello from C#!!!"); return 0; } From 938ac15f82f0b910330ae05e9abc9c3b46bca774 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Tue, 25 Mar 2008 14:42:28 -0700 Subject: [PATCH 39/54] 6627817: Remove ^M characters in all files (Makefiles too) Some files included the use of the ^M character, which has been deleted Reviewed-by: xdono --- .../corba/se/impl/corba/orb_config_design.txt | 2 +- corba/src/share/classes/org/omg/CORBA/ir.idl | 22 +++++++++---------- .../classes/org/omg/DynamicAny/DynamicAny.idl | 18 +++++++-------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/corba/src/share/classes/com/sun/corba/se/impl/corba/orb_config_design.txt b/corba/src/share/classes/com/sun/corba/se/impl/corba/orb_config_design.txt index 6ceeec0bd5f..30cf698cbbc 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/corba/orb_config_design.txt +++ b/corba/src/share/classes/com/sun/corba/se/impl/corba/orb_config_design.txt @@ -318,7 +318,7 @@ ORB classes: 11. RequestHandler and ORB - The RH interface is currently implemented in the ORB class, but migþt better be a separate + The RH interface is currently implemented in the ORB class, but might better be a separate class. The API is currently almost the same as a ServerSubcontract. Should we regularize this? Also, the API would need to be extended to handle shutdown properly. diff --git a/corba/src/share/classes/org/omg/CORBA/ir.idl b/corba/src/share/classes/org/omg/CORBA/ir.idl index 8383443d72a..5ea8a1979dd 100644 --- a/corba/src/share/classes/org/omg/CORBA/ir.idl +++ b/corba/src/share/classes/org/omg/CORBA/ir.idl @@ -774,18 +774,18 @@ module CORBA { // orbos 98-01-18: Objects By Value -- end - enum TCKind { - tk_null, tk_void, + enum TCKind { + tk_null, tk_void, tk_short, tk_long, tk_ushort, tk_ulong, - tk_float, tk_double, tk_boolean, tk_char, - tk_octet, tk_any, tk_TypeCode, tk_Principal, tk_objref, - tk_struct, tk_union, tk_enum, tk_string, - tk_sequence, tk_array, tk_alias, tk_except, - tk_longlong, tk_ulonglong, tk_longdouble, - tk_wchar, tk_wstring, tk_fixed, - tk_value, tk_value_box, - tk_native, - tk_abstract_interface + tk_float, tk_double, tk_boolean, tk_char, + tk_octet, tk_any, tk_TypeCode, tk_Principal, tk_objref, + tk_struct, tk_union, tk_enum, tk_string, + tk_sequence, tk_array, tk_alias, tk_except, + tk_longlong, tk_ulonglong, tk_longdouble, + tk_wchar, tk_wstring, tk_fixed, + tk_value, tk_value_box, + tk_native, + tk_abstract_interface }; interface NativeDef : TypedefDef { diff --git a/corba/src/share/classes/org/omg/DynamicAny/DynamicAny.idl b/corba/src/share/classes/org/omg/DynamicAny/DynamicAny.idl index e38d7be01c9..b0149c3e256 100644 --- a/corba/src/share/classes/org/omg/DynamicAny/DynamicAny.idl +++ b/corba/src/share/classes/org/omg/DynamicAny/DynamicAny.idl @@ -1042,24 +1042,24 @@ module DynamicAny { /** * DynValueCommon provides operations supported by both the DynValue and DynValueBox interfaces. */ - interface DynValueCommon : DynAny { + interface DynValueCommon : DynAny { /** * Returns true if the DynValueCommon represents a null value type. */ - boolean is_null(); + boolean is_null(); /** * Changes the representation of a DynValueCommon to a null value type. */ - void set_to_null(); + void set_to_null(); /** * Replaces a null value type with a newly constructed value. Its components are initialized * to default values as in DynAnyFactory.create_dyn_any_from_type_code. * If the DynValueCommon represents a non-null value type, then this operation has no effect. */ - void set_to_value(); - }; + void set_to_value(); + }; /** * DynValue objects support the manipulation of IDL non-boxed value types. @@ -1164,14 +1164,14 @@ module DynamicAny { * of the boxed type. A DynValueBox representing a null value type has no components * and a current position of -1. */ - interface DynValueBox : DynValueCommon { + interface DynValueBox : DynValueCommon { /** * Returns the boxed value as an Any. * * @exception InvalidValue if this object represents a null value box type */ - any get_boxed_value() + any get_boxed_value() raises(InvalidValue); /** @@ -1189,7 +1189,7 @@ module DynamicAny { * * @exception InvalidValue if this object represents a null value box type */ - DynAny get_boxed_value_as_dyn_any() + DynAny get_boxed_value_as_dyn_any() raises(InvalidValue); /** @@ -1199,7 +1199,7 @@ module DynamicAny { * @exception TypeMismatch if this object represents a non-null value box type and the type * of the parameter is not matching the current boxed value type. */ - void set_boxed_value_as_dyn_any(in DynAny boxed) + void set_boxed_value_as_dyn_any(in DynAny boxed) raises(TypeMismatch); }; From 332059a5554e9119861041a5e9efa66ec61a0aac Mon Sep 17 00:00:00 2001 From: Eamonn McManus Date: Tue, 1 Apr 2008 14:45:23 +0200 Subject: [PATCH 40/54] 6610917: Define a generic NotificationFilter Adds javax.management.QueryNotificationFilter Reviewed-by: dfuchs --- .../DefaultMBeanServerInterceptor.java | 17 +- .../sun/jmx/mbeanserver/MBeanAnalyzer.java | 20 +- .../jmx/mbeanserver/MBeanIntrospector.java | 14 + .../mbeanserver/NotificationMBeanSupport.java | 81 ++++ .../sun/jmx/mbeanserver/OpenConverter.java | 2 +- .../com/sun/jmx/mbeanserver/Repository.java | 13 +- .../classes/com/sun/jmx/mbeanserver/Util.java | 10 + .../classes/javax/management/ObjectName.java | 17 +- .../management/QueryNotificationFilter.java | 417 ++++++++++++++++++ .../query/QueryNotifFilterTest.java | 347 +++++++++++++++ 10 files changed, 885 insertions(+), 53 deletions(-) create mode 100644 jdk/src/share/classes/com/sun/jmx/mbeanserver/NotificationMBeanSupport.java create mode 100644 jdk/src/share/classes/javax/management/QueryNotificationFilter.java create mode 100644 jdk/test/javax/management/query/QueryNotifFilterTest.java diff --git a/jdk/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java b/jdk/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java index a637aa14745..eea8d4309eb 100644 --- a/jdk/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java +++ b/jdk/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java @@ -34,8 +34,6 @@ import java.util.Set; import java.util.HashSet; import java.util.WeakHashMap; import java.lang.ref.WeakReference; -import java.io.PrintWriter; -import java.io.StringWriter; import java.security.AccessControlContext; import java.security.Permission; import java.security.ProtectionDomain; @@ -51,7 +49,6 @@ import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException; import javax.management.IntrospectionException; import javax.management.InvalidAttributeValueException; -import javax.management.JMException; import javax.management.JMRuntimeException; import javax.management.ListenerNotFoundException; import javax.management.MalformedObjectNameException; @@ -84,11 +81,10 @@ import static com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER; import com.sun.jmx.mbeanserver.DynamicMBean2; import com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository; import com.sun.jmx.mbeanserver.MBeanInstantiator; -import com.sun.jmx.mbeanserver.MXBeanSupport; import com.sun.jmx.mbeanserver.Repository; import com.sun.jmx.mbeanserver.NamedObject; -import com.sun.jmx.defaults.ServiceName; import com.sun.jmx.mbeanserver.Introspector; +import com.sun.jmx.mbeanserver.Util; import com.sun.jmx.remote.util.EnvHelp; /** @@ -623,18 +619,9 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { List result = new ArrayList(domains.length); for (int i = 0; i < domains.length; i++) { try { - ObjectName domain = new ObjectName(domains[i] + ":x=x"); + ObjectName domain = Util.newObjectName(domains[i] + ":x=x"); checkMBeanPermission((String) null, null, domain, "getDomains"); result.add(domains[i]); - } catch (MalformedObjectNameException e) { - // Should never occur... But let's log it just in case. - if (MBEANSERVER_LOGGER.isLoggable(Level.SEVERE)) { - MBEANSERVER_LOGGER.logp(Level.SEVERE, - DefaultMBeanServerInterceptor.class.getName(), - "getDomains", - "Failed to check permission for domain = " + - domains[i], e); - } } catch (SecurityException e) { // OK: Do not add this domain to the list } diff --git a/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanAnalyzer.java b/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanAnalyzer.java index f908a352a2b..5975f1a391b 100644 --- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanAnalyzer.java +++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanAnalyzer.java @@ -107,10 +107,7 @@ class MBeanAnalyzer { private MBeanAnalyzer(Class mbeanInterface, MBeanIntrospector introspector) throws NotCompliantMBeanException { - if (!mbeanInterface.isInterface()) { - throw new NotCompliantMBeanException("Not an interface: " + - mbeanInterface.getName()); - } + introspector.checkCompliance(mbeanInterface); try { initMaps(mbeanInterface, introspector); @@ -121,11 +118,10 @@ class MBeanAnalyzer { // Introspect the mbeanInterface and initialize this object's maps. // - private void initMaps(Class mbeanInterface, + private void initMaps(Class mbeanType, MBeanIntrospector introspector) throws Exception { - final Method[] methodArray = mbeanInterface.getMethods(); - - final List methods = eliminateCovariantMethods(methodArray); + final List methods1 = introspector.getMethods(mbeanType); + final List methods = eliminateCovariantMethods(methods1); /* Run through the methods to detect inconsistencies and to enable us to give getter and setter together to visitAttribute. */ @@ -234,13 +230,13 @@ class MBeanAnalyzer { but existing code may depend on it and users may be used to seeing operations or attributes appear in a particular order. */ static List - eliminateCovariantMethods(Method[] methodArray) { + eliminateCovariantMethods(List startMethods) { // We are assuming that you never have very many methods with the // same name, so it is OK to use algorithms that are quadratic // in the number of methods with the same name. - final int len = methodArray.length; - final Method[] sorted = methodArray.clone(); + final int len = startMethods.size(); + final Method[] sorted = startMethods.toArray(new Method[len]); Arrays.sort(sorted,MethodOrder.instance); final Set overridden = newSet(); for (int i=1;i { } } - final List methods = newList(Arrays.asList(methodArray)); + final List methods = newList(startMethods); methods.removeAll(overridden); return methods; } diff --git a/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanIntrospector.java b/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanIntrospector.java index c191005d621..ea7dbdade33 100644 --- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanIntrospector.java +++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanIntrospector.java @@ -34,6 +34,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; +import java.util.Arrays; import java.util.List; import java.util.WeakHashMap; @@ -169,6 +170,19 @@ abstract class MBeanIntrospector { */ abstract Descriptor getMBeanDescriptor(Class resourceClass); + void checkCompliance(Class mbeanType) throws NotCompliantMBeanException { + if (!mbeanType.isInterface()) { + throw new NotCompliantMBeanException("Not an interface: " + + mbeanType.getName()); + } + } + + /** + * Get the methods to be analyzed to build the MBean interface. + */ + List getMethods(final Class mbeanType) throws Exception { + return Arrays.asList(mbeanType.getMethods()); + } final PerInterface getPerInterface(Class mbeanInterface) throws NotCompliantMBeanException { diff --git a/jdk/src/share/classes/com/sun/jmx/mbeanserver/NotificationMBeanSupport.java b/jdk/src/share/classes/com/sun/jmx/mbeanserver/NotificationMBeanSupport.java new file mode 100644 index 00000000000..f1e3a13c891 --- /dev/null +++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/NotificationMBeanSupport.java @@ -0,0 +1,81 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package com.sun.jmx.mbeanserver; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import javax.management.NotCompliantMBeanException; +import javax.management.Notification; + +/** + *

A variant of {@code StandardMBeanSupport} where the only + * methods included are public getters. This is used by + * {@code QueryNotificationFilter} to pretend that a Notification is + * an MBean so it can have a query evaluated on it. Standard queries + * never set attributes or invoke methods but custom queries could and + * we don't want to allow that. Also we don't want to fail if a + * Notification happens to have inconsistent types in a pair of getX and + * setX methods, and we want to include the Object.getClass() method. + */ +public class NotificationMBeanSupport extends StandardMBeanSupport { + public NotificationMBeanSupport(T n) + throws NotCompliantMBeanException { + super(n, Util.>cast(n.getClass())); + } + + @Override + MBeanIntrospector getMBeanIntrospector() { + return introspector; + } + + private static class Introspector extends StandardMBeanIntrospector { + @Override + void checkCompliance(Class mbeanType) {} + + @Override + List getMethods(final Class mbeanType) + throws Exception { + List methods = new ArrayList(); + for (Method m : mbeanType.getMethods()) { + String name = m.getName(); + Class ret = m.getReturnType(); + if (m.getParameterTypes().length == 0) { + if ((name.startsWith("is") && name.length() > 2 && + ret == boolean.class) || + (name.startsWith("get") && name.length() > 3 && + ret != void.class)) { + methods.add(m); + } + } + } + return methods; + } + + } + private static final MBeanIntrospector introspector = + new Introspector(); +} diff --git a/jdk/src/share/classes/com/sun/jmx/mbeanserver/OpenConverter.java b/jdk/src/share/classes/com/sun/jmx/mbeanserver/OpenConverter.java index ccd0ed57bf5..25ac0a28e10 100644 --- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/OpenConverter.java +++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/OpenConverter.java @@ -438,7 +438,7 @@ public abstract class OpenConverter { c.getClassLoader() == null); final List methods = - MBeanAnalyzer.eliminateCovariantMethods(c.getMethods()); + MBeanAnalyzer.eliminateCovariantMethods(Arrays.asList(c.getMethods())); final SortedMap getterMap = newSortedMap(); /* Select public methods that look like "T getX()" or "boolean diff --git a/jdk/src/share/classes/com/sun/jmx/mbeanserver/Repository.java b/jdk/src/share/classes/com/sun/jmx/mbeanserver/Repository.java index e33492d945e..38a1fc6d4f4 100644 --- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/Repository.java +++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/Repository.java @@ -415,17 +415,8 @@ public class Repository { boolean to_default_domain = false; // Set domain to default if domain is empty and not already set - if (dom.length() == 0) { - try { - name = new ObjectName(domain + name.toString()); - } catch (MalformedObjectNameException e) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) { - MBEANSERVER_LOGGER.logp(Level.FINEST, - Repository.class.getName(), "addMBean", - "Unexpected MalformedObjectNameException", e); - } - } - } + if (dom.length() == 0) + name = Util.newObjectName(domain + name.toString()); // Do we have default domain ? if (dom == domain) { diff --git a/jdk/src/share/classes/com/sun/jmx/mbeanserver/Util.java b/jdk/src/share/classes/com/sun/jmx/mbeanserver/Util.java index 712b4e378a8..f2dbe60bbdf 100644 --- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/Util.java +++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/Util.java @@ -38,6 +38,8 @@ import java.util.Map; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; public class Util { static Map newMap() { @@ -85,6 +87,14 @@ public class Util { return new ArrayList(c); } + public static ObjectName newObjectName(String s) { + try { + return new ObjectName(s); + } catch (MalformedObjectNameException e) { + throw new IllegalArgumentException(e); + } + } + /* This method can be used by code that is deliberately violating the * allowed checked casts. Rather than marking the whole method containing * the code with @SuppressWarnings, you can use a call to this method for diff --git a/jdk/src/share/classes/javax/management/ObjectName.java b/jdk/src/share/classes/javax/management/ObjectName.java index cef869510b1..ff11962b666 100644 --- a/jdk/src/share/classes/javax/management/ObjectName.java +++ b/jdk/src/share/classes/javax/management/ObjectName.java @@ -26,6 +26,7 @@ package javax.management; import com.sun.jmx.mbeanserver.GetPropertyAction; +import com.sun.jmx.mbeanserver.Util; import java.io.IOException; import java.io.InvalidObjectException; import java.io.ObjectInputStream; @@ -1386,12 +1387,7 @@ public class ObjectName extends ToQueryString throws NullPointerException { if (name.getClass().equals(ObjectName.class)) return name; - try { - return new ObjectName(name.getSerializedNameString()); - } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException("Unexpected: " + e); - // can't happen - } + return Util.newObjectName(name.getSerializedNameString()); } /** @@ -1950,14 +1946,7 @@ public class ObjectName extends ToQueryString * * @since 1.6 */ - public static final ObjectName WILDCARD; - static { - try { - WILDCARD = new ObjectName("*:*"); - } catch (MalformedObjectNameException e) { - throw new Error("Can't initialize wildcard name", e); - } - } + public static final ObjectName WILDCARD = Util.newObjectName("*:*"); // Category : Utilities <=================================== diff --git a/jdk/src/share/classes/javax/management/QueryNotificationFilter.java b/jdk/src/share/classes/javax/management/QueryNotificationFilter.java new file mode 100644 index 00000000000..c6c10393902 --- /dev/null +++ b/jdk/src/share/classes/javax/management/QueryNotificationFilter.java @@ -0,0 +1,417 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package javax.management; + +import com.sun.jmx.mbeanserver.NotificationMBeanSupport; +import com.sun.jmx.mbeanserver.Util; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.Collections; +import java.util.Set; + +/** + *

General-purpose notification filter. This filter can be used to + * filter notifications from a possibly-remote MBean. Most filtering + * decisions can be coded using this filter, which avoids having to + * write a custom implementation of the {@link NotificationFilter} + * class. Writing a custom implementation requires you to deploy it + * on both the client and the server in the remote case, so using this class + * instead is recommended where possible.

+ * + * + * + *

This class uses the {@linkplain Query Query API} to specify the + * filtering logic. For example, to select only notifications where the + * {@linkplain Notification#getType() type} is {@code "com.example.mytype"}, + * you could use

+ * + *
+ * NotificationFilter filter =
+ *     new QueryNotificationFilter("Type = 'com.example.mytype'");
+ * 
+ * + *

or equivalently

+ * + *
+ * NotificationFilter filter =
+ *     new QueryNotificationFilter(
+ *             Query.eq(Query.attr("Type"), Query.value("com.example.mytype")));
+ * 
+ * + *

(This particular example could also use + * {@link NotificationFilterSupport}.)

+ * + *

Here are some other examples of filters you can specify with this class.

+ * + *
+ * + *
{@code QueryNotificationFilter("Type = 'com.example.type1' or + * Type = 'com.example.type2'")} + *
Notifications where the type is either of the given strings. + * + *
{@code QueryNotificationFilter("Type in ('com.example.type1', + * 'com.example.type2')")} + *
Another way to write the previous example. + * + *
{@code QueryNotificationFilter("SequenceNumber > 1000")} + *
Notifications where the {@linkplain Notification#getSequenceNumber() + * sequence number} is greater than 1000. + * + *
{@code QueryNotificationFilter(AttributeChangeNotification.class, null)} + *
Notifications where the notification class is + * {@link AttributeChangeNotification} or a subclass of it. + * + *
{@code QueryNotificationFilter(AttributeChangeNotification.class, + * "AttributeName = 'Size'")} + *
Notifications where the notification class is + * {@link AttributeChangeNotification} or a subclass, and where the + * {@linkplain AttributeChangeNotification#getAttributeName() name of the + * changed attribute} is {@code Size}. + * + *
{@code QueryNotificationFilter(AttributeChangeNotification.class, + * "AttributeName = 'Size' and NewValue - OldValue > 100")} + *
As above, but the difference between the + * {@linkplain AttributeChangeNotification#getNewValue() new value} and the + * {@linkplain AttributeChangeNotification#getOldValue() old value} must be + * greater than 100. + * + *
{@code QueryNotificationFilter("like 'com.example.mydomain:*'")} + *
Notifications where the {@linkplain Notification#getSource() source} + * is an ObjectName that matches the pattern. + * + *
{@code QueryNotificationFilter("Source.canonicalName like + * 'com.example.mydomain:%'")} + *
Another way to write the previous example. + * + *
{@code QueryNotificationFilter(MBeanServerNotification.class, + * "Type = 'JMX.mbean.registered' and MBeanName.canonicalName like + * 'com.example.mydomain:%'")} + *
Notifications of class {@link MBeanServerNotification} representing + * an object registered in the domain {@code com.example.mydomain}. + * + *
+ * + *

How it works

+ * + *

Although the examples above are clear, looking closely at the + * Query API reveals a subtlety. A {@link QueryExp} is evaluated on + * an {@link ObjectName}, not a {@code Notification}.

+ * + *

Every time a {@code Notification} is to be filtered by a + * {@code QueryNotificationFilter}, a special {@link MBeanServer} is created. + * This {@code MBeanServer} contains exactly one MBean, which represents the + * {@code Notification}. If the {@linkplain Notification#getSource() + * source} of the notification is an {@code ObjectName}, which is + * recommended practice, then the name of the MBean representing the + * {@code Notification} will be this {@code ObjectName}. Otherwise the + * name is unspecified.

+ * + *

The query specified in the {@code QueryNotificationFilter} constructor + * is evaluated against this {@code MBeanServer} and {@code ObjectName}, + * and the filter returns true if and only if the query does. If the + * query throws an exception, then the filter will return false.

+ * + *

The MBean representing the {@code Notification} has one attribute for + * every property of the {@code Notification}. Specifically, for every public + * method {@code T getX()} in the {@code NotificationClass}, the MBean will + * have an attribute called {@code X} of type {@code T}. For example, if the + * {@code Notification} is an {@code AttributeChangeNotification}, then the + * MBean will have an attribute called {@code AttributeName} of type + * {@code "java.lang.String"}, corresponding to the method {@link + * AttributeChangeNotification#getAttributeName}.

+ * + *

Query evaluation usually involves calls to the methods of {@code + * MBeanServer}. The methods have the following behavior:

+ * + *
    + *
  • The {@link MBeanServer#getAttribute getAttribute} method returns the + * value of the corresponding property. + *
  • The {@link MBeanServer#getObjectInstance getObjectInstance} + * method returns an {@link ObjectInstance} where the {@link + * ObjectInstance#getObjectName ObjectName} is the name of the MBean and the + * {@link ObjectInstance#getClassName ClassName} is the class name of the + * {@code Notification}. + *
  • The {@link MBeanServer#isInstanceOf isInstanceOf} method returns true + * if and only if the {@code Notification}'s {@code ClassLoader} can load the + * named class, and the {@code Notification} is an {@linkplain Class#isInstance + * instance} of that class. + *
+ * + *

These are the only {@code MBeanServer} methods that are needed to + * evaluate standard queries. The behavior of the other {@code MBeanServer} + * methods is unspecified.

+ * + * @since 1.7 + */ +public class QueryNotificationFilter implements NotificationFilter { + private static final long serialVersionUID = -8408613922660635231L; + + private static final ObjectName DEFAULT_NAME = + Util.newObjectName(":type=Notification"); + private static final QueryExp trueQuery; + static { + ValueExp zero = Query.value(0); + trueQuery = Query.eq(zero, zero); + } + + private final QueryExp query; + + /** + * Construct a {@code QueryNotificationFilter} that evaluates the given + * {@code QueryExp} to determine whether to accept a notification. + * + * @param query the {@code QueryExp} to evaluate. Can be null, + * in which case all notifications are accepted. + */ + public QueryNotificationFilter(QueryExp query) { + if (query == null) + this.query = trueQuery; + else + this.query = query; + } + + /** + * Construct a {@code QueryNotificationFilter} that evaluates the query + * in the given string to determine whether to accept a notification. + * The string is converted into a {@code QueryExp} using + * {@link Query#fromString Query.fromString}. + * + * @param query the string specifying the query to evaluate. Can be null, + * in which case all notifications are accepted. + * + * @throws IllegalArgumentException if the string is not a valid + * query string. + */ + public QueryNotificationFilter(String query) { + this(Query.fromString(query)); + } + + /** + *

Construct a {@code QueryNotificationFilter} that evaluates the query + * in the given string to determine whether to accept a notification, + * and where the notification must also be an instance of the given class. + * The string is converted into a {@code QueryExp} using + * {@link Query#fromString Query.fromString}.

+ * + * @param notifClass the class that the notification must be an instance of. + * Cannot be null. + * + * @param query the string specifying the query to evaluate. Can be null, + * in which case all notifications are accepted. + * + * @throws IllegalArgumentException if the string is not a valid + * query string, or if {@code notifClass} is null. + */ + public QueryNotificationFilter( + Class notifClass, String query) { + this(Query.and(Query.isInstanceOf(Query.value(notNull(notifClass).getName())), + Query.fromString(query))); + } + + private static T notNull(T x) { + if (x == null) + throw new IllegalArgumentException("Null argument"); + return x; + } + + /** + * Retrieve the query that this notification filter will evaluate for + * each notification. + * + * @return the query. + */ + public QueryExp getQuery() { + return query; + } + + public boolean isNotificationEnabled(Notification notification) { + ObjectName name; + + Object source = notification.getSource(); + if (source instanceof ObjectName) + name = (ObjectName) source; + else + name = DEFAULT_NAME; + + MBS mbsImpl = new MBS(notification, name); + MBeanServer mbs = (MBeanServer) Proxy.newProxyInstance( + MBeanServer.class.getClassLoader(), + new Class[] {MBeanServer.class}, + new ForwardIH(mbsImpl)); + return evalQuery(query, mbs, name); + } + + private static boolean evalQuery( + QueryExp query, MBeanServer mbs, ObjectName name) { + MBeanServer oldMBS = QueryEval.getMBeanServer(); + try { + if (mbs != null) + query.setMBeanServer(mbs); + return query.apply(name); + } catch (Exception e) { + return false; + } finally { + query.setMBeanServer(oldMBS); + } + } + + private static class ForwardIH implements InvocationHandler { + private final MBS mbs; + + ForwardIH(MBS mbs) { + this.mbs = mbs; + } + + public Object invoke(Object proxy, Method method, Object[] args) + throws Throwable { + Method forward; + try { + forward = MBS.class.getMethod( + method.getName(), method.getParameterTypes()); + } catch (NoSuchMethodException e) { + throw new UnsupportedOperationException(method.getName()); + } + try { + return forward.invoke(mbs, args); + } catch (InvocationTargetException e) { + throw e.getCause(); + } + } + } + + private static class MBS { + private final Notification notification; + private final ObjectName objectName; + private final ObjectInstance objectInstance; + private volatile DynamicMBean mbean; + + MBS(Notification n, ObjectName name) { + this.notification = n; + this.objectName = name; + this.objectInstance = new ObjectInstance(name, n.getClass().getName()); + } + + private void checkName(ObjectName name) throws InstanceNotFoundException { + if (!objectName.equals(name)) + throw new InstanceNotFoundException(String.valueOf(name)); + } + + private DynamicMBean mbean(ObjectName name) + throws InstanceNotFoundException, ReflectionException { + if (mbean == null) { + try { + mbean = new NotificationMBeanSupport(notification); + } catch (NotCompliantMBeanException e) { + throw new ReflectionException(e); + } + } + return mbean; + } + + public ObjectInstance getObjectInstance(ObjectName name) + throws InstanceNotFoundException { + checkName(name); + return objectInstance; + } + + public Set queryMBeans(ObjectName name, QueryExp query) { + Set names = queryNames(name, query); + switch (names.size()) { + case 0: + return Collections.emptySet(); + case 1: + return Collections.singleton(objectInstance); + default: + throw new UnsupportedOperationException("Internal error"); + } + } + + public Set queryNames(ObjectName name, QueryExp query) { + if ((name != null && !name.apply(objectName)) || + (query != null && !evalQuery(query, null, name))) + return Collections.emptySet(); + return Collections.singleton(objectName); + } + + public boolean isRegistered(ObjectName name) { + return objectName.equals(name); + } + + public Integer getMBeanCount() { + return 1; + } + + public Object getAttribute(ObjectName name, String attribute) + throws MBeanException, AttributeNotFoundException, + InstanceNotFoundException, ReflectionException { + return mbean(name).getAttribute(attribute); + } + + public AttributeList getAttributes(ObjectName name, String[] attributes) + throws InstanceNotFoundException, ReflectionException { + return mbean(name).getAttributes(attributes); + } + + public String getDefaultDomain() { + return objectName.getDomain(); + } + + public String[] getDomains() { + return new String[] {objectName.getDomain()}; + } + + public MBeanInfo getMBeanInfo(ObjectName name) + throws InstanceNotFoundException, ReflectionException { + return mbean(name).getMBeanInfo(); + } + + public boolean isInstanceOf(ObjectName name, String className) + throws InstanceNotFoundException { + try { + mbean(name); + ClassLoader loader = notification.getClass().getClassLoader(); + Class c = Class.forName(className, false, loader); + return c.isInstance(notification); + } catch (ReflectionException e) { + return false; + } catch (ClassNotFoundException e) { + return false; + } + } + + public ClassLoader getClassLoaderFor(ObjectName mbeanName) + throws InstanceNotFoundException { + checkName(mbeanName); + return notification.getClass().getClassLoader(); + } + } +} diff --git a/jdk/test/javax/management/query/QueryNotifFilterTest.java b/jdk/test/javax/management/query/QueryNotifFilterTest.java new file mode 100644 index 00000000000..b22bf1baa5f --- /dev/null +++ b/jdk/test/javax/management/query/QueryNotifFilterTest.java @@ -0,0 +1,347 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test QueryNotifFilterTest + * @bug 6610917 + * @summary Test the QueryNotificationFilter class + * @author Eamonn McManus + */ + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import javax.management.Attribute; +import javax.management.AttributeChangeNotification; +import javax.management.MBeanAttributeInfo; +import javax.management.MBeanInfo; +import javax.management.MBeanServer; +import javax.management.MalformedObjectNameException; +import javax.management.Notification; +import javax.management.NotificationFilter; +import javax.management.ObjectInstance; +import javax.management.ObjectName; +import javax.management.Query; +import javax.management.QueryEval; +import javax.management.QueryExp; +import javax.management.QueryNotificationFilter; + +public class QueryNotifFilterTest { + private static class Case { + final Notification notif; + final QueryExp query; + final boolean expect; + final Class notifClass; + Case(Notification notif, String query, boolean expect) { + this(notif, query, notif.getClass(), expect); + } + Case(Notification notif, String query, + Class notifClass, boolean expect) { + this(notif, Query.fromString(query), notifClass, expect); + } + Case(Notification notif, QueryExp query, boolean expect) { + this(notif, query, notif.getClass(), expect); + } + Case(Notification notif, QueryExp query, + Class notifClass, boolean expect) { + this.notif = notif; + this.query = query; + this.expect = expect; + this.notifClass = notifClass; + } + } + + /* In principle users can create their own implementations of QueryExp + * and use them with QueryNotificationFilter. If they do so, then + * they can call any MBeanServer method. Not all of those methods + * will work with the special MBeanServer we concoct to analyze a + * Notification, but some will, including some that are not called + * by the standard queries. So we check each of those cases too. + */ + private static class ExoticCase { + final Notification trueNotif; + final Notification falseNotif; + final QueryExp query; + ExoticCase(Notification trueNotif, Notification falseNotif, QueryExp query) { + this.trueNotif = trueNotif; + this.falseNotif = falseNotif; + this.query = query; + } + } + + private static abstract class ExoticQuery + extends QueryEval implements QueryExp { + private final String queryString; + ExoticQuery(String queryString) { + this.queryString = queryString; + } + abstract boolean apply(MBeanServer mbs, ObjectName name) throws Exception; + @Override + public boolean apply(ObjectName name) { + try { + return apply(getMBeanServer(), name); + } catch (Exception e) { + e.printStackTrace(System.out); + return false; + } + } + @Override + public String toString() { + return queryString; + } + } + + private static ObjectName makeObjectName(String s) { + try { + return new ObjectName(s); + } catch (MalformedObjectNameException e) { + throw new RuntimeException(e); + } + } + + public static class CustomNotification extends Notification { + public CustomNotification(String type, Object source, long seqNo) { + super(type, source, seqNo); + } + + public String getName() { + return "claude"; + } + + public boolean isInteresting() { + return true; + } + } + + private static final Notification simpleNotif = + new Notification("mytype", "source", 0L); + private static final Notification attrChangeNotif = + new AttributeChangeNotification( + "x", 0L, 0L, "msg", "AttrName", "int", 2, 3); + private static final ObjectName testObjectName = makeObjectName("a:b=c"); + private static final Notification sourcedNotif = + new Notification("mytype", testObjectName, 0L); + private static final Notification customNotif = + new CustomNotification("mytype", testObjectName, 0L); + + private static final Case[] testCases = { + new Case(simpleNotif, "Type = 'mytype'", true), + new Case(simpleNotif, "Type = 'mytype'", + Notification.class, true), + new Case(simpleNotif, "Type = 'mytype'", + AttributeChangeNotification.class, false), + new Case(simpleNotif, "Type != 'mytype'", false), + new Case(simpleNotif, "Type = 'somethingelse'", false), + new Case(attrChangeNotif, "AttributeName = 'AttrName'", true), + new Case(attrChangeNotif, + "instanceof 'javax.management.AttributeChangeNotification'", + true), + new Case(attrChangeNotif, + "instanceof 'javax.management.Notification'", + true), + new Case(attrChangeNotif, + "instanceof 'javax.management.relation.MBeanServerNotification'", + false), + new Case(attrChangeNotif, + "class = 'javax.management.AttributeChangeNotification'", + true), + new Case(attrChangeNotif, + "javax.management.AttributeChangeNotification#AttributeName = 'AttrName'", + true), + new Case(sourcedNotif, + testObjectName, + true), + new Case(sourcedNotif, + makeObjectName("a*:b=*"), + true), + new Case(sourcedNotif, + makeObjectName("a*:c=*"), + false), + new Case(customNotif, "Name = 'claude'", true), + new Case(customNotif, "Name = 'tiddly'", false), + new Case(customNotif, "Interesting = true", true), + new Case(customNotif, "Interesting = false", false), + }; + + private static final ExoticCase[] exoticTestCases = { + new ExoticCase( + simpleNotif, new Notification("notmytype", "source", 0L), + new ExoticQuery("getAttributes") { + boolean apply(MBeanServer mbs, ObjectName name) + throws Exception { + List attrs = mbs.getAttributes( + name, new String[] {"Type", "Source"}).asList(); + return (attrs.get(0).equals(new Attribute("Type", "mytype")) && + attrs.get(1).equals(new Attribute("Source", "source"))); + } + }), + new ExoticCase( + new Notification("mytype", "source", 0L) {}, + simpleNotif, + new ExoticQuery("getClassLoaderFor") { + boolean apply(MBeanServer mbs, ObjectName name) + throws Exception { + return (mbs.getClassLoaderFor(name) == + this.getClass().getClassLoader()); + } + }), + new ExoticCase( + sourcedNotif, simpleNotif, + new ExoticQuery("getDomains") { + boolean apply(MBeanServer mbs, ObjectName name) + throws Exception { + return Arrays.equals(mbs.getDomains(), + new String[] {testObjectName.getDomain()}); + } + }), + new ExoticCase( + simpleNotif, attrChangeNotif, + new ExoticQuery("getMBeanInfo") { + boolean apply(MBeanServer mbs, ObjectName name) + throws Exception { + MBeanInfo mbi = mbs.getMBeanInfo(name); + // If we ever add a constructor to Notification then + // we will have to change the 4 below. + if (mbi.getOperations().length > 0 || + mbi.getConstructors().length != 4 || + mbi.getNotifications().length > 0) + return false; + Set expect = new HashSet( + Arrays.asList( + "Class", "Message", "SequenceNumber", "Source", + "TimeStamp", "Type", "UserData")); + Set actual = new HashSet(); + for (MBeanAttributeInfo mbai : mbi.getAttributes()) + actual.add(mbai.getName()); + return actual.equals(expect); + } + }), + new ExoticCase( + simpleNotif, attrChangeNotif, + new ExoticQuery("getObjectInstance") { + boolean apply(MBeanServer mbs, ObjectName name) + throws Exception { + ObjectInstance oi = mbs.getObjectInstance(name); + return oi.getClassName().equals(Notification.class.getName()); + } + }), + new ExoticCase( + sourcedNotif, simpleNotif, + new ExoticQuery("queryNames") { + boolean apply(MBeanServer mbs, ObjectName name) + throws Exception { + Set names = mbs.queryNames(null, + Query.eq(Query.attr("Type"), Query.value("mytype"))); + return names.equals(Collections.singleton(testObjectName)); + } + }), + new ExoticCase( + sourcedNotif, simpleNotif, + new ExoticQuery("queryMBeans") { + boolean apply(MBeanServer mbs, ObjectName name) + throws Exception { + Set insts = mbs.queryMBeans(null, + Query.eq(Query.attr("Type"), Query.value("mytype"))); + if (insts.size() != 1) + return false; + ObjectInstance inst = insts.iterator().next(); + return (inst.getObjectName().equals(testObjectName) && + inst.getClassName().equals(Notification.class.getName())); + } + }), + }; + + private static enum Test { + QUERY_EXP("query"), STRING("string"), STRING_PLUS_CLASS("string with class"); + private final String name; + Test(String name) { + this.name = name; + } + @Override + public String toString() { + return name; + } + } + + public static void main(String[] args) throws Exception { + boolean allok = true; + for (Case testCase : testCases) { + for (Test test : Test.values()) { + QueryNotificationFilter nf; + String queryString; + switch (test) { + case QUERY_EXP: { + QueryExp inst = Query.isInstanceOf( + Query.value(testCase.notifClass.getName())); + QueryExp and = Query.and(inst, testCase.query); + queryString = Query.toString(and); + nf = new QueryNotificationFilter(and); + break; + } + case STRING: { + String s = "instanceof '" + testCase.notifClass.getName() + "'"; + queryString = s + " and " + Query.toString(testCase.query); + nf = new QueryNotificationFilter(queryString); + break; + } + case STRING_PLUS_CLASS: + queryString = null; + nf = new QueryNotificationFilter( + testCase.notifClass, Query.toString(testCase.query)); + break; + default: + throw new AssertionError(); + } + boolean accept = nf.isNotificationEnabled(testCase.notif); + if (queryString != null) { + queryString = Query.toString(Query.fromString(queryString)); + if (!queryString.equals(Query.toString(nf.getQuery()))) { + System.out.println("FAIL: query string mismatch: expected " + + "\"" + queryString + "\", got \"" + + Query.toString(nf.getQuery())); + allok = false; + } + } + boolean ok = (accept == testCase.expect); + System.out.println((ok ? "pass" : "FAIL") + ": " + + testCase.query + " (" + test + ")"); + allok &= ok; + } + } + for (ExoticCase testCase : exoticTestCases) { + NotificationFilter nf = new QueryNotificationFilter(testCase.query); + for (boolean expect : new boolean[] {true, false}) { + Notification n = expect ? testCase.trueNotif : testCase.falseNotif; + boolean accept = nf.isNotificationEnabled(n); + boolean ok = (accept == expect); + System.out.println((ok ? "pass" : "FAIL") + ": " + + testCase.query + ": " + n); + allok &= ok; + } + } + if (!allok) + throw new Exception("TEST FAILED"); + } +} From 4cab019dcbc76ce9008dcdb81617eb1f2e4849e5 Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 16:33:56 +0200 Subject: [PATCH 41/54] Added tag jdk7-b24 for changeset 1cc8dd79fd1c --- .hgtags | 1 + 1 file changed, 1 insertion(+) create mode 100644 .hgtags diff --git a/.hgtags b/.hgtags new file mode 100644 index 00000000000..b80715a46ad --- /dev/null +++ b/.hgtags @@ -0,0 +1 @@ +1cc8dd79fd1cd13d36b385196271a29632c67c3b jdk7-b24 From d045aa8a11f8645a608e43066ebabe2e95a1d07a Mon Sep 17 00:00:00 2001 From: Xiomara Jayasena Date: Wed, 9 Apr 2008 11:19:07 -0700 Subject: [PATCH 42/54] Added tag jdk7-b25 for changeset 8d655ddd5a03 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 898e4a75668..6eaa20bbab7 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -1 +1,2 @@ 37a05a11f281b4d238e2f9e7ebb67c63f64d0e77 jdk7-b24 +75fca0b0ab83ab1392e615910cea020f66535390 jdk7-b25 From da0bf7574c827a7a33d02dbedccb9406e04be2d1 Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Thu, 10 Apr 2008 09:02:22 -0700 Subject: [PATCH 43/54] 6684582: Launcher needs improved error reporting Indicate the missing main class in the error message Reviewed-by: darcy, kbr --- jdk/src/share/bin/emessages.h | 4 +-- jdk/src/share/bin/java.c | 6 ++-- jdk/test/tools/launcher/Arrrghs.java | 32 +++++++++------------ jdk/test/tools/launcher/Arrrghs.sh | 43 ++++++++++++++++++++++++++-- 4 files changed, 60 insertions(+), 25 deletions(-) diff --git a/jdk/src/share/bin/emessages.h b/jdk/src/share/bin/emessages.h index f11c396ad60..03824bba5d1 100644 --- a/jdk/src/share/bin/emessages.h +++ b/jdk/src/share/bin/emessages.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ #define JAR_ERROR2 "Error: Unable to access jarfile %s" #define JAR_ERROR3 "Error: Invalid or corrupt jarfile %s" -#define CLS_ERROR1 "Error: Could not find the main class.\n" JNI_ERROR +#define CLS_ERROR1 "Error: Could not find the main class %s.\n" JNI_ERROR #define CLS_ERROR2 "Error: Failed to load Main Class: %s\n%s" #define CLS_ERROR3 "Error: No main method found in specified class.\n" GEN_ERROR #define CLS_ERROR4 "Error: Main method not public\n" GEN_ERROR diff --git a/jdk/src/share/bin/java.c b/jdk/src/share/bin/java.c index 47c2fc17cd0..f7cbcdc95bc 100644 --- a/jdk/src/share/bin/java.c +++ b/jdk/src/share/bin/java.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -414,7 +414,7 @@ JavaMain(void * _args) mainClass = LoadClass(env, classname); if(mainClass == NULL) { /* exception occured */ ReportExceptionDescription(env); - ReportErrorMessage(CLS_ERROR1); + ReportErrorMessage(CLS_ERROR1, classname); goto leave; } (*env)->ReleaseStringUTFChars(env, mainClassName, classname); @@ -433,7 +433,7 @@ JavaMain(void * _args) mainClass = LoadClass(env, classname); if(mainClass == NULL) { /* exception occured */ ReportExceptionDescription(env); - ReportErrorMessage(CLS_ERROR1); + ReportErrorMessage(CLS_ERROR1, classname); goto leave; } (*env)->ReleaseStringUTFChars(env, mainClassName, classname); diff --git a/jdk/test/tools/launcher/Arrrghs.java b/jdk/test/tools/launcher/Arrrghs.java index 8f93df67198..34bfcee369b 100644 --- a/jdk/test/tools/launcher/Arrrghs.java +++ b/jdk/test/tools/launcher/Arrrghs.java @@ -1,17 +1,5 @@ -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - /* - * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,8 +21,19 @@ import java.util.StringTokenizer; * have any questions. */ +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; -public class Arrrghs{ +public class Arrrghs { /** * A group of tests to ensure that arguments are passed correctly to @@ -113,12 +112,10 @@ public class Arrrghs{ return retval; } - - private static boolean doExec0(ProcessBuilder pb, String expectedArguments) { boolean retval = false; try { - pb.redirectErrorStream(_debug); + pb.redirectErrorStream(true); Process p = pb.start(); retval = detectCookie(p.getInputStream(), expectedArguments); p.waitFor(); @@ -167,7 +164,6 @@ public class Arrrghs{ } } - if (_debug) System.out.println("Starting Arrrghs tests"); // Basic test if (!doExec("-a -b -c -d")) exitValue++; diff --git a/jdk/test/tools/launcher/Arrrghs.sh b/jdk/test/tools/launcher/Arrrghs.sh index c2fe084d02f..f5ee6b0a75b 100644 --- a/jdk/test/tools/launcher/Arrrghs.sh +++ b/jdk/test/tools/launcher/Arrrghs.sh @@ -1,13 +1,13 @@ #!/bin/sh # @test Arrrghs.sh -# @bug 5030233 6214916 6356475 6571029 +# @bug 5030233 6214916 6356475 6571029 6684582 # @build Arrrghs # @run shell Arrrghs.sh # @summary Argument parsing validation. # @author Joseph E. Kowalski # -# Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved. +# Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -103,6 +103,44 @@ TestHelp() { fi } +# +# Test to ensure that a missing main class is indicated in the error message +# +TestMissingMainClass() { + # First create a small jar file with no main + printf "public class Foo {}\n" > Foo.java + $TESTJAVA/bin/javac Foo.java + if [ $? -ne 0 ]; then + printf "Error: compilation of Foo.java failed\n" + exit 1 + fi + printf "Main-Class: Bar\n" > manifest + $TESTJAVA/bin/jar -cvfm some.jar manifest Foo.class + if [ ! -f some.jar ]; then + printf "Error: did not find some.jar\n" + exit 1 + fi + + # test a non-existence main-class using -jar + mess="`$TESTJAVA/bin/java -jar some.jar 2>&1 1>/dev/null`" + echo $mess | grep 'Bar' 2>&1 > /dev/null + if [ $? -ne 0 ]; then + printf "Error: did not find main class missing message\n" + exit 1 + fi + + # test a non-existent main-class using classpath + mess="`$TESTJAVA/bin/java -cp some.jar Bar 2>&1 1>/dev/null`" + echo $mess | grep 'Bar' 2>&1 > /dev/null + if [ $? -ne 0 ]; then + printf "Error: did not find main class missing message\n" + exit 1 + fi + + # cleanup + rm -f some.jar Foo.* manifest +} + # # Main processing: # @@ -117,6 +155,7 @@ TestCP javac -cp TestCP javac -classpath TestXUsage TestHelp +TestMissingMainClass # # Tests for 6214916 From 98ecfdaa4705f9b995d376126c0893c9c4730a1b Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Thu, 10 Apr 2008 10:47:13 -0700 Subject: [PATCH 44/54] 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031) Add new methods in ManagementFactory class to obtain platform MXBeans Reviewed-by: alanb, dfuchs, emcmanus --- .../management/HotSpotDiagnosticMXBean.java | 9 +- .../lang/management/ClassLoadingMXBean.java | 8 +- .../lang/management/CompilationMXBean.java | 6 +- .../management/GarbageCollectorMXBean.java | 4 + .../lang/management/ManagementFactory.java | 201 +++++++- .../java/lang/management/MemoryMXBean.java | 6 +- .../lang/management/MemoryManagerMXBean.java | 6 +- .../lang/management/MemoryPoolMXBean.java | 6 +- .../management/OperatingSystemMXBean.java | 6 +- .../lang/management/PlatformComponent.java | 382 ++++++++++++++ .../management/PlatformManagedObject.java | 61 +++ .../java/lang/management/RuntimeMXBean.java | 6 +- .../java/lang/management/ThreadInfo.java | 10 +- .../java/lang/management/ThreadMXBean.java | 6 +- .../classes/java/util/logging/Logging.java | 5 + .../java/util/logging/LoggingMXBean.java | 9 +- .../sun/management/ClassLoadingImpl.java | 8 +- .../sun/management/CompilationImpl.java | 9 +- .../sun/management/GarbageCollectorImpl.java | 5 + .../classes/sun/management/GcInfoBuilder.java | 2 +- .../sun/management/GcInfoCompositeData.java | 20 +- .../sun/management/HotSpotDiagnostic.java | 8 +- .../sun/management/HotspotCompilation.java | 2 +- .../sun/management/HotspotInternal.java | 9 +- .../sun/management/LockDataConverter.java | 8 +- .../sun/management/ManagementFactory.java | 467 +----------------- .../management/ManagementFactoryHelper.java | 340 +++++++++++++ .../sun/management/MappedMXBeanType.java | 14 +- .../classes/sun/management/MemoryImpl.java | 23 +- .../sun/management/MemoryManagerImpl.java | 7 + .../MemoryNotifInfoCompositeData.java | 4 +- .../sun/management/MemoryPoolImpl.java | 18 +- .../management/MemoryUsageCompositeData.java | 4 +- .../management/MonitorInfoCompositeData.java | 4 +- .../NotificationEmitterSupport.java | 2 +- .../sun/management/OperatingSystemImpl.java | 7 + .../classes/sun/management/RuntimeImpl.java | 11 +- .../StackTraceElementCompositeData.java | 4 +- .../classes/sun/management/ThreadImpl.java | 27 +- .../management/ThreadInfoCompositeData.java | 4 +- .../share/classes/sun/management/Util.java | 80 +-- .../sun/management/VMManagementImpl.java | 4 +- .../sun/management/VMOptionCompositeData.java | 4 +- .../HotSpotDiagnosticMXBean/DumpHeap.java | 6 +- .../GetDiagnosticOptions.java | 5 +- .../HotSpotDiagnosticMXBean/GetVMOption.java | 6 +- .../HotSpotDiagnosticMXBean/SetVMOption.java | 7 +- .../ManagementFactory/GetPlatformMXBeans.java | 180 +++++++ .../PlatformMXBeanTest.java | 69 +++ 49 files changed, 1484 insertions(+), 615 deletions(-) create mode 100644 jdk/src/share/classes/java/lang/management/PlatformComponent.java create mode 100644 jdk/src/share/classes/java/lang/management/PlatformManagedObject.java create mode 100644 jdk/src/share/classes/sun/management/ManagementFactoryHelper.java create mode 100644 jdk/test/java/lang/management/ManagementFactory/GetPlatformMXBeans.java create mode 100644 jdk/test/java/lang/management/OperatingSystemMXBean/PlatformMXBeanTest.java diff --git a/jdk/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java b/jdk/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java index 45c1b55a861..f736dc500bd 100644 --- a/jdk/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java +++ b/jdk/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java @@ -25,6 +25,8 @@ package com.sun.management; +import java.lang.management.PlatformManagedObject; + /** * Diagnostic management interface for the HotSpot Virtual Machine. * The diagnostic MBean is registered to the platform MBeanServer @@ -35,8 +37,13 @@ package com.sun.management; *
* com.sun.management:type=HotSpotDiagnostic *
+.* + * It can be obtained by calling the + * {@link PlatformManagedObject#getObjectName} method. + * + * @see ManagementFactory#getPlatformMXBeans(Class) */ -public interface HotSpotDiagnosticMXBean { +public interface HotSpotDiagnosticMXBean extends PlatformManagedObject { /** * Dumps the heap to the outputFile file in the same * format as the hprof heap dump. diff --git a/jdk/src/share/classes/java/lang/management/ClassLoadingMXBean.java b/jdk/src/share/classes/java/lang/management/ClassLoadingMXBean.java index 62f31e48769..762e14cb2f5 100644 --- a/jdk/src/share/classes/java/lang/management/ClassLoadingMXBean.java +++ b/jdk/src/share/classes/java/lang/management/ClassLoadingMXBean.java @@ -35,7 +35,7 @@ package java.lang.management; * that can be obtained by calling * the {@link ManagementFactory#getClassLoadingMXBean} method or * from the {@link ManagementFactory#getPlatformMBeanServer - * platform MBeanServer} method. + * platform MBeanServer}. * *

The ObjectName for uniquely identifying the MXBean for * the class loading system within an MBeanServer is: @@ -44,6 +44,10 @@ package java.lang.management; * java.lang:type=ClassLoading} * * + * It can be obtained by calling the + * {@link PlatformManagedObject#getObjectName} method. + * + * @see ManagementFactory#getPlatformMXBeans(Class) * @see * JMX Specification. * @see @@ -52,7 +56,7 @@ package java.lang.management; * @author Mandy Chung * @since 1.5 */ -public interface ClassLoadingMXBean { +public interface ClassLoadingMXBean extends PlatformManagedObject { /** * Returns the total number of classes that have been loaded since diff --git a/jdk/src/share/classes/java/lang/management/CompilationMXBean.java b/jdk/src/share/classes/java/lang/management/CompilationMXBean.java index 94f97bb4507..ea93a2b0ccb 100644 --- a/jdk/src/share/classes/java/lang/management/CompilationMXBean.java +++ b/jdk/src/share/classes/java/lang/management/CompilationMXBean.java @@ -44,6 +44,10 @@ package java.lang.management; * java.lang:type=Compilation} * * + * It can be obtained by calling the + * {@link PlatformManagedObject#getObjectName} method. + * + * @see ManagementFactory#getPlatformMXBeans(Class) * @see * JMX Specification. * @see @@ -52,7 +56,7 @@ package java.lang.management; * @author Mandy Chung * @since 1.5 */ -public interface CompilationMXBean { +public interface CompilationMXBean extends PlatformManagedObject { /** * Returns the name of the Just-in-time (JIT) compiler. * diff --git a/jdk/src/share/classes/java/lang/management/GarbageCollectorMXBean.java b/jdk/src/share/classes/java/lang/management/GarbageCollectorMXBean.java index f737a9c2ec5..50ee93d8d79 100644 --- a/jdk/src/share/classes/java/lang/management/GarbageCollectorMXBean.java +++ b/jdk/src/share/classes/java/lang/management/GarbageCollectorMXBean.java @@ -48,9 +48,13 @@ package java.lang.management; * java.lang:type=GarbageCollector},name=collector's name * * + * It can be obtained by calling the + * {@link PlatformManagedObject#getObjectName} method. + * * A platform usually includes additional platform-dependent information * specific to a garbage collection algorithm for monitoring. * + * @see ManagementFactory#getPlatformMXBeans(Class) * @see MemoryMXBean * * @see diff --git a/jdk/src/share/classes/java/lang/management/ManagementFactory.java b/jdk/src/share/classes/java/lang/management/ManagementFactory.java index dff4f19a4e3..c9e12708ef8 100644 --- a/jdk/src/share/classes/java/lang/management/ManagementFactory.java +++ b/jdk/src/share/classes/java/lang/management/ManagementFactory.java @@ -24,17 +24,31 @@ */ package java.lang.management; +import javax.management.DynamicMBean; import javax.management.MBeanServer; import javax.management.MBeanServerConnection; +import javax.management.MBeanServerFactory; import javax.management.MBeanServerPermission; +import javax.management.NotificationEmitter; +import javax.management.ObjectInstance; import javax.management.ObjectName; +import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException; import javax.management.MalformedObjectNameException; +import javax.management.MBeanRegistrationException; +import javax.management.NotCompliantMBeanException; +import javax.management.StandardEmitterMBean; +import javax.management.StandardMBean; +import java.util.Collections; +import java.util.ArrayList; import java.util.List; import java.security.AccessController; import java.security.Permission; import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; import javax.management.JMX; +import sun.management.ManagementFactoryHelper; /** * The ManagementFactory class is a factory class for getting @@ -49,13 +63,16 @@ import javax.management.JMX; *