attrs;
public final boolean selfClosing;
diff -r adec2a5d510a -r ec434cfd2752 src/share/classes/com/sun/tools/javac/util/Bits.java
--- a/src/share/classes/com/sun/tools/javac/util/Bits.java Thu May 02 13:35:55 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/util/Bits.java Mon May 06 11:53:44 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
import java.util.Arrays;
+import static com.sun.tools.javac.util.Bits.BitsOpKind.*;
+
/** A class for extensible, mutable bit sets.
*
* This is NOT part of any supported API.
@@ -36,31 +38,114 @@
*/
public class Bits {
+ public enum BitsOpKind {
+ INIT,
+ CLEAR,
+ INCL_BIT,
+ EXCL_BIT,
+ ASSIGN,
+ AND_SET,
+ OR_SET,
+ DIFF_SET,
+ XOR_SET,
+ INCL_RANGE,
+ EXCL_RANGE,
+ }
+
+ // ____________ reset _________
+ // / UNKNOWN \ <-------- / UNINIT \
+ // \____________/ | \_________/
+ // | | |
+ // |assign | | any
+ // | ___________ |
+ // ------> / NORMAL \ <----
+ // \___________/ |
+ // | |
+ // | |
+ // -----------
+ // any
+ private enum BitsState {
+ /* A Bits instance is in UNKNOWN state if it has been explicitly reset.
+ * It is possible to get to this state from any other by calling the
+ * reset method. An instance in the UNKNOWN state can pass to the
+ * NORMAL state after being assigned another Bits instance.
+ */
+ UNKNOWN,
+ /* A Bits instance is in UNINIT when it is created with the default
+ * constructor but it isn't explicitly reset. The main objective of this
+ * internal state is to save some memory.
+ */
+ UNINIT,
+ /* The normal state is reached after creating a Bits instance from an
+ * existing one or after applying any operation to an instance on UNINIT
+ * or NORMAL state. From this state a bits instance can pass to the
+ * UNKNOWN state by calling the reset method.
+ */
+ NORMAL;
+
+ static BitsState getState(int[] someBits, boolean reset) {
+ if (reset) {
+ return UNKNOWN;
+ } else {
+ if (someBits != unassignedBits) {
+ return NORMAL;
+ } else {
+ return UNINIT;
+ }
+ }
+ }
+
+ }
private final static int wordlen = 32;
private final static int wordshift = 5;
private final static int wordmask = wordlen - 1;
- private int[] bits;
+ public int[] bits = null;
+ // This field will store last version of bits after every change.
+ public int[] oldBits = null;
+
+ public BitsOpKind lastOperation = null;
+
+ private static final int[] unassignedBits = new int[0];
+
+ private BitsState currentState;
/** Construct an initially empty set.
*/
public Bits() {
- this(new int[1]);
+ this(false);
+ }
+
+ public Bits(Bits someBits) {
+ this(someBits.dup().bits, BitsState.getState(someBits.bits, false));
+ }
+
+ public Bits(boolean reset) {
+ this(unassignedBits, BitsState.getState(unassignedBits, reset));
}
/** Construct a set consisting initially of given bit vector.
*/
- public Bits(int[] bits) {
+ private Bits(int[] bits, BitsState initState) {
this.bits = bits;
+ this.currentState = initState;
+ switch (initState) {
+ case UNKNOWN:
+ reset(); //this will also set current state;
+ break;
+ case NORMAL:
+ Assert.check(bits != unassignedBits);
+ lastOperation = INIT;
+ break;
+ }
}
- /** Construct a set consisting initially of given range.
+ /** This method will be called after any operation that causes a change to
+ * the bits. Subclasses can thus override it in order to extract information
+ * from the changes produced to the bits by the given operation.
*/
- public Bits(int start, int limit) {
- this();
- inclRange(start, limit);
- }
+ public void changed() {}
private void sizeTo(int len) {
if (bits.length < len) {
@@ -71,57 +156,110 @@
/** This set = {}.
*/
public void clear() {
+ Assert.check(currentState != BitsState.UNKNOWN);
+ oldBits = bits;
+ lastOperation = CLEAR;
for (int i = 0; i < bits.length; i++) bits[i] = 0;
+ changed();
+ currentState = BitsState.NORMAL;
+ }
+
+ public void reset() {
+ bits = null;
+ oldBits = null;
+ currentState = BitsState.UNKNOWN;
+ }
+
+ public boolean isReset() {
+ return currentState == BitsState.UNKNOWN;
+ }
+
+ public Bits assign(Bits someBits) {
+ lastOperation = ASSIGN;
+ oldBits = bits;
+ bits = someBits.dup().bits;
+ changed();
+ currentState = BitsState.NORMAL;
+ return this;
}
/** Return a copy of this set.
*/
- public Bits dup() {
- int[] newbits = new int[bits.length];
- System.arraycopy(bits, 0, newbits, 0, bits.length);
- return new Bits(newbits);
+ private Bits dup() {
+ Assert.check(currentState != BitsState.UNKNOWN);
+ Bits tmp = new Bits();
+ if (currentState != BitsState.NORMAL) {
+ tmp.bits = bits;
+ } else {
+ tmp.bits = new int[bits.length];
+ System.arraycopy(bits, 0, tmp.bits, 0, bits.length);
+ }
+ currentState = BitsState.NORMAL;
+ return tmp;
}
/** Include x in this set.
*/
public void incl(int x) {
+ Assert.check(currentState != BitsState.UNKNOWN);
Assert.check(x >= 0);
+ oldBits = bits;
+ lastOperation = INCL_BIT;
sizeTo((x >>> wordshift) + 1);
bits[x >>> wordshift] = bits[x >>> wordshift] |
(1 << (x & wordmask));
+ changed();
+ currentState = BitsState.NORMAL;
}
/** Include [start..limit) in this set.
*/
public void inclRange(int start, int limit) {
+ Assert.check(currentState != BitsState.UNKNOWN);
+ oldBits = bits;
+ lastOperation = INCL_RANGE;
sizeTo((limit >>> wordshift) + 1);
- for (int x = start; x < limit; x++)
+ for (int x = start; x < limit; x++) {
bits[x >>> wordshift] = bits[x >>> wordshift] |
(1 << (x & wordmask));
+ }
+ changed();
+ currentState = BitsState.NORMAL;
}
/** Exclude [start...end] from this set.
*/
public void excludeFrom(int start) {
+ Assert.check(currentState != BitsState.UNKNOWN);
+ oldBits = bits;
+ lastOperation = EXCL_RANGE;
Bits temp = new Bits();
temp.sizeTo(bits.length);
temp.inclRange(0, start);
- andSet(temp);
+ internalAndSet(temp);
+ changed();
+ currentState = BitsState.NORMAL;
}
/** Exclude x from this set.
*/
public void excl(int x) {
+ Assert.check(currentState != BitsState.UNKNOWN);
Assert.check(x >= 0);
+ oldBits = bits;
+ lastOperation = EXCL_BIT;
sizeTo((x >>> wordshift) + 1);
bits[x >>> wordshift] = bits[x >>> wordshift] &
~(1 << (x & wordmask));
+ changed();
+ currentState = BitsState.NORMAL;
}
/** Is x an element of this set?
*/
public boolean isMember(int x) {
+ Assert.check(currentState != BitsState.UNKNOWN);
return
0 <= x && x < (bits.length << wordshift) &&
(bits[x >>> wordshift] & (1 << (x & wordmask))) != 0;
@@ -130,38 +268,66 @@
/** {@literal this set = this set & xs}.
*/
public Bits andSet(Bits xs) {
+ Assert.check(currentState != BitsState.UNKNOWN);
+ oldBits = bits;
+ lastOperation = AND_SET;
+ internalAndSet(xs);
+ changed();
+ currentState = BitsState.NORMAL;
+ return this;
+ }
+
+ private void internalAndSet(Bits xs) {
+ Assert.check(currentState != BitsState.UNKNOWN);
sizeTo(xs.bits.length);
- for (int i = 0; i < xs.bits.length; i++)
+ for (int i = 0; i < xs.bits.length; i++) {
bits[i] = bits[i] & xs.bits[i];
- return this;
+ }
}
/** this set = this set | xs.
*/
public Bits orSet(Bits xs) {
+ Assert.check(currentState != BitsState.UNKNOWN);
+ oldBits = bits;
+ lastOperation = OR_SET;
sizeTo(xs.bits.length);
- for (int i = 0; i < xs.bits.length; i++)
+ for (int i = 0; i < xs.bits.length; i++) {
bits[i] = bits[i] | xs.bits[i];
+ }
+ changed();
+ currentState = BitsState.NORMAL;
return this;
}
/** this set = this set \ xs.
*/
public Bits diffSet(Bits xs) {
+ Assert.check(currentState != BitsState.UNKNOWN);
+ oldBits = bits;
+ lastOperation = DIFF_SET;
for (int i = 0; i < bits.length; i++) {
if (i < xs.bits.length) {
bits[i] = bits[i] & ~xs.bits[i];
}
}
+ changed();
+ currentState = BitsState.NORMAL;
return this;
}
/** this set = this set ^ xs.
*/
public Bits xorSet(Bits xs) {
+ Assert.check(currentState != BitsState.UNKNOWN);
+ oldBits = bits;
+ lastOperation = XOR_SET;
sizeTo(xs.bits.length);
- for (int i = 0; i < xs.bits.length; i++)
+ for (int i = 0; i < xs.bits.length; i++) {
bits[i] = bits[i] ^ xs.bits[i];
+ }
+ changed();
+ currentState = BitsState.NORMAL;
return this;
}
@@ -187,6 +353,7 @@
* }
*/
public int nextBit(int x) {
+ Assert.check(currentState != BitsState.UNKNOWN);
int windex = x >>> wordshift;
if (windex >= bits.length) return -1;
int word = bits[windex] & ~((1 << (x & wordmask))-1);
@@ -202,17 +369,20 @@
/** a string representation of this set.
*/
public String toString() {
- char[] digits = new char[bits.length * wordlen];
- for (int i = 0; i < bits.length * wordlen; i++)
- digits[i] = isMember(i) ? '1' : '0';
- return new String(digits);
+ if (bits.length > 0) {
+ char[] digits = new char[bits.length * wordlen];
+ for (int i = 0; i < bits.length * wordlen; i++)
+ digits[i] = isMember(i) ? '1' : '0';
+ return new String(digits);
+ } else {
+ return "[]";
+ }
}
/** Test Bits.nextBit(int). */
public static void main(String[] args) {
java.util.Random r = new java.util.Random();
Bits bits = new Bits();
- int dupCount = 0;
for (int i=0; i<125; i++) {
int k;
do {
diff -r adec2a5d510a -r ec434cfd2752 src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java
--- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Thu May 02 13:35:55 2013 -0700
+++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Mon May 06 11:53:44 2013 -0700
@@ -341,9 +341,14 @@
*
*/
public String name() {
- return getClassName(tsym, false);
+ if (name == null) {
+ name = getClassName(tsym, false);
+ }
+ return name;
}
+ private String name;
+
/**
* Return the qualified class name as a String.
*
@@ -354,9 +359,14 @@
*
*/
public String qualifiedName() {
- return getClassName(tsym, true);
+ if (qualifiedName == null) {
+ qualifiedName = getClassName(tsym, true);
+ }
+ return qualifiedName;
}
+ private String qualifiedName;
+
/**
* Return unqualified name of type excluding any dimension information.
*
@@ -380,9 +390,14 @@
* Return the simple name of this type.
*/
public String simpleTypeName() {
- return tsym.name.toString();
+ if (simpleTypeName == null) {
+ simpleTypeName = tsym.name.toString();
+ }
+ return simpleTypeName;
}
+ private String simpleTypeName;
+
/**
* Return the qualified name and any type parameters.
* Each parameter is a type variable with optional bounds.
diff -r adec2a5d510a -r ec434cfd2752 src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java
--- a/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java Thu May 02 13:35:55 2013 -0700
+++ b/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java Mon May 06 11:53:44 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -252,13 +252,23 @@
}
public String name() {
- return sym.name.toString();
+ if (name == null) {
+ name = sym.name.toString();
+ }
+ return name;
}
+ private String name;
+
public String qualifiedName() {
- return sym.enclClass().getQualifiedName() + "." + name();
+ if (qualifiedName == null) {
+ qualifiedName = sym.enclClass().getQualifiedName() + "." + name();
+ }
+ return qualifiedName;
}
+ private String qualifiedName;
+
/**
* Return the source position of the entity, or null if
* no position is available.
diff -r adec2a5d510a -r ec434cfd2752 src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java
--- a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java Thu May 02 13:35:55 2013 -0700
+++ b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java Mon May 06 11:53:44 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -203,13 +203,23 @@
public String name() {
- return sym.name.toString();
+ if (name == null) {
+ name = sym.name.toString();
+ }
+ return name;
}
+ private String name;
+
public String qualifiedName() {
- return sym.enclClass().getQualifiedName() + "." + sym.name;
+ if (qualifiedName == null) {
+ qualifiedName = sym.enclClass().getQualifiedName() + "." + sym.name;
+ }
+ return qualifiedName;
}
+ private String qualifiedName;
+
/**
* Returns a string representation of this method. Includes the
* qualified signature, the qualified method name, and any type
diff -r adec2a5d510a -r ec434cfd2752 src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java
--- a/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java Thu May 02 13:35:55 2013 -0700
+++ b/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java Mon May 06 11:53:44 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -334,12 +334,17 @@
* Get package name.
*/
public String qualifiedName() {
- Name fullname = sym.getQualifiedName();
- // Some bogus tests depend on the interned "" being returned.
- // See 6457276.
- return fullname.isEmpty() ? "" : fullname.toString();
+ if (qualifiedName == null) {
+ Name fullname = sym.getQualifiedName();
+ // Some bogus tests depend on the interned "" being returned.
+ // See 6457276.
+ qualifiedName = fullname.isEmpty() ? "" : fullname.toString();
+ }
+ return qualifiedName;
}
+ private String qualifiedName;
+
/**
* set doc path for an unzipped directory
*/
diff -r adec2a5d510a -r ec434cfd2752 test/tools/javac/api/TestJavacTaskScanner.java
--- a/test/tools/javac/api/TestJavacTaskScanner.java Thu May 02 13:35:55 2013 -0700
+++ b/test/tools/javac/api/TestJavacTaskScanner.java Mon May 06 11:53:44 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -93,7 +93,7 @@
System.out.println("#allMembers: " + numAllMembers);
check(numTokens, "#Tokens", 1222);
- check(numParseTypeElements, "#parseTypeElements", 136);
+ check(numParseTypeElements, "#parseTypeElements", 158);
check(numAllMembers, "#allMembers", 52);
}
diff -r adec2a5d510a -r ec434cfd2752 test/tools/javac/defaultMethods/CheckACC_STRICTFlagOnDefaultMethodTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/defaultMethods/CheckACC_STRICTFlagOnDefaultMethodTest.java Mon May 06 11:53:44 2013 -0700
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8012723
+ * @summary strictfp interface misses strictfp modifer on default method
+ * @run main CheckACC_STRICTFlagOnDefaultMethodTest
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+import java.io.File;
+import java.io.IOException;
+
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Descriptor;
+import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
+import com.sun.tools.classfile.Method;
+
+import static com.sun.tools.classfile.AccessFlags.ACC_STRICT;
+
+public class CheckACC_STRICTFlagOnDefaultMethodTest {
+ private static final String AssertionErrorMessage =
+ "All methods should have the ACC_STRICT access flag " +
+ "please check output";
+ private static final String offendingMethodErrorMessage =
+ "Method %s of class %s doesn't have the ACC_STRICT access flag";
+
+ private List errors = new ArrayList<>();
+
+ public static void main(String[] args)
+ throws IOException, ConstantPoolException, InvalidDescriptor {
+ new CheckACC_STRICTFlagOnDefaultMethodTest().run();
+ }
+
+ private void run()
+ throws IOException, ConstantPoolException, InvalidDescriptor {
+ String testClasses = System.getProperty("test.classes");
+ check(testClasses,
+ "CheckACC_STRICTFlagOnDefaultMethodTest$StrictfpInterface.class");
+ if (errors.size() > 0) {
+ for (String error: errors) {
+ System.err.println(error);
+ }
+ throw new AssertionError(AssertionErrorMessage);
+ }
+ }
+
+ void check(String dir, String... fileNames)
+ throws
+ IOException,
+ ConstantPoolException,
+ Descriptor.InvalidDescriptor {
+ for (String fileName : fileNames) {
+ ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));
+
+ for (Method method : classFileToCheck.methods) {
+ if ((method.access_flags.flags & ACC_STRICT) == 0) {
+ errors.add(String.format(offendingMethodErrorMessage,
+ method.getName(classFileToCheck.constant_pool),
+ classFileToCheck.getName()));
+ }
+ }
+ }
+ }
+
+ strictfp interface StrictfpInterface {
+ default void default_interface_method() {}
+ static void static_interface_method() {}
+ }
+
+}
diff -r adec2a5d510a -r ec434cfd2752 test/tools/javac/doctree/positions/TestPosition.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/doctree/positions/TestPosition.java Mon May 06 11:53:44 2013 -0700
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8008174
+ * @summary proper source positions for doc comments
+ * @build TestPosition
+ * @compile/ref=TestPosition.out -processor TestPosition -proc:only TestPositionSource.java
+ */
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.util.DocSourcePositions;
+import com.sun.source.util.DocTreeScanner;
+import com.sun.source.util.DocTrees;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.TreePathScanner;
+import java.io.IOException;
+import java.util.Set;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+
+@SupportedAnnotationTypes("*")
+public class TestPosition extends AbstractProcessor {
+
+ @Override
+ public boolean process(Set extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ TypeElement source = processingEnv.getElementUtils().getTypeElement("TestPositionSource");
+
+ if (source == null) throw new IllegalStateException();
+
+ if (!roundEnv.getRootElements().contains(source)) return false;
+
+ final DocTrees trees = DocTrees.instance(processingEnv);
+ final TreePath testElement = trees.getPath(source);
+
+ if (testElement == null) throw new IllegalStateException();
+
+ String code;
+
+ try {
+ code = testElement.getCompilationUnit().getSourceFile().getCharContent(false).toString();
+ } catch ( IOException ex) {
+ throw new IllegalStateException(ex);
+ }
+
+ new TreePathScanner() {
+ @Override public Void visitMethod(MethodTree node, Void p) {
+ final DocCommentTree docCommentTree = trees.getDocCommentTree(getCurrentPath());
+
+ if (docCommentTree != null) {
+ System.out.println(node.getName() + ":");
+ new DocTreeScanner() {
+ @Override public Void scan(DocTree node, Void p) {
+ if (node != null) {
+ DocSourcePositions sp = (DocSourcePositions) trees.getSourcePositions(); //XXX: the cast???
+ int start = (int) sp.getStartPosition(testElement.getCompilationUnit(), docCommentTree, node);
+ int end = (int) sp.getEndPosition(testElement.getCompilationUnit(), docCommentTree, node);
+ String snippet = code.substring(start, end).replace(" \n", "!trailing-whitespace!\n");
+
+ if (snippet.endsWith(" ")) {
+ snippet = snippet.substring(0, snippet.length() - 1) + "!trailing-whitespace!";
+ }
+ System.out.println(node.getKind().name() + ":" + snippet);
+ }
+ return super.scan(node, p);
+ }
+ }.scan(docCommentTree, null);
+ }
+
+ return super.visitMethod(node, p);
+ }
+ }.scan(testElement, null);
+
+ return false;
+ }
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+}
diff -r adec2a5d510a -r ec434cfd2752 test/tools/javac/doctree/positions/TestPosition.out
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/doctree/positions/TestPosition.out Mon May 06 11:53:44 2013 -0700
@@ -0,0 +1,99 @@
+valid:
+DOC_COMMENT:First sentence.
+ *
+ * Description with {@link java.io.InputStream link}
+ *
+ * @param first description
+ * @param second description
+ * @return whatever
+ * @throws IllegalStateException why?
+ * @since 1.15
+ * @see java.util.List
+TEXT:First sentence.
+START_ELEMENT:
+TEXT:Description with!trailing-whitespace!
+LINK:{@link java.io.InputStream link}
+REFERENCE:java.io.InputStream
+TEXT:link
+PARAM:@param first description
+IDENTIFIER:first
+TEXT:description
+PARAM:@param second description
+IDENTIFIER:second
+TEXT:description
+RETURN:@return whatever
+TEXT:whatever
+THROWS:@throws IllegalStateException why?
+REFERENCE:IllegalStateException
+TEXT:why?
+SINCE:@since 1.15
+TEXT:1.15
+SEE:@see java.util.List
+REFERENCE:java.util.List
+erroneous:
+DOC_COMMENT:First sentence.
+ *
+ *
Description with {@link}, {@link java.util.List}, {@link
+ *
+ * @param
+ * @param second
+ * @return
+ * @throws
+ * @throws IllegalStateException
+ * @since
+ * @see
+TEXT:First sentence.
+START_ELEMENT:
+TEXT:Description with!trailing-whitespace!
+LINK:{@link}
+TEXT:,!trailing-whitespace!
+LINK:{@link java.util.List}
+REFERENCE:java.util.List
+TEXT:,!trailing-whitespace!
+ERRONEOUS:{@link
+ERRONEOUS:@param
+PARAM:@param second
+IDENTIFIER:second
+RETURN:@return
+ERRONEOUS:@throws
+THROWS:@throws IllegalStateException
+REFERENCE:IllegalStateException
+SINCE:@since
+ERRONEOUS:@see
+withWhiteSpaces:
+DOC_COMMENT:First sentence.
+ *
+ *
Description with {@link }, {@link java.util.List#add( int )},
+ * {@link java.util.List#add( int ) some text with whitespaces}, {@link
+ *
+ * @param first
+ * @param second some text with trailing whitespace
+ * @return some return
+ * @throws java.lang.IllegalStateException
+ * @throws java.lang.IllegalStateException some text
+TEXT:First sentence.
+START_ELEMENT:
+TEXT:Description with!trailing-whitespace!
+LINK:{@link }
+TEXT:,!trailing-whitespace!
+LINK:{@link java.util.List#add( int )}
+REFERENCE:java.util.List#add( int )
+TEXT:,
+ *!trailing-whitespace!
+LINK:{@link java.util.List#add( int ) some text with whitespaces}
+REFERENCE:java.util.List#add( int )
+TEXT:some text with whitespaces
+TEXT:,!trailing-whitespace!
+ERRONEOUS:{@link
+PARAM:@param first
+IDENTIFIER:first
+PARAM:@param second some text with trailing whitespace
+IDENTIFIER:second
+TEXT:some text with trailing whitespace
+RETURN:@return some return
+TEXT:some return
+THROWS:@throws java.lang.IllegalStateException
+REFERENCE:java.lang.IllegalStateException
+THROWS:@throws java.lang.IllegalStateException some text
+REFERENCE:java.lang.IllegalStateException
+TEXT:some text
\ No newline at end of file
diff -r adec2a5d510a -r ec434cfd2752 test/tools/javac/doctree/positions/TestPositionSource.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/doctree/positions/TestPositionSource.java Mon May 06 11:53:44 2013 -0700
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+public class TestPositionSource {
+
+ /**First sentence.
+ *
+ *
Description with {@link java.io.InputStream link}
+ *
+ * @param first description
+ * @param second description
+ * @return whatever
+ * @throws IllegalStateException why?
+ * @since 1.15
+ * @see java.util.List
+ */
+ public boolean valid(int first, int second) throws IllegalStateException {
+ return true;
+ }
+
+ /**First sentence.
+ *
+ *
Description with {@link}, {@link java.util.List}, {@link
+ *
+ * @param
+ * @param second
+ * @return
+ * @throws
+ * @throws IllegalStateException
+ * @since
+ * @see
+ */
+ public boolean erroneous(int first, int second) throws IllegalStateException {
+ return true;
+ }
+
+ /**First sentence.
+ *
+ *
Description with {@link }, {@link java.util.List#add( int )},
+ * {@link java.util.List#add( int ) some text with whitespaces}, {@link
+ *
+ * @param first
+ * @param second some text with trailing whitespace
+ * @return some return
+ * @throws java.lang.IllegalStateException
+ * @throws java.lang.IllegalStateException some text
+ */
+ public boolean withWhiteSpaces(int first, int second) throws IllegalStateException {
+ return true;
+ }
+
+}
diff -r adec2a5d510a -r ec434cfd2752 test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNewInnerImplicitArgs.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNewInnerImplicitArgs.java Mon May 06 11:53:44 2013 -0700
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8011591
+ * @summary BootstrapMethodError when capturing constructor ref to local classes
+ * @run testng MethodReferenceTestNewInnerImplicitArgs
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * Test the case that a constructor has implicit parameters added to
+ * access local variables and that this constructor is used in a
+ * method reference.
+ * @author Robert Field
+ */
+
+@Test
+public class MethodReferenceTestNewInnerImplicitArgs {
+
+
+ static class S {
+ String b;
+ S(String s, String s2) { b = s + s2; }
+ }
+
+ interface I {
+ S m();
+ }
+
+ interface I2 {
+ S m(int i, int j);
+ }
+
+ public static void testConstructorReferenceImplicitParameters() {
+ String title = "Hey";
+ String a2 = "!!!";
+ class MS extends S {
+ MS() {
+ super(title, a2);
+ }
+ }
+
+ I result = MS::new;
+ assertEquals(result.m().b, "Hey!!!");
+
+ class MS2 extends S {
+ MS2(int x, int y) {
+ super(title+x, a2+y);
+ }
+ }
+
+ I2 result2 = MS2::new;
+ assertEquals(result2.m(8, 4).b, "Hey8!!!4");
+ }
+}
diff -r adec2a5d510a -r ec434cfd2752 test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java Mon May 06 11:53:44 2013 -0700
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8011027
+ * @library /tools/javac/lib
+ * @build JavacTestingAbstractProcessor TestTypeParameterAnnotations
+ * @compile -processor TestTypeParameterAnnotations -proc:only TestTypeParameterAnnotations.java
+ */
+
+import java.util.*;
+import java.lang.annotation.*;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import javax.lang.model.util.*;
+import javax.tools.*;
+
+public class TestTypeParameterAnnotations<@Foo @Bar @Baz T> extends JavacTestingAbstractProcessor {
+ int round = 0;
+
+ public boolean process(Set extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (++round == 1) {
+ int found = (new Scanner()).scan(roundEnv.getRootElements(), null);
+ if (found == expect) {
+ ; //nop
+ } else {
+ error("unexpected number of results: expected " + expect
+ + ", found " + found);
+ }
+
+ }
+ return true;
+ }
+
+ class Scanner extends JavacTestingAbstractProcessor.ElementScanner {
+ @Override
+ public Integer visitExecutable(ExecutableElement e, Void p) {
+ super.visitExecutable(e, p);
+ found += check(e, e.getTypeParameters());
+ return found;
+ }
+
+ @Override
+ public Integer visitType(TypeElement e, Void p) {
+ super.visitType(e, p);
+ found += check(e, e.getTypeParameters());
+ return found;
+ }
+
+ int found;
+ }
+
+ int check(Element e, List extends TypeParameterElement> typarams) {
+ if (typarams.isEmpty())
+ return 0;
+ if (typarams.size() != 1)
+ return 0;
+
+ for (TypeParameterElement tpe: typarams) {
+ boolean b1 = checkAnnotationMirrors(tpe, tpe.getAnnotationMirrors());
+ boolean b2 = checkAnnotationMirrors(tpe, elements.getAllAnnotationMirrors(tpe));
+ boolean b3 = checkGetAnnotation(tpe);
+ boolean b4 = checkGetAnnotations(tpe);
+ return b1 && b2 && b3 && b4 ? 1 : 0;
+ }
+ return 0;
+ }
+
+ boolean checkAnnotationMirrors(TypeParameterElement tpe, List extends AnnotationMirror> l) {
+ if (l.size() != 3) {
+ error("To few annotations, got " + l.size() +
+ ", should be 3", tpe);
+ return false;
+ }
+
+ AnnotationMirror m = l.get(0);
+ if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Foo"))) {
+ error("Wrong type of annotation, was expecting @Foo", m.getAnnotationType().asElement());
+ return false;
+ }
+ m = l.get(1);
+ if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Bar"))) {
+ error("Wrong type of annotation, was expecting @Bar", m.getAnnotationType().asElement());
+ return false;
+ }
+ m = l.get(2);
+ if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Baz"))) {
+ error("Wrong type of annotation, was expecting @Baz", m.getAnnotationType().asElement());
+ return false;
+ }
+ return true;
+ }
+
+ boolean checkGetAnnotation(TypeParameterElement tpe) {
+ Foo f = tpe.getAnnotation(Foo.class);
+ if (f == null)
+ error("Expecting @Foo to be present in getAnnotation()", tpe);
+
+ Bar b = tpe.getAnnotation(Bar.class);
+ if (b == null)
+ error("Expecting @Bar to be present in getAnnotation()", tpe);
+
+ Baz z = tpe.getAnnotation(Baz.class);
+ if (z == null)
+ error("Expecting @Baz to be present in getAnnotation()", tpe);
+
+ return f != null &&
+ b != null &&
+ z != null;
+ }
+
+ boolean checkGetAnnotations(TypeParameterElement tpe) {
+ Foo[] f = tpe.getAnnotationsByType(Foo.class);
+ if (f.length != 1) {
+ error("Expecting 1 @Foo to be present in getAnnotationsByType()", tpe);
+ return false;
+ }
+
+ Bar[] b = tpe.getAnnotationsByType(Bar.class);
+ if (b.length != 1) {
+ error("Expecting 1 @Bar to be present in getAnnotationsByType()", tpe);
+ return false;
+ }
+
+ Baz[] z = tpe.getAnnotationsByType(Baz.class);
+ if (z.length != 1) {
+ error("Expecting 1 @Baz to be present in getAnnotationsByType()", tpe);
+ return false;
+ }
+
+ return true;
+ }
+
+ void note(String msg) {
+ messager.printMessage(Diagnostic.Kind.NOTE, msg);
+ }
+
+ void note(String msg, Element e) {
+ messager.printMessage(Diagnostic.Kind.NOTE, msg, e);
+ }
+
+ void error(String msg, Element e) {
+ messager.printMessage(Diagnostic.Kind.ERROR, msg, e);
+ }
+
+ void error(String msg) {
+ messager.printMessage(Diagnostic.Kind.ERROR, msg);
+ }
+
+ // additional generic elements to test
+ <@Foo @Bar @Baz X> X m(X x) { return x; }
+
+ interface Intf<@Foo @Bar @Baz X> { X m() ; }
+
+ class Class<@Foo @Bar @Baz X> {
+ <@Foo @Bar @Baz Y> Class() { }
+ }
+
+ final int expect = 5; // top level class, plus preceding examples
+}
+
+@Target(ElementType.TYPE_PARAMETER)
+@interface Foo {}
+
+@Target(ElementType.TYPE_PARAMETER)
+@interface Bar {}
+
+@Target(ElementType.TYPE_PARAMETER)
+@interface Baz {}