Fri, 18 Sep 2009 08:48:50 -0700
Merge
1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Thu Sep 17 13:47:11 2009 -0700 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Fri Sep 18 08:48:50 2009 -0700 1.3 @@ -1435,7 +1435,17 @@ 1.4 // documented, this must be an inherited link. Redirect it. 1.5 // The current class either overrides the referenced member or 1.6 // inherits it automatically. 1.7 - containing = ((ClassWriterImpl) this).getClassDoc(); 1.8 + if (this instanceof ClassWriterImpl) { 1.9 + containing = ((ClassWriterImpl) this).getClassDoc(); 1.10 + } else if (!containing.isPublic()){ 1.11 + configuration.getDocletSpecificMsg().warning( 1.12 + see.position(), "doclet.see.class_or_package_not_accessible", 1.13 + tagName, containing.qualifiedName()); 1.14 + } else { 1.15 + configuration.getDocletSpecificMsg().warning( 1.16 + see.position(), "doclet.see.class_or_package_not_found", 1.17 + tagName, seetext); 1.18 + } 1.19 } 1.20 if (configuration.currentcd != containing) { 1.21 refMemName = containing.name() + "." + refMemName;
2.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Thu Sep 17 13:47:11 2009 -0700 2.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Fri Sep 18 08:48:50 2009 -0700 2.3 @@ -69,6 +69,7 @@ 2.4 doclet.No_Package_Comment_File=For Package {0} Package.Comment file not found 2.5 doclet.No_Source_For_Class=Source information for class {0} not available. 2.6 doclet.see.class_or_package_not_found=Tag {0}: reference not found: {1} 2.7 +doclet.see.class_or_package_not_accessible=Tag {0}: reference not accessible: {1} 2.8 doclet.see.malformed_tag=Tag {0}: Malformed: {1} 2.9 doclet.Inherited_API_Summary=Inherited API Summary 2.10 doclet.Deprecated_API=Deprecated API
3.1 --- a/src/share/classes/com/sun/tools/javac/code/Source.java Thu Sep 17 13:47:11 2009 -0700 3.2 +++ b/src/share/classes/com/sun/tools/javac/code/Source.java Fri Sep 18 08:48:50 2009 -0700 3.3 @@ -159,6 +159,12 @@ 3.4 public boolean allowTypeAnnotations() { 3.5 return compareTo(JDK1_7) >= 0; 3.6 } 3.7 + public boolean allowBinaryLiterals() { 3.8 + return compareTo(JDK1_7) >= 0; 3.9 + } 3.10 + public boolean allowUnderscoresInLiterals() { 3.11 + return compareTo(JDK1_7) >= 0; 3.12 + } 3.13 public static SourceVersion toSourceVersion(Source source) { 3.14 switch(source) { 3.15 case JDK1_2:
4.1 --- a/src/share/classes/com/sun/tools/javac/file/CloseableURLClassLoader.java Thu Sep 17 13:47:11 2009 -0700 4.2 +++ b/src/share/classes/com/sun/tools/javac/file/CloseableURLClassLoader.java Fri Sep 18 08:48:50 2009 -0700 4.3 @@ -69,8 +69,10 @@ 4.4 if (l.getClass().getName().equals("sun.misc.URLClassPath$JarLoader")) { 4.5 Field jarField = l.getClass().getDeclaredField("jar"); 4.6 JarFile jar = (JarFile) getField(l, jarField); 4.7 - //System.err.println("CloseableURLClassLoader: closing " + jar); 4.8 - jar.close(); 4.9 + if (jar != null) { 4.10 + //System.err.println("CloseableURLClassLoader: closing " + jar); 4.11 + jar.close(); 4.12 + } 4.13 } 4.14 } 4.15 } catch (Throwable t) {
5.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Thu Sep 17 13:47:11 2009 -0700 5.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Fri Sep 18 08:48:50 2009 -0700 5.3 @@ -593,7 +593,7 @@ 5.4 //where 5.5 boolean isZero(String s) { 5.6 char[] cs = s.toCharArray(); 5.7 - int base = ((Character.toLowerCase(s.charAt(1)) == 'x') ? 16 : 10); 5.8 + int base = ((cs.length > 1 && Character.toLowerCase(cs[1]) == 'x') ? 16 : 10); 5.9 int i = ((base==16) ? 2 : 0); 5.10 while (i < cs.length && (cs[i] == '0' || cs[i] == '.')) i++; 5.11 return !(i < cs.length && (Character.digit(cs[i], base) > 0));
6.1 --- a/src/share/classes/com/sun/tools/javac/parser/Scanner.java Thu Sep 17 13:47:11 2009 -0700 6.2 +++ b/src/share/classes/com/sun/tools/javac/parser/Scanner.java Fri Sep 18 08:48:50 2009 -0700 6.3 @@ -100,6 +100,18 @@ 6.4 */ 6.5 private boolean allowHexFloats; 6.6 6.7 + /** Allow binary literals. 6.8 + */ 6.9 + private boolean allowBinaryLiterals; 6.10 + 6.11 + /** Allow underscores in literals. 6.12 + */ 6.13 + private boolean allowUnderscoresInLiterals; 6.14 + 6.15 + /** The source language setting. 6.16 + */ 6.17 + private Source source; 6.18 + 6.19 /** The token's position, 0-based offset from beginning of text. 6.20 */ 6.21 private int pos; 6.22 @@ -162,10 +174,13 @@ 6.23 6.24 /** Common code for constructors. */ 6.25 private Scanner(Factory fac) { 6.26 - this.log = fac.log; 6.27 - this.names = fac.names; 6.28 - this.keywords = fac.keywords; 6.29 - this.allowHexFloats = fac.source.allowHexFloats(); 6.30 + log = fac.log; 6.31 + names = fac.names; 6.32 + keywords = fac.keywords; 6.33 + source = fac.source; 6.34 + allowBinaryLiterals = source.allowBinaryLiterals(); 6.35 + allowHexFloats = source.allowHexFloats(); 6.36 + allowUnderscoresInLiterals = source.allowBinaryLiterals(); 6.37 } 6.38 6.39 private static final boolean hexFloatsWork = hexFloatsWork(); 6.40 @@ -396,23 +411,42 @@ 6.41 scanLitChar(true); 6.42 } 6.43 6.44 + private void scanDigits(int digitRadix) { 6.45 + char saveCh; 6.46 + int savePos; 6.47 + do { 6.48 + if (ch != '_') { 6.49 + putChar(ch); 6.50 + } else { 6.51 + if (!allowUnderscoresInLiterals) { 6.52 + lexError("unsupported.underscore", source.name); 6.53 + allowUnderscoresInLiterals = true; 6.54 + } 6.55 + } 6.56 + saveCh = ch; 6.57 + savePos = bp; 6.58 + scanChar(); 6.59 + } while (digit(digitRadix) >= 0 || ch == '_'); 6.60 + if (saveCh == '_') 6.61 + lexError(savePos, "illegal.underscore"); 6.62 + } 6.63 + 6.64 /** Read fractional part of hexadecimal floating point number. 6.65 */ 6.66 private void scanHexExponentAndSuffix() { 6.67 if (ch == 'p' || ch == 'P') { 6.68 putChar(ch); 6.69 scanChar(); 6.70 + skipIllegalUnderscores(); 6.71 if (ch == '+' || ch == '-') { 6.72 putChar(ch); 6.73 scanChar(); 6.74 } 6.75 + skipIllegalUnderscores(); 6.76 if ('0' <= ch && ch <= '9') { 6.77 - do { 6.78 - putChar(ch); 6.79 - scanChar(); 6.80 - } while ('0' <= ch && ch <= '9'); 6.81 + scanDigits(10); 6.82 if (!allowHexFloats) { 6.83 - lexError("unsupported.fp.lit"); 6.84 + lexError("unsupported.fp.lit", source.name); 6.85 allowHexFloats = true; 6.86 } 6.87 else if (!hexFloatsWork) 6.88 @@ -438,23 +472,22 @@ 6.89 /** Read fractional part of floating point number. 6.90 */ 6.91 private void scanFraction() { 6.92 - while (digit(10) >= 0) { 6.93 - putChar(ch); 6.94 - scanChar(); 6.95 + skipIllegalUnderscores(); 6.96 + if ('0' <= ch && ch <= '9') { 6.97 + scanDigits(10); 6.98 } 6.99 int sp1 = sp; 6.100 if (ch == 'e' || ch == 'E') { 6.101 putChar(ch); 6.102 scanChar(); 6.103 + skipIllegalUnderscores(); 6.104 if (ch == '+' || ch == '-') { 6.105 putChar(ch); 6.106 scanChar(); 6.107 } 6.108 + skipIllegalUnderscores(); 6.109 if ('0' <= ch && ch <= '9') { 6.110 - do { 6.111 - putChar(ch); 6.112 - scanChar(); 6.113 - } while ('0' <= ch && ch <= '9'); 6.114 + scanDigits(10); 6.115 return; 6.116 } 6.117 lexError("malformed.fp.lit"); 6.118 @@ -487,10 +520,10 @@ 6.119 assert ch == '.'; 6.120 putChar(ch); 6.121 scanChar(); 6.122 - while (digit(16) >= 0) { 6.123 + skipIllegalUnderscores(); 6.124 + if (digit(16) >= 0) { 6.125 seendigit = true; 6.126 - putChar(ch); 6.127 - scanChar(); 6.128 + scanDigits(16); 6.129 } 6.130 if (!seendigit) 6.131 lexError("invalid.hex.number"); 6.132 @@ -498,28 +531,35 @@ 6.133 scanHexExponentAndSuffix(); 6.134 } 6.135 6.136 + private void skipIllegalUnderscores() { 6.137 + if (ch == '_') { 6.138 + lexError(bp, "illegal.underscore"); 6.139 + while (ch == '_') 6.140 + scanChar(); 6.141 + } 6.142 + } 6.143 + 6.144 /** Read a number. 6.145 - * @param radix The radix of the number; one of 8, 10, 16. 6.146 + * @param radix The radix of the number; one of 2, j8, 10, 16. 6.147 */ 6.148 private void scanNumber(int radix) { 6.149 this.radix = radix; 6.150 // for octal, allow base-10 digit in case it's a float literal 6.151 - int digitRadix = (radix <= 10) ? 10 : 16; 6.152 + int digitRadix = (radix == 8 ? 10 : radix); 6.153 boolean seendigit = false; 6.154 - while (digit(digitRadix) >= 0) { 6.155 + if (digit(digitRadix) >= 0) { 6.156 seendigit = true; 6.157 - putChar(ch); 6.158 - scanChar(); 6.159 + scanDigits(digitRadix); 6.160 } 6.161 if (radix == 16 && ch == '.') { 6.162 scanHexFractionAndSuffix(seendigit); 6.163 } else if (seendigit && radix == 16 && (ch == 'p' || ch == 'P')) { 6.164 scanHexExponentAndSuffix(); 6.165 - } else if (radix <= 10 && ch == '.') { 6.166 + } else if (digitRadix == 10 && ch == '.') { 6.167 putChar(ch); 6.168 scanChar(); 6.169 scanFractionAndSuffix(); 6.170 - } else if (radix <= 10 && 6.171 + } else if (digitRadix == 10 && 6.172 (ch == 'e' || ch == 'E' || 6.173 ch == 'f' || ch == 'F' || 6.174 ch == 'd' || ch == 'D')) { 6.175 @@ -821,6 +861,7 @@ 6.176 scanChar(); 6.177 if (ch == 'x' || ch == 'X') { 6.178 scanChar(); 6.179 + skipIllegalUnderscores(); 6.180 if (ch == '.') { 6.181 scanHexFractionAndSuffix(false); 6.182 } else if (digit(16) < 0) { 6.183 @@ -828,8 +869,25 @@ 6.184 } else { 6.185 scanNumber(16); 6.186 } 6.187 + } else if (ch == 'b' || ch == 'B') { 6.188 + if (!allowBinaryLiterals) { 6.189 + lexError("unsupported.binary.lit", source.name); 6.190 + allowBinaryLiterals = true; 6.191 + } 6.192 + scanChar(); 6.193 + skipIllegalUnderscores(); 6.194 + scanNumber(2); 6.195 } else { 6.196 putChar('0'); 6.197 + if (ch == '_') { 6.198 + int savePos = bp; 6.199 + do { 6.200 + scanChar(); 6.201 + } while (ch == '_'); 6.202 + if (digit(10) < 0) { 6.203 + lexError(savePos, "illegal.underscore"); 6.204 + } 6.205 + } 6.206 scanNumber(8); 6.207 } 6.208 return;
7.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Sep 17 13:47:11 2009 -0700 7.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Sep 18 08:48:50 2009 -0700 7.3 @@ -216,6 +216,8 @@ 7.4 illegal line end in character literal 7.5 compiler.err.illegal.nonascii.digit=\ 7.6 illegal non-ASCII digit 7.7 +compiler.err.illegal.underscore=\ 7.8 + illegal underscore 7.9 compiler.err.illegal.qual.not.icls=\ 7.10 illegal qualifier; {0} is not an inner class 7.11 compiler.err.illegal.start.of.expr=\ 7.12 @@ -1163,7 +1165,16 @@ 7.13 # Diagnostics for language feature changes 7.14 ######################################## 7.15 compiler.err.unsupported.fp.lit=\ 7.16 - hexadecimal floating-point literals are not supported before -source 5 7.17 + hexadecimal floating point literals are not supported in -source {0}\n\ 7.18 +(use -source 5 or higher to enable hexadecimal floating point literals) 7.19 + 7.20 +compiler.err.unsupported.binary.lit=\ 7.21 + binary literals are not supported in -source {0}\n\ 7.22 +(use -source 7 or higher to enable binary literals) 7.23 + 7.24 +compiler.err.unsupported.underscore.lit=\ 7.25 + underscores in literals are not supported in -source {0}\n\ 7.26 +(use -source 7 or higher to enable underscores in literals) 7.27 7.28 compiler.warn.enum.as.identifier=\ 7.29 as of release 5, ''enum'' is a keyword, and may not be used as an identifier\n\
8.1 --- a/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java Thu Sep 17 13:47:11 2009 -0700 8.2 +++ b/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java Fri Sep 18 08:48:50 2009 -0700 8.3 @@ -60,7 +60,12 @@ 8.4 */ 8.5 public AnnotationTypeDoc annotationType() { 8.6 ClassSymbol atsym = (ClassSymbol)annotation.type.tsym; 8.7 - return (AnnotationTypeDoc)env.getClassDoc(atsym); 8.8 + if (annotation.type.isErroneous()) { 8.9 + env.warning(null, "javadoc.class_not_found", annotation.type.toString()); 8.10 + return new AnnotationTypeDocImpl(env, atsym); 8.11 + } else { 8.12 + return (AnnotationTypeDoc)env.getClassDoc(atsym); 8.13 + } 8.14 } 8.15 8.16 /**
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/test/com/sun/javadoc/5093723/DocumentedClass.java Fri Sep 18 08:48:50 2009 -0700 9.3 @@ -0,0 +1,34 @@ 9.4 +/* 9.5 + * Copyright 2009 Google, Inc. All Rights Reserved. 9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.7 + * 9.8 + * This code is free software; you can redistribute it and/or modify it 9.9 + * under the terms of the GNU General Public License version 2 only, as 9.10 + * published by the Free Software Foundation. 9.11 + * 9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 9.15 + * version 2 for more details (a copy is included in the LICENSE file that 9.16 + * accompanied this code). 9.17 + * 9.18 + * You should have received a copy of the GNU General Public License version 9.19 + * 2 along with this work; if not, write to the Free Software Foundation, 9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 9.21 + * 9.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 9.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 9.24 + * have any questions. 9.25 + */ 9.26 + 9.27 +/** A documented class. */ 9.28 +public class DocumentedClass extends UndocumentedClass { 9.29 + /** {@link #method} */ 9.30 + public void m1() {} 9.31 + /** {@link #publicMethod} */ 9.32 + public void m2() {} 9.33 + /** {@link #protectedMethod} */ 9.34 + public void m3() {} 9.35 + /** {@link #privateMethod} */ 9.36 + public void m4() {} 9.37 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/com/sun/javadoc/5093723/T5093723.java Fri Sep 18 08:48:50 2009 -0700 10.3 @@ -0,0 +1,57 @@ 10.4 +/* 10.5 + * Copyright 2009 Google, Inc. All Rights Reserved. 10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.7 + * 10.8 + * This code is free software; you can redistribute it and/or modify it 10.9 + * under the terms of the GNU General Public License version 2 only, as 10.10 + * published by the Free Software Foundation. 10.11 + * 10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.15 + * version 2 for more details (a copy is included in the LICENSE file that 10.16 + * accompanied this code). 10.17 + * 10.18 + * You should have received a copy of the GNU General Public License version 10.19 + * 2 along with this work; if not, write to the Free Software Foundation, 10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.21 + * 10.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 10.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 10.24 + * have any questions. 10.25 + */ 10.26 + 10.27 +/* 10.28 + * @test 10.29 + * @bug 5093723 10.30 + * @summary REGRESSION: ClassCastException in SingleIndexWriter 10.31 + * @library ../lib/ 10.32 + * @build JavadocTester 10.33 + * @build T5093723 10.34 + * @run main T5093723 10.35 + */ 10.36 + 10.37 +public class T5093723 extends JavadocTester { 10.38 + 10.39 + private static final String BUG_ID = "5093723"; 10.40 + 10.41 + private static final String[] ARGS = new String[] { 10.42 + "-d", BUG_ID + ".out", "-source", "5", 10.43 + SRC_DIR + "/DocumentedClass.java", 10.44 + SRC_DIR + "/UndocumentedClass.java" 10.45 + }; 10.46 + 10.47 + public static void main(String... args) { 10.48 + T5093723 tester = new T5093723(); 10.49 + if (tester.runJavadoc(ARGS) != 0) 10.50 + throw new AssertionError("non-zero return code from javadoc"); 10.51 + } 10.52 + 10.53 + public String getBugId() { 10.54 + return BUG_ID; 10.55 + } 10.56 + 10.57 + public String getBugName() { 10.58 + return getClass().getName(); 10.59 + } 10.60 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/com/sun/javadoc/5093723/UndocumentedClass.java Fri Sep 18 08:48:50 2009 -0700 11.3 @@ -0,0 +1,29 @@ 11.4 +/* 11.5 + * Copyright 2009 Google, Inc. All Rights Reserved. 11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.7 + * 11.8 + * This code is free software; you can redistribute it and/or modify it 11.9 + * under the terms of the GNU General Public License version 2 only, as 11.10 + * published by the Free Software Foundation. 11.11 + * 11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11.15 + * version 2 for more details (a copy is included in the LICENSE file that 11.16 + * accompanied this code). 11.17 + * 11.18 + * You should have received a copy of the GNU General Public License version 11.19 + * 2 along with this work; if not, write to the Free Software Foundation, 11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 11.21 + * 11.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 11.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 11.24 + * have any questions. 11.25 + */ 11.26 + 11.27 +class UndocumentedClass { 11.28 + void method() {} 11.29 + public void publicMethod() {} 11.30 + protected void protectedMethod() {} 11.31 + private void privateMethod() {} 11.32 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/tools/javac/T6882235.java Fri Sep 18 08:48:50 2009 -0700 12.3 @@ -0,0 +1,14 @@ 12.4 +/* 12.5 + * @test /nodynamiccopyright/ 12.6 + * @bug 6882235 12.7 + * @summary invalid exponent causes silent javac crash 12.8 + * 12.9 + * @compile/fail T6882235.java 12.10 + * @compile/fail/ref=T6882235.out -XDrawDiagnostics T6882235.java 12.11 + */ 12.12 + 12.13 +class T6882235 { 12.14 + int i = ; // invalid expression 12.15 + float f = 0e*; // invalid exponent, should not crash compiler 12.16 + int j = ; // invalid expression 12.17 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/test/tools/javac/T6882235.out Fri Sep 18 08:48:50 2009 -0700 13.3 @@ -0,0 +1,5 @@ 13.4 +T6882235.java:11:13: compiler.err.illegal.start.of.expr 13.5 +T6882235.java:12:15: compiler.err.malformed.fp.lit 13.6 +T6882235.java:12:18: compiler.err.illegal.start.of.expr 13.7 +T6882235.java:13:13: compiler.err.illegal.start.of.expr 13.8 +4 errors
14.1 --- a/test/tools/javac/enum/6384542/T6384542.out Thu Sep 17 13:47:11 2009 -0700 14.2 +++ b/test/tools/javac/enum/6384542/T6384542.out Fri Sep 18 08:48:50 2009 -0700 14.3 @@ -1,6 +1,6 @@ 14.4 T6384542.java:10:8: compiler.err.static.import.not.supported.in.source: 1.4 14.5 T6384542.java:12:8: compiler.err.enums.not.supported.in.source: 1.4 14.6 -T6384542.java:14:13: compiler.err.unsupported.fp.lit 14.7 +T6384542.java:14:13: compiler.err.unsupported.fp.lit: 1.4 14.8 T6384542.java:15:9: compiler.err.generics.not.supported.in.source: 1.4 14.9 T6384542.java:16:35: compiler.err.varargs.not.supported.in.source: 1.4 14.10 T6384542.java:17:25: compiler.err.foreach.not.supported.in.source: 1.4
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/test/tools/javac/literals/BadBinaryLiterals.6.out Fri Sep 18 08:48:50 2009 -0700 15.3 @@ -0,0 +1,8 @@ 15.4 +BadBinaryLiterals.java:10:17: compiler.err.unsupported.binary.lit: 1.6 15.5 +BadBinaryLiterals.java:11:24: compiler.err.expected: ';' 15.6 +BadBinaryLiterals.java:13:21: compiler.err.int.number.too.large: 111111111111111111111111111111111 15.7 +BadBinaryLiterals.java:15:21: compiler.err.int.number.too.large: 11111111111111111111111111111111111111111111111111111111111111111 15.8 +BadBinaryLiterals.java:16:27: compiler.err.expected: ';' 15.9 +BadBinaryLiterals.java:17:27: compiler.err.expected: ';' 15.10 +BadBinaryLiterals.java:17:30: compiler.err.expected: token.identifier 15.11 +7 errors
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/test/tools/javac/literals/BadBinaryLiterals.7.out Fri Sep 18 08:48:50 2009 -0700 16.3 @@ -0,0 +1,7 @@ 16.4 +BadBinaryLiterals.java:11:24: compiler.err.expected: ';' 16.5 +BadBinaryLiterals.java:13:21: compiler.err.int.number.too.large: 111111111111111111111111111111111 16.6 +BadBinaryLiterals.java:15:21: compiler.err.int.number.too.large: 11111111111111111111111111111111111111111111111111111111111111111 16.7 +BadBinaryLiterals.java:16:27: compiler.err.expected: ';' 16.8 +BadBinaryLiterals.java:17:27: compiler.err.expected: ';' 16.9 +BadBinaryLiterals.java:17:30: compiler.err.expected: token.identifier 16.10 +6 errors
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/test/tools/javac/literals/BadBinaryLiterals.java Fri Sep 18 08:48:50 2009 -0700 17.3 @@ -0,0 +1,18 @@ 17.4 +/* 17.5 + * @test /nodynamiccopyright/ 17.6 + * @bug 6860965 17.7 + * @summary Project Coin: binary literals 17.8 + * @compile/fail/ref=BadBinaryLiterals.6.out -XDrawDiagnostics -source 6 BadBinaryLiterals.java 17.9 + * @compile/fail/ref=BadBinaryLiterals.7.out -XDrawDiagnostics BadBinaryLiterals.java 17.10 + */ 17.11 + 17.12 +public class BadBinaryLiterals { 17.13 + int valid = 0b0; // valid literal, illegal in source 6 17.14 + int baddigit = 0b012; // bad digit 17.15 + //aaaabbbbccccddddeeeeffffgggghhhh 17.16 + int overflow1 = 0b111111111111111111111111111111111; // too long for int 17.17 + //aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooopppp 17.18 + int overflow2 = 0b11111111111111111111111111111111111111111111111111111111111111111L; // too long for long 17.19 + float badfloat1 = 0b01.01; // no binary floats 17.20 + float badfloat2 = 0b01e01; // no binary floats 17.21 +}
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/test/tools/javac/literals/BadUnderscoreLiterals.6.out Fri Sep 18 08:48:50 2009 -0700 18.3 @@ -0,0 +1,21 @@ 18.4 +BadUnderscoreLiterals.java:14:17: compiler.err.unsupported.underscore: 1.6 18.5 +BadUnderscoreLiterals.java:18:15: compiler.err.illegal.underscore 18.6 +BadUnderscoreLiterals.java:22:19: compiler.err.illegal.underscore 18.7 +BadUnderscoreLiterals.java:25:14: compiler.err.unsupported.binary.lit: 1.6 18.8 +BadUnderscoreLiterals.java:25:16: compiler.err.illegal.underscore 18.9 +BadUnderscoreLiterals.java:26:17: compiler.err.illegal.underscore 18.10 +BadUnderscoreLiterals.java:29:16: compiler.err.illegal.underscore 18.11 +BadUnderscoreLiterals.java:30:17: compiler.err.illegal.underscore 18.12 +BadUnderscoreLiterals.java:33:17: compiler.err.illegal.underscore 18.13 +BadUnderscoreLiterals.java:34:18: compiler.err.illegal.underscore 18.14 +BadUnderscoreLiterals.java:35:19: compiler.err.illegal.underscore 18.15 +BadUnderscoreLiterals.java:36:19: compiler.err.illegal.underscore 18.16 +BadUnderscoreLiterals.java:37:18: compiler.err.illegal.underscore 18.17 +BadUnderscoreLiterals.java:38:19: compiler.err.illegal.underscore 18.18 +BadUnderscoreLiterals.java:41:19: compiler.err.illegal.underscore 18.19 +BadUnderscoreLiterals.java:42:20: compiler.err.illegal.underscore 18.20 +BadUnderscoreLiterals.java:43:21: compiler.err.illegal.underscore 18.21 +BadUnderscoreLiterals.java:44:22: compiler.err.illegal.underscore 18.22 +BadUnderscoreLiterals.java:45:21: compiler.err.illegal.underscore 18.23 +BadUnderscoreLiterals.java:46:22: compiler.err.illegal.underscore 18.24 +20 errors
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/test/tools/javac/literals/BadUnderscoreLiterals.7.out Fri Sep 18 08:48:50 2009 -0700 19.3 @@ -0,0 +1,19 @@ 19.4 +BadUnderscoreLiterals.java:18:15: compiler.err.illegal.underscore 19.5 +BadUnderscoreLiterals.java:22:19: compiler.err.illegal.underscore 19.6 +BadUnderscoreLiterals.java:25:16: compiler.err.illegal.underscore 19.7 +BadUnderscoreLiterals.java:26:17: compiler.err.illegal.underscore 19.8 +BadUnderscoreLiterals.java:29:16: compiler.err.illegal.underscore 19.9 +BadUnderscoreLiterals.java:30:17: compiler.err.illegal.underscore 19.10 +BadUnderscoreLiterals.java:33:17: compiler.err.illegal.underscore 19.11 +BadUnderscoreLiterals.java:34:18: compiler.err.illegal.underscore 19.12 +BadUnderscoreLiterals.java:35:19: compiler.err.illegal.underscore 19.13 +BadUnderscoreLiterals.java:36:19: compiler.err.illegal.underscore 19.14 +BadUnderscoreLiterals.java:37:18: compiler.err.illegal.underscore 19.15 +BadUnderscoreLiterals.java:38:19: compiler.err.illegal.underscore 19.16 +BadUnderscoreLiterals.java:41:19: compiler.err.illegal.underscore 19.17 +BadUnderscoreLiterals.java:42:20: compiler.err.illegal.underscore 19.18 +BadUnderscoreLiterals.java:43:21: compiler.err.illegal.underscore 19.19 +BadUnderscoreLiterals.java:44:22: compiler.err.illegal.underscore 19.20 +BadUnderscoreLiterals.java:45:21: compiler.err.illegal.underscore 19.21 +BadUnderscoreLiterals.java:46:22: compiler.err.illegal.underscore 19.22 +18 errors
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 20.2 +++ b/test/tools/javac/literals/BadUnderscoreLiterals.java Fri Sep 18 08:48:50 2009 -0700 20.3 @@ -0,0 +1,48 @@ 20.4 +/* 20.5 + * @test /nodynamiccopyright/ 20.6 + * @bug 6860973 20.7 + * @summary Project Coin: underscores in literals 20.8 + * 20.9 + * @compile/fail BadUnderscoreLiterals.java 20.10 + * @compile/fail/ref=BadUnderscoreLiterals.7.out -XDrawDiagnostics BadUnderscoreLiterals.java 20.11 + * 20.12 + * @compile/fail -source 6 BadUnderscoreLiterals.java 20.13 + * @compile/fail/ref=BadUnderscoreLiterals.6.out -XDrawDiagnostics -source 6 BadUnderscoreLiterals.java 20.14 + */ 20.15 + 20.16 +public class BadUnderscoreLiterals { 20.17 + int valid = 1_1; // valid literal; illegal in -source 6 20.18 + 20.19 + // test zero 20.20 + int z1 = _0; // valid (but undefined) variable 20.21 + int z2 = 0_; // trailing underscore 20.22 + 20.23 + // test simple (decimal) integers 20.24 + int i1 = _1_2_3; // valid (but undefined) variable 20.25 + int i2 = 1_2_3_; // trailing underscore 20.26 + 20.27 + // test binary integers 20.28 + int b1 = 0b_0; // leading underscore after radix 20.29 + int b2 = 0b0_; // trailing underscore 20.30 + 20.31 + // test hexadecimal integers 20.32 + int x1 = 0x_0; // leading underscore after radix 20.33 + int x2 = 0x0_; // trailing underscore 20.34 + 20.35 + // test floating point numbers 20.36 + float f1 = 0_.1; // trailing underscore before decimal point 20.37 + float f2 = 0._1; // leading underscore after decimal point 20.38 + float f3 = 0.1_; // trailing underscore 20.39 + float f4 = 0.1_e0; // trailing underscore before exponent 20.40 + float f5 = 0e_1; // leading underscore in exponent 20.41 + float f6 = 0e1_; // trailing underscore in exponent 20.42 + 20.43 + // hexadecimal floating point 20.44 + float xf1 = 0x_0.1p0; // leading underscore after radix 20.45 + float xf2 = 0x0_.1p0; // trailing underscore before decimal point 20.46 + float xf3 = 0x0._1p0; // leading underscore after decimal point 20.47 + float xf4 = 0x0.1_p0; // trailing underscore before exponent 20.48 + float xf5 = 0x0p_1; // leading underscore after exponent 20.49 + float xf6 = 0x0p1_; // trailing underscore 20.50 +} 20.51 +
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 21.2 +++ b/test/tools/javac/literals/BinaryLiterals.java Fri Sep 18 08:48:50 2009 -0700 21.3 @@ -0,0 +1,132 @@ 21.4 +/* 21.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 21.7 + * 21.8 + * This code is free software; you can redistribute it and/or modify it 21.9 + * under the terms of the GNU General Public License version 2 only, as 21.10 + * published by the Free Software Foundation. 21.11 + * 21.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 21.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21.15 + * version 2 for more details (a copy is included in the LICENSE file that 21.16 + * accompanied this code). 21.17 + * 21.18 + * You should have received a copy of the GNU General Public License version 21.19 + * 2 along with this work; if not, write to the Free Software Foundation, 21.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21.21 + * 21.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 21.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 21.24 + * have any questions. 21.25 + */ 21.26 + 21.27 +/* 21.28 + * @test 21.29 + * @bug 6860965 21.30 + * @summary Project Coin: binary literals 21.31 + */ 21.32 + 21.33 +public class BinaryLiterals { 21.34 + public static void main(String... args) throws Exception { 21.35 + new BinaryLiterals().run(); 21.36 + } 21.37 + 21.38 + public void run() throws Exception { 21.39 + test(0, 0B0); 21.40 + test(1, 0B1); 21.41 + test(2, 0B10); 21.42 + test(3, 0B11); 21.43 + 21.44 + test(0, 0b0); 21.45 + test(1, 0b1); 21.46 + test(2, 0b10); 21.47 + test(3, 0b11); 21.48 + 21.49 + test(-0, -0b0); 21.50 + test(-1, -0b1); 21.51 + test(-2, -0b10); 21.52 + test(-3, -0b11); 21.53 + 21.54 + test(-1, 0b11111111111111111111111111111111); 21.55 + test(-2, 0b11111111111111111111111111111110); 21.56 + test(-3, 0b11111111111111111111111111111101); 21.57 + 21.58 + test( 1, -0b11111111111111111111111111111111); 21.59 + test( 2, -0b11111111111111111111111111111110); 21.60 + test( 3, -0b11111111111111111111111111111101); 21.61 + 21.62 + test(0, 0b00); 21.63 + test(1, 0b001); 21.64 + test(2, 0b00010); 21.65 + test(3, 0b000011); 21.66 + 21.67 + // aaaabbbbccccddddeeeeffffgggghhhh 21.68 + test( 0x10, 0b10000); 21.69 + test( 0x100, 0b100000000); 21.70 + test( 0x10000, 0b10000000000000000); 21.71 + test(0x80000000, 0b10000000000000000000000000000000); 21.72 + test(0xffffffff, 0b11111111111111111111111111111111); 21.73 + 21.74 + test(0L, 0b0L); 21.75 + test(1L, 0b1L); 21.76 + test(2L, 0b10L); 21.77 + test(3L, 0b11L); 21.78 + 21.79 + test(0, 0b00L); 21.80 + test(1, 0b001L); 21.81 + test(2, 0b00010L); 21.82 + test(3, 0b000011L); 21.83 + 21.84 + // aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooopppp 21.85 + test( 0x10L, 0b10000L); 21.86 + test( 0x100L, 0b100000000L); 21.87 + test( 0x10000L, 0b10000000000000000L); 21.88 + test( 0x80000000L, 0b10000000000000000000000000000000L); 21.89 + test( 0xffffffffL, 0b11111111111111111111111111111111L); 21.90 + test(0x8000000000000000L, 0b1000000000000000000000000000000000000000000000000000000000000000L); 21.91 + test(0xffffffffffffffffL, 0b1111111111111111111111111111111111111111111111111111111111111111L); 21.92 + 21.93 + test(0l, 0b0l); 21.94 + test(1l, 0b1l); 21.95 + test(2l, 0b10l); 21.96 + test(3l, 0b11l); 21.97 + 21.98 + test(0, 0b00l); 21.99 + test(1, 0b001l); 21.100 + test(2, 0b00010l); 21.101 + test(3, 0b000011l); 21.102 + 21.103 + // aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooopppp 21.104 + test( 0x10l, 0b10000l); 21.105 + test( 0x100l, 0b100000000l); 21.106 + test( 0x10000l, 0b10000000000000000l); 21.107 + test( 0x80000000l, 0b10000000000000000000000000000000l); 21.108 + test( 0xffffffffl, 0b11111111111111111111111111111111l); 21.109 + test(0x8000000000000000l, 0b1000000000000000000000000000000000000000000000000000000000000000l); 21.110 + test(0xffffffffffffffffl, 0b1111111111111111111111111111111111111111111111111111111111111111l); 21.111 + 21.112 + if (errors > 0) 21.113 + throw new Exception(errors + " errors found"); 21.114 + } 21.115 + 21.116 + void test(int expect, int found) { 21.117 + count++; 21.118 + if (found != expect) 21.119 + error("test " + count + "\nexpected: 0x" + Integer.toHexString(expect) + "\n found: 0x" + Integer.toHexString(found)); 21.120 + } 21.121 + 21.122 + void test(long expect, long found) { 21.123 + count++; 21.124 + if (found != expect) 21.125 + error("test " + count + "\nexpected: 0x" + Long.toHexString(expect) + "\n found: 0x" + Long.toHexString(found)); 21.126 + } 21.127 + 21.128 + void error(String message) { 21.129 + System.out.println(message); 21.130 + errors++; 21.131 + } 21.132 + 21.133 + int count; 21.134 + int errors; 21.135 +}
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 22.2 +++ b/test/tools/javac/literals/UnderscoreLiterals.java Fri Sep 18 08:48:50 2009 -0700 22.3 @@ -0,0 +1,195 @@ 22.4 +/* 22.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 22.7 + * 22.8 + * This code is free software; you can redistribute it and/or modify it 22.9 + * under the terms of the GNU General Public License version 2 only, as 22.10 + * published by the Free Software Foundation. 22.11 + * 22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 22.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 22.15 + * version 2 for more details (a copy is included in the LICENSE file that 22.16 + * accompanied this code). 22.17 + * 22.18 + * You should have received a copy of the GNU General Public License version 22.19 + * 2 along with this work; if not, write to the Free Software Foundation, 22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22.21 + * 22.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 22.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 22.24 + * have any questions. 22.25 + */ 22.26 + 22.27 +/* 22.28 + * @test 22.29 + * @bug 6860973 22.30 + * @summary Project Coin: Underscores in literals 22.31 + */ 22.32 + 22.33 + 22.34 +public class UnderscoreLiterals { 22.35 + public static void main(String... args) throws Exception { 22.36 + new UnderscoreLiterals().run(); 22.37 + } 22.38 + 22.39 + public void run() throws Exception { 22.40 + // decimal 22.41 + test(1, 1); 22.42 + test(10, 10); 22.43 + test(1_0, 10); 22.44 + test(1__0, 10); 22.45 + test(1_0_0, 100); 22.46 + test(1__0__0, 100); 22.47 + test(123_456_789, 123456789); 22.48 + 22.49 + // long 22.50 + test(1l, 1l); 22.51 + test(10l, 10l); 22.52 + test(1_0l, 10l); 22.53 + test(1__0l, 10l); 22.54 + test(1_0_0l, 100l); 22.55 + test(1__0__0l, 100l); 22.56 + test(123_456_789l, 123456789l); 22.57 + 22.58 + // float 22.59 + test(.1f, .1f); 22.60 + test(.10f, .10f); 22.61 + test(.1_0f, .10f); 22.62 + test(.1__0f, .10f); 22.63 + test(.1_0_0f, .100f); 22.64 + test(.1__0__0f, .100f); 22.65 + test(1e1, 1e1); 22.66 + test(1e10, 1e10); 22.67 + test(1e1_0, 1e10); 22.68 + test(1e1__0, 1e10); 22.69 + test(1e1_0_0, 1e100); 22.70 + test(1e1__0__0, 1e100); 22.71 + test(.123_456_789f, .123456789f); 22.72 + test(0.1f, 0.1f); 22.73 + test(0.10f, 0.10f); 22.74 + test(0.1_0f, 0.10f); 22.75 + test(0.1__0f, 0.10f); 22.76 + test(0.1_0_0f, 0.100f); 22.77 + test(0.1__0__0f, 0.100f); 22.78 + test(0.123_456_789f, 0.123456789f); 22.79 + test(1_1.1f, 1_1.1f); 22.80 + test(1_1.10f, 1_1.10f); 22.81 + test(1_1.1_0f, 1_1.10f); 22.82 + test(1_1.1__0f, 1_1.10f); 22.83 + test(1_1.1_0_0f, 1_1.100f); 22.84 + test(1_1.1__0__0f, 1_1.100f); 22.85 + test(1_1.123_456_789f, 1_1.123456789f); 22.86 + 22.87 + // double 22.88 + test(.1d, .1d); 22.89 + test(.10d, .10d); 22.90 + test(.1_0d, .10d); 22.91 + test(.1__0d, .10d); 22.92 + test(.1_0_0d, .100d); 22.93 + test(.1__0__0d, .100d); 22.94 + test(1e1, 1e1); 22.95 + test(1e10, 1e10); 22.96 + test(1e1_0, 1e10); 22.97 + test(1e1__0, 1e10); 22.98 + test(1e1_0_0, 1e100); 22.99 + test(1e1__0__0, 1e100); 22.100 + test(.123_456_789d, .123456789d); 22.101 + test(0.1d, 0.1d); 22.102 + test(0.10d, 0.10d); 22.103 + test(0.1_0d, 0.10d); 22.104 + test(0.1__0d, 0.10d); 22.105 + test(0.1_0_0d, 0.100d); 22.106 + test(0.1__0__0d, 0.100d); 22.107 + test(0.123_456_789d, 0.123456789d); 22.108 + test(1_1.1d, 1_1.1d); 22.109 + test(1_1.10d, 1_1.10d); 22.110 + test(1_1.1_0d, 1_1.10d); 22.111 + test(1_1.1__0d, 1_1.10d); 22.112 + test(1_1.1_0_0d, 1_1.100d); 22.113 + test(1_1.1__0__0d, 1_1.100d); 22.114 + test(1_1.123_456_789d, 1_1.123456789d); 22.115 + 22.116 + // binary 22.117 + test(0b1, 1); 22.118 + test(0b10, 2); 22.119 + test(0b1_0, 2); 22.120 + test(0b1__0, 2); 22.121 + test(0b1_0_0, 4); 22.122 + test(0b1__0__0, 4); 22.123 + test(0b0001_0010_0011, 0x123); 22.124 + 22.125 + // octal 22.126 + test(01, 1); 22.127 + test(010, 8); 22.128 + test(01_0, 8); 22.129 + test(01__0, 8); 22.130 + test(01_0_0, 64); 22.131 + test(01__0__0, 64); 22.132 + test(0_1, 1); 22.133 + test(0_10, 8); 22.134 + test(0_1_0, 8); 22.135 + test(0_1__0, 8); 22.136 + test(0_1_0_0, 64); 22.137 + test(0_1__0__0, 64); 22.138 + test(0_001_002_003, 01002003); 22.139 + 22.140 + // hexadecimal 22.141 + test(0x1, 1); 22.142 + test(0x10, 16); 22.143 + test(0x1_0, 16); 22.144 + test(0x1__0, 16); 22.145 + test(0x1_0_0, 256); 22.146 + test(0x1__0__0, 256); 22.147 + test(0x01_02_03_04, 0x1020304); 22.148 + 22.149 + // misc 22.150 + long creditCardNumber = 1234_5678_9012_3456L; 22.151 + test(creditCardNumber, 1234567890123456L); 22.152 + long socialSecurityNumbers = 999_99_9999L; 22.153 + test(socialSecurityNumbers, 999999999L); 22.154 + double monetaryAmount = 12_345_132.12d; 22.155 + test(monetaryAmount, 12345132.12d); 22.156 + long hexBytes = 0xFF_EC_DE_5E; 22.157 + test(hexBytes, 0xffecde5e); 22.158 + long hexWords = 0xFFEC_DE5E; 22.159 + test(hexWords, 0xffecde5e); 22.160 + long maxLong = 0x7fff_ffff_ffff_ffffL; 22.161 + test(maxLong, 0x7fffffffffffffffL); 22.162 + long maxLongDecimal = 9223372036854775807L; 22.163 + long alsoMaxLong = 9_223_372_036_854_775_807L; 22.164 + test(alsoMaxLong, maxLongDecimal); 22.165 + double whyWouldYouEverDoThis = 0x1.ffff_ffff_ffff_fp10_23; 22.166 + double whyWouldYouEverDoEvenThis = 0x1.fffffffffffffp1023; 22.167 + test(whyWouldYouEverDoThis, whyWouldYouEverDoEvenThis); 22.168 + 22.169 + if (errors > 0) 22.170 + throw new Exception(errors + " errors found"); 22.171 + } 22.172 + 22.173 + void test(int value, int expect) { 22.174 + count++; 22.175 + if (value != expect) 22.176 + error("test " + count + "\nexpected: 0x" + Integer.toHexString(expect) + "\n found: 0x" + Integer.toHexString(value)); 22.177 + } 22.178 + 22.179 + void test(double value, double expect) { 22.180 + count++; 22.181 + if (value != expect) 22.182 + error("test " + count + "\nexpected: 0x" + expect + "\n found: 0x" + value); 22.183 + } 22.184 + 22.185 + void test(long value, long expect) { 22.186 + count++; 22.187 + if (value != expect) 22.188 + error("test " + count + "\nexpected: 0x" + Long.toHexString(expect) + "\n found: 0x" + Long.toHexString(value)); 22.189 + } 22.190 + 22.191 + void error(String message) { 22.192 + System.out.println(message); 22.193 + errors++; 22.194 + } 22.195 + 22.196 + int count; 22.197 + int errors; 22.198 +}
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 23.2 +++ b/test/tools/javadoc/annotations/missing/Main.java Fri Sep 18 08:48:50 2009 -0700 23.3 @@ -0,0 +1,52 @@ 23.4 +/* 23.5 + * Copyright 2009 Google, Inc. All Rights Reserved. 23.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 23.7 + * 23.8 + * This code is free software; you can redistribute it and/or modify it 23.9 + * under the terms of the GNU General Public License version 2 only, as 23.10 + * published by the Free Software Foundation. 23.11 + * 23.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 23.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 23.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 23.15 + * version 2 for more details (a copy is included in the LICENSE file that 23.16 + * accompanied this code). 23.17 + * 23.18 + * You should have received a copy of the GNU General Public License version 23.19 + * 2 along with this work; if not, write to the Free Software Foundation, 23.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 23.21 + * 23.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 23.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 23.24 + * have any questions. 23.25 + */ 23.26 + 23.27 +/* 23.28 + * @test 23.29 + * @bug 6709246 23.30 + * @summary Class-cast exception when annotation type is missing. 23.31 + * @library ../../lib 23.32 + */ 23.33 + 23.34 +import java.io.IOException; 23.35 +import com.sun.javadoc.RootDoc; 23.36 +import com.sun.javadoc.ClassDoc; 23.37 +import com.sun.javadoc.AnnotationDesc; 23.38 + 23.39 +public class Main extends Tester.Doclet { 23.40 + 23.41 + private static final Tester tester = new Tester("Main", "somepackage"); 23.42 + 23.43 + public static void main(String... args) throws Exception { 23.44 + tester.run(); 23.45 + } 23.46 + 23.47 + public static boolean start(RootDoc root) { 23.48 + for (ClassDoc d : root.classes()) { 23.49 + for (AnnotationDesc a : d.annotations()) { 23.50 + System.out.println(a.annotationType()); 23.51 + } 23.52 + } 23.53 + return true; 23.54 + } 23.55 +}
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 24.2 +++ b/test/tools/javadoc/annotations/missing/somepackage/MissingAnnotationClass.java Fri Sep 18 08:48:50 2009 -0700 24.3 @@ -0,0 +1,31 @@ 24.4 +/* 24.5 + * Copyright 2009 Google, Inc. All Rights Reserved. 24.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 24.7 + * 24.8 + * This code is free software; you can redistribute it and/or modify it 24.9 + * under the terms of the GNU General Public License version 2 only, as 24.10 + * published by the Free Software Foundation. 24.11 + * 24.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 24.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 24.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 24.15 + * version 2 for more details (a copy is included in the LICENSE file that 24.16 + * accompanied this code). 24.17 + * 24.18 + * You should have received a copy of the GNU General Public License version 24.19 + * 2 along with this work; if not, write to the Free Software Foundation, 24.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 24.21 + * 24.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 24.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 24.24 + * have any questions. 24.25 + */ 24.26 + 24.27 +package somepackage; 24.28 + 24.29 +/** 24.30 + * This class has an annotation which is not available. 24.31 + */ 24.32 +@NoSuchAnnotation 24.33 +public class MissingAnnotationClass { 24.34 +}