--- a/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -33,7 +33,9 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface AttributeTree extends DocTree {
+ @jdk.Supported
enum ValueKind { EMPTY, UNQUOTED, SINGLE, DOUBLE };
Name getName();
--- a/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -35,6 +35,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface AuthorTree extends BlockTagTree {
List<? extends DocTree> getName();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -31,6 +31,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface BlockTagTree extends DocTree {
String getTagName();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -33,6 +33,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface CommentTree extends DocTree {
String getBody();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -35,6 +35,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface DeprecatedTree extends BlockTagTree {
List<? extends DocTree> getBody();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -35,6 +35,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface DocCommentTree extends DocTree {
List<? extends DocTree> getFirstSentence();
List<? extends DocTree> getBody();
--- a/langtools/src/share/classes/com/sun/source/doctree/DocRootTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/DocRootTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -33,4 +33,5 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface DocRootTree extends InlineTagTree { }
--- a/langtools/src/share/classes/com/sun/source/doctree/DocTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/DocTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -30,7 +30,9 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface DocTree {
+ @jdk.Supported
enum Kind {
/**
* Used for instances of {@link AttributeTree}
--- a/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -54,6 +54,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface DocTreeVisitor<R,P> {
R visitAttribute(AttributeTree node, P p);
R visitAuthor(AuthorTree node, P p);
--- a/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -35,6 +35,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface EndElementTree extends DocTree {
Name getName();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -36,6 +36,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface EntityTree extends DocTree {
Name getName();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -32,6 +32,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface ErroneousTree extends TextTree {
/**
* Gets a diagnostic object giving details about
--- a/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -35,6 +35,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface IdentifierTree extends DocTree {
Name getName();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/InheritDocTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/InheritDocTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -34,4 +34,5 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface InheritDocTree extends InlineTagTree { }
--- a/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -31,6 +31,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface InlineTagTree extends DocTree {
String getTagName();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -36,6 +36,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface LinkTree extends InlineTagTree {
ReferenceTree getReference();
List<? extends DocTree> getLabel();
--- a/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -34,6 +34,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface LiteralTree extends InlineTagTree {
TextTree getBody();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -35,6 +35,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface ParamTree extends BlockTagTree {
boolean isTypeParameter();
IdentifierTree getName();
--- a/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -33,6 +33,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface ReferenceTree extends DocTree {
String getSignature();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -35,6 +35,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface ReturnTree extends BlockTagTree {
List<? extends DocTree> getDescription();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -38,6 +38,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface SeeTree extends BlockTagTree {
List<? extends DocTree> getReference();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -35,6 +35,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface SerialDataTree extends BlockTagTree {
List<? extends DocTree> getDescription();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -35,6 +35,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface SerialFieldTree extends BlockTagTree {
IdentifierTree getName();
ReferenceTree getType();
--- a/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -35,6 +35,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface SerialTree extends BlockTagTree {
List<? extends DocTree> getDescription();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -35,6 +35,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface SinceTree extends BlockTagTree {
List<? extends DocTree> getBody();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -36,6 +36,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface StartElementTree extends DocTree {
Name getName();
List<? extends DocTree> getAttributes();
--- a/langtools/src/share/classes/com/sun/source/doctree/TextTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/TextTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -30,6 +30,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface TextTree extends DocTree {
String getBody();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -38,6 +38,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface ThrowsTree extends BlockTagTree {
ReferenceTree getExceptionName();
List<? extends DocTree> getDescription();
--- a/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -35,6 +35,7 @@
* @since 1.8
*
*/
+@jdk.Supported
public interface UnknownBlockTagTree extends BlockTagTree {
List<? extends DocTree> getContent();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -35,6 +35,7 @@
* @since 1.8
*
*/
+@jdk.Supported
public interface UnknownInlineTagTree extends InlineTagTree {
List<? extends DocTree> getContent();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -33,6 +33,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface ValueTree extends InlineTagTree {
ReferenceTree getReference();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -36,6 +36,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface VersionTree extends BlockTagTree {
List<? extends DocTree> getBody();
}
--- a/langtools/src/share/classes/com/sun/source/doctree/package-info.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/doctree/package-info.java Tue Mar 12 16:43:53 2013 -0700
@@ -31,4 +31,5 @@
* @since 1.8
* @see <a href="http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags">http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags</a>
*/
+@jdk.Supported
package com.sun.source.doctree;
--- a/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -41,6 +41,7 @@
* @author Mahmood Ali
* @since 1.8
*/
+@jdk.Supported
public interface AnnotatedTypeTree extends ExpressionTree {
List<? extends AnnotationTree> getAnnotations();
ExpressionTree getUnderlyingType();
--- a/langtools/src/share/classes/com/sun/source/tree/AnnotationTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/AnnotationTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -42,6 +42,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface AnnotationTree extends ExpressionTree {
Tree getAnnotationType();
List<? extends ExpressionTree> getArguments();
--- a/langtools/src/share/classes/com/sun/source/tree/ArrayAccessTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ArrayAccessTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface ArrayAccessTree extends ExpressionTree {
ExpressionTree getExpression();
ExpressionTree getIndex();
--- a/langtools/src/share/classes/com/sun/source/tree/ArrayTypeTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ArrayTypeTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface ArrayTypeTree extends Tree {
Tree getType();
}
--- a/langtools/src/share/classes/com/sun/source/tree/AssertTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/AssertTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -41,6 +41,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface AssertTree extends StatementTree {
ExpressionTree getCondition();
ExpressionTree getDetail();
--- a/langtools/src/share/classes/com/sun/source/tree/AssignmentTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/AssignmentTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface AssignmentTree extends ExpressionTree {
ExpressionTree getVariable();
ExpressionTree getExpression();
--- a/langtools/src/share/classes/com/sun/source/tree/BinaryTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/BinaryTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -40,6 +40,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface BinaryTree extends ExpressionTree {
ExpressionTree getLeftOperand();
ExpressionTree getRightOperand();
--- a/langtools/src/share/classes/com/sun/source/tree/BlockTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/BlockTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -45,6 +45,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface BlockTree extends StatementTree {
boolean isStatic();
List<? extends StatementTree> getStatements();
--- a/langtools/src/share/classes/com/sun/source/tree/BreakTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/BreakTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -43,6 +43,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface BreakTree extends StatementTree {
Name getLabel();
}
--- a/langtools/src/share/classes/com/sun/source/tree/CaseTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/CaseTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -45,6 +45,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface CaseTree extends Tree {
/**
* @return null if and only if this Case is {@code default:}
--- a/langtools/src/share/classes/com/sun/source/tree/CatchTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/CatchTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -40,6 +40,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface CatchTree extends Tree {
VariableTree getParameter();
BlockTree getBlock();
--- a/langtools/src/share/classes/com/sun/source/tree/ClassTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ClassTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -48,6 +48,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface ClassTree extends StatementTree {
ModifiersTree getModifiers();
Name getSimpleName();
--- a/langtools/src/share/classes/com/sun/source/tree/CompilationUnitTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/CompilationUnitTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, 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
@@ -37,6 +37,7 @@
* @author Peter von der Ahé
* @since 1.6
*/
+@jdk.Supported
public interface CompilationUnitTree extends Tree {
List<? extends AnnotationTree> getPackageAnnotations();
ExpressionTree getPackageName();
--- a/langtools/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -40,6 +40,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface CompoundAssignmentTree extends ExpressionTree {
ExpressionTree getVariable();
ExpressionTree getExpression();
--- a/langtools/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface ConditionalExpressionTree extends ExpressionTree {
ExpressionTree getCondition();
ExpressionTree getTrueExpression();
--- a/langtools/src/share/classes/com/sun/source/tree/ContinueTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ContinueTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -42,6 +42,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface ContinueTree extends StatementTree {
Name getLabel();
}
--- a/langtools/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -41,6 +41,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface DoWhileLoopTree extends StatementTree {
ExpressionTree getCondition();
StatementTree getStatement();
--- a/langtools/src/share/classes/com/sun/source/tree/EmptyStatementTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/EmptyStatementTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -39,4 +39,5 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface EmptyStatementTree extends StatementTree {}
--- a/langtools/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -40,6 +40,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface EnhancedForLoopTree extends StatementTree {
VariableTree getVariable();
ExpressionTree getExpression();
--- a/langtools/src/share/classes/com/sun/source/tree/ErroneousTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ErroneousTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -34,6 +34,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface ErroneousTree extends ExpressionTree {
List<? extends Tree> getErrorTrees();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface ExpressionStatementTree extends StatementTree {
ExpressionTree getExpression();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ExpressionTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ExpressionTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -35,4 +35,5 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface ExpressionTree extends Tree {}
--- a/langtools/src/share/classes/com/sun/source/tree/ForLoopTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ForLoopTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -42,6 +42,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface ForLoopTree extends StatementTree {
List<? extends StatementTree> getInitializer();
ExpressionTree getCondition();
--- a/langtools/src/share/classes/com/sun/source/tree/IdentifierTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/IdentifierTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -41,6 +41,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface IdentifierTree extends ExpressionTree {
Name getName();
}
--- a/langtools/src/share/classes/com/sun/source/tree/IfTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/IfTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -45,6 +45,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface IfTree extends StatementTree {
ExpressionTree getCondition();
StatementTree getThenStatement();
--- a/langtools/src/share/classes/com/sun/source/tree/ImportTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ImportTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -41,6 +41,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface ImportTree extends Tree {
boolean isStatic();
/**
--- a/langtools/src/share/classes/com/sun/source/tree/InstanceOfTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/InstanceOfTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface InstanceOfTree extends ExpressionTree {
ExpressionTree getExpression();
Tree getType();
--- a/langtools/src/share/classes/com/sun/source/tree/IntersectionTypeTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/IntersectionTypeTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -34,6 +34,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface IntersectionTypeTree extends Tree {
List<? extends Tree> getBounds();
}
--- a/langtools/src/share/classes/com/sun/source/tree/LabeledStatementTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/LabeledStatementTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -41,6 +41,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface LabeledStatementTree extends StatementTree {
Name getLabel();
StatementTree getStatement();
--- a/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -37,12 +37,14 @@
* (x,y)-> { return x + y; }
* }</pre>
*/
+@jdk.Supported
public interface LambdaExpressionTree extends ExpressionTree {
/**
* Lambda expressions come in two forms: (i) expression lambdas, whose body
* is an expression, and (ii) statement lambdas, whose body is a block
*/
+ @jdk.Supported
public enum BodyKind {
/** enum constant for expression lambdas */
EXPRESSION,
--- a/langtools/src/share/classes/com/sun/source/tree/LineMap.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/LineMap.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -31,6 +31,7 @@
*
* @since 1.6
*/
+@jdk.Supported
public interface LineMap {
/**
* Find the start position of a line.
--- a/langtools/src/share/classes/com/sun/source/tree/LiteralTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/LiteralTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -40,6 +40,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface LiteralTree extends ExpressionTree {
Object getValue();
}
--- a/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -39,12 +39,14 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface MemberReferenceTree extends ExpressionTree {
/**
* There are two kinds of member references: (i) method references and
* (ii) constructor references
*/
+ @jdk.Supported
public enum ReferenceMode {
/** enum constant for method references */
INVOKE,
--- a/langtools/src/share/classes/com/sun/source/tree/MemberSelectTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/MemberSelectTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -41,6 +41,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface MemberSelectTree extends ExpressionTree {
ExpressionTree getExpression();
Name getIdentifier();
--- a/langtools/src/share/classes/com/sun/source/tree/MethodInvocationTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/MethodInvocationTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -43,6 +43,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface MethodInvocationTree extends ExpressionTree {
List<? extends Tree> getTypeArguments();
ExpressionTree getMethodSelect();
--- a/langtools/src/share/classes/com/sun/source/tree/MethodTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/MethodTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -46,6 +46,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface MethodTree extends Tree {
ModifiersTree getModifiers();
Name getName();
--- a/langtools/src/share/classes/com/sun/source/tree/ModifiersTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ModifiersTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -45,6 +45,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface ModifiersTree extends Tree {
Set<Modifier> getFlags();
List<? extends AnnotationTree> getAnnotations();
--- a/langtools/src/share/classes/com/sun/source/tree/NewArrayTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/NewArrayTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -43,6 +43,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface NewArrayTree extends ExpressionTree {
Tree getType();
List<? extends ExpressionTree> getDimensions();
--- a/langtools/src/share/classes/com/sun/source/tree/NewClassTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/NewClassTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -48,6 +48,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface NewClassTree extends ExpressionTree {
ExpressionTree getEnclosingExpression();
List<? extends Tree> getTypeArguments();
--- a/langtools/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -41,6 +41,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface ParameterizedTypeTree extends Tree {
Tree getType();
List<? extends Tree> getTypeArguments();
--- a/langtools/src/share/classes/com/sun/source/tree/ParenthesizedTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ParenthesizedTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -40,6 +40,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface ParenthesizedTree extends ExpressionTree {
ExpressionTree getExpression();
}
--- a/langtools/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -41,6 +41,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface PrimitiveTypeTree extends Tree {
TypeKind getPrimitiveTypeKind();
}
--- a/langtools/src/share/classes/com/sun/source/tree/ReturnTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ReturnTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -40,6 +40,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface ReturnTree extends StatementTree {
ExpressionTree getExpression();
}
--- a/langtools/src/share/classes/com/sun/source/tree/Scope.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/Scope.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -48,6 +48,7 @@
*
* @since 1.6
*/
+@jdk.Supported
public interface Scope {
/**
* Returns the enclosing scope.
--- a/langtools/src/share/classes/com/sun/source/tree/StatementTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/StatementTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -35,4 +35,5 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface StatementTree extends Tree {}
--- a/langtools/src/share/classes/com/sun/source/tree/SwitchTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/SwitchTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -43,6 +43,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface SwitchTree extends StatementTree {
ExpressionTree getExpression();
List<? extends CaseTree> getCases();
--- a/langtools/src/share/classes/com/sun/source/tree/SynchronizedTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/SynchronizedTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -40,6 +40,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface SynchronizedTree extends StatementTree {
ExpressionTree getExpression();
BlockTree getBlock();
--- a/langtools/src/share/classes/com/sun/source/tree/ThrowTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/ThrowTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface ThrowTree extends StatementTree {
ExpressionTree getExpression();
}
--- a/langtools/src/share/classes/com/sun/source/tree/Tree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/Tree.java Tue Mar 12 16:43:53 2013 -0700
@@ -39,11 +39,13 @@
*
* @since 1.6
*/
+@jdk.Supported
public interface Tree {
/**
* Enumerates all kinds of trees.
*/
+ @jdk.Supported
public enum Kind {
ANNOTATED_TYPE(AnnotatedTypeTree.class),
--- a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java Tue Mar 12 16:43:53 2013 -0700
@@ -56,6 +56,7 @@
*
* @since 1.6
*/
+@jdk.Supported
public interface TreeVisitor<R,P> {
R visitAnnotatedType(AnnotatedTypeTree node, P p);
R visitAnnotation(AnnotationTree node, P p);
--- a/langtools/src/share/classes/com/sun/source/tree/TryTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/TryTree.java Tue Mar 12 16:43:53 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
@@ -45,6 +45,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface TryTree extends StatementTree {
BlockTree getBlock();
List<? extends CatchTree> getCatches();
--- a/langtools/src/share/classes/com/sun/source/tree/TypeCastTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/TypeCastTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface TypeCastTree extends ExpressionTree {
Tree getType();
ExpressionTree getExpression();
--- a/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -44,6 +44,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface TypeParameterTree extends Tree {
Name getName();
List<? extends Tree> getBounds();
--- a/langtools/src/share/classes/com/sun/source/tree/UnaryTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/UnaryTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -42,6 +42,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface UnaryTree extends ExpressionTree {
ExpressionTree getExpression();
}
--- a/langtools/src/share/classes/com/sun/source/tree/UnionTypeTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/UnionTypeTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -34,6 +34,7 @@
*
* @since 1.7
*/
+@jdk.Supported
public interface UnionTypeTree extends Tree {
List<? extends Tree> getTypeAlternatives();
}
--- a/langtools/src/share/classes/com/sun/source/tree/VariableTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/VariableTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -41,6 +41,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface VariableTree extends StatementTree {
ModifiersTree getModifiers();
Name getName();
--- a/langtools/src/share/classes/com/sun/source/tree/WhileLoopTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/WhileLoopTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -41,6 +41,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface WhileLoopTree extends StatementTree {
ExpressionTree getCondition();
StatementTree getStatement();
--- a/langtools/src/share/classes/com/sun/source/tree/WildcardTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/WildcardTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -44,6 +44,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface WildcardTree extends Tree {
Tree getBound();
}
--- a/langtools/src/share/classes/com/sun/source/tree/package-info.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/tree/package-info.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -31,4 +31,5 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
package com.sun.source.tree;
--- a/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -67,6 +67,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public class DocTreeScanner<R,P> implements DocTreeVisitor<R,P> {
/**
--- a/langtools/src/share/classes/com/sun/source/util/DocTrees.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/DocTrees.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -38,6 +38,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public abstract class DocTrees extends Trees {
/**
* Gets a DocTrees object for a given CompilationTask.
--- a/langtools/src/share/classes/com/sun/source/util/JavacTask.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/JavacTask.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, 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
@@ -48,6 +48,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public abstract class JavacTask implements CompilationTask {
/**
--- a/langtools/src/share/classes/com/sun/source/util/Plugin.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/Plugin.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, 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
@@ -48,6 +48,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public interface Plugin {
/**
* Get the user-friendly name of this plug-in.
--- a/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, 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
@@ -32,6 +32,7 @@
*
* @since 1.8
*/
+@jdk.Supported
public class SimpleDocTreeVisitor<R,P> implements DocTreeVisitor<R, P> {
protected final R DEFAULT_VALUE;
--- a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java Tue Mar 12 16:43:53 2013 -0700
@@ -33,6 +33,7 @@
* @author Peter von der Ahé
* @since 1.6
*/
+@jdk.Supported
public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> {
protected final R DEFAULT_VALUE;
--- a/langtools/src/share/classes/com/sun/source/util/SourcePositions.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/SourcePositions.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -35,6 +35,7 @@
* @author Peter von der Ahé
* @since 1.6
*/
+@jdk.Supported
public interface SourcePositions {
/**
--- a/langtools/src/share/classes/com/sun/source/util/TaskEvent.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/TaskEvent.java Tue Mar 12 16:43:53 2013 -0700
@@ -36,12 +36,14 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public final class TaskEvent
{
/**
* Kind of task event.
* @since 1.6
*/
+ @jdk.Supported
public enum Kind {
/**
* For events related to the parsing of a file.
--- a/langtools/src/share/classes/com/sun/source/util/TaskListener.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/TaskListener.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -32,6 +32,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public interface TaskListener
{
public void started(TaskEvent e);
--- a/langtools/src/share/classes/com/sun/source/util/TreePath.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/TreePath.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -36,6 +36,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public class TreePath implements Iterable<Tree> {
/**
* Gets a tree path for a tree node within a compilation unit.
--- a/langtools/src/share/classes/com/sun/source/util/TreePathScanner.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/TreePathScanner.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -38,6 +38,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public class TreePathScanner<R, P> extends TreeScanner<R, P> {
/**
--- a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java Tue Mar 12 16:43:53 2013 -0700
@@ -68,6 +68,7 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
public class TreeScanner<R,P> implements TreeVisitor<R,P> {
/** Scan a single node.
--- a/langtools/src/share/classes/com/sun/source/util/Trees.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/Trees.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, 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
@@ -51,6 +51,7 @@
*
* @author Peter von der Ahé
*/
+@jdk.Supported
public abstract class Trees {
/**
* Gets a Trees object for a given CompilationTask.
--- a/langtools/src/share/classes/com/sun/source/util/package-info.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/source/util/package-info.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 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
@@ -30,4 +30,5 @@
* @author Jonathan Gibbons
* @since 1.6
*/
+@jdk.Supported
package com.sun.source.util;
--- a/langtools/src/share/classes/com/sun/tools/classfile/ClassWriter.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/classfile/ClassWriter.java Tue Mar 12 16:43:53 2013 -0700
@@ -483,7 +483,7 @@
out.writeByte(attr.method_parameter_table.length);
for (MethodParameters_attribute.Entry e : attr.method_parameter_table) {
out.writeShort(e.name_index);
- out.writeInt(e.flags);
+ out.writeShort(e.flags);
}
return null;
}
--- a/langtools/src/share/classes/com/sun/tools/classfile/MethodParameters_attribute.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/classfile/MethodParameters_attribute.java Tue Mar 12 16:43:53 2013 -0700
@@ -73,7 +73,7 @@
public static class Entry {
Entry(ClassReader cr) throws IOException {
name_index = cr.readUnsignedShort();
- flags = cr.readInt();
+ flags = cr.readUnsignedShort();
}
public static int length() {
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java Tue Mar 12 16:43:53 2013 -0700
@@ -60,7 +60,7 @@
ClassDoc classDoc) {
super(writer, classDoc);
VisibleMemberMap visibleMemberMap = new VisibleMemberMap(classDoc,
- VisibleMemberMap.CONSTRUCTORS, configuration.nodeprecated);
+ VisibleMemberMap.CONSTRUCTORS, configuration);
List<ProgramElementDoc> constructors = new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
for (int i = 0; i < constructors.size(); i++) {
if ((constructors.get(i)).isProtected() ||
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Tue Mar 12 16:43:53 2013 -0700
@@ -543,7 +543,8 @@
}
HtmlTree navList = new HtmlTree(HtmlTag.UL);
navList.addStyle(HtmlStyle.navList);
- navList.addAttr(HtmlAttr.TITLE, "Navigation");
+ navList.addAttr(HtmlAttr.TITLE,
+ configuration.getText("doclet.Navigation"));
if (configuration.createoverview) {
navList.addContent(getNavLinkContents());
}
@@ -1299,13 +1300,31 @@
*/
public String getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
String label, boolean strong) {
+ return getDocLink(context, classDoc, doc, label, strong, false);
+ }
+
+ /**
+ * Return the link for the given member.
+ *
+ * @param context the id of the context where the link will be printed.
+ * @param classDoc the classDoc that we should link to. This is not
+ * necessarily equal to doc.containingClass(). We may be
+ * inheriting comments.
+ * @param doc the member being linked to.
+ * @param label the label for the link.
+ * @param strong true if the link should be strong.
+ * @param isProperty true if the doc parameter is a JavaFX property.
+ * @return the link for the given member.
+ */
+ public String getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
+ String label, boolean strong, boolean isProperty) {
if (! (doc.isIncluded() ||
Util.isLinkable(classDoc, configuration))) {
return label;
} else if (doc instanceof ExecutableMemberDoc) {
ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
return getLink(new LinkInfoImpl(configuration, context, classDoc,
- getAnchor(emd), label, strong));
+ getAnchor(emd, isProperty), label, strong));
} else if (doc instanceof MemberDoc) {
return getLink(new LinkInfoImpl(configuration, context, classDoc,
doc.name(), label, strong));
@@ -1343,6 +1362,13 @@
}
public String getAnchor(ExecutableMemberDoc emd) {
+ return getAnchor(emd, false);
+ }
+
+ public String getAnchor(ExecutableMemberDoc emd, boolean isProperty) {
+ if (isProperty) {
+ return emd.name();
+ }
StringBuilder signature = new StringBuilder(emd.signature());
StringBuilder signatureParsed = new StringBuilder();
int counter = 0;
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java Tue Mar 12 16:43:53 2013 -0700
@@ -198,6 +198,11 @@
*/
public static final int CONTEXT_CLASS_USE_HEADER = 33;
+ /**
+ * The header for property documentation copied from parent.
+ */
+ public static final int CONTEXT_PROPERTY_DOC_COPY = 34;
+
public final ConfigurationImpl configuration;
/**
@@ -422,6 +427,7 @@
case CONTEXT_SUBCLASSES:
case CONTEXT_METHOD_DOC_COPY:
case CONTEXT_FIELD_DOC_COPY:
+ case CONTEXT_PROPERTY_DOC_COPY:
case CONTEXT_CLASS_USE_HEADER:
includeTypeInClassLinkLabel = false;
break;
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -161,6 +161,7 @@
*/
protected void addClassKindListing(ClassDoc[] arr, Content labelContent,
Content contentTree) {
+ arr = Util.filterOutPrivateClasses(arr, configuration.javafx);
if(arr.length > 0) {
Arrays.sort(arr);
boolean printedHeader = false;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,322 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.formats.html;
+
+import java.io.*;
+
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+
+/**
+ * Writes property documentation in HTML format.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ *
+ * @author Robert Field
+ * @author Atul M Dambalkar
+ * @author Jamie Ho (rewrite)
+ * @author Bhavesh Patel (Modified)
+ */
+public class PropertyWriterImpl extends AbstractMemberWriter
+ implements PropertyWriter, MemberSummaryWriter {
+
+ public PropertyWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) {
+ super(writer, classdoc);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getMemberSummaryHeader(ClassDoc classDoc,
+ Content memberSummaryTree) {
+ memberSummaryTree.addContent(HtmlConstants.START_OF_PROPERTY_SUMMARY);
+ Content memberTree = writer.getMemberTreeHeader();
+ writer.addSummaryHeader(this, classDoc, memberTree);
+ return memberTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getPropertyDetailsTreeHeader(ClassDoc classDoc,
+ Content memberDetailsTree) {
+ memberDetailsTree.addContent(HtmlConstants.START_OF_PROPERTY_DETAILS);
+ Content propertyDetailsTree = writer.getMemberTreeHeader();
+ propertyDetailsTree.addContent(writer.getMarkerAnchor("property_detail"));
+ Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+ writer.propertyDetailsLabel);
+ propertyDetailsTree.addContent(heading);
+ return propertyDetailsTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getPropertyDocTreeHeader(MethodDoc property,
+ Content propertyDetailsTree) {
+ propertyDetailsTree.addContent(
+ writer.getMarkerAnchor(property.name()));
+ Content propertyDocTree = writer.getMemberTreeHeader();
+ Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+ heading.addContent(property.name().substring(0, property.name().lastIndexOf("Property")));
+ propertyDocTree.addContent(heading);
+ return propertyDocTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getSignature(MethodDoc property) {
+ Content pre = new HtmlTree(HtmlTag.PRE);
+ writer.addAnnotationInfo(property, pre);
+ addModifiers(property, pre);
+ Content propertylink = new RawHtml(writer.getLink(new LinkInfoImpl(
+ configuration, LinkInfoImpl.CONTEXT_MEMBER,
+ property.returnType())));
+ pre.addContent(propertylink);
+ pre.addContent(" ");
+ if (configuration.linksource) {
+ Content propertyName = new StringContent(property.name());
+ writer.addSrcLink(property, propertyName, pre);
+ } else {
+ addName(property.name(), pre);
+ }
+ return pre;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addDeprecated(MethodDoc property, Content propertyDocTree) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addComments(MethodDoc property, Content propertyDocTree) {
+ ClassDoc holder = property.containingClass();
+ if (property.inlineTags().length > 0) {
+ if (holder.equals(classdoc) ||
+ (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) {
+ writer.addInlineComment(property, propertyDocTree);
+ } else {
+ Content link = new RawHtml(
+ writer.getDocLink(LinkInfoImpl.CONTEXT_PROPERTY_DOC_COPY,
+ holder, property,
+ holder.isIncluded() ?
+ holder.typeName() : holder.qualifiedTypeName(),
+ false));
+ Content codeLink = HtmlTree.CODE(link);
+ Content strong = HtmlTree.STRONG(holder.isClass()?
+ writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
+ strong.addContent(writer.getSpace());
+ strong.addContent(codeLink);
+ propertyDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, strong));
+ writer.addInlineComment(property, propertyDocTree);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addTags(MethodDoc property, Content propertyDocTree) {
+ writer.addTagsInfo(property, propertyDocTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getPropertyDetails(Content propertyDetailsTree) {
+ return getMemberTree(propertyDetailsTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getPropertyDoc(Content propertyDocTree,
+ boolean isLastContent) {
+ return getMemberTree(propertyDocTree, isLastContent);
+ }
+
+ /**
+ * Close the writer.
+ */
+ public void close() throws IOException {
+ writer.close();
+ }
+
+ public int getMemberKind() {
+ return VisibleMemberMap.PROPERTIES;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addSummaryLabel(Content memberTree) {
+ Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ writer.getResource("doclet.Property_Summary"));
+ memberTree.addContent(label);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getTableSummary() {
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Property_Summary"),
+ configuration.getText("doclet.properties"));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getCaption() {
+ return configuration.getText("doclet.Properties");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getSummaryTableHeader(ProgramElementDoc member) {
+ String[] header = new String[] {
+ configuration.getText("doclet.Type"),
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Property"),
+ configuration.getText("doclet.Description"))
+ };
+ return header;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
+ memberTree.addContent(writer.getMarkerAnchor("property_summary"));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
+ inheritedTree.addContent(writer.getMarkerAnchor(
+ "properties_inherited_from_class_" + configuration.getClassName(cd)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
+ Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
+ LinkInfoImpl.CONTEXT_MEMBER, cd, false));
+ Content label = new StringContent(cd.isClass() ?
+ configuration.getText("doclet.Properties_Inherited_From_Class") :
+ configuration.getText("doclet.Properties_Inherited_From_Interface"));
+ Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
+ label);
+ labelHeading.addContent(writer.getSpace());
+ labelHeading.addContent(classLink);
+ inheritedTree.addContent(labelHeading);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
+ Content tdSummary) {
+ Content strong = HtmlTree.STRONG(new RawHtml(
+ writer.getDocLink(context,
+ cd,
+ (MemberDoc) member,
+ member.name().substring(0, member.name().lastIndexOf("Property")),
+ false,
+ true)));
+
+ Content code = HtmlTree.CODE(strong);
+ tdSummary.addContent(code);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addInheritedSummaryLink(ClassDoc cd,
+ ProgramElementDoc member, Content linksTree) {
+ linksTree.addContent(new RawHtml(
+ writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
+ ((member.name().lastIndexOf("Property") != -1) && configuration.javafx)
+ ? member.name().substring(0, member.name().length() - "Property".length())
+ : member.name(),
+ false, true)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
+ MethodDoc property = (MethodDoc)member;
+ addModifierAndType(property, property.returnType(), tdSummaryType);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Content getDeprecatedLink(ProgramElementDoc member) {
+ return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
+ (MemberDoc) member, ((MethodDoc)member).qualifiedName());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
+ if (link) {
+ return writer.getHyperLink((cd == null)?
+ "property_summary":
+ "properties_inherited_from_class_" +
+ configuration.getClassName(cd),
+ writer.getResource("doclet.navProperty"));
+ } else {
+ return writer.getResource("doclet.navProperty");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addNavDetailLink(boolean link, Content liNav) {
+ if (link) {
+ liNav.addContent(writer.getHyperLink("property_detail",
+ writer.getResource("doclet.navProperty")));
+ } else {
+ liNav.addContent(writer.getResource("doclet.navProperty"));
+ }
+ }
+}
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java Tue Mar 12 16:43:53 2013 -0700
@@ -146,6 +146,15 @@
/**
* {@inheritDoc}
*/
+ public PropertyWriterImpl getPropertyWriter(ClassWriter classWriter)
+ throws Exception {
+ return new PropertyWriterImpl((SubWriterHolderWriter) classWriter,
+ classWriter.getClassDoc());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public MethodWriterImpl getMethodWriter(ClassWriter classWriter)
throws Exception {
return new MethodWriterImpl((SubWriterHolderWriter) classWriter,
@@ -174,6 +183,8 @@
return getEnumConstantWriter(classWriter);
case VisibleMemberMap.FIELDS:
return getFieldWriter(classWriter);
+ case VisibleMemberMap.PROPERTIES:
+ return getPropertyWriter(classWriter);
case VisibleMemberMap.INNERCLASSES:
return new NestedClassWriterImpl((SubWriterHolderWriter)
classWriter, classWriter.getClassDoc());
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlConstants.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlConstants.java Tue Mar 12 16:43:53 2013 -0700
@@ -112,6 +112,12 @@
new Comment("=========== FIELD SUMMARY ===========");
/**
+ * Marker to identify start of properties summary.
+ */
+ public static final Content START_OF_PROPERTY_SUMMARY =
+ new Comment("=========== PROPERTY SUMMARY ===========");
+
+ /**
* Marker to identify start of method summary.
*/
public static final Content START_OF_METHOD_SUMMARY =
@@ -136,6 +142,12 @@
new Comment("============ FIELD DETAIL ===========");
/**
+ * Marker to identify start of property details.
+ */
+ public static final Content START_OF_PROPERTY_DETAILS =
+ new Comment("============ PROPERTY DETAIL ===========");
+
+ /**
* Marker to identify start of constructor details.
*/
public static final Content START_OF_CONSTRUCTOR_DETAILS =
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Tue Mar 12 16:43:53 2013 -0700
@@ -148,6 +148,8 @@
public final Content fieldDetailsLabel;
+ public final Content propertyDetailsLabel;
+
public final Content constructorDetailsLabel;
public final Content enumConstantsDetailsLabel;
@@ -226,6 +228,7 @@
methodDetailsLabel = getResource("doclet.Method_Detail");
annotationTypeDetailsLabel = getResource("doclet.Annotation_Type_Member_Detail");
fieldDetailsLabel = getResource("doclet.Field_Detail");
+ propertyDetailsLabel = getResource("doclet.Property_Detail");
constructorDetailsLabel = getResource("doclet.Constructor_Detail");
enumConstantsDetailsLabel = getResource("doclet.Enum_Constant_Detail");
specifiedByLabel = getResource("doclet.Specified_By");
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Tue Mar 12 16:43:53 2013 -0700
@@ -36,6 +36,7 @@
doclet.navAnnotationTypeRequiredMember=Required
doclet.navAnnotationTypeMember=Element
doclet.navField=Field
+doclet.navProperty=Property
doclet.navEnum=Enum Constants
doclet.navConstructor=Constr
doclet.navMethod=Method
@@ -44,6 +45,7 @@
doclet.Window_Split_Index={0}-Index
doclet.Help=Help
doclet.Skip_navigation_links=Skip navigation links
+doclet.Navigation=Navigation
doclet.New_Page=NewPage
doclet.navDeprecated=Deprecated
doclet.Window_Deprecated_List=Deprecated List
@@ -95,7 +97,7 @@
doclet.Subinterfaces=All Known Subinterfaces:
doclet.Implementing_Classes=All Known Implementing Classes:
doclet.Functional_Interface=Functional Interface:
-doclet.Functional_Interface_Message=This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
+doclet.Functional_Interface_Message=This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
doclet.also=also
doclet.Frames=Frames
doclet.No_Frames=No Frames
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java Tue Mar 12 16:43:53 2013 -0700
@@ -80,6 +80,9 @@
}
try {
doclet.startGeneration(root);
+ } catch (Configuration.Fault f) {
+ root.printError(f.getMessage());
+ return false;
} catch (Exception exc) {
exc.printStackTrace();
return false;
@@ -110,7 +113,7 @@
*
* @see com.sun.javadoc.RootDoc
*/
- private void startGeneration(RootDoc root) throws Exception {
+ private void startGeneration(RootDoc root) throws Configuration.Fault, Exception {
if (root.classes().length == 0) {
configuration.message.
error("doclet.No_Public_Classes_To_Document");
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Tue Mar 12 16:43:53 2013 -0700
@@ -54,6 +54,21 @@
public abstract class Configuration {
/**
+ * Exception used to report a problem during setOptions.
+ */
+ public class Fault extends Exception {
+ private static final long serialVersionUID = 0;
+
+ Fault(String msg) {
+ super(msg);
+ }
+
+ Fault(String msg, Exception cause) {
+ super(msg, cause);
+ }
+ }
+
+ /**
* The factory for builders.
*/
protected BuilderFactory builderFactory;
@@ -176,6 +191,12 @@
public boolean showauthor = false;
/**
+ * Generate documentation for JavaFX getters and setters automatically
+ * by copying it from the appropriate property definition.
+ */
+ public boolean javafx = false;
+
+ /**
* Generate version specific information for the all the classes
* if @version tag is used in the doc comment and if -version option is
* used. <code>showversion</code> is set to true if -version option is
@@ -251,7 +272,7 @@
* @param options The array of option names and values.
* @throws DocletAbortException
*/
- public abstract void setSpecificDocletOptions(String[][] options);
+ public abstract void setSpecificDocletOptions(String[][] options) throws Fault;
/**
* Return the doclet specific {@link MessageRetriever}
@@ -317,6 +338,7 @@
option = option.toLowerCase();
if (option.equals("-author") ||
option.equals("-docfilessubdirs") ||
+ option.equals("-javafx") ||
option.equals("-keywords") ||
option.equals("-linksource") ||
option.equals("-nocomment") ||
@@ -406,15 +428,26 @@
*
* @param options the two dimensional array of options.
*/
- public void setOptions(String[][] options) {
+ public void setOptions(String[][] options) throws Fault {
LinkedHashSet<String[]> customTagStrs = new LinkedHashSet<String[]>();
+
+ // Some options, specifically -link and -linkoffline, require that
+ // the output directory has already been created: so do that first.
for (int oi = 0; oi < options.length; ++oi) {
String[] os = options[oi];
String opt = os[0].toLowerCase();
if (opt.equals("-d")) {
destDirName = addTrailingFileSep(os[1]);
docFileDestDirName = destDirName;
- } else if (opt.equals("-docfilessubdirs")) {
+ ensureOutputDirExists();
+ break;
+ }
+ }
+
+ for (int oi = 0; oi < options.length; ++oi) {
+ String[] os = options[oi];
+ String opt = os[0].toLowerCase();
+ if (opt.equals("-docfilessubdirs")) {
copydocfilesubdirs = true;
} else if (opt.equals("-docencoding")) {
docencoding = os[1];
@@ -422,6 +455,8 @@
encoding = os[1];
} else if (opt.equals("-author")) {
showauthor = true;
+ } else if (opt.equals("-javafx")) {
+ javafx = true;
} else if (opt.equals("-nosince")) {
nosince = true;
} else if (opt.equals("-version")) {
@@ -494,7 +529,7 @@
*
* @throws DocletAbortException
*/
- public void setOptions() {
+ public void setOptions() throws Fault {
initPackageArray();
setOptions(root.options());
if (!profilespath.isEmpty()) {
@@ -508,6 +543,23 @@
setSpecificDocletOptions(root.options());
}
+ private void ensureOutputDirExists() throws Fault {
+ DocFile destDir = DocFile.createFileForDirectory(this, destDirName);
+ if (!destDir.exists()) {
+ //Create the output directory (in case it doesn't exist yet)
+ root.printNotice(getText("doclet.dest_dir_create", destDirName));
+ destDir.mkdirs();
+ } else if (!destDir.isDirectory()) {
+ throw new Fault(getText(
+ "doclet.destination_directory_not_directory_0",
+ destDir.getPath()));
+ } else if (!destDir.canWrite()) {
+ throw new Fault(getText(
+ "doclet.destination_directory_not_writable_0",
+ destDir.getPath()));
+ }
+ }
+
/**
* Initialize the taglet manager. The strings to initialize the simple custom tags should
@@ -517,7 +569,7 @@
*/
private void initTagletManager(Set<String[]> customTagStrs) {
tagletManager = tagletManager == null ?
- new TagletManager(nosince, showversion, showauthor, message) :
+ new TagletManager(nosince, showversion, showauthor, javafx, message) :
tagletManager;
String[] args;
for (Iterator<String[]> it = customTagStrs.iterator(); it.hasNext(); ) {
@@ -641,26 +693,7 @@
for (int oi = 0; oi < options.length; oi++) {
String[] os = options[oi];
String opt = os[0].toLowerCase();
- if (opt.equals("-d")) {
- String destdirname = addTrailingFileSep(os[1]);
- DocFile destDir = DocFile.createFileForDirectory(this, destdirname);
- if (!destDir.exists()) {
- //Create the output directory (in case it doesn't exist yet)
- reporter.printNotice(getText("doclet.dest_dir_create",
- destdirname));
- destDir.mkdirs();
- } else if (!destDir.isDirectory()) {
- reporter.printError(getText(
- "doclet.destination_directory_not_directory_0",
- destDir.getPath()));
- return false;
- } else if (!destDir.canWrite()) {
- reporter.printError(getText(
- "doclet.destination_directory_not_writable_0",
- destDir.getPath()));
- return false;
- }
- } else if (opt.equals("-docencoding")) {
+ if (opt.equals("-docencoding")) {
docencodingfound = true;
if (!checkOutputFileEncoding(os[1], reporter)) {
return false;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/PropertyWriter.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2003, 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.
+ */
+
+package com.sun.tools.doclets.internal.toolkit;
+
+import java.io.*;
+import com.sun.javadoc.*;
+
+/**
+ * The interface for writing property output.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ *
+ * @author Jamie Ho
+ * @author Bhavesh Patel (Modified)
+ * @since 1.7
+ */
+
+public interface PropertyWriter {
+
+ /**
+ * Get the property details tree header.
+ *
+ * @param classDoc the class being documented
+ * @param memberDetailsTree the content tree representing member details
+ * @return content tree for the property details header
+ */
+ public Content getPropertyDetailsTreeHeader(ClassDoc classDoc,
+ Content memberDetailsTree);
+
+ /**
+ * Get the property documentation tree header.
+ *
+ * @param property the property being documented
+ * @param propertyDetailsTree the content tree representing property details
+ * @return content tree for the property documentation header
+ */
+ public Content getPropertyDocTreeHeader(MethodDoc property,
+ Content propertyDetailsTree);
+
+ /**
+ * Get the signature for the given property.
+ *
+ * @param property the property being documented
+ * @return content tree for the property signature
+ */
+ public Content getSignature(MethodDoc property);
+
+ /**
+ * Add the deprecated output for the given property.
+ *
+ * @param property the property being documented
+ * @param propertyDocTree content tree to which the deprecated information will be added
+ */
+ public void addDeprecated(MethodDoc property, Content propertyDocTree);
+
+ /**
+ * Add the comments for the given property.
+ *
+ * @param property the property being documented
+ * @param propertyDocTree the content tree to which the comments will be added
+ */
+ public void addComments(MethodDoc property, Content propertyDocTree);
+
+ /**
+ * Add the tags for the given property.
+ *
+ * @param property the property being documented
+ * @param propertyDocTree the content tree to which the tags will be added
+ */
+ public void addTags(MethodDoc property, Content propertyDocTree);
+
+ /**
+ * Get the property details tree.
+ *
+ * @param memberDetailsTree the content tree representing member details
+ * @return content tree for the property details
+ */
+ public Content getPropertyDetails(Content memberDetailsTree);
+
+ /**
+ * Get the property documentation.
+ *
+ * @param propertyDocTree the content tree representing property documentation
+ * @param isLastContent true if the content to be added is the last content
+ * @return content tree for the property documentation
+ */
+ public Content getPropertyDoc(Content propertyDocTree, boolean isLastContent);
+
+ /**
+ * Close the writer.
+ */
+ public void close() throws IOException;
+}
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/WriterFactory.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/WriterFactory.java Tue Mar 12 16:43:53 2013 -0700
@@ -175,6 +175,16 @@
throws Exception;
/**
+ * Return the property writer for a given class.
+ *
+ * @param classWriter the writer for the class being documented.
+ * @return the property writer for the give class. Return null if this
+ * writer is not supported by the doclet.
+ */
+ public abstract PropertyWriter getPropertyWriter(ClassWriter classWriter)
+ throws Exception;
+
+ /**
* Return the constructor writer for a given class.
*
* @param classWriter the writer for the class being documented.
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -86,7 +86,7 @@
this.classDoc = classDoc;
this.writer = writer;
this.visibleMemberMap = new VisibleMemberMap(classDoc, memberType,
- configuration.nodeprecated);
+ configuration);
this.members = new ArrayList<ProgramElementDoc>(
this.visibleMemberMap.getMembersFor(classDoc));
if (configuration.getMemberComparator() != null) {
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java Tue Mar 12 16:43:53 2013 -0700
@@ -228,6 +228,19 @@
}
/**
+ * Return an instance of the property builder for the given class.
+ *
+ * @return an instance of the field builder for the given class.
+ */
+ public AbstractBuilder getPropertyBuilder(ClassWriter classWriter) throws Exception {
+ final PropertyWriter propertyWriter =
+ writerFactory.getPropertyWriter(classWriter);
+ return PropertyBuilder.getInstance(context,
+ classWriter.getClassDoc(),
+ propertyWriter);
+ }
+
+ /**
* Return an instance of the constructor builder for the given class.
*
* @return an instance of the constructor builder for the given class.
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -381,6 +381,17 @@
}
/**
+ * Build the property documentation.
+ *
+ * @param elements the XML elements that specify how a field is documented.
+ */
+ public void buildPropertyDetails(XMLNode node,
+ Content memberDetailsTree) throws Exception {
+ configuration.getBuilderFactory().
+ getPropertyBuilder(writer).buildChildren(node, memberDetailsTree);
+ }
+
+ /**
* Build the constructor documentation.
*
* @param node the XML element that specifies which components to document
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -265,7 +265,7 @@
*/
private boolean hasConstantField (ClassDoc classDoc) {
VisibleMemberMap visibleMemberMapFields = new VisibleMemberMap(classDoc,
- VisibleMemberMap.FIELDS, configuration.nodeprecated);
+ VisibleMemberMap.FIELDS, configuration);
List<?> fields = visibleMemberMapFields.getLeafClassMembers(configuration);
for (Iterator<?> iter = fields.iterator(); iter.hasNext(); ) {
FieldDoc field = (FieldDoc) iter.next();
@@ -323,9 +323,9 @@
public ConstantFieldBuilder(ClassDoc classdoc) {
this.classdoc = classdoc;
visibleMemberMapFields = new VisibleMemberMap(classdoc,
- VisibleMemberMap.FIELDS, configuration.nodeprecated);
+ VisibleMemberMap.FIELDS, configuration);
visibleMemberMapEnumConst = new VisibleMemberMap(classdoc,
- VisibleMemberMap.ENUM_CONSTANTS, configuration.nodeprecated);
+ VisibleMemberMap.ENUM_CONSTANTS, configuration);
}
/**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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 @@
new VisibleMemberMap(
classDoc,
VisibleMemberMap.CONSTRUCTORS,
- configuration.nodeprecated);
+ configuration);
constructors =
new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
for (int i = 0; i < constructors.size(); i++) {
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -87,7 +87,7 @@
new VisibleMemberMap(
classDoc,
VisibleMemberMap.ENUM_CONSTANTS,
- configuration.nodeprecated);
+ configuration);
enumConstants =
new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
if (configuration.getMemberComparator() != null) {
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -88,7 +88,7 @@
new VisibleMemberMap(
classDoc,
VisibleMemberMap.FIELDS,
- configuration.nodeprecated);
+ configuration);
fields =
new ArrayList<ProgramElementDoc>(visibleMemberMap.getLeafClassMembers(
configuration));
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -26,6 +26,7 @@
package com.sun.tools.doclets.internal.toolkit.builders;
import java.util.*;
+import java.text.MessageFormat;
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
@@ -82,7 +83,7 @@
new VisibleMemberMap(
classDoc,
i,
- configuration.nodeprecated);
+ configuration);
}
}
@@ -254,6 +255,17 @@
}
/**
+ * Build the summary for the fields.
+ */
+ public void buildPropertiesSummary(XMLNode node, Content memberSummaryTree) {
+ MemberSummaryWriter writer =
+ memberSummaryWriters[VisibleMemberMap.PROPERTIES];
+ VisibleMemberMap visibleMemberMap =
+ visibleMemberMaps[VisibleMemberMap.PROPERTIES];
+ addSummary(writer, visibleMemberMap, true, memberSummaryTree);
+ }
+
+ /**
* Build the summary for the nested classes.
*
* @param node the XML element that specifies which components to document
@@ -311,6 +323,11 @@
List<Content> tableContents = new LinkedList<Content>();
for (int i = 0; i < members.size(); i++) {
ProgramElementDoc member = members.get(i);
+ final ProgramElementDoc propertyDoc =
+ visibleMemberMap.getPropertyMemberDoc(member);
+ if (propertyDoc != null) {
+ processProperty(visibleMemberMap, member, propertyDoc);
+ }
Tag[] firstSentenceTags = member.firstSentenceTags();
if (member instanceof MethodDoc && firstSentenceTags.length == 0) {
//Inherit comments from overriden or implemented method if
@@ -330,6 +347,106 @@
}
/**
+ * Process the property method, property setter and/or property getter
+ * comment text so that it contains the documentation from
+ * the property field. The method adds the leading sentence,
+ * copied documentation including the defaultValue tag and
+ * the see tags if the appropriate property getter and setter are
+ * available.
+ *
+ * @param visibleMemberMap the members information.
+ * @param member the member which is to be augmented.
+ * @param propertyDoc the original property documentation.
+ */
+ private void processProperty(VisibleMemberMap visibleMemberMap,
+ ProgramElementDoc member,
+ ProgramElementDoc propertyDoc) {
+ StringBuilder commentTextBuilder = new StringBuilder();
+ final boolean isSetter = isSetter(member);
+ final boolean isGetter = isGetter(member);
+ if (isGetter || isSetter) {
+ //add "[GS]ets the value of the property PROPERTY_NAME."
+ if (isSetter) {
+ commentTextBuilder.append(
+ MessageFormat.format(
+ configuration.getText("doclet.PropertySetterWithName"),
+ Util.propertyNameFromMethodName(member.name())));
+ }
+ if (isGetter) {
+ commentTextBuilder.append(
+ MessageFormat.format(
+ configuration.getText("doclet.PropertyGetterWithName"),
+ Util.propertyNameFromMethodName(member.name())));
+ }
+ if (propertyDoc.commentText() != null
+ && !propertyDoc.commentText().isEmpty()) {
+ commentTextBuilder.append(" \n @propertyDescription ");
+ }
+ }
+ commentTextBuilder.append(propertyDoc.commentText());
+
+ Tag[] tags = propertyDoc.tags("@defaultValue");
+ if (tags != null) {
+ for (Tag tag: tags) {
+ commentTextBuilder.append("\n")
+ .append(tag.name())
+ .append(" ")
+ .append(tag.text());
+ }
+ }
+
+ //add @see tags
+ if (!isGetter && !isSetter) {
+ MethodDoc getter = (MethodDoc) visibleMemberMap.getGetterForProperty(member);
+ MethodDoc setter = (MethodDoc) visibleMemberMap.getSetterForProperty(member);
+
+ if ((null != getter)
+ && (commentTextBuilder.indexOf("@see #" + getter.name()) == -1)) {
+ commentTextBuilder.append("\n @see #")
+ .append(getter.name())
+ .append("() ");
+ }
+
+ if ((null != setter)
+ && (commentTextBuilder.indexOf("@see #" + setter.name()) == -1)) {
+ String typeName = setter.parameters()[0].typeName();
+ // Removal of type parameters and package information.
+ typeName = typeName.split("<")[0];
+ if (typeName.contains(".")) {
+ typeName = typeName.substring(typeName.lastIndexOf(".") + 1);
+ }
+ commentTextBuilder.append("\n @see #").append(setter.name());
+
+ if (setter.parameters()[0].type().asTypeVariable() == null) {
+ commentTextBuilder.append("(").append(typeName).append(")");
+ }
+ commentTextBuilder.append(" \n");
+ }
+ }
+ member.setRawCommentText(commentTextBuilder.toString());
+ }
+ /**
+ * Test whether the method is a getter.
+ * @param ped property method documentation. Needs to be either property
+ * method, property getter, or property setter.
+ * @return true if the given documentation belongs to a getter.
+ */
+ private boolean isGetter(ProgramElementDoc ped) {
+ final String pedName = ped.name();
+ return pedName.startsWith("get") || pedName.startsWith("is");
+ }
+
+ /**
+ * Test whether the method is a setter.
+ * @param ped property method documentation. Needs to be either property
+ * method, property getter, or property setter.
+ * @return true if the given documentation belongs to a setter.
+ */
+ private boolean isSetter(ProgramElementDoc ped) {
+ return ped.name().startsWith("set");
+ }
+
+ /**
* Build the inherited member summary for the given methods.
*
* @param writer the writer for this member summary.
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -88,7 +88,7 @@
visibleMemberMap = new VisibleMemberMap(
classDoc,
VisibleMemberMap.METHODS,
- configuration.nodeprecated);
+ configuration);
methods =
new ArrayList<ProgramElementDoc>(visibleMemberMap.getLeafClassMembers(
configuration));
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -176,6 +176,7 @@
? packageDoc.interfaces()
: configuration.classDocCatalog.interfaces(
Util.getPackageName(packageDoc));
+ interfaces = Util.filterOutPrivateClasses(interfaces, configuration.javafx);
if (interfaces.length > 0) {
packageWriter.addClassesSummary(
interfaces,
@@ -205,6 +206,7 @@
? packageDoc.ordinaryClasses()
: configuration.classDocCatalog.ordinaryClasses(
Util.getPackageName(packageDoc));
+ classes = Util.filterOutPrivateClasses(classes, configuration.javafx);
if (classes.length > 0) {
packageWriter.addClassesSummary(
classes,
@@ -234,6 +236,7 @@
? packageDoc.enums()
: configuration.classDocCatalog.enums(
Util.getPackageName(packageDoc));
+ enums = Util.filterOutPrivateClasses(enums, configuration.javafx);
if (enums.length > 0) {
packageWriter.addClassesSummary(
enums,
@@ -263,6 +266,7 @@
? packageDoc.exceptions()
: configuration.classDocCatalog.exceptions(
Util.getPackageName(packageDoc));
+ exceptions = Util.filterOutPrivateClasses(exceptions, configuration.javafx);
if (exceptions.length > 0) {
packageWriter.addClassesSummary(
exceptions,
@@ -292,6 +296,7 @@
? packageDoc.errors()
: configuration.classDocCatalog.errors(
Util.getPackageName(packageDoc));
+ errors = Util.filterOutPrivateClasses(errors, configuration.javafx);
if (errors.length > 0) {
packageWriter.addClassesSummary(
errors,
@@ -321,6 +326,7 @@
? packageDoc.annotationTypes()
: configuration.classDocCatalog.annotationTypes(
Util.getPackageName(packageDoc));
+ annotationTypes = Util.filterOutPrivateClasses(annotationTypes, configuration.javafx);
if (annotationTypes.length > 0) {
packageWriter.addClassesSummary(
annotationTypes,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PropertyBuilder.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2003, 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.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.builders;
+
+import java.util.*;
+
+import com.sun.tools.doclets.internal.toolkit.util.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.javadoc.*;
+
+/**
+ * Builds documentation for a property.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ *
+ * @author Jamie Ho
+ * @author Bhavesh Patel (Modified)
+ * @since 1.7
+ */
+public class PropertyBuilder extends AbstractMemberBuilder {
+
+ /**
+ * The class whose properties are being documented.
+ */
+ private final ClassDoc classDoc;
+
+ /**
+ * The visible properties for the given class.
+ */
+ private final VisibleMemberMap visibleMemberMap;
+
+ /**
+ * The writer to output the property documentation.
+ */
+ private final PropertyWriter writer;
+
+ /**
+ * The list of properties being documented.
+ */
+ private final List<ProgramElementDoc> properties;
+
+ /**
+ * The index of the current property that is being documented at this point
+ * in time.
+ */
+ private int currentPropertyIndex;
+
+ /**
+ * Construct a new PropertyBuilder.
+ *
+ * @param context the build context.
+ * @param classDoc the class whoses members are being documented.
+ * @param writer the doclet specific writer.
+ */
+ private PropertyBuilder(Context context,
+ ClassDoc classDoc,
+ PropertyWriter writer) {
+ super(context);
+ this.classDoc = classDoc;
+ this.writer = writer;
+ visibleMemberMap =
+ new VisibleMemberMap(
+ classDoc,
+ VisibleMemberMap.PROPERTIES,
+ configuration);
+ properties =
+ new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
+ if (configuration.getMemberComparator() != null) {
+ Collections.sort(properties, configuration.getMemberComparator());
+ }
+ }
+
+ /**
+ * Construct a new PropertyBuilder.
+ *
+ * @param context the build context.
+ * @param classDoc the class whoses members are being documented.
+ * @param writer the doclet specific writer.
+ */
+ public static PropertyBuilder getInstance(Context context,
+ ClassDoc classDoc,
+ PropertyWriter writer) {
+ return new PropertyBuilder(context, classDoc, writer);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return "PropertyDetails";
+ }
+
+ /**
+ * Returns a list of properties that will be documented for the given class.
+ * This information can be used for doclet specific documentation
+ * generation.
+ *
+ * @param classDoc the {@link ClassDoc} we want to check.
+ * @return a list of properties that will be documented.
+ */
+ public List<ProgramElementDoc> members(ClassDoc classDoc) {
+ return visibleMemberMap.getMembersFor(classDoc);
+ }
+
+ /**
+ * Returns the visible member map for the properties of this class.
+ *
+ * @return the visible member map for the properties of this class.
+ */
+ public VisibleMemberMap getVisibleMemberMap() {
+ return visibleMemberMap;
+ }
+
+ /**
+ * summaryOrder.size()
+ */
+ public boolean hasMembersToDocument() {
+ return properties.size() > 0;
+ }
+
+ /**
+ * Build the property documentation.
+ *
+ * @param node the XML element that specifies which components to document
+ * @param memberDetailsTree the content tree to which the documentation will be added
+ */
+ public void buildPropertyDoc(XMLNode node, Content memberDetailsTree) {
+ if (writer == null) {
+ return;
+ }
+ int size = properties.size();
+ if (size > 0) {
+ Content propertyDetailsTree = writer.getPropertyDetailsTreeHeader(
+ classDoc, memberDetailsTree);
+ for (currentPropertyIndex = 0; currentPropertyIndex < size;
+ currentPropertyIndex++) {
+ Content propertyDocTree = writer.getPropertyDocTreeHeader(
+ (MethodDoc) properties.get(currentPropertyIndex),
+ propertyDetailsTree);
+ buildChildren(node, propertyDocTree);
+ propertyDetailsTree.addContent(writer.getPropertyDoc(
+ propertyDocTree, (currentPropertyIndex == size - 1)));
+ }
+ memberDetailsTree.addContent(
+ writer.getPropertyDetails(propertyDetailsTree));
+ }
+ }
+
+ /**
+ * Build the signature.
+ *
+ * @param node the XML element that specifies which components to document
+ * @param propertyDocTree the content tree to which the documentation will be added
+ */
+ public void buildSignature(XMLNode node, Content propertyDocTree) {
+ propertyDocTree.addContent(
+ writer.getSignature((MethodDoc) properties.get(currentPropertyIndex)));
+ }
+
+ /**
+ * Build the deprecation information.
+ *
+ * @param node the XML element that specifies which components to document
+ * @param propertyDocTree the content tree to which the documentation will be added
+ */
+ public void buildDeprecationInfo(XMLNode node, Content propertyDocTree) {
+ writer.addDeprecated(
+ (MethodDoc) properties.get(currentPropertyIndex), propertyDocTree);
+ }
+
+ /**
+ * Build the comments for the property. Do nothing if
+ * {@link Configuration#nocomment} is set to true.
+ *
+ * @param node the XML element that specifies which components to document
+ * @param propertyDocTree the content tree to which the documentation will be added
+ */
+ public void buildPropertyComments(XMLNode node, Content propertyDocTree) {
+ if (!configuration.nocomment) {
+ writer.addComments((MethodDoc) properties.get(currentPropertyIndex), propertyDocTree);
+ }
+ }
+
+ /**
+ * Build the tag information.
+ *
+ * @param node the XML element that specifies which components to document
+ * @param propertyDocTree the content tree to which the documentation will be added
+ */
+ public void buildTagInfo(XMLNode node, Content propertyDocTree) {
+ writer.addTags((MethodDoc) properties.get(currentPropertyIndex), propertyDocTree);
+ }
+
+ /**
+ * Return the property writer for this builder.
+ *
+ * @return the property writer for this builder.
+ */
+ public PropertyWriter getWriter() {
+ return writer;
+ }
+}
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml Tue Mar 12 16:43:53 2013 -0700
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<!--
- Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2003, 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
@@ -107,6 +107,7 @@
<ClassTagInfo/>
</ClassInfo>
<MemberSummary>
+ <PropertiesSummary/>
<NestedClassesSummary/>
<EnumConstantsSummary/>
<FieldsSummary/>
@@ -122,6 +123,13 @@
<TagInfo/>
</EnumConstant>
</EnumConstantsDetails>
+ <PropertyDetails>
+ <PropertyDoc>
+ <Signature/>
+ <PropertyComments/>
+ <TagInfo/>
+ </PropertyDoc>
+ </PropertyDetails>
<FieldDetails>
<FieldDoc>
<Signature/>
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties Tue Mar 12 16:43:53 2013 -0700
@@ -40,6 +40,12 @@
doclet.Error_taglet_not_registered=Error - Exception {0} thrown while trying to register Taglet {1}...
doclet.Error_invalid_custom_tag_argument=Error - {0} is an invalid argument to the -tag option...
doclet.Author=Author:
+doclet.DefaultValue=Default value:
+doclet.PropertyDescription=Property description:
+doclet.PropertyGetter=Gets the value of the property
+doclet.PropertySetter=Sets the value of the property
+doclet.PropertyGetterWithName=Gets the value of the property {0}.
+doclet.PropertySetterWithName=Sets the value of the property {0}.
doclet.Default=Default:
doclet.Parameters=Parameters:
doclet.TypeParameters=Type Parameters:
@@ -61,6 +67,7 @@
doclet.noInheritedDoc=@inheritDoc used but {0} does not override or implement any method.
doclet.malformed_html_link_tag=<a> tag is malformed:\n"{0}"
doclet.tag_misuse=Tag {0} cannot be used in {1} documentation. It can only be used in the following types of documentation: {2}.
+doclet.javafx_tag_misuse=Tags @propertyGetter, @propertySetter and @propertyDescription can only be used in JavaFX properties getters and setters.
doclet.Package_Summary=Package Summary
doclet.Profile_Summary=Profile Summary
doclet.Interface_Summary=Interface Summary
@@ -73,6 +80,7 @@
doclet.Annotation_Type_Optional_Member_Summary=Optional Element Summary
doclet.Annotation_Type_Required_Member_Summary=Required Element Summary
doclet.Field_Summary=Field Summary
+doclet.Property_Summary=Property Summary
doclet.Enum_Constant_Summary=Enum Constant Summary
doclet.Constructor_Summary=Constructor Summary
doclet.Method_Summary=Method Summary
@@ -115,10 +123,13 @@
doclet.Methods_Inherited_From_Interface=Methods inherited from interface
doclet.Fields_Inherited_From_Class=Fields inherited from class
doclet.Fields_Inherited_From_Interface=Fields inherited from interface
+doclet.Properties_Inherited_From_Class=Properties inherited from class
+doclet.Properties_Inherited_From_Interface=Properties inherited from interface
doclet.Annotation_Type_Member_Detail=Element Detail
doclet.Enum_Constant_Detail=Enum Constant Detail
doclet.Constants_Summary=Constant Field Values
doclet.Field_Detail=Field Detail
+doclet.Property_Detail=Property Detail
doclet.Method_Detail=Method Detail
doclet.Constructor_Detail=Constructor Detail
doclet.Deprecated=Deprecated.
@@ -132,6 +143,8 @@
doclet.Member_Table_Summary={0} table, listing {1}, and an explanation
doclet.fields=fields
doclet.Fields=Fields
+doclet.properties=properties
+doclet.Properties=Properties
doclet.constructors=constructors
doclet.Constructors=Constructors
doclet.methods=methods
@@ -149,6 +162,7 @@
doclet.Modifier=Modifier
doclet.Type=Type
doclet.Field=Field
+doclet.Property=Property
doclet.Constructor=Constructor
doclet.Method=Method
doclet.Annotation_Type_Optional_Member=Optional Element
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BasePropertyTaglet.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2001, 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.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.taglets;
+
+import com.sun.javadoc.Tag;
+
+/**
+ * An abstract class that implements the {@link Taglet} interface and
+ * serves as a base for JavaFX property getter and setter taglets.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ *
+ */
+public abstract class BasePropertyTaglet extends BaseTaglet {
+
+ public BasePropertyTaglet() {
+ }
+
+ /**
+ * This method returns the text to be put in the resulting javadoc before
+ * the property name.
+ *
+ * @param tagletWriter the taglet writer for output
+ * @return the string to be put in the resulting javadoc.
+ */
+ abstract String getText(TagletWriter tagletWriter);
+
+ /**
+ * Given the <code>Tag</code> representation of this custom
+ * tag, return its string representation, which is output
+ * to the generated page.
+ * @param tag the <code>Tag</code> representation of this custom tag.
+ * @param tagletWriter the taglet writer for output.
+ * @return the TagletOutput representation of this <code>Tag</code>.
+ */
+ public TagletOutput getTagletOutput(Tag tag, TagletWriter tagletWriter) {
+ TagletOutput tagletOutput = tagletWriter.getOutputInstance();
+ StringBuilder output = new StringBuilder("<P>");
+ output.append(getText(tagletWriter));
+ output.append(" <CODE>");
+ output.append(tag.text());
+ output.append("</CODE>.</P>");
+ tagletOutput.setOutput(output.toString());
+ return tagletOutput;
+ }
+
+ /**
+ * Will return false because this tag may
+ * only appear in Methods.
+ * @return false since this is not a method.
+ */
+ public boolean inConstructor() {
+ return false;
+ }
+
+ /**
+ * Will return false because this tag may
+ * only appear in Methods.
+ * @return false since this is not a method.
+ */
+ public boolean inOverview() {
+ return false;
+ }
+
+ /**
+ * Will return false because this tag may
+ * only appear in Methods.
+ * @return false since this is not a method.
+ */
+ public boolean inPackage() {
+ return false;
+ }
+
+ /**
+ * Will return false because this tag may
+ * only appear in Methods.
+ * @return false since this is not a method.
+ */
+ public boolean inType() {
+ return false;
+ }
+
+ /**
+ * Will return false because this tag is not inline.
+ * @return false since this is not an inline tag.
+ */
+ public boolean isInlineTag() {
+ return false;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ExpertTaglet.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2003, 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.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.taglets;
+
+import java.util.Map;
+
+import com.sun.tools.doclets.Taglet;
+import com.sun.javadoc.Tag;
+
+/**
+ * An inline Taglet used to denote information for experts.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ *
+ */
+public class ExpertTaglet implements Taglet {
+
+ private static final String NAME = "expert";
+ private static final String START_TAG = "<sub id=\"expert\">";
+ private static final String END_TAG = "</sub>";
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean inField() {
+ return true;
+ }
+
+ public boolean inConstructor() {
+ return true;
+ }
+
+ public boolean inMethod() {
+ return true;
+ }
+
+ public boolean inOverview() {
+ return true;
+ }
+
+ public boolean inPackage() {
+ return true;
+ }
+
+ public boolean inType() {
+ return true;
+ }
+
+ public boolean isInlineTag() {
+ return false;
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public static void register(Map<String, Taglet> map) {
+ map.remove(NAME);
+ map.put(NAME, new ExpertTaglet());
+ }
+
+ public String toString(Tag tag) {
+ return (tag.text() == null || tag.text().length() == 0) ? null :
+ START_TAG + LiteralTaglet.textToString(tag.text()) + END_TAG;
+ }
+
+
+ public String toString(Tag[] tags) {
+ if (tags == null || tags.length == 0) return null;
+
+ StringBuffer sb = new StringBuffer(START_TAG);
+
+ for(Tag t:tags) {
+ sb.append(LiteralTaglet.textToString(t.text()));
+ }
+ sb.append(END_TAG);
+ return sb.toString();
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/PropertyGetterTaglet.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2001, 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.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.taglets;
+
+/**
+ * A taglet that adds the initial line of documentation to the JavaFX
+ * property getters.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+public class PropertyGetterTaglet extends BasePropertyTaglet {
+
+ /**
+ * Construct a new PropertyGetterTaglet.
+ */
+ public PropertyGetterTaglet () {
+ name = "propertyGetter";
+ }
+
+ @Override
+ String getText(TagletWriter tagletWriter) {
+ return tagletWriter.configuration().getText("doclet.PropertyGetter");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/PropertySetterTaglet.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2001, 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.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.taglets;
+
+/**
+ * A taglet that adds the initial line of documentation to the JavaFX
+ * property setters.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+public class PropertySetterTaglet extends BasePropertyTaglet {
+
+ /**
+ * Construct a new PropertyGetterTaglet.
+ */
+ public PropertySetterTaglet () {
+ name = "propertySetter";
+ }
+
+ @Override
+ String getText(TagletWriter tagletWriter) {
+ return tagletWriter.configuration().getText("doclet.PropertySetter");
+ }
+}
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -157,6 +157,13 @@
private boolean showauthor;
/**
+ * True if we want to use JavaFX-related tags (@propertyGetter,
+ * @propertySetter, @propertyDescription, @defaultValue, @treatAsPrivate,
+ * @expert).
+ */
+ private boolean javafx;
+
+ /**
* Construct a new <code>TagletManager</code>.
* @param nosince true if we do not want to use @since tags.
* @param showversion true if we want to use @version tags.
@@ -164,7 +171,8 @@
* @param message the message retriever to print warnings.
*/
public TagletManager(boolean nosince, boolean showversion,
- boolean showauthor, MessageRetriever message) {
+ boolean showauthor, boolean javafx,
+ MessageRetriever message) {
overridenStandardTags = new HashSet<String>();
potentiallyConflictingTags = new HashSet<String>();
standardTags = new HashSet<String>();
@@ -174,6 +182,7 @@
this.nosince = nosince;
this.showversion = showversion;
this.showauthor = showauthor;
+ this.javafx = javafx;
this.message = message;
initStandardTags();
initStandardTagsLowercase();
@@ -677,6 +686,33 @@
standardTags.add("Text");
standardTags.add("literal");
standardTags.add("code");
+
+ if (javafx) {
+ initJavaFXTags();
+ }
+ }
+
+ /**
+ * Initialize JavaFX-related tags.
+ */
+ private void initJavaFXTags() {
+ Taglet temp;
+ customTags.put((temp = new PropertyGetterTaglet()).getName(), temp);
+ customTags.put((temp = new PropertySetterTaglet()).getName(), temp);
+ customTags.put((temp = new SimpleTaglet("propertyDescription", message.getText("doclet.PropertyDescription"),
+ SimpleTaglet.FIELD + SimpleTaglet.METHOD)).getName(), temp);
+ customTags.put((temp = new SimpleTaglet("defaultValue", message.getText("doclet.DefaultValue"),
+ SimpleTaglet.FIELD + SimpleTaglet.METHOD)).getName(), temp);
+ customTags.put((temp = new SimpleTaglet("treatAsPrivate", null,
+ SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE)).getName(), temp);
+ customTags.put((temp = new LegacyTaglet(new ExpertTaglet())).getName(), temp);
+
+ standardTags.add("propertyGetter");
+ standardTags.add("propertySetter");
+ standardTags.add("propertyDescription");
+ standardTags.add("defaultValue");
+ standardTags.add("treatAsPrivate");
+ standardTags.add("expert");
}
/**
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -180,6 +180,7 @@
tagletManager.checkTags(doc, doc.inlineTags(), true);
TagletOutput currentOutput = null;
for (int i = 0; i < taglets.length; i++) {
+ currentOutput = null;
if (doc instanceof ClassDoc && taglets[i] instanceof ParamTaglet) {
//The type parameters are documented in a special section away
//from the tag info, so skip here.
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -132,6 +132,12 @@
Util.isDeprecated(classes[i].containingPackage()))) {
continue;
}
+
+ if (configuration.javafx
+ && classes[i].tags("treatAsPrivate").length > 0) {
+ continue;
+ }
+
if (classes[i].isEnum()) {
processType(classes[i], configuration, baseEnums, subEnums);
} else if (classes[i].isClass()) {
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -63,6 +63,11 @@
*/
private boolean classesOnly;
+ /**
+ * Indicates javafx mode.
+ */
+ private boolean javafx;
+
// make ProgramElementDoc[] when new toArray is available
protected final Object[] elements;
@@ -115,6 +120,7 @@
}
this.noDeprecated = noDeprecated;
this.classesOnly = classesOnly;
+ this.javafx = configuration.javafx;
buildIndexMap(configuration.root);
Set<Character> set = indexmap.keySet();
elements = set.toArray();
@@ -209,6 +215,12 @@
* Should this doc element be added to the index map?
*/
protected boolean shouldAddToIndexMap(Doc element) {
+ if (javafx) {
+ if (element.tags("treatAsPrivate").length > 0) {
+ return false;
+ }
+ }
+
if (element instanceof PackageDoc)
// Do not add to index map if -nodeprecated option is set and the
// package is marked as deprecated.
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Tue Mar 12 16:43:53 2013 -0700
@@ -722,6 +722,56 @@
}
/**
+ * A convenience method to get property name from the name of the
+ * getter or setter method.
+ * @param name name of the getter or setter method.
+ * @return the name of the property of the given setter of getter.
+ */
+ public static String propertyNameFromMethodName(String name) {
+ String propertyName = null;
+ if (name.startsWith("get") || name.startsWith("set")) {
+ propertyName = name.substring(3);
+ } else if (name.startsWith("is")) {
+ propertyName = name.substring(2);
+ }
+ if ((propertyName == null) || propertyName.isEmpty()){
+ return "";
+ }
+ return propertyName.substring(0, 1).toLowerCase()
+ + propertyName.substring(1);
+ }
+
+ /**
+ * In case of JavaFX mode on, filters out classes that are private,
+ * package private or having the @treatAsPrivate annotation. Those are not
+ * documented in JavaFX mode.
+ *
+ * @param classes array of classes to be filtered.
+ * @param javafx set to true if in JavaFX mode.
+ * @return list of filtered classes.
+ */
+ public static ClassDoc[] filterOutPrivateClasses(final ClassDoc[] classes,
+ boolean javafx) {
+ if (!javafx) {
+ return classes;
+ }
+ final List<ClassDoc> filteredOutClasses =
+ new ArrayList<ClassDoc>(classes.length);
+ for (ClassDoc classDoc : classes) {
+ if (classDoc.isPrivate() || classDoc.isPackagePrivate()) {
+ continue;
+ }
+ Tag[] aspTags = classDoc.tags("treatAsPrivate");
+ if (aspTags != null && aspTags.length > 0) {
+ continue;
+ }
+ filteredOutClasses.add(classDoc);
+ }
+
+ return filteredOutClasses.toArray(new ClassDoc[0]);
+ }
+
+ /**
* Test whether the given FieldDoc is one of the declaration annotation ElementTypes
* defined in Java 5.
* Instead of testing for one of the new enum constants added in Java 8, test for
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java Tue Mar 12 16:43:53 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
@@ -26,6 +26,7 @@
package com.sun.tools.doclets.internal.toolkit.util;
import java.util.*;
+import java.util.regex.Pattern;
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
@@ -56,11 +57,12 @@
public static final int METHODS = 4;
public static final int ANNOTATION_TYPE_MEMBER_OPTIONAL = 5;
public static final int ANNOTATION_TYPE_MEMBER_REQUIRED = 6;
+ public static final int PROPERTIES = 7;
/**
* The total number of member types is {@value}.
*/
- public static final int NUM_MEMBER_TYPES = 7;
+ public static final int NUM_MEMBER_TYPES = 8;
public static final String STARTLEVEL = "start";
@@ -93,23 +95,34 @@
private final int kind;
/**
- * Deprected members should be excluded or not?
+ * The configuration this VisibleMemberMap was created with.
*/
- private final boolean nodepr;
+ private final Configuration configuration;
+
+ private static final Map<ClassDoc, ProgramElementDoc[]> propertiesCache =
+ new HashMap<ClassDoc, ProgramElementDoc[]>();
+ private static final Map<ProgramElementDoc, ProgramElementDoc> classPropertiesMap =
+ new HashMap<ProgramElementDoc, ProgramElementDoc>();
+ private static final Map<ProgramElementDoc, GetterSetter> getterSetterMap =
+ new HashMap<ProgramElementDoc, GetterSetter>();
/**
* Construct a VisibleMemberMap of the given type for the given
- * class. If nodepr is true, exclude the deprecated members from
- * the map.
+ * class.
*
* @param classdoc the class whose members are being mapped.
* @param kind the kind of member that is being mapped.
- * @param nodepr if true, exclude the deprecated members from the map.
+ * @param configuration the configuration to use to construct this
+ * VisibleMemberMap. If the field configuration.nodeprecated is true the
+ * deprecated members are excluded from the map. If the field
+ * configuration.javafx is true the JavaFX features are used.
*/
- public VisibleMemberMap(ClassDoc classdoc, int kind, boolean nodepr) {
+ public VisibleMemberMap(ClassDoc classdoc,
+ int kind,
+ Configuration configuration) {
this.classdoc = classdoc;
- this.nodepr = nodepr;
this.kind = kind;
+ this.configuration = configuration;
new ClassMembers(classdoc, STARTLEVEL).build();
}
@@ -124,6 +137,33 @@
}
/**
+ * Returns the property field documentation belonging to the given member.
+ * @param ped the member for which the property documentation is needed.
+ * @return the property field documentation, null if there is none.
+ */
+ public ProgramElementDoc getPropertyMemberDoc(ProgramElementDoc ped) {
+ return classPropertiesMap.get(ped);
+ }
+
+ /**
+ * Returns the getter documentation belonging to the given property method.
+ * @param propertyMethod the method for which the getter is needed.
+ * @return the getter documentation, null if there is none.
+ */
+ public ProgramElementDoc getGetterForProperty(ProgramElementDoc propertyMethod) {
+ return getterSetterMap.get(propertyMethod).getGetter();
+ }
+
+ /**
+ * Returns the setter documentation belonging to the given property method.
+ * @param propertyMethod the method for which the setter is needed.
+ * @return the setter documentation, null if there is none.
+ */
+ public ProgramElementDoc getSetterForProperty(ProgramElementDoc propertyMethod) {
+ return getterSetterMap.get(propertyMethod).getSetter();
+ }
+
+ /**
* Return the package private members inherited by the class. Only return
* if parent is package private and not documented.
*
@@ -334,8 +374,9 @@
ProgramElementDoc pgmelem = cdmembers.get(i);
if (!found(members, pgmelem) &&
memberIsVisible(pgmelem) &&
- !isOverridden(pgmelem, level)) {
- incllist.add(pgmelem);
+ !isOverridden(pgmelem, level) &&
+ !isTreatedAsPrivate(pgmelem)) {
+ incllist.add(pgmelem);
}
}
if (incllist.size() > 0) {
@@ -345,6 +386,16 @@
fillMemberLevelMap(getClassMembers(fromClass, false), level);
}
+ private boolean isTreatedAsPrivate(ProgramElementDoc pgmelem) {
+ if (!configuration.javafx) {
+ return false;
+ }
+
+ Tag[] aspTags = pgmelem.tags("@treatAsPrivate");
+ boolean result = (aspTags != null) && (aspTags.length > 0);
+ return result;
+ }
+
/**
* Is given doc item visible in given classdoc in terms fo inheritance?
* The given doc item is visible in the given classdoc if it is public
@@ -406,11 +457,16 @@
break;
case METHODS:
members = cd.methods(filter);
+ checkOnPropertiesTags((MethodDoc[])members);
+ break;
+ case PROPERTIES:
+ members = properties(cd, filter);
break;
default:
members = new ProgramElementDoc[0];
}
- if (nodepr) {
+ // Deprected members should be excluded or not?
+ if (configuration.nodeprecated) {
return Util.excludeDeprecatedMembersAsList(members);
}
return Arrays.asList(members);
@@ -472,6 +528,206 @@
}
return false;
}
+
+ private ProgramElementDoc[] properties(final ClassDoc cd, final boolean filter) {
+ final MethodDoc[] allMethods = cd.methods(filter);
+ final FieldDoc[] allFields = cd.fields(false);
+
+ if (propertiesCache.containsKey(cd)) {
+ return propertiesCache.get(cd);
+ }
+
+ final List<MethodDoc> result = new ArrayList<MethodDoc>();
+
+ for (final MethodDoc propertyMethod : allMethods) {
+
+ if (!isPropertyMethod(propertyMethod)) {
+ continue;
+ }
+
+ final MethodDoc getter = getterForField(allMethods, propertyMethod);
+ final MethodDoc setter = setterForField(allMethods, propertyMethod);
+ final FieldDoc field = fieldForProperty(allFields, propertyMethod);
+
+ addToPropertiesMap(setter, getter, propertyMethod, field);
+ getterSetterMap.put(propertyMethod, new GetterSetter(getter, setter));
+ result.add(propertyMethod);
+ }
+ final ProgramElementDoc[] resultAray =
+ result.toArray(new ProgramElementDoc[result.size()]);
+ propertiesCache.put(cd, resultAray);
+ return resultAray;
+ }
+
+ private void addToPropertiesMap(MethodDoc setter,
+ MethodDoc getter,
+ MethodDoc propertyMethod,
+ FieldDoc field) {
+ if ((field == null)
+ || (field.getRawCommentText() == null)
+ || field.getRawCommentText().length() == 0) {
+ addToPropertiesMap(setter, propertyMethod);
+ addToPropertiesMap(getter, propertyMethod);
+ addToPropertiesMap(propertyMethod, propertyMethod);
+ } else {
+ addToPropertiesMap(getter, field);
+ addToPropertiesMap(setter, field);
+ addToPropertiesMap(propertyMethod, field);
+ }
+ }
+
+ private void addToPropertiesMap(ProgramElementDoc propertyMethod,
+ ProgramElementDoc commentSource) {
+ if (null == propertyMethod || null == commentSource) {
+ return;
+ }
+ final String methodRawCommentText = propertyMethod.getRawCommentText();
+
+ /* The second condition is required for the property buckets. In
+ * this case the comment is at the property method (not at the field)
+ * and it needs to be listed in the map.
+ */
+ if ((null == methodRawCommentText || 0 == methodRawCommentText.length())
+ || propertyMethod.equals(commentSource)) {
+ classPropertiesMap.put(propertyMethod, commentSource);
+ }
+ }
+
+ private MethodDoc getterForField(MethodDoc[] methods,
+ MethodDoc propertyMethod) {
+ final String propertyMethodName = propertyMethod.name();
+ final String fieldName =
+ propertyMethodName.substring(0,
+ propertyMethodName.lastIndexOf("Property"));
+ final String fieldNameUppercased =
+ "" + Character.toUpperCase(fieldName.charAt(0))
+ + fieldName.substring(1);
+ final String getterNamePattern;
+ final String fieldTypeName = propertyMethod.returnType().toString();
+ if ("boolean".equals(fieldTypeName)
+ || fieldTypeName.endsWith("BooleanProperty")) {
+ getterNamePattern = "(is|get)" + fieldNameUppercased;
+ } else {
+ getterNamePattern = "get" + fieldNameUppercased;
+ }
+
+ for (MethodDoc methodDoc : methods) {
+ if (Pattern.matches(getterNamePattern, methodDoc.name())) {
+ if (0 == methodDoc.parameters().length
+ && (methodDoc.isPublic() || methodDoc.isProtected())) {
+ return methodDoc;
+ }
+ }
+ }
+ return null;
+ }
+
+ private MethodDoc setterForField(MethodDoc[] methods,
+ MethodDoc propertyMethod) {
+ final String propertyMethodName = propertyMethod.name();
+ final String fieldName =
+ propertyMethodName.substring(0,
+ propertyMethodName.lastIndexOf("Property"));
+ final String fieldNameUppercased =
+ "" + Character.toUpperCase(fieldName.charAt(0))
+ + fieldName.substring(1);
+ final String setter = "set" + fieldNameUppercased;
+
+ for (MethodDoc methodDoc : methods) {
+ if (setter.equals(methodDoc.name())) {
+ if (1 == methodDoc.parameters().length
+ && "void".equals(methodDoc.returnType().simpleTypeName())
+ && (methodDoc.isPublic() || methodDoc.isProtected())) {
+ return methodDoc;
+ }
+ }
+ }
+ return null;
+ }
+
+ private FieldDoc fieldForProperty(FieldDoc[] fields, MethodDoc property) {
+
+ for (FieldDoc field : fields) {
+ final String fieldName = field.name();
+ final String propertyName = fieldName + "Property";
+ if (propertyName.equals(property.name())) {
+ return field;
+ }
+ }
+ return null;
+ }
+
+ // properties aren't named setA* or getA*
+ private final Pattern pattern = Pattern.compile("[sg]et\\p{Upper}.*");
+ private boolean isPropertyMethod(MethodDoc method) {
+ if (!method.name().endsWith("Property")) {
+ return false;
+ }
+
+ if (! memberIsVisible(method)) {
+ return false;
+ }
+
+ if (pattern.matcher(method.name()).matches()) {
+ return false;
+ }
+
+ return 0 == method.parameters().length
+ && !"void".equals(method.returnType().simpleTypeName());
+ }
+
+ private void checkOnPropertiesTags(MethodDoc[] members) {
+ for (MethodDoc methodDoc: members) {
+ if (methodDoc.isIncluded()) {
+ for (Tag tag: methodDoc.tags()) {
+ String tagName = tag.name();
+ if (tagName.equals("@propertySetter")
+ || tagName.equals("@propertyGetter")
+ || tagName.equals("@propertyDescription")) {
+ if (!isPropertyGetterOrSetter(members, methodDoc)) {
+ configuration.message.warning(tag.position(),
+ "doclet.javafx_tag_misuse");
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ private boolean isPropertyGetterOrSetter(MethodDoc[] members,
+ MethodDoc methodDoc) {
+ boolean found = false;
+ String propertyName = Util.propertyNameFromMethodName(methodDoc.name());
+ if (!propertyName.isEmpty()) {
+ String propertyMethodName = propertyName + "Property";
+ for (MethodDoc member: members) {
+ if (member.name().equals(propertyMethodName)) {
+ found = true;
+ break;
+ }
+ }
+ }
+ return found;
+ }
+ }
+
+ private class GetterSetter {
+ private final ProgramElementDoc getter;
+ private final ProgramElementDoc setter;
+
+ public GetterSetter(ProgramElementDoc getter, ProgramElementDoc setter) {
+ this.getter = getter;
+ this.setter = setter;
+ }
+
+ public ProgramElementDoc getGetter() {
+ return getter;
+ }
+
+ public ProgramElementDoc getSetter() {
+ return setter;
+ }
}
/**
--- a/langtools/src/share/classes/com/sun/tools/javac/Main.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/Main.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2011, 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
@@ -41,6 +41,7 @@
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.
*/
+@jdk.Supported
public class Main {
/** Unsupported command line interface.
--- a/langtools/src/share/classes/com/sun/tools/javac/Server.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/Server.java Tue Mar 12 16:43:53 2013 -0700
@@ -44,6 +44,7 @@
* @author Peter von der Ahé
* @since 1.6
*/
+@jdk.Supported(false)
class Server implements Runnable {
private final BufferedReader in;
private final OutputStream out;
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, 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
@@ -121,19 +121,23 @@
return result.toList();
}
- public Boolean call() {
+ public Main.Result doCall() {
if (!used.getAndSet(true)) {
initContext();
notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>();
compilerMain.setAPIMode(true);
result = compilerMain.compile(args, classNames, context, fileObjects, processors);
cleanup();
- return result.isOK();
+ return result;
} else {
throw new IllegalStateException("multiple calls to method 'call'");
}
}
+ public Boolean call() {
+ return doCall().isOK();
+ }
+
public void setProcessors(Iterable<? extends Processor> processors) {
processors.getClass(); // null check
// not mt-safe
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java Tue Mar 12 16:43:53 2013 -0700
@@ -258,7 +258,7 @@
public static final long CLASH = 1L<<42;
/**
- * Flag that marks either a default method or an interface containing default methods
+ * Flag that marks either a default method or an interface containing default methods.
*/
public static final long DEFAULT = 1L<<43;
@@ -273,6 +273,11 @@
*/
public static final long NOT_IN_PROFILE = 1L<<45;
+ /**
+ * Flag that indicates that an override error has been detected by Check.
+ */
+ public static final long BAD_OVERRIDE = 1L<<45;
+
/** Modifier masks.
*/
public static final int
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java Tue Mar 12 16:43:53 2013 -0700
@@ -26,10 +26,7 @@
package com.sun.tools.javac.code;
import java.util.EnumSet;
-import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
-import javax.lang.model.element.Modifier;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Tue Mar 12 16:43:53 2013 -0700
@@ -237,7 +237,7 @@
}
/** Has this symbol an empty name? This includes anonymous
- * inner classses.
+ * inner classes.
*/
public boolean isAnonymous() {
return name.isEmpty();
@@ -1305,7 +1305,7 @@
return implementation(origin, types, checkResult, implementation_filter);
}
// where
- private static final Filter<Symbol> implementation_filter = new Filter<Symbol>() {
+ public static final Filter<Symbol> implementation_filter = new Filter<Symbol>() {
public boolean accepts(Symbol s) {
return s.kind == Kinds.MTH &&
(s.flags() & SYNTHETIC) == 0;
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java Tue Mar 12 16:43:53 2013 -0700
@@ -126,6 +126,7 @@
public final Type stringBuilderType;
public final Type cloneableType;
public final Type serializableType;
+ public final Type serializedLambdaType;
public final Type methodHandleType;
public final Type methodHandleLookupType;
public final Type methodTypeType;
@@ -147,6 +148,7 @@
public final Type listType;
public final Type collectionsType;
public final Type comparableType;
+ public final Type comparatorType;
public final Type arraysType;
public final Type iterableType;
public final Type iteratorType;
@@ -475,6 +477,7 @@
cloneableType = enterClass("java.lang.Cloneable");
throwableType = enterClass("java.lang.Throwable");
serializableType = enterClass("java.io.Serializable");
+ serializedLambdaType = enterClass("java.lang.invoke.SerializedLambda");
methodHandleType = enterClass("java.lang.invoke.MethodHandle");
methodHandleLookupType = enterClass("java.lang.invoke.MethodHandles$Lookup");
methodTypeType = enterClass("java.lang.invoke.MethodType");
@@ -500,6 +503,7 @@
listType = enterClass("java.util.List");
collectionsType = enterClass("java.util.Collections");
comparableType = enterClass("java.lang.Comparable");
+ comparatorType = enterClass("java.util.Comparator");
arraysType = enterClass("java.util.Arrays");
iterableType = target.hasIterable()
? enterClass("java.lang.Iterable")
@@ -531,6 +535,7 @@
synthesizeEmptyInterfaceIfMissing(cloneableType);
synthesizeEmptyInterfaceIfMissing(serializableType);
synthesizeEmptyInterfaceIfMissing(lambdaMetafactory);
+ synthesizeEmptyInterfaceIfMissing(serializedLambdaType);
synthesizeBoxTypeIfMissing(doubleType);
synthesizeBoxTypeIfMissing(floatType);
synthesizeBoxTypeIfMissing(voidType);
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java Tue Mar 12 16:43:53 2013 -0700
@@ -1367,7 +1367,7 @@
for (Type b : prevBounds) {
//check for redundancy - use strict version of isSameType on tvars
//(as the standard version will lead to false positives w.r.t. clones ivars)
- if (types.isSameType(b, bound2, true)) return;
+ if (types.isSameType(b, bound2, true) || bound == qtype) return;
}
bounds.put(ib, prevBounds.prepend(bound2));
notifyChange(EnumSet.of(ib));
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Tue Mar 12 16:43:53 2013 -0700
@@ -48,6 +48,7 @@
import static com.sun.tools.javac.code.Symbol.*;
import static com.sun.tools.javac.code.Type.*;
import static com.sun.tools.javac.code.TypeTag.*;
+import static com.sun.tools.javac.jvm.ClassFile.externalize;
import static com.sun.tools.javac.util.ListBuffer.lb;
/**
@@ -356,26 +357,11 @@
}
public Type getType(Type site) {
- if (capture(site) != site) {
- Type formalInterface = site.tsym.type;
- ListBuffer<Type> typeargs = ListBuffer.lb();
- List<Type> actualTypeargs = site.getTypeArguments();
- //simply replace the wildcards with its bound
- for (Type t : formalInterface.getTypeArguments()) {
- if (actualTypeargs.head.hasTag(WILDCARD)) {
- WildcardType wt = (WildcardType)actualTypeargs.head;
- typeargs.append(wt.type);
- } else {
- typeargs.append(actualTypeargs.head);
- }
- actualTypeargs = actualTypeargs.tail;
- }
- site = subst(formalInterface, formalInterface.getTypeArguments(), typeargs.toList());
- if (!chk.checkValidGenericType(site)) {
- //if the inferred functional interface type is not well-formed,
- //or if it's not a subtype of the original target, issue an error
- throw failure(diags.fragment("no.suitable.functional.intf.inst", site));
- }
+ site = removeWildcards(site);
+ if (!chk.checkValidGenericType(site)) {
+ //if the inferred functional interface type is not well-formed,
+ //or if it's not a subtype of the original target, issue an error
+ throw failure(diags.fragment("no.suitable.functional.intf.inst", site));
}
return memberType(site, descSym);
}
@@ -526,7 +512,7 @@
@Override
public Type getType(Type origin) {
Type mt = memberType(origin, getSymbol());
- return new MethodType(mt.getParameterTypes(), mt.getReturnType(), thrown1, syms.methodClass);
+ return createMethodTypeWithThrown(mt, thrown1);
}
};
}
@@ -584,6 +570,42 @@
return false;
}
}
+
+ public Type removeWildcards(Type site) {
+ Type capturedSite = capture(site);
+ if (capturedSite != site) {
+ Type formalInterface = site.tsym.type;
+ ListBuffer<Type> typeargs = ListBuffer.lb();
+ List<Type> actualTypeargs = site.getTypeArguments();
+ List<Type> capturedTypeargs = capturedSite.getTypeArguments();
+ //simply replace the wildcards with its bound
+ for (Type t : formalInterface.getTypeArguments()) {
+ if (actualTypeargs.head.hasTag(WILDCARD)) {
+ WildcardType wt = (WildcardType)actualTypeargs.head;
+ Type bound;
+ switch (wt.kind) {
+ case EXTENDS:
+ case UNBOUND:
+ CapturedType capVar = (CapturedType)capturedTypeargs.head;
+ //use declared bound if it doesn't depend on formal type-args
+ bound = capVar.bound.containsAny(capturedSite.getTypeArguments()) ?
+ syms.objectType : capVar.bound;
+ break;
+ default:
+ bound = wt.type;
+ }
+ typeargs.append(bound);
+ } else {
+ typeargs.append(actualTypeargs.head);
+ }
+ actualTypeargs = actualTypeargs.tail;
+ capturedTypeargs = capturedTypeargs.tail;
+ }
+ return subst(formalInterface, formalInterface.getTypeArguments(), typeargs.toList());
+ } else {
+ return site;
+ }
+ }
// </editor-fold>
/**
@@ -2600,16 +2622,17 @@
candidates = candidates.prepend((MethodSymbol)s);
}
}
- return prune(candidates, ownerComparator);
+ return prune(candidates);
}
- public List<MethodSymbol> prune(List<MethodSymbol> methods, Comparator<MethodSymbol> cmp) {
+ public List<MethodSymbol> prune(List<MethodSymbol> methods) {
ListBuffer<MethodSymbol> methodsMin = ListBuffer.lb();
for (MethodSymbol m1 : methods) {
boolean isMin_m1 = true;
for (MethodSymbol m2 : methods) {
if (m1 == m2) continue;
- if (cmp.compare(m2, m1) < 0) {
+ if (m2.owner != m1.owner &&
+ asSuper(m2.owner.type, m1.owner) != null) {
isMin_m1 = false;
break;
}
@@ -2619,12 +2642,6 @@
}
return methodsMin.toList();
}
-
- Comparator<MethodSymbol> ownerComparator = new Comparator<MethodSymbol>() {
- public int compare(MethodSymbol s1, MethodSymbol s2) {
- return s1.owner.isSubClass(s2.owner, Types.this) ? -1 : 1;
- }
- };
// where
private class MethodFilter implements Filter<Symbol> {
@@ -4353,4 +4370,172 @@
return vis;
}
// </editor-fold>
+
+ // <editor-fold defaultstate="collapsed" desc="Signature Generation">
+
+ public static abstract class SignatureGenerator {
+
+ private final Types types;
+
+ protected abstract void append(char ch);
+ protected abstract void append(byte[] ba);
+ protected abstract void append(Name name);
+ protected void classReference(ClassSymbol c) { /* by default: no-op */ }
+
+ protected SignatureGenerator(Types types) {
+ this.types = types;
+ }
+
+ /**
+ * Assemble signature of given type in string buffer.
+ */
+ public void assembleSig(Type type) {
+ type = type.unannotatedType();
+ switch (type.getTag()) {
+ case BYTE:
+ append('B');
+ break;
+ case SHORT:
+ append('S');
+ break;
+ case CHAR:
+ append('C');
+ break;
+ case INT:
+ append('I');
+ break;
+ case LONG:
+ append('J');
+ break;
+ case FLOAT:
+ append('F');
+ break;
+ case DOUBLE:
+ append('D');
+ break;
+ case BOOLEAN:
+ append('Z');
+ break;
+ case VOID:
+ append('V');
+ break;
+ case CLASS:
+ append('L');
+ assembleClassSig(type);
+ append(';');
+ break;
+ case ARRAY:
+ ArrayType at = (ArrayType) type;
+ append('[');
+ assembleSig(at.elemtype);
+ break;
+ case METHOD:
+ MethodType mt = (MethodType) type;
+ append('(');
+ assembleSig(mt.argtypes);
+ append(')');
+ assembleSig(mt.restype);
+ if (hasTypeVar(mt.thrown)) {
+ for (List<Type> l = mt.thrown; l.nonEmpty(); l = l.tail) {
+ append('^');
+ assembleSig(l.head);
+ }
+ }
+ break;
+ case WILDCARD: {
+ Type.WildcardType ta = (Type.WildcardType) type;
+ switch (ta.kind) {
+ case SUPER:
+ append('-');
+ assembleSig(ta.type);
+ break;
+ case EXTENDS:
+ append('+');
+ assembleSig(ta.type);
+ break;
+ case UNBOUND:
+ append('*');
+ break;
+ default:
+ throw new AssertionError(ta.kind);
+ }
+ break;
+ }
+ case TYPEVAR:
+ append('T');
+ append(type.tsym.name);
+ append(';');
+ break;
+ case FORALL:
+ Type.ForAll ft = (Type.ForAll) type;
+ assembleParamsSig(ft.tvars);
+ assembleSig(ft.qtype);
+ break;
+ default:
+ throw new AssertionError("typeSig " + type.getTag());
+ }
+ }
+
+ public boolean hasTypeVar(List<Type> l) {
+ while (l.nonEmpty()) {
+ if (l.head.hasTag(TypeTag.TYPEVAR)) {
+ return true;
+ }
+ l = l.tail;
+ }
+ return false;
+ }
+
+ public void assembleClassSig(Type type) {
+ type = type.unannotatedType();
+ ClassType ct = (ClassType) type;
+ ClassSymbol c = (ClassSymbol) ct.tsym;
+ classReference(c);
+ Type outer = ct.getEnclosingType();
+ if (outer.allparams().nonEmpty()) {
+ boolean rawOuter =
+ c.owner.kind == Kinds.MTH || // either a local class
+ c.name == types.names.empty; // or anonymous
+ assembleClassSig(rawOuter
+ ? types.erasure(outer)
+ : outer);
+ append('.');
+ Assert.check(c.flatname.startsWith(c.owner.enclClass().flatname));
+ append(rawOuter
+ ? c.flatname.subName(c.owner.enclClass().flatname.getByteLength() + 1, c.flatname.getByteLength())
+ : c.name);
+ } else {
+ append(externalize(c.flatname));
+ }
+ if (ct.getTypeArguments().nonEmpty()) {
+ append('<');
+ assembleSig(ct.getTypeArguments());
+ append('>');
+ }
+ }
+
+ public void assembleParamsSig(List<Type> typarams) {
+ append('<');
+ for (List<Type> ts = typarams; ts.nonEmpty(); ts = ts.tail) {
+ Type.TypeVar tvar = (Type.TypeVar) ts.head;
+ append(tvar.tsym.name);
+ List<Type> bounds = types.getBounds(tvar);
+ if ((bounds.head.tsym.flags() & INTERFACE) != 0) {
+ append(':');
+ }
+ for (List<Type> l = bounds; l.nonEmpty(); l = l.tail) {
+ append(':');
+ assembleSig(l.head);
+ }
+ }
+ append('>');
+ }
+
+ private void assembleSig(List<Type> types) {
+ for (List<Type> ts = types; ts.nonEmpty(); ts = ts.tail) {
+ assembleSig(ts.head);
+ }
+ }
+ }
+ // </editor-fold>
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java Tue Mar 12 16:43:53 2013 -0700
@@ -384,10 +384,16 @@
Assert.check(!annotations.isEmpty() &&
!annotations.tail.isEmpty()); // i.e. size() > 1
+ int count = 0;
for (List<T> al = annotations;
!al.isEmpty();
al = al.tail)
{
+ count++;
+
+ // There must be more than a single anno in the annotation list
+ Assert.check(count > 1 || !al.tail.isEmpty());
+
T currentAnno = al.head;
origAnnoType = currentAnno.type;
@@ -395,7 +401,9 @@
arrayOfOrigAnnoType = types.makeArrayType(origAnnoType);
}
- Type currentContainerType = getContainingType(currentAnno, ctx.pos.get(currentAnno));
+ // Only report errors if this isn't the first occurrence I.E. count > 1
+ boolean reportError = count > 1;
+ Type currentContainerType = getContainingType(currentAnno, ctx.pos.get(currentAnno), reportError);
if (currentContainerType == null) {
continue;
}
@@ -464,7 +472,8 @@
/** Fetches the actual Type that should be the containing annotation. */
private Type getContainingType(Attribute.Compound currentAnno,
- DiagnosticPosition pos)
+ DiagnosticPosition pos,
+ boolean reportError)
{
Type origAnnoType = currentAnno.type;
TypeSymbol origAnnoDecl = origAnnoType.tsym;
@@ -473,7 +482,8 @@
// annotation's declaration, or null if it has none
Attribute.Compound ca = origAnnoDecl.attribute(syms.repeatableType.tsym);
if (ca == null) { // has no Repeatable annotation
- log.error(pos, "duplicate.annotation.missing.container", origAnnoType, syms.repeatableType);
+ if (reportError)
+ log.error(pos, "duplicate.annotation.missing.container", origAnnoType, syms.repeatableType);
return null;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Mar 12 16:43:53 2013 -0700
@@ -2151,8 +2151,11 @@
ResultInfo findDiamondResult = new ResultInfo(VAL,
resultInfo.checkContext.inferenceContext().free(resultInfo.pt) ? Type.noType : pt());
Type inferred = deferredAttr.attribSpeculative(tree, env, findDiamondResult).type;
+ Type polyPt = allowPoly ?
+ syms.objectType :
+ clazztype;
if (!inferred.isErroneous() &&
- types.isAssignable(inferred, pt().hasTag(NONE) ? syms.objectType : pt(), types.noWarnings)) {
+ types.isAssignable(inferred, pt().hasTag(NONE) ? polyPt : pt(), types.noWarnings)) {
String key = types.isSameType(clazztype, inferred) ?
"diamond.redundant.args" :
"diamond.redundant.args.1";
@@ -2532,8 +2535,7 @@
try {
//attribute member reference qualifier - if this is a constructor
//reference, the expected kind must be a type
- Type exprType = attribTree(that.expr,
- env, new ResultInfo(that.getMode() == ReferenceMode.INVOKE ? VAL | TYP : TYP, Type.noType));
+ Type exprType = attribTree(that.expr, env, memberReferenceQualifierResult(that));
if (that.getMode() == JCMemberReference.ReferenceMode.NEW) {
exprType = chk.checkConstructorRefType(that.expr, exprType);
@@ -2622,8 +2624,39 @@
}
}
+ that.sym = refSym.baseSymbol();
+ that.kind = lookupHelper.referenceKind(that.sym);
+ that.ownerAccessible = rs.isAccessible(localEnv, that.sym.enclClass());
+
+ if (desc.getReturnType() == Type.recoveryType) {
+ // stop here
+ result = that.type = target;
+ return;
+ }
+
if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) {
- if (refSym.isStatic() && TreeInfo.isStaticSelector(that.expr, names) &&
+
+ if (!that.kind.isUnbound() &&
+ that.getMode() == ReferenceMode.INVOKE &&
+ TreeInfo.isStaticSelector(that.expr, names) &&
+ !that.sym.isStatic()) {
+ log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()),
+ diags.fragment("non-static.cant.be.ref", Kinds.kindName(refSym), refSym));
+ result = that.type = types.createErrorType(target);
+ return;
+ }
+
+ if (that.kind.isUnbound() &&
+ that.getMode() == ReferenceMode.INVOKE &&
+ TreeInfo.isStaticSelector(that.expr, names) &&
+ that.sym.isStatic()) {
+ log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()),
+ diags.fragment("static.method.in.unbound.lookup", Kinds.kindName(refSym), refSym));
+ result = that.type = types.createErrorType(target);
+ return;
+ }
+
+ if (that.sym.isStatic() && TreeInfo.isStaticSelector(that.expr, names) &&
exprType.getTypeArguments().nonEmpty()) {
//static ref with class type-args
log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()),
@@ -2632,20 +2665,19 @@
return;
}
- if (refSym.isStatic() && !TreeInfo.isStaticSelector(that.expr, names) &&
- !lookupHelper.referenceKind(refSym).isUnbound()) {
+ if (that.sym.isStatic() && !TreeInfo.isStaticSelector(that.expr, names) &&
+ !that.kind.isUnbound()) {
//no static bound mrefs
log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()),
diags.fragment("static.bound.mref"));
result = that.type = types.createErrorType(target);
return;
}
- }
-
- if (desc.getReturnType() == Type.recoveryType) {
- // stop here
- result = that.type = target;
- return;
+
+ if (!refSym.isStatic() && that.kind == JCMemberReference.ReferenceKind.SUPER) {
+ // Check that super-qualified symbols are not abstract (JLS)
+ rs.checkNonAbstract(that.pos(), that.sym);
+ }
}
that.sym = refSym.baseSymbol();
@@ -2680,6 +2712,12 @@
return;
}
}
+ //where
+ ResultInfo memberReferenceQualifierResult(JCMemberReference tree) {
+ //if this is a constructor reference, the expected kind must be a type
+ return new ResultInfo(tree.getMode() == ReferenceMode.INVOKE ? VAL | TYP : TYP, Type.noType);
+ }
+
@SuppressWarnings("fallthrough")
void checkReferenceCompatible(JCMemberReference tree, Type descriptor, Type refType, CheckContext checkContext, boolean speculativeAttr) {
@@ -3558,8 +3596,7 @@
env.info.defaultSuperCallSite = null;
}
- if (sym.isStatic() && site.isInterface()) {
- Assert.check(env.tree.hasTag(APPLY));
+ if (sym.isStatic() && site.isInterface() && env.tree.hasTag(APPLY)) {
JCMethodInvocation app = (JCMethodInvocation)env.tree;
if (app.meth.hasTag(SELECT) &&
!TreeInfo.isStaticSelector(((JCFieldAccess)app.meth).selected, names)) {
@@ -3979,6 +4016,7 @@
attribClassBody(env, c);
chk.checkDeprecatedAnnotation(env.tree.pos(), c);
+ chk.checkClassOverrideEqualsAndHashIfNeeded(env.tree.pos(), c);
} finally {
env.info.returnResult = prevReturnRes;
log.useSource(prev);
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Mar 12 16:43:53 2013 -0700
@@ -285,7 +285,7 @@
* @param ex The failure to report.
*/
public Type completionError(DiagnosticPosition pos, CompletionFailure ex) {
- log.error(pos, "cant.access", ex.sym, ex.getDetailValue());
+ log.error(JCDiagnostic.DiagnosticFlag.NON_DEFERRABLE, pos, "cant.access", ex.sym, ex.getDetailValue());
if (ex instanceof ClassReader.BadClassFile
&& !suppressAbortOnBadClassFile) throw new Abort();
else return syms.errType;
@@ -670,11 +670,18 @@
t = checkClassOrArrayType(pos, t);
if (t.hasTag(CLASS)) {
if ((t.tsym.flags() & (ABSTRACT | INTERFACE)) != 0) {
- log.error(pos, "abstract.cant.be.instantiated");
+ log.error(pos, "abstract.cant.be.instantiated", t.tsym);
t = types.createErrorType(t);
} else if ((t.tsym.flags() & ENUM) != 0) {
log.error(pos, "enum.cant.be.instantiated");
t = types.createErrorType(t);
+ } else {
+ t = checkClassType(pos, t, true);
+ }
+ } else if (t.hasTag(ARRAY)) {
+ if (!types.isReifiable(((ArrayType)t).elemtype)) {
+ log.error(pos, "generic.array.creation");
+ t = types.createErrorType(t);
}
}
return t;
@@ -1591,6 +1598,7 @@
(other.flags() & STATIC) == 0) {
log.error(TreeInfo.diagnosticPositionFor(m, tree), "override.static",
cannotOverride(m, other));
+ m.flags_field |= BAD_OVERRIDE;
return;
}
@@ -1602,6 +1610,7 @@
log.error(TreeInfo.diagnosticPositionFor(m, tree), "override.meth",
cannotOverride(m, other),
asFlagSet(other.flags() & (FINAL | STATIC)));
+ m.flags_field |= BAD_OVERRIDE;
return;
}
@@ -1618,6 +1627,7 @@
other.flags() == 0 ?
Flag.PACKAGE :
asFlagSet(other.flags() & AccessFlags));
+ m.flags_field |= BAD_OVERRIDE;
return;
}
@@ -1645,6 +1655,7 @@
"override.incompatible.ret",
cannotOverride(m, other),
mtres, otres);
+ m.flags_field |= BAD_OVERRIDE;
return;
}
} else if (overrideWarner.hasNonSilentLint(LintCategory.UNCHECKED)) {
@@ -1664,6 +1675,7 @@
"override.meth.doesnt.throw",
cannotOverride(m, other),
unhandledUnerased.head);
+ m.flags_field |= BAD_OVERRIDE;
return;
}
else if (unhandledUnerased.nonEmpty()) {
@@ -1959,6 +1971,52 @@
}
}
+ private Filter<Symbol> equalsHasCodeFilter = new Filter<Symbol>() {
+ public boolean accepts(Symbol s) {
+ return MethodSymbol.implementation_filter.accepts(s) &&
+ (s.flags() & BAD_OVERRIDE) == 0;
+
+ }
+ };
+
+ public void checkClassOverrideEqualsAndHashIfNeeded(DiagnosticPosition pos,
+ ClassSymbol someClass) {
+ /* At present, annotations cannot possibly have a method that is override
+ * equivalent with Object.equals(Object) but in any case the condition is
+ * fine for completeness.
+ */
+ if (someClass == (ClassSymbol)syms.objectType.tsym ||
+ someClass.isInterface() || someClass.isEnum() ||
+ (someClass.flags() & ANNOTATION) != 0 ||
+ (someClass.flags() & ABSTRACT) != 0) return;
+ //anonymous inner classes implementing interfaces need especial treatment
+ if (someClass.isAnonymous()) {
+ List<Type> interfaces = types.interfaces(someClass.type);
+ if (interfaces != null && !interfaces.isEmpty() &&
+ interfaces.head.tsym == syms.comparatorType.tsym) return;
+ }
+ checkClassOverrideEqualsAndHash(pos, someClass);
+ }
+
+ private void checkClassOverrideEqualsAndHash(DiagnosticPosition pos,
+ ClassSymbol someClass) {
+ if (lint.isEnabled(LintCategory.OVERRIDES)) {
+ MethodSymbol equalsAtObject = (MethodSymbol)syms.objectType
+ .tsym.members().lookup(names.equals).sym;
+ MethodSymbol hashCodeAtObject = (MethodSymbol)syms.objectType
+ .tsym.members().lookup(names.hashCode).sym;
+ boolean overridesEquals = types.implementation(equalsAtObject,
+ someClass, false, equalsHasCodeFilter).owner == someClass;
+ boolean overridesHashCode = types.implementation(hashCodeAtObject,
+ someClass, false, equalsHasCodeFilter) != hashCodeAtObject;
+
+ if (overridesEquals && !overridesHashCode) {
+ log.warning(LintCategory.OVERRIDES, pos,
+ "override.equals.but.not.hashcode", someClass);
+ }
+ }
+ }
+
private boolean checkNameClash(ClassSymbol origin, Symbol s1, Symbol s2) {
ClashFilter cf = new ClashFilter(origin.type);
return (cf.accepts(s1) &&
@@ -2235,10 +2293,13 @@
void checkFunctionalInterface(JCTree tree, Type funcInterface) {
ClassType c = new ClassType(Type.noType, List.<Type>nil(), null);
ClassSymbol csym = new ClassSymbol(0, names.empty, c, syms.noSymbol);
- c.interfaces_field = List.of(funcInterface);
+ c.interfaces_field = List.of(types.removeWildcards(funcInterface));
c.supertype_field = syms.objectType;
c.tsym = csym;
csym.members_field = new Scope(csym);
+ Symbol descSym = types.findDescriptorSymbol(funcInterface.tsym);
+ Type descType = types.findDescriptorType(funcInterface);
+ csym.members_field.enter(new MethodSymbol(PUBLIC, descSym.name, descType, csym));
csym.completer = null;
checkImplementations(tree, csym, csym);
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Tue Mar 12 16:43:53 2013 -0700
@@ -68,6 +68,7 @@
final JCDiagnostic.Factory diags;
final Enter enter;
final Infer infer;
+ final Resolve rs;
final Log log;
final Symtab syms;
final TreeMaker make;
@@ -87,6 +88,7 @@
diags = JCDiagnostic.Factory.instance(context);
enter = Enter.instance(context);
infer = Infer.instance(context);
+ rs = Resolve.instance(context);
log = Log.instance(context);
syms = Symtab.instance(context);
make = TreeMaker.instance(context);
@@ -274,25 +276,33 @@
* disabled during speculative type-checking.
*/
JCTree attribSpeculative(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo) {
- JCTree newTree = new TreeCopier<Object>(make).copy(tree);
+ final JCTree newTree = new TreeCopier<Object>(make).copy(tree);
Env<AttrContext> speculativeEnv = env.dup(newTree, env.info.dup(env.info.scope.dupUnshared()));
speculativeEnv.info.scope.owner = env.info.scope.owner;
- final JavaFileObject currentSource = log.currentSourceFile();
Log.DeferredDiagnosticHandler deferredDiagnosticHandler =
new Log.DeferredDiagnosticHandler(log, new Filter<JCDiagnostic>() {
- public boolean accepts(JCDiagnostic t) {
- return t.getDiagnosticSource().getFile().equals(currentSource);
+ public boolean accepts(final JCDiagnostic d) {
+ class PosScanner extends TreeScanner {
+ boolean found = false;
+
+ @Override
+ public void scan(JCTree tree) {
+ if (tree != null &&
+ tree.pos() == d.getDiagnosticPosition()) {
+ found = true;
+ }
+ super.scan(tree);
+ }
+ };
+ PosScanner posScanner = new PosScanner();
+ posScanner.scan(newTree);
+ return posScanner.found;
}
});
try {
attr.attribTree(newTree, speculativeEnv, resultInfo);
unenterScanner.scan(newTree);
return newTree;
- } catch (Abort ex) {
- //if some very bad condition occurred during deferred attribution
- //we should dump all errors before killing javac
- deferredDiagnosticHandler.reportDeferredDiagnostics();
- throw ex;
} finally {
unenterScanner.scan(newTree);
log.popDiagnosticHandler(deferredDiagnosticHandler);
@@ -463,10 +473,12 @@
ResultInfo resultInfo;
InferenceContext inferenceContext;
+ Env<AttrContext> env;
public Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
this.resultInfo = resultInfo;
this.inferenceContext = deferredAttrContext.inferenceContext;
+ this.env = dt.env.dup(dt.tree, dt.env.info.dup());
dt.tree.accept(this);
dt.speculativeCache.put(deferredAttrContext.msym, stuckTree, deferredAttrContext.phase);
return Type.noType;
@@ -511,12 +523,30 @@
return;
} else {
try {
- //TODO: we should speculative determine if there's a match
- //based on arity - if yes, method is applicable.
types.findDescriptorType(pt);
} catch (Types.FunctionDescriptorLookupError ex) {
checkContext.report(null, ex.getDiagnostic());
}
+ JCExpression exprTree = (JCExpression)attribSpeculative(tree.getQualifierExpression(), env,
+ attr.memberReferenceQualifierResult(tree));
+ ListBuffer<Type> argtypes = ListBuffer.lb();
+ for (Type t : types.findDescriptorType(pt).getParameterTypes()) {
+ argtypes.append(syms.errType);
+ }
+ JCMemberReference mref2 = new TreeCopier<Void>(make).copy(tree);
+ mref2.expr = exprTree;
+ Pair<Symbol, ?> lookupRes =
+ rs.resolveMemberReference(tree, env, mref2, exprTree.type, tree.name, argtypes.toList(), null, true);
+ switch (lookupRes.fst.kind) {
+ //note: as argtypes are erroneous types, type-errors must
+ //have been caused by arity mismatch
+ case Kinds.ABSENT_MTH:
+ case Kinds.WRONG_MTH:
+ case Kinds.WRONG_MTHS:
+ case Kinds.STATICERR:
+ case Kinds.MISSING_ENCL:
+ checkContext.report(null, diags.fragment("incompatible.arg.types.in.mref"));
+ }
}
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Tue Mar 12 16:43:53 2013 -0700
@@ -641,6 +641,8 @@
if (inferenceContext.inferenceVars().contains(b)) {
UndetVar uv2 = (UndetVar)inferenceContext.asFree(b);
//alpha <: beta
+ //0. set beta :> alpha
+ uv2.addBound(InferenceBound.LOWER, uv.qtype, infer.types);
//1. copy alpha's lower to beta's
for (Type l : uv.getBounds(InferenceBound.LOWER)) {
uv2.addBound(InferenceBound.LOWER, inferenceContext.asInstType(l), infer.types);
@@ -664,6 +666,8 @@
if (inferenceContext.inferenceVars().contains(b)) {
UndetVar uv2 = (UndetVar)inferenceContext.asFree(b);
//alpha :> beta
+ //0. set beta <: alpha
+ uv2.addBound(InferenceBound.UPPER, uv.qtype, infer.types);
//1. copy alpha's upper to beta's
for (Type u : uv.getBounds(InferenceBound.UPPER)) {
uv2.addBound(InferenceBound.UPPER, inferenceContext.asInstType(u), infer.types);
@@ -687,6 +691,8 @@
if (inferenceContext.inferenceVars().contains(b)) {
UndetVar uv2 = (UndetVar)inferenceContext.asFree(b);
//alpha == beta
+ //0. set beta == alpha
+ uv2.addBound(InferenceBound.EQ, uv.qtype, infer.types);
//1. copy all alpha's bounds to beta's
for (InferenceBound ib : InferenceBound.values()) {
for (Type b2 : uv.getBounds(ib)) {
@@ -1216,7 +1222,7 @@
* created, effectively replacing the original cyclic nodes.
*/
void initNodes() {
- ArrayList<Node> nodes = new ArrayList<Node>();
+ nodes = new ArrayList<Node>();
for (Type t : inferenceContext.restvars()) {
nodes.add(new Node(t));
}
@@ -1228,14 +1234,10 @@
if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
//update i's deps
n_i.deps.add(n_j);
- //update j's deps - only if i's bounds contain _exactly_ j
- if (uv_i.getBounds(InferenceBound.values()).contains(j)) {
- n_j.deps.add(n_i);
- }
}
}
}
- this.nodes = new ArrayList<Node>();
+ ArrayList<Node> acyclicNodes = new ArrayList<Node>();
for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
if (conSubGraph.length() > 1) {
Node root = conSubGraph.head;
@@ -1244,8 +1246,9 @@
notifyUpdate(n, root);
}
}
- this.nodes.add(conSubGraph.head);
+ acyclicNodes.add(conSubGraph.head);
}
+ nodes = acyclicNodes;
}
/**
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -31,8 +31,8 @@
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.tree.TreeScanner;
import com.sun.tools.javac.tree.TreeTranslator;
-import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Kinds;
+import com.sun.tools.javac.code.Scope;
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Symbol.ClassSymbol;
import com.sun.tools.javac.code.Symbol.DynamicMethodSymbol;
@@ -44,6 +44,7 @@
import com.sun.tools.javac.code.Type.MethodType;
import com.sun.tools.javac.code.Types;
import com.sun.tools.javac.comp.LambdaToMethod.LambdaAnalyzer.*;
+import com.sun.tools.javac.comp.Lower.BasicFreeVarCollector;
import com.sun.tools.javac.jvm.*;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.List;
@@ -57,9 +58,7 @@
import static com.sun.tools.javac.comp.LambdaToMethod.LambdaSymbolKind.*;
import static com.sun.tools.javac.code.Flags.*;
import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTag.BOT;
-import static com.sun.tools.javac.code.TypeTag.NONE;
-import static com.sun.tools.javac.code.TypeTag.VOID;
+import static com.sun.tools.javac.code.TypeTag.*;
import static com.sun.tools.javac.tree.JCTree.Tag.*;
/**
@@ -72,6 +71,7 @@
*/
public class LambdaToMethod extends TreeTranslator {
+ private Lower lower;
private Names names;
private Symtab syms;
private Resolve rs;
@@ -89,9 +89,52 @@
/** current translation context (visitor argument) */
private TranslationContext<?> context;
- /** list of translated methods
- **/
- private ListBuffer<JCTree> translatedMethodList;
+ /** info about the current class being processed */
+ private KlassInfo kInfo;
+
+ /** Flag for alternate metafactories indicating the lambda object is intended to be serializable */
+ public static final int FLAG_SERIALIZABLE = 1 << 0;
+
+ /** Flag for alternate metafactories indicating the lambda object has multiple targets */
+ public static final int FLAG_MARKERS = 1 << 1;
+
+ private class KlassInfo {
+
+ /**
+ * list of methods to append
+ */
+ private ListBuffer<JCTree> appendedMethodList;
+
+ /**
+ * list of deserialization cases
+ */
+ private final Map<String, ListBuffer<JCStatement>> deserializeCases;
+
+ /**
+ * deserialize method symbol
+ */
+ private final MethodSymbol deserMethodSym;
+
+ /**
+ * deserialize method parameter symbol
+ */
+ private final VarSymbol deserParamSym;
+
+ private KlassInfo(Symbol kSym) {
+ appendedMethodList = ListBuffer.lb();
+ deserializeCases = new HashMap<String, ListBuffer<JCStatement>>();
+ long flags = PRIVATE | STATIC | SYNTHETIC;
+ MethodType type = new MethodType(List.of(syms.serializedLambdaType), syms.objectType,
+ List.<Type>nil(), syms.methodClass);
+ deserMethodSym = makeSyntheticMethod(flags, names.deserializeLambda, type, kSym);
+ deserParamSym = new VarSymbol(FINAL, names.fromString("lambda"),
+ syms.serializedLambdaType, deserMethodSym);
+ }
+
+ private void addMethod(JCTree decl) {
+ appendedMethodList = appendedMethodList.prepend(decl);
+ }
+ }
// <editor-fold defaultstate="collapsed" desc="Instantiating">
private static final Context.Key<LambdaToMethod> unlambdaKey =
@@ -106,17 +149,14 @@
}
private LambdaToMethod(Context context) {
+ lower = Lower.instance(context);
names = Names.instance(context);
syms = Symtab.instance(context);
rs = Resolve.instance(context);
make = TreeMaker.instance(context);
types = Types.instance(context);
transTypes = TransTypes.instance(context);
- this.analyzer = makeAnalyzer();
- }
-
- private LambdaAnalyzer makeAnalyzer() {
- return new LambdaAnalyzer();
+ analyzer = new LambdaAnalyzer();
}
// </editor-fold>
@@ -168,18 +208,22 @@
//analyze class
analyzer.analyzeClass(tree);
}
- ListBuffer<JCTree> prevTranslated = translatedMethodList;
+ KlassInfo prevKlassInfo = kInfo;
try {
- translatedMethodList = ListBuffer.lb();
+ kInfo = new KlassInfo(tree.sym);
super.visitClassDef(tree);
+ if (!kInfo.deserializeCases.isEmpty()) {
+ kInfo.addMethod(makeDeserializeMethod(tree.sym));
+ }
//add all translated instance methods here
- tree.defs = tree.defs.appendList(translatedMethodList.toList());
- for (JCTree lambda : translatedMethodList) {
+ List<JCTree> newMethods = kInfo.appendedMethodList.toList();
+ tree.defs = tree.defs.appendList(newMethods);
+ for (JCTree lambda : newMethods) {
tree.sym.members().enter(((JCMethodDecl)lambda).sym);
}
result = tree;
} finally {
- translatedMethodList = prevTranslated;
+ kInfo = prevKlassInfo;
}
}
@@ -217,7 +261,7 @@
lambdaDecl.body = translate(makeLambdaBody(tree, lambdaDecl));
//Add the method to the list of methods to be added to this class.
- translatedMethodList = translatedMethodList.prepend(lambdaDecl);
+ kInfo.addMethod(lambdaDecl);
//now that we have generated a method for the lambda expression,
//we can translate the lambda into a method reference pointing to the newly
@@ -234,7 +278,7 @@
if (!sym.isStatic()) {
syntheticInits.append(makeThis(
- sym.owner.asType(),
+ sym.owner.enclClass().asType(),
localContext.owner.enclClass()));
}
@@ -253,7 +297,7 @@
int refKind = referenceKind(sym);
//convert to an invokedynamic call
- result = makeMetaFactoryIndyCall(tree, refKind, sym, indy_args);
+ result = makeMetaFactoryIndyCall(tree, context.needsAltMetafactory(), context.isSerializable(), refKind, sym, indy_args);
}
private JCIdent makeThis(Type type, Symbol owner) {
@@ -291,8 +335,8 @@
case IMPLICIT_INNER: /** Inner :: new */
case SUPER: /** super :: instMethod */
init = makeThis(
- localContext.owner.owner.asType(),
- localContext.owner);
+ localContext.owner.enclClass().asType(),
+ localContext.owner.enclClass());
break;
case BOUND: /** Expr :: instMethod */
@@ -314,7 +358,7 @@
//build a sam instance using an indy call to the meta-factory
- result = makeMetaFactoryIndyCall(tree, localContext.referenceKind(), refSym, indy_args);
+ result = makeMetaFactoryIndyCall(tree, localContext.needsAltMetafactory(), localContext.isSerializable(), localContext.referenceKind(), refSym, indy_args);
}
/**
@@ -333,6 +377,9 @@
} else if (lambdaContext.getSymbolMap(LOCAL_VAR).containsKey(tree.sym)) {
Symbol translatedSym = lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym);
result = make.Ident(translatedSym).setType(tree.type);
+ } else if (lambdaContext.getSymbolMap(TYPE_VAR).containsKey(tree.sym)) {
+ Symbol translatedSym = lambdaContext.getSymbolMap(TYPE_VAR).get(tree.sym);
+ result = make.Ident(translatedSym).setType(translatedSym.type);
} else if (lambdaContext.getSymbolMap(CAPTURED_VAR).containsKey(tree.sym)) {
Symbol translatedSym = lambdaContext.getSymbolMap(CAPTURED_VAR).get(tree.sym);
result = make.Ident(translatedSym).setType(tree.type);
@@ -362,6 +409,16 @@
if (context != null && lambdaContext.getSymbolMap(LOCAL_VAR).containsKey(tree.sym)) {
JCExpression init = translate(tree.init);
result = make.VarDef((VarSymbol)lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym), init);
+ } else if (context != null && lambdaContext.getSymbolMap(TYPE_VAR).containsKey(tree.sym)) {
+ JCExpression init = translate(tree.init);
+ VarSymbol xsym = (VarSymbol)lambdaContext.getSymbolMap(TYPE_VAR).get(tree.sym);
+ result = make.VarDef(xsym, init);
+ // Replace the entered symbol for this variable
+ Scope sc = tree.sym.owner.members();
+ if (sc != null) {
+ sc.remove(tree.sym);
+ sc.enter(xsym);
+ }
} else {
super.visitVarDef(tree);
}
@@ -451,6 +508,135 @@
return trans_block;
}
+ private JCMethodDecl makeDeserializeMethod(Symbol kSym) {
+ ListBuffer<JCCase> cases = ListBuffer.lb();
+ ListBuffer<JCBreak> breaks = ListBuffer.lb();
+ for (Map.Entry<String, ListBuffer<JCStatement>> entry : kInfo.deserializeCases.entrySet()) {
+ JCBreak br = make.Break(null);
+ breaks.add(br);
+ List<JCStatement> stmts = entry.getValue().append(br).toList();
+ cases.add(make.Case(make.Literal(entry.getKey()), stmts));
+ }
+ JCSwitch sw = make.Switch(deserGetter("getImplMethodName", syms.stringType), cases.toList());
+ for (JCBreak br : breaks) {
+ br.target = sw;
+ }
+ JCBlock body = make.Block(0L, List.<JCStatement>of(
+ sw,
+ make.Throw(makeNewClass(
+ syms.illegalArgumentExceptionType,
+ List.<JCExpression>of(make.Literal("Invalid lambda deserialization"))))));
+ JCMethodDecl deser = make.MethodDef(make.Modifiers(kInfo.deserMethodSym.flags()),
+ names.deserializeLambda,
+ make.QualIdent(kInfo.deserMethodSym.getReturnType().tsym),
+ List.<JCTypeParameter>nil(),
+ List.of(make.VarDef(kInfo.deserParamSym, null)),
+ List.<JCExpression>nil(),
+ body,
+ null);
+ deser.sym = kInfo.deserMethodSym;
+ deser.type = kInfo.deserMethodSym.type;
+ //System.err.printf("DESER: '%s'\n", deser);
+ return deser;
+ }
+
+ /** Make an attributed class instance creation expression.
+ * @param ctype The class type.
+ * @param args The constructor arguments.
+ */
+ JCNewClass makeNewClass(Type ctype, List<JCExpression> args) {
+ JCNewClass tree = make.NewClass(null,
+ null, make.QualIdent(ctype.tsym), args, null);
+ tree.constructor = rs.resolveConstructor(
+ null, attrEnv, ctype, TreeInfo.types(args), List.<Type>nil());
+ tree.type = ctype;
+ return tree;
+ }
+
+ private void addDeserializationCase(int implMethodKind, Symbol refSym, Type targetType, MethodSymbol samSym,
+ DiagnosticPosition pos, List<Object> staticArgs, MethodType indyType) {
+ String functionalInterfaceClass = classSig(targetType);
+ String functionalInterfaceMethodName = samSym.getSimpleName().toString();
+ String functionalInterfaceMethodSignature = methodSig(types.erasure(samSym.type));
+ String implClass = classSig(types.erasure(refSym.owner.type));
+ String implMethodName = refSym.getQualifiedName().toString();
+ String implMethodSignature = methodSig(types.erasure(refSym.type));
+
+ JCExpression kindTest = eqTest(syms.intType, deserGetter("getImplMethodKind", syms.intType), make.Literal(implMethodKind));
+ ListBuffer<JCExpression> serArgs = ListBuffer.lb();
+ int i = 0;
+ for (Type t : indyType.getParameterTypes()) {
+ List<JCExpression> indexAsArg = ListBuffer.<JCExpression>lb().append(make.Literal(i)).toList();
+ List<Type> argTypes = ListBuffer.<Type>lb().append(syms.intType).toList();
+ serArgs.add(make.TypeCast(types.erasure(t), deserGetter("getCapturedArg", syms.objectType, argTypes, indexAsArg)));
+ ++i;
+ }
+ JCStatement stmt = make.If(
+ deserTest(deserTest(deserTest(deserTest(deserTest(
+ kindTest,
+ "getFunctionalInterfaceClass", functionalInterfaceClass),
+ "getFunctionalInterfaceMethodName", functionalInterfaceMethodName),
+ "getFunctionalInterfaceMethodSignature", functionalInterfaceMethodSignature),
+ "getImplClass", implClass),
+ "getImplMethodSignature", implMethodSignature),
+ make.Return(makeIndyCall(
+ pos,
+ syms.lambdaMetafactory,
+ names.altMetaFactory,
+ staticArgs, indyType, serArgs.toList())),
+ null);
+ ListBuffer<JCStatement> stmts = kInfo.deserializeCases.get(implMethodName);
+ if (stmts == null) {
+ stmts = ListBuffer.lb();
+ kInfo.deserializeCases.put(implMethodName, stmts);
+ }
+ /****
+ System.err.printf("+++++++++++++++++\n");
+ System.err.printf("*functionalInterfaceClass: '%s'\n", functionalInterfaceClass);
+ System.err.printf("*functionalInterfaceMethodName: '%s'\n", functionalInterfaceMethodName);
+ System.err.printf("*functionalInterfaceMethodSignature: '%s'\n", functionalInterfaceMethodSignature);
+ System.err.printf("*implMethodKind: %d\n", implMethodKind);
+ System.err.printf("*implClass: '%s'\n", implClass);
+ System.err.printf("*implMethodName: '%s'\n", implMethodName);
+ System.err.printf("*implMethodSignature: '%s'\n", implMethodSignature);
+ ****/
+ stmts.append(stmt);
+ }
+
+ private JCExpression eqTest(Type argType, JCExpression arg1, JCExpression arg2) {
+ JCBinary testExpr = make.Binary(JCTree.Tag.EQ, arg1, arg2);
+ testExpr.operator = rs.resolveBinaryOperator(null, JCTree.Tag.EQ, attrEnv, argType, argType);
+ testExpr.setType(syms.booleanType);
+ return testExpr;
+ }
+
+ private JCExpression deserTest(JCExpression prev, String func, String lit) {
+ MethodType eqmt = new MethodType(List.of(syms.objectType), syms.booleanType, List.<Type>nil(), syms.methodClass);
+ Symbol eqsym = rs.resolveQualifiedMethod(null, attrEnv, syms.objectType, names.equals, List.of(syms.objectType), List.<Type>nil());
+ JCMethodInvocation eqtest = make.Apply(
+ List.<JCExpression>nil(),
+ make.Select(deserGetter(func, syms.stringType), eqsym).setType(eqmt),
+ List.<JCExpression>of(make.Literal(lit)));
+ eqtest.setType(syms.booleanType);
+ JCBinary compound = make.Binary(JCTree.Tag.AND, prev, eqtest);
+ compound.operator = rs.resolveBinaryOperator(null, JCTree.Tag.AND, attrEnv, syms.booleanType, syms.booleanType);
+ compound.setType(syms.booleanType);
+ return compound;
+ }
+
+ private JCExpression deserGetter(String func, Type type) {
+ return deserGetter(func, type, List.<Type>nil(), List.<JCExpression>nil());
+ }
+
+ private JCExpression deserGetter(String func, Type type, List<Type> argTypes, List<JCExpression> args) {
+ MethodType getmt = new MethodType(argTypes, type, List.<Type>nil(), syms.methodClass);
+ Symbol getsym = rs.resolveQualifiedMethod(null, attrEnv, syms.serializedLambdaType, names.fromString(func), argTypes, List.<Type>nil());
+ return make.Apply(
+ List.<JCExpression>nil(),
+ make.Select(make.Ident(kInfo.deserParamSym).setType(syms.serializedLambdaType), getsym).setType(getmt),
+ args).setType(type);
+ }
+
/**
* Create new synthetic method with given flags, name, type, owner
*/
@@ -556,7 +742,8 @@
List<Type> refPTypes = tree.sym.type.getParameterTypes();
int refSize = refPTypes.size();
int samSize = samPTypes.size();
- int last = localContext.needsVarArgsConversion() ? refSize - 1 : refSize; // Last parameter to copy from referenced method
+ // Last parameter to copy from referenced method
+ int last = localContext.needsVarArgsConversion() ? refSize - 1 : refSize;
List<Type> l = refPTypes;
// Use parameter types of the referenced method, excluding final var args
@@ -581,12 +768,13 @@
null,
null);
bridgeDecl.sym = (MethodSymbol) localContext.bridgeSym;
- bridgeDecl.type = localContext.bridgeSym.type = types.createMethodTypeWithParameters(samDesc, TreeInfo.types(params.toList()));
+ bridgeDecl.type = localContext.bridgeSym.type =
+ types.createMethodTypeWithParameters(samDesc, TreeInfo.types(params.toList()));
//bridge method body generation - this can be either a method call or a
//new instance creation expression, depending on the member reference kind
JCExpression bridgeExpr = (tree.getMode() == ReferenceMode.INVOKE)
- ? bridgeExpressionInvoke(rcvr)
+ ? bridgeExpressionInvoke(makeReceiver(rcvr))
: bridgeExpressionNew();
//the body is either a return expression containing a method call,
@@ -599,6 +787,16 @@
make.at(prevPos);
}
}
+ //where
+ private JCExpression makeReceiver(VarSymbol rcvr) {
+ if (rcvr == null) return null;
+ JCExpression rcvrExpr = make.Ident(rcvr);
+ Type rcvrType = tree.sym.enclClass().type;
+ if (!rcvr.type.tsym.isSubClass(rcvrType.tsym, types)) {
+ rcvrExpr = make.TypeCast(make.Type(rcvrType), rcvrExpr).setType(rcvrType);
+ }
+ return rcvrExpr;
+ }
/**
* determine the receiver of the bridged method call - the receiver can
@@ -606,12 +804,12 @@
* original qualifier expression is never used here, as it might refer
* to symbols not available in the static context of the bridge
*/
- private JCExpression bridgeExpressionInvoke(VarSymbol rcvr) {
+ private JCExpression bridgeExpressionInvoke(JCExpression rcvr) {
JCExpression qualifier =
tree.sym.isStatic() ?
make.Type(tree.sym.owner.type) :
(rcvr != null) ?
- make.Ident(rcvr) :
+ rcvr :
tree.getQualifierExpression();
//create the qualifier expression
@@ -621,7 +819,8 @@
//create the method call expression
JCExpression apply = make.Apply(List.<JCExpression>nil(), select,
- convertArgs(tree.sym, args.toList(), tree.varargsElement)).setType(tree.sym.erasure(types).getReturnType());
+ convertArgs(tree.sym, args.toList(), tree.varargsElement)).
+ setType(tree.sym.erasure(types).getReturnType());
apply = transTypes.coerce(apply, localContext.generatedRefSig().getReturnType());
setVarargsIfNeeded(apply, tree.varargsElement);
@@ -635,7 +834,8 @@
private JCExpression bridgeExpressionNew() {
if (tree.kind == ReferenceKind.ARRAY_CTOR) {
//create the array creation expression
- JCNewArray newArr = make.NewArray(make.Type(types.elemtype(tree.getQualifierExpression().type)),
+ JCNewArray newArr = make.NewArray(
+ make.Type(types.elemtype(tree.getQualifierExpression().type)),
List.of(make.Ident(params.first())),
null);
newArr.type = tree.getQualifierExpression().type;
@@ -678,19 +878,20 @@
* * super is used
*/
private void bridgeMemberReference(JCMemberReference tree, ReferenceTranslationContext localContext) {
- JCMethodDecl bridgeDecl = (new MemberReferenceBridger(tree, localContext).bridge());
- translatedMethodList = translatedMethodList.prepend(bridgeDecl);
+ kInfo.addMethod(new MemberReferenceBridger(tree, localContext).bridge());
}
/**
* Generate an indy method call to the meta factory
*/
- private JCExpression makeMetaFactoryIndyCall(JCFunctionalExpression tree, int refKind, Symbol refSym, List<JCExpression> indy_args) {
+ private JCExpression makeMetaFactoryIndyCall(JCFunctionalExpression tree, boolean needsAltMetafactory,
+ boolean isSerializable, int refKind, Symbol refSym, List<JCExpression> indy_args) {
//determine the static bsm args
Type mtype = types.erasure(tree.descriptorType);
MethodSymbol samSym = (MethodSymbol) types.findDescriptorSymbol(tree.type.tsym);
List<Object> staticArgs = List.<Object>of(
- new Pool.MethodHandle(ClassFile.REF_invokeInterface, types.findDescriptorSymbol(tree.type.tsym), types),
+ new Pool.MethodHandle(ClassFile.REF_invokeInterface,
+ types.findDescriptorSymbol(tree.type.tsym), types),
new Pool.MethodHandle(refKind, refSym, types),
new MethodType(mtype.getParameterTypes(),
mtype.getReturnType(),
@@ -709,14 +910,39 @@
List.<Type>nil(),
syms.methodClass);
- return makeIndyCall(tree, syms.lambdaMetafactory, names.metaFactory, staticArgs, indyType, indy_args);
+ Name metafactoryName = needsAltMetafactory ?
+ names.altMetaFactory : names.metaFactory;
+
+ if (needsAltMetafactory) {
+ ListBuffer<Object> markers = ListBuffer.lb();
+ for (Symbol t : tree.targets.tail) {
+ if (t != syms.serializableType.tsym) {
+ markers.append(t);
+ }
+ }
+ int flags = isSerializable? FLAG_SERIALIZABLE : 0;
+ boolean hasMarkers = markers.nonEmpty();
+ flags |= hasMarkers ? FLAG_MARKERS : 0;
+ staticArgs = staticArgs.append(flags);
+ if (hasMarkers) {
+ staticArgs = staticArgs.append(markers.length());
+ staticArgs = staticArgs.appendList(markers.toList());
+ }
+ if (isSerializable) {
+ addDeserializationCase(refKind, refSym, tree.type, samSym,
+ tree, staticArgs, indyType);
+ }
+ }
+
+ return makeIndyCall(tree, syms.lambdaMetafactory, metafactoryName, staticArgs, indyType, indy_args);
}
/**
* Generate an indy method call with given name, type and static bootstrap
* arguments types
*/
- private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName, List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs) {
+ private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName,
+ List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs) {
int prevPos = make.pos;
try {
make.at(pos);
@@ -730,7 +956,9 @@
DynamicMethodSymbol dynSym =
new DynamicMethodSymbol(names.lambda,
syms.noSymbol,
- bsm.isStatic() ? ClassFile.REF_invokeStatic : ClassFile.REF_invokeVirtual,
+ bsm.isStatic() ?
+ ClassFile.REF_invokeStatic :
+ ClassFile.REF_invokeVirtual,
(MethodSymbol)bsm,
indyType,
staticArgs.toArray());
@@ -795,6 +1023,7 @@
}
}
}
+
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Lambda/reference analyzer">\
@@ -814,8 +1043,25 @@
*/
private int lambdaCount = 0;
+ /**
+ * keep the count of lambda expression defined in given context (used to
+ * generate unambiguous names for serializable lambdas)
+ */
+ private Map<String, Integer> serializableLambdaCounts =
+ new HashMap<String, Integer>();
+
+ private Map<Symbol, JCClassDecl> localClassDefs;
+
+ /**
+ * maps for fake clinit symbols to be used as owners of lambda occurring in
+ * a static var init context
+ */
+ private Map<ClassSymbol, Symbol> clinits =
+ new HashMap<ClassSymbol, Symbol>();
+
private void analyzeClass(JCClassDecl tree) {
frameStack = List.nil();
+ localClassDefs = new HashMap<Symbol, JCClassDecl>();
scan(tree);
}
@@ -836,21 +1082,28 @@
@Override
public void visitClassDef(JCClassDecl tree) {
List<Frame> prevStack = frameStack;
+ Map<String, Integer> prevSerializableLambdaCount =
+ serializableLambdaCounts;
+ Map<ClassSymbol, Symbol> prevClinits = clinits;
try {
- if (frameStack.nonEmpty() && enclosingLambda() != null) {
+ serializableLambdaCounts = new HashMap<String, Integer>();
+ prevClinits = new HashMap<ClassSymbol, Symbol>();
+ if (tree.sym.owner.kind == MTH) {
+ localClassDefs.put(tree.sym, tree);
+ }
+ if (directlyEnclosingLambda() != null) {
tree.sym.owner = owner();
- LambdaTranslationContext lambdaContext = (LambdaTranslationContext)contextMap.get(enclosingLambda());
- Type encl = lambdaContext.enclosingType();
- if (encl.hasTag(NONE)) {
- //if the translated lambda body occurs in a static context,
- //any class declaration within it must be made static
- tree.sym.flags_field |= STATIC;
- ((ClassType)tree.sym.type).setEnclosingType(Type.noType);
- } else {
- //if the translated lambda body is in an instance context
- //the enclosing type of any class declaration within it
- //must be updated to point to the new enclosing type (if any)
- ((ClassType)tree.sym.type).setEnclosingType(encl);
+ if (tree.sym.hasOuterInstance()) {
+ //if a class is defined within a lambda, the lambda must capture
+ //its enclosing instance (if any)
+ TranslationContext<?> localContext = context();
+ while (localContext != null) {
+ if (localContext.tree.getTag() == LAMBDA) {
+ ((LambdaTranslationContext)localContext)
+ .addSymbol(tree.sym.type.getEnclosingType().tsym, CAPTURED_THIS);
+ }
+ localContext = localContext.prev;
+ }
}
}
frameStack = frameStack.prepend(new Frame(tree));
@@ -858,19 +1111,14 @@
}
finally {
frameStack = prevStack;
- }
- if (!tree.sym.isStatic() && frameStack.nonEmpty() && enclosingLambda() != null) {
- // Any (non-static) class defined within a lambda is an implicit 'this' reference
- // because its constructor will reference the enclosing class
- ((LambdaTranslationContext) context()).addSymbol(tree.sym.type.getEnclosingType().tsym, CAPTURED_THIS);
+ serializableLambdaCounts = prevSerializableLambdaCount;
+ clinits = prevClinits;
}
}
@Override
public void visitIdent(JCIdent tree) {
- if (context() == null || !lambdaIdentSymbolFilter(tree.sym)) {
- super.visitIdent(tree);
- } else {
+ if (context() != null && lambdaIdentSymbolFilter(tree.sym)) {
if (tree.sym.kind == VAR &&
tree.sym.owner.kind == MTH &&
tree.type.constValue() == null) {
@@ -879,7 +1127,8 @@
if (localContext.tree.getTag() == LAMBDA) {
JCTree block = capturedDecl(localContext.depth, tree.sym);
if (block == null) break;
- ((LambdaTranslationContext)localContext).addSymbol(tree.sym, CAPTURED_VAR);
+ ((LambdaTranslationContext)localContext)
+ .addSymbol(tree.sym, CAPTURED_VAR);
}
localContext = localContext.prev;
}
@@ -892,7 +1141,8 @@
switch (block.getTag()) {
case CLASSDEF:
JCClassDecl cdecl = (JCClassDecl)block;
- ((LambdaTranslationContext)localContext).addSymbol(cdecl.sym, CAPTURED_THIS);
+ ((LambdaTranslationContext)localContext)
+ .addSymbol(cdecl.sym, CAPTURED_THIS);
break;
default:
Assert.error("bad block kind");
@@ -902,6 +1152,7 @@
}
}
}
+ super.visitIdent(tree);
}
@Override
@@ -938,10 +1189,50 @@
@Override
public void visitNewClass(JCNewClass tree) {
if (lambdaNewClassFilter(context(), tree)) {
- ((LambdaTranslationContext) context()).addSymbol(tree.type.getEnclosingType().tsym, CAPTURED_THIS);
+ TranslationContext<?> localContext = context();
+ while (localContext != null) {
+ if (localContext.tree.getTag() == LAMBDA) {
+ ((LambdaTranslationContext)localContext)
+ .addSymbol(tree.type.getEnclosingType().tsym, CAPTURED_THIS);
+ }
+ localContext = localContext.prev;
+ }
+ }
+ if (context() != null && tree.type.tsym.owner.kind == MTH) {
+ LambdaTranslationContext lambdaContext = (LambdaTranslationContext)context();
+ captureLocalClassDefs(tree.type.tsym, lambdaContext);
}
super.visitNewClass(tree);
}
+ //where
+ void captureLocalClassDefs(Symbol csym, final LambdaTranslationContext lambdaContext) {
+ JCClassDecl localCDef = localClassDefs.get(csym);
+ if (localCDef != null && localCDef.pos < lambdaContext.tree.pos) {
+ BasicFreeVarCollector fvc = lower.new BasicFreeVarCollector() {
+ @Override
+ void addFreeVars(ClassSymbol c) {
+ captureLocalClassDefs(c, lambdaContext);
+ }
+ @Override
+ void visitSymbol(Symbol sym) {
+ if (sym.kind == VAR &&
+ sym.owner.kind == MTH &&
+ ((VarSymbol)sym).getConstValue() == null) {
+ TranslationContext<?> localContext = context();
+ while (localContext != null) {
+ if (localContext.tree.getTag() == LAMBDA) {
+ JCTree block = capturedDecl(localContext.depth, sym);
+ if (block == null) break;
+ ((LambdaTranslationContext)localContext).addSymbol(sym, CAPTURED_VAR);
+ }
+ localContext = localContext.prev;
+ }
+ }
+ }
+ };
+ fvc.scan(localCDef);
+ }
+ }
@Override
public void visitReference(JCMemberReference tree) {
@@ -969,9 +1260,22 @@
@Override
public void visitVarDef(JCVariableDecl tree) {
- if (frameStack.head.tree.hasTag(LAMBDA)) {
- ((LambdaTranslationContext)context()).addSymbol(tree.sym, LOCAL_VAR);
+ TranslationContext<?> context = context();
+ LambdaTranslationContext ltc = (context != null && context instanceof LambdaTranslationContext)?
+ (LambdaTranslationContext)context :
+ null;
+ if (ltc != null) {
+ if (frameStack.head.tree.hasTag(LAMBDA)) {
+ ltc.addSymbol(tree.sym, LOCAL_VAR);
+ }
+ // Check for type variables (including as type arguments).
+ // If they occur within class nested in a lambda, mark for erasure
+ Type type = tree.sym.asType();
+ if (inClassWithinLambda() && !types.isSameType(types.erasure(type), type)) {
+ ltc.addSymbol(tree.sym, TYPE_VAR);
+ }
}
+
List<Frame> prevStack = frameStack;
try {
if (tree.sym.owner.kind == MTH) {
@@ -986,7 +1290,30 @@
}
private Name lambdaName() {
- return names.lambda.append(names.fromString("$" + lambdaCount++));
+ return names.lambda.append(names.fromString("" + lambdaCount++));
+ }
+
+ private Name serializedLambdaName(Symbol owner) {
+ StringBuilder buf = new StringBuilder();
+ buf.append(names.lambda);
+ String methodName = owner.name.toString();
+ if (methodName.equals("<clinit>"))
+ methodName = "static";
+ else if (methodName.equals("<init>"))
+ methodName = "new";
+ buf.append(methodName);
+ buf.append('$');
+ int methTypeHash = methodSig(owner.type).hashCode();
+ buf.append(Integer.toHexString(methTypeHash));
+ buf.append('$');
+ String temp = buf.toString();
+ Integer count = serializableLambdaCounts.get(temp);
+ if (count == null) {
+ count = 0;
+ }
+ buf.append(count++);
+ serializableLambdaCounts.put(temp, count);
+ return names.fromString(buf.toString());
}
/**
@@ -1008,17 +1335,20 @@
break;
}
JCClassDecl cdecl = (JCClassDecl)frameStack2.tail.head.tree;
- return makeSyntheticMethod(((JCVariableDecl)frameStack2.head.tree).sym.flags() & STATIC, names.empty, null, cdecl.sym);
+ return initSym(cdecl.sym,
+ ((JCVariableDecl)frameStack2.head.tree).sym.flags() & STATIC);
case BLOCK:
JCClassDecl cdecl2 = (JCClassDecl)frameStack2.tail.head.tree;
- return makeSyntheticMethod(((JCBlock)frameStack2.head.tree).flags & STATIC | Flags.BLOCK, names.empty, null, cdecl2.sym);
+ return initSym(cdecl2.sym,
+ ((JCBlock)frameStack2.head.tree).flags & STATIC);
case CLASSDEF:
return ((JCClassDecl)frameStack2.head.tree).sym;
case METHODDEF:
return ((JCMethodDecl)frameStack2.head.tree).sym;
case LAMBDA:
if (!skipLambda)
- return ((LambdaTranslationContext)contextMap.get(frameStack2.head.tree)).translatedSym;
+ return ((LambdaTranslationContext)contextMap
+ .get(frameStack2.head.tree)).translatedSym;
default:
frameStack2 = frameStack2.tail;
}
@@ -1027,7 +1357,33 @@
return null;
}
- private JCTree enclosingLambda() {
+ private Symbol initSym(ClassSymbol csym, long flags) {
+ boolean isStatic = (flags & STATIC) != 0;
+ if (isStatic) {
+ //static clinits are generated in Gen - so we need to fake them
+ Symbol clinit = clinits.get(csym);
+ if (clinit == null) {
+ clinit = makeSyntheticMethod(STATIC,
+ names.clinit,
+ new MethodType(List.<Type>nil(), syms.voidType, List.<Type>nil(), syms.methodClass),
+ csym);
+ clinits.put(csym, clinit);
+ }
+ return clinit;
+ } else {
+ //get the first constructor and treat it as the instance init sym
+ for (Symbol s : csym.members_field.getElementsByName(names.init)) {
+ return s;
+ }
+ }
+ Assert.error("init not found");
+ return null;
+ }
+
+ private JCTree directlyEnclosingLambda() {
+ if (frameStack.isEmpty()) {
+ return null;
+ }
List<Frame> frameStack2 = frameStack;
while (frameStack2.nonEmpty()) {
switch (frameStack2.head.tree.getTag()) {
@@ -1044,6 +1400,28 @@
return null;
}
+ private boolean inClassWithinLambda() {
+ if (frameStack.isEmpty()) {
+ return false;
+ }
+ List<Frame> frameStack2 = frameStack;
+ boolean classFound = false;
+ while (frameStack2.nonEmpty()) {
+ switch (frameStack2.head.tree.getTag()) {
+ case LAMBDA:
+ return classFound;
+ case CLASSDEF:
+ classFound = true;
+ frameStack2 = frameStack2.tail;
+ break;
+ default:
+ frameStack2 = frameStack2.tail;
+ }
+ }
+ // No lambda
+ return false;
+ }
+
/**
* Return the declaration corresponding to a symbol in the enclosing
* scope; the depth parameter is used to filter out symbols defined
@@ -1178,6 +1556,22 @@
this.depth = frameStack.size() - 1;
this.prev = context();
}
+
+ /** does this functional expression need to be created using alternate metafactory? */
+ boolean needsAltMetafactory() {
+ return (tree.targets.length() > 1 ||
+ isSerializable());
+ }
+
+ /** does this functional expression require serialization support? */
+ boolean isSerializable() {
+ for (Symbol target : tree.targets) {
+ if (types.asSuper(target.type, syms.serializableType.tsym) != null) {
+ return true;
+ }
+ }
+ return false;
+ }
}
/**
@@ -1203,6 +1597,9 @@
/** map from class symbols to translated synthetic parameters (for captured member access) */
Map<Symbol, Symbol> capturedThis = new LinkedHashMap<Symbol, Symbol>();
+ /** map from original to translated lambda locals */
+ Map<Symbol, Symbol> typeVars = new LinkedHashMap<Symbol, Symbol>();
+
/** the synthetic symbol for the method hoisting the translated lambda */
Symbol translatedSym;
@@ -1214,18 +1611,32 @@
if (frame.tree.hasTag(VARDEF)) {
self = ((JCVariableDecl)frame.tree).sym;
}
- this.translatedSym = makeSyntheticMethod(0, lambdaName(), null, owner.enclClass());
+ Name name = isSerializable() ? serializedLambdaName(owner) : lambdaName();
+ this.translatedSym = makeSyntheticMethod(0, name, null, owner.enclClass());
}
/**
* Translate a symbol of a given kind into something suitable for the
* synthetic lambda body
*/
- Symbol translate(String name, Symbol sym, LambdaSymbolKind skind) {
- if (skind == CAPTURED_THIS) {
- return sym; // self represented
- } else {
- return makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym);
+ Symbol translate(String name, final Symbol sym, LambdaSymbolKind skind) {
+ switch (skind) {
+ case CAPTURED_THIS:
+ return sym; // self represented
+ case TYPE_VAR:
+ // Just erase the type var
+ return new VarSymbol(sym.flags(), names.fromString(name),
+ types.erasure(sym.type), sym.owner);
+ case CAPTURED_VAR:
+ return new VarSymbol(SYNTHETIC | FINAL, names.fromString(name), types.erasure(sym.type), translatedSym) {
+ @Override
+ public Symbol baseSymbol() {
+ //keep mapping with original captured symbol
+ return sym;
+ }
+ };
+ default:
+ return makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym);
}
}
@@ -1249,6 +1660,10 @@
transMap = lambdaParams;
preferredName = sym.name.toString();
break;
+ case TYPE_VAR:
+ transMap = typeVars;
+ preferredName = sym.name.toString();
+ break;
default: throw new AssertionError();
}
if (!transMap.containsKey(sym)) {
@@ -1272,6 +1687,9 @@
case PARAM:
translationMap.putAll(lambdaParams);
break;
+ case TYPE_VAR:
+ translationMap.putAll(typeVars);
+ break;
default: throw new AssertionError();
}
}
@@ -1294,7 +1712,8 @@
// If instance access isn't needed, make it static
// Interface methods much be public default methods, otherwise make it private
- translatedSym.flags_field = SYNTHETIC | (needInstance? 0 : STATIC) | (inInterface? PUBLIC | DEFAULT : PRIVATE);
+ translatedSym.flags_field = SYNTHETIC | (needInstance? 0 : STATIC) |
+ (inInterface? PUBLIC | DEFAULT : PRIVATE);
//compute synthetic params
ListBuffer<JCVariableDecl> params = ListBuffer.lb();
@@ -1311,17 +1730,11 @@
syntheticParams = params.toList();
//prepend synthetic args to translated lambda method signature
- translatedSym.type = (MethodType) types.createMethodTypeWithParameters(
- (MethodType) generatedLambdaSig(),
+ translatedSym.type = types.createMethodTypeWithParameters(
+ generatedLambdaSig(),
TreeInfo.types(syntheticParams));
}
- Type enclosingType() {
- return owner.isStatic() ?
- Type.noType :
- owner.enclClass().type;
- }
-
Type generatedLambdaSig() {
return types.erasure(tree.descriptorType);
}
@@ -1366,12 +1779,27 @@
return tree.sym.owner == syms.arrayClass;
}
+ boolean isPrivateConstructor() {
+ //hack needed to workaround 292 bug (8005122)
+ //when 292 issue is fixed we should simply remove this
+ return tree.sym.name == names.init &&
+ (tree.sym.flags() & PRIVATE) != 0;
+ }
+
+ boolean receiverAccessible() {
+ //hack needed to workaround 292 bug (7087658)
+ //when 292 issue is fixed we should remove this and change the backend
+ //code to always generate a method handle to an accessible method
+ return tree.ownerAccessible;
+ }
+
/**
* Does this reference needs a bridge (i.e. var args need to be
* expanded or "super" is used)
*/
final boolean needsBridge() {
- return isSuper || needsVarArgsConversion() || isArrayOp();
+ return isSuper || needsVarArgsConversion() || isArrayOp() ||
+ isPrivateConstructor() || !receiverAccessible();
}
Type generatedRefSig() {
@@ -1389,6 +1817,60 @@
CAPTURED_VAR,
CAPTURED_THIS,
LOCAL_VAR,
- PARAM;
+ PARAM,
+ TYPE_VAR;
+ }
+
+ /**
+ * ****************************************************************
+ * Signature Generation
+ * ****************************************************************
+ */
+
+ private String methodSig(Type type) {
+ L2MSignatureGenerator sg = new L2MSignatureGenerator();
+ sg.assembleSig(type);
+ return sg.toString();
+ }
+
+ private String classSig(Type type) {
+ L2MSignatureGenerator sg = new L2MSignatureGenerator();
+ sg.assembleClassSig(type);
+ return sg.toString();
+ }
+
+ /**
+ * Signature Generation
+ */
+ private class L2MSignatureGenerator extends Types.SignatureGenerator {
+
+ /**
+ * An output buffer for type signatures.
+ */
+ StringBuilder sb = new StringBuilder();
+
+ L2MSignatureGenerator() {
+ super(types);
+ }
+
+ @Override
+ protected void append(char ch) {
+ sb.append(ch);
+ }
+
+ @Override
+ protected void append(byte[] ba) {
+ sb.append(new String(ba));
+ }
+
+ @Override
+ protected void append(Name name) {
+ sb.append(name.toString());
+ }
+
+ @Override
+ public String toString() {
+ return sb.toString();
+ }
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Mar 12 16:43:53 2013 -0700
@@ -163,6 +163,12 @@
*/
JCTree outermostMemberDef;
+ /** A map from local variable symbols to their translation (as per LambdaToMethod).
+ * This is required when a capturing local class is created from a lambda (in which
+ * case the captured symbols should be replaced with the translated lambda symbols).
+ */
+ Map<Symbol, Symbol> lambdaTranslationMap = null;
+
/** A navigator class for assembling a mapping from local class symbols
* to class definition trees.
* There is only one case; all other cases simply traverse down the tree.
@@ -206,10 +212,51 @@
Map<ClassSymbol,List<VarSymbol>> freevarCache;
/** A navigator class for collecting the free variables accessed
- * from a local class.
- * There is only one case; all other cases simply traverse down the tree.
+ * from a local class. There is only one case; all other cases simply
+ * traverse down the tree. This class doesn't deal with the specific
+ * of Lower - it's an abstract visitor that is meant to be reused in
+ * order to share the local variable capture logic.
*/
- class FreeVarCollector extends TreeScanner {
+ abstract class BasicFreeVarCollector extends TreeScanner {
+
+ /** Add all free variables of class c to fvs list
+ * unless they are already there.
+ */
+ abstract void addFreeVars(ClassSymbol c);
+
+ /** If tree refers to a variable in owner of local class, add it to
+ * free variables list.
+ */
+ public void visitIdent(JCIdent tree) {
+ visitSymbol(tree.sym);
+ }
+ // where
+ abstract void visitSymbol(Symbol _sym);
+
+ /** If tree refers to a class instance creation expression
+ * add all free variables of the freshly created class.
+ */
+ public void visitNewClass(JCNewClass tree) {
+ ClassSymbol c = (ClassSymbol)tree.constructor.owner;
+ addFreeVars(c);
+ super.visitNewClass(tree);
+ }
+
+ /** If tree refers to a superclass constructor call,
+ * add all free variables of the superclass.
+ */
+ public void visitApply(JCMethodInvocation tree) {
+ if (TreeInfo.name(tree.meth) == names._super) {
+ addFreeVars((ClassSymbol) TreeInfo.symbol(tree.meth).owner);
+ }
+ super.visitApply(tree);
+ }
+ }
+
+ /**
+ * Lower-specific subclass of {@code BasicFreeVarCollector}.
+ */
+ class FreeVarCollector extends BasicFreeVarCollector {
/** The owner of the local class.
*/
@@ -238,10 +285,8 @@
fvs = fvs.prepend(v);
}
- /** Add all free variables of class c to fvs list
- * unless they are already there.
- */
- private void addFreeVars(ClassSymbol c) {
+ @Override
+ void addFreeVars(ClassSymbol c) {
List<VarSymbol> fvs = freevarCache.get(c);
if (fvs != null) {
for (List<VarSymbol> l = fvs; l.nonEmpty(); l = l.tail) {
@@ -250,15 +295,8 @@
}
}
- /** If tree refers to a variable in owner of local class, add it to
- * free variables list.
- */
- public void visitIdent(JCIdent tree) {
- result = tree;
- visitSymbol(tree.sym);
- }
- // where
- private void visitSymbol(Symbol _sym) {
+ @Override
+ void visitSymbol(Symbol _sym) {
Symbol sym = _sym;
if (sym.kind == VAR || sym.kind == MTH) {
while (sym != null && sym.owner != owner)
@@ -281,7 +319,6 @@
*/
public void visitNewClass(JCNewClass tree) {
ClassSymbol c = (ClassSymbol)tree.constructor.owner;
- addFreeVars(c);
if (tree.encl == null &&
c.hasOuterInstance() &&
outerThisStack.head != null)
@@ -306,7 +343,6 @@
*/
public void visitApply(JCMethodInvocation tree) {
if (TreeInfo.name(tree.meth) == names._super) {
- addFreeVars((ClassSymbol) TreeInfo.symbol(tree.meth).owner);
Symbol constructor = TreeInfo.symbol(tree.meth);
ClassSymbol c = (ClassSymbol)constructor.owner;
if (c.hasOuterInstance() &&
@@ -1171,6 +1207,14 @@
accessBase(tree.pos(), sym), sym).setType(tree.type);
}
}
+ } else if (sym.owner.kind == MTH && lambdaTranslationMap != null) {
+ //sym is a local variable - check the lambda translation map to
+ //see if sym has been translated to something else in the current
+ //scope (by LambdaToMethod)
+ Symbol translatedSym = lambdaTranslationMap.get(sym);
+ if (translatedSym != null) {
+ tree = make.at(tree.pos).Ident(translatedSym);
+ }
}
}
return tree;
@@ -2725,10 +2769,30 @@
outerThisStack = prevOuterThisStack;
} else {
- super.visitMethodDef(tree);
+ Map<Symbol, Symbol> prevLambdaTranslationMap =
+ lambdaTranslationMap;
+ try {
+ lambdaTranslationMap = (tree.sym.flags() & SYNTHETIC) != 0 &&
+ tree.sym.name.startsWith(names.lambda) ?
+ makeTranslationMap(tree) : null;
+ super.visitMethodDef(tree);
+ } finally {
+ lambdaTranslationMap = prevLambdaTranslationMap;
+ }
}
result = tree;
}
+ //where
+ private Map<Symbol, Symbol> makeTranslationMap(JCMethodDecl tree) {
+ Map<Symbol, Symbol> translationMap = new HashMap<Symbol,Symbol>();
+ for (JCVariableDecl vd : tree.params) {
+ Symbol p = vd.sym;
+ if (p != p.baseSymbol()) {
+ translationMap.put(p.baseSymbol(), p);
+ }
+ }
+ return translationMap;
+ }
public void visitAnnotatedType(JCAnnotatedType tree) {
// No need to retain type annotations any longer.
@@ -3094,38 +3158,59 @@
}
public void visitAssignop(final JCAssignOp tree) {
+ JCTree lhsAccess = access(TreeInfo.skipParens(tree.lhs));
final boolean boxingReq = !tree.lhs.type.isPrimitive() &&
tree.operator.type.getReturnType().isPrimitive();
- // boxing required; need to rewrite as x = (unbox typeof x)(x op y);
- // or if x == (typeof x)z then z = (unbox typeof x)((typeof x)z op y)
- // (but without recomputing x)
- JCTree newTree = abstractLval(tree.lhs, new TreeBuilder() {
- public JCTree build(final JCTree lhs) {
- JCTree.Tag newTag = tree.getTag().noAssignOp();
- // Erasure (TransTypes) can change the type of
- // tree.lhs. However, we can still get the
- // unerased type of tree.lhs as it is stored
- // in tree.type in Attr.
- Symbol newOperator = rs.resolveBinaryOperator(tree.pos(),
- newTag,
- attrEnv,
- tree.type,
- tree.rhs.type);
- JCExpression expr = (JCExpression)lhs;
- if (expr.type != tree.type)
- expr = make.TypeCast(tree.type, expr);
- JCBinary opResult = make.Binary(newTag, expr, tree.rhs);
- opResult.operator = newOperator;
- opResult.type = newOperator.type.getReturnType();
- JCExpression newRhs = boxingReq ?
- make.TypeCast(types.unboxedType(tree.type),
- opResult) :
+ if (boxingReq || lhsAccess.hasTag(APPLY)) {
+ // boxing required; need to rewrite as x = (unbox typeof x)(x op y);
+ // or if x == (typeof x)z then z = (unbox typeof x)((typeof x)z op y)
+ // (but without recomputing x)
+ JCTree newTree = abstractLval(tree.lhs, new TreeBuilder() {
+ public JCTree build(final JCTree lhs) {
+ JCTree.Tag newTag = tree.getTag().noAssignOp();
+ // Erasure (TransTypes) can change the type of
+ // tree.lhs. However, we can still get the
+ // unerased type of tree.lhs as it is stored
+ // in tree.type in Attr.
+ Symbol newOperator = rs.resolveBinaryOperator(tree.pos(),
+ newTag,
+ attrEnv,
+ tree.type,
+ tree.rhs.type);
+ JCExpression expr = (JCExpression)lhs;
+ if (expr.type != tree.type)
+ expr = make.TypeCast(tree.type, expr);
+ JCBinary opResult = make.Binary(newTag, expr, tree.rhs);
+ opResult.operator = newOperator;
+ opResult.type = newOperator.type.getReturnType();
+ JCExpression newRhs = boxingReq ?
+ make.TypeCast(types.unboxedType(tree.type), opResult) :
opResult;
- return make.Assign((JCExpression)lhs, newRhs).setType(tree.type);
- }
- });
- result = translate(newTree);
+ return make.Assign((JCExpression)lhs, newRhs).setType(tree.type);
+ }
+ });
+ result = translate(newTree);
+ return;
+ }
+ tree.lhs = translate(tree.lhs, tree);
+ tree.rhs = translate(tree.rhs, tree.operator.type.getParameterTypes().tail.head);
+
+ // If translated left hand side is an Apply, we are
+ // seeing an access method invocation. In this case, append
+ // right hand side as last argument of the access method.
+ if (tree.lhs.hasTag(APPLY)) {
+ JCMethodInvocation app = (JCMethodInvocation)tree.lhs;
+ // if operation is a += on strings,
+ // make sure to convert argument to string
+ JCExpression rhs = (((OperatorSymbol)tree.operator).opcode == string_add)
+ ? makeString(tree.rhs)
+ : tree.rhs;
+ app.args = List.of(rhs).prependList(app.args);
+ result = app;
+ } else {
+ result = tree;
+ }
}
/** Lower a tree of the form e++ or e-- where e is an object type */
@@ -3722,8 +3807,16 @@
@Override
public void visitTry(JCTry tree) {
+ /* special case of try without catchers and with finally emtpy.
+ * Don't give it a try, translate only the body.
+ */
if (tree.resources.isEmpty()) {
- super.visitTry(tree);
+ if (tree.catchers.isEmpty() &&
+ tree.finalizer.getStatements().isEmpty()) {
+ result = translate(tree.body);
+ } else {
+ super.visitTry(tree);
+ }
} else {
result = makeTwrTry(tree);
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Tue Mar 12 16:43:53 2013 -0700
@@ -984,7 +984,7 @@
Type ret_t = desc_t.getReturnType();
Type ret_s = desc_s.getReturnType();
result &= ((tree.refPolyKind == PolyKind.STANDALONE)
- ? standaloneMostSpecific(ret_t, ret_s, tree.type, warn)
+ ? standaloneMostSpecific(ret_t, ret_s, tree.sym.type.getReturnType(), warn)
: polyMostSpecific(ret_t, ret_s, warn));
} else {
return;
@@ -1244,9 +1244,12 @@
boolean useVarargs,
boolean operator) {
if (sym.kind == ERR ||
- !sym.isInheritedIn(site.tsym, types) ||
- (useVarargs && (sym.flags() & VARARGS) == 0)) {
+ !sym.isInheritedIn(site.tsym, types)) {
return bestSoFar;
+ } else if (useVarargs && (sym.flags() & VARARGS) == 0) {
+ return bestSoFar.kind >= ERRONEOUS ?
+ new BadVarargsMethod((ResolveError)bestSoFar) :
+ bestSoFar;
}
Assert.check(sym.kind < AMBIGUOUS);
try {
@@ -2501,10 +2504,10 @@
//merge results
Pair<Symbol, ReferenceLookupHelper> res;
- if (unboundSym.kind != MTH) {
+ if (!lookupSuccess(unboundSym)) {
res = new Pair<Symbol, ReferenceLookupHelper>(boundSym, boundLookupHelper);
env.info.pendingResolutionPhase = boundEnv.info.pendingResolutionPhase;
- } else if (boundSym.kind == MTH) {
+ } else if (lookupSuccess(boundSym)) {
res = new Pair<Symbol, ReferenceLookupHelper>(ambiguityError(boundSym, unboundSym), boundLookupHelper);
env.info.pendingResolutionPhase = boundEnv.info.pendingResolutionPhase;
} else {
@@ -2514,6 +2517,10 @@
return res;
}
+ //private
+ boolean lookupSuccess(Symbol s) {
+ return s.kind == MTH || s.kind == AMBIGUOUS;
+ }
/**
* Helper for defining custom method-like lookup logic; a lookup helper
@@ -2654,22 +2661,12 @@
super(referenceTree, name, site, argtypes, typeargtypes, maxPhase);
}
- protected Symbol lookupReferenceInternal(Env<AttrContext> env, MethodResolutionPhase phase) {
+ @Override
+ final Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
return findMethod(env, site, name, argtypes, typeargtypes,
phase.isBoxingRequired(), phase.isVarargsRequired(), syms.operatorNames.contains(name));
}
- protected Symbol adjustLookupResult(Env<AttrContext> env, Symbol sym) {
- return !TreeInfo.isStaticSelector(referenceTree.expr, names) ||
- sym.kind != MTH ||
- sym.isStatic() ? sym : new StaticError(sym);
- }
-
- @Override
- final Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
- return adjustLookupResult(env, lookupReferenceInternal(env, phase));
- }
-
@Override
ReferenceLookupHelper unboundLookup() {
if (TreeInfo.isStaticSelector(referenceTree.expr, names) &&
@@ -2706,14 +2703,11 @@
UnboundMethodReferenceLookupHelper(JCMemberReference referenceTree, Name name, Type site,
List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
- super(referenceTree, name,
- site.isRaw() ? types.asSuper(argtypes.head, site.tsym) : site,
- argtypes.tail, typeargtypes, maxPhase);
- }
-
- @Override
- protected Symbol adjustLookupResult(Env<AttrContext> env, Symbol sym) {
- return sym.kind != MTH || !sym.isStatic() ? sym : new StaticError(sym);
+ super(referenceTree, name, site, argtypes.tail, typeargtypes, maxPhase);
+ Type asSuperSite = types.asSuper(argtypes.head, site.tsym);
+ if (site.isRaw() && !asSuperSite.isErroneous()) {
+ this.site = asSuperSite;
+ }
}
@Override
@@ -3516,6 +3510,31 @@
}
}
+ class BadVarargsMethod extends ResolveError {
+
+ ResolveError delegatedError;
+
+ BadVarargsMethod(ResolveError delegatedError) {
+ super(delegatedError.kind, "badVarargs");
+ this.delegatedError = delegatedError;
+ }
+
+ @Override
+ protected Symbol access(Name name, TypeSymbol location) {
+ return delegatedError.access(name, location);
+ }
+
+ @Override
+ public boolean exists() {
+ return true;
+ }
+
+ @Override
+ JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
+ return delegatedError.getDiagnostic(dkind, pos, location, site, name, argtypes, typeargtypes);
+ }
+ }
+
enum MethodResolutionPhase {
BASIC(false, false),
BOX(true, false),
@@ -3600,6 +3619,7 @@
* while inapplicable candidates contain further details about the
* reason why the method has been considered inapplicable.
*/
+ @SuppressWarnings("overrides")
class Candidate {
final MethodResolutionPhase step;
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Mar 12 16:43:53 2013 -0700
@@ -318,7 +318,9 @@
/** Add member to class unless it is synthetic.
*/
private void enterMember(ClassSymbol c, Symbol sym) {
- if ((sym.flags_field & (SYNTHETIC|BRIDGE)) != SYNTHETIC)
+ // Synthetic members are not entered -- reason lost to history (optimization?).
+ // Lambda methods must be entered because they may have inner classes (which reference them)
+ if ((sym.flags_field & (SYNTHETIC|BRIDGE)) != SYNTHETIC || sym.name.startsWith(names.lambda))
c.members_field.enter(sym);
}
@@ -1043,7 +1045,7 @@
haveParameterNameIndices = true;
for (int i = 0; i < numEntries; i++) {
int nameIndex = nextChar();
- int flags = nextInt();
+ int flags = nextChar();
parameterNameIndices[i] = nameIndex;
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Tue Mar 12 16:43:53 2013 -0700
@@ -39,6 +39,9 @@
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Attribute.RetentionPolicy;
import com.sun.tools.javac.code.Attribute.TypeCompound;
+import static com.sun.tools.javac.code.BoundKind.EXTENDS;
+import static com.sun.tools.javac.code.BoundKind.SUPER;
+import static com.sun.tools.javac.code.BoundKind.UNBOUND;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Type.*;
import com.sun.tools.javac.code.Types.UniqueType;
@@ -126,10 +129,6 @@
*/
ByteBuffer poolbuf = new ByteBuffer(POOL_BUF_SIZE);
- /** An output buffer for type signatures.
- */
- ByteBuffer sigbuf = new ByteBuffer();
-
/** The constant pool.
*/
Pool pool;
@@ -158,6 +157,9 @@
/** Access to files. */
private final JavaFileManager fileManager;
+ /** Sole signature generator */
+ private final CWSignatureGenerator signatureGen;
+
/** The tags and constants used in compressed stackmap. */
static final int SAME_FRAME_SIZE = 64;
static final int SAME_LOCALS_1_STACK_ITEM_EXTENDED = 247;
@@ -185,6 +187,7 @@
source = Source.instance(context);
types = Types.instance(context);
fileManager = context.get(JavaFileManager.class);
+ signatureGen = new CWSignatureGenerator(types);
verbose = options.isSet(VERBOSE);
scramble = options.isSet("-scramble");
@@ -270,172 +273,81 @@
buf.elems[adr+3] = (byte)((x ) & 0xFF);
}
-/******************************************************************
- * Signature Generation
- ******************************************************************/
-
- /** Assemble signature of given type in string buffer.
+ /**
+ * Signature Generation
*/
- void assembleSig(Type type) {
- type = type.unannotatedType();
- switch (type.getTag()) {
- case BYTE:
- sigbuf.appendByte('B');
- break;
- case SHORT:
- sigbuf.appendByte('S');
- break;
- case CHAR:
- sigbuf.appendByte('C');
- break;
- case INT:
- sigbuf.appendByte('I');
- break;
- case LONG:
- sigbuf.appendByte('J');
- break;
- case FLOAT:
- sigbuf.appendByte('F');
- break;
- case DOUBLE:
- sigbuf.appendByte('D');
- break;
- case BOOLEAN:
- sigbuf.appendByte('Z');
- break;
- case VOID:
- sigbuf.appendByte('V');
- break;
- case CLASS:
- sigbuf.appendByte('L');
- assembleClassSig(type);
- sigbuf.appendByte(';');
- break;
- case ARRAY:
- ArrayType at = (ArrayType)type;
- sigbuf.appendByte('[');
- assembleSig(at.elemtype);
- break;
- case METHOD:
- MethodType mt = (MethodType)type;
- sigbuf.appendByte('(');
- assembleSig(mt.argtypes);
- sigbuf.appendByte(')');
- assembleSig(mt.restype);
- if (hasTypeVar(mt.thrown)) {
- for (List<Type> l = mt.thrown; l.nonEmpty(); l = l.tail) {
- sigbuf.appendByte('^');
- assembleSig(l.head);
- }
+ private class CWSignatureGenerator extends Types.SignatureGenerator {
+
+ /**
+ * An output buffer for type signatures.
+ */
+ ByteBuffer sigbuf = new ByteBuffer();
+
+ CWSignatureGenerator(Types types) {
+ super(types);
+ }
+
+ /**
+ * Assemble signature of given type in string buffer.
+ * Check for uninitialized types before calling the general case.
+ */
+ @Override
+ public void assembleSig(Type type) {
+ type = type.unannotatedType();
+ switch (type.getTag()) {
+ case UNINITIALIZED_THIS:
+ case UNINITIALIZED_OBJECT:
+ // we don't yet have a spec for uninitialized types in the
+ // local variable table
+ assembleSig(types.erasure(((UninitializedType)type).qtype));
+ break;
+ default:
+ super.assembleSig(type);
}
- break;
- case WILDCARD: {
- WildcardType ta = (WildcardType) type;
- switch (ta.kind) {
- case SUPER:
- sigbuf.appendByte('-');
- assembleSig(ta.type);
- break;
- case EXTENDS:
- sigbuf.appendByte('+');
- assembleSig(ta.type);
- break;
- case UNBOUND:
- sigbuf.appendByte('*');
- break;
- default:
- throw new AssertionError(ta.kind);
- }
- break;
+ }
+
+ @Override
+ protected void append(char ch) {
+ sigbuf.appendByte(ch);
+ }
+
+ @Override
+ protected void append(byte[] ba) {
+ sigbuf.appendBytes(ba);
+ }
+
+ @Override
+ protected void append(Name name) {
+ sigbuf.appendName(name);
}
- case TYPEVAR:
- sigbuf.appendByte('T');
- sigbuf.appendName(type.tsym.name);
- sigbuf.appendByte(';');
- break;
- case FORALL:
- ForAll ft = (ForAll)type;
- assembleParamsSig(ft.tvars);
- assembleSig(ft.qtype);
- break;
- case UNINITIALIZED_THIS:
- case UNINITIALIZED_OBJECT:
- // we don't yet have a spec for uninitialized types in the
- // local variable table
- assembleSig(types.erasure(((UninitializedType)type).qtype));
- break;
- default:
- throw new AssertionError("typeSig " + type.getTag());
+
+ @Override
+ protected void classReference(ClassSymbol c) {
+ enterInner(c);
+ }
+
+ private void reset() {
+ sigbuf.reset();
+ }
+
+ private Name toName() {
+ return sigbuf.toName(names);
+ }
+
+ private boolean isEmpty() {
+ return sigbuf.length == 0;
}
}
- boolean hasTypeVar(List<Type> l) {
- while (l.nonEmpty()) {
- if (l.head.hasTag(TYPEVAR)) return true;
- l = l.tail;
- }
- return false;
- }
-
- void assembleClassSig(Type type) {
- type = type.unannotatedType();
- ClassType ct = (ClassType)type;
- ClassSymbol c = (ClassSymbol)ct.tsym;
- enterInner(c);
- Type outer = ct.getEnclosingType();
- if (outer.allparams().nonEmpty()) {
- boolean rawOuter =
- c.owner.kind == MTH || // either a local class
- c.name == names.empty; // or anonymous
- assembleClassSig(rawOuter
- ? types.erasure(outer)
- : outer);
- sigbuf.appendByte('.');
- Assert.check(c.flatname.startsWith(c.owner.enclClass().flatname));
- sigbuf.appendName(rawOuter
- ? c.flatname.subName(c.owner.enclClass().flatname.getByteLength()+1,c.flatname.getByteLength())
- : c.name);
- } else {
- sigbuf.appendBytes(externalize(c.flatname));
- }
- if (ct.getTypeArguments().nonEmpty()) {
- sigbuf.appendByte('<');
- assembleSig(ct.getTypeArguments());
- sigbuf.appendByte('>');
- }
- }
-
-
- void assembleSig(List<Type> types) {
- for (List<Type> ts = types; ts.nonEmpty(); ts = ts.tail)
- assembleSig(ts.head);
- }
-
- void assembleParamsSig(List<Type> typarams) {
- sigbuf.appendByte('<');
- for (List<Type> ts = typarams; ts.nonEmpty(); ts = ts.tail) {
- TypeVar tvar = (TypeVar)ts.head;
- sigbuf.appendName(tvar.tsym.name);
- List<Type> bounds = types.getBounds(tvar);
- if ((bounds.head.tsym.flags() & INTERFACE) != 0) {
- sigbuf.appendByte(':');
- }
- for (List<Type> l = bounds; l.nonEmpty(); l = l.tail) {
- sigbuf.appendByte(':');
- assembleSig(l.head);
- }
- }
- sigbuf.appendByte('>');
- }
-
- /** Return signature of given type
+ /**
+ * Return signature of given type
*/
Name typeSig(Type type) {
- Assert.check(sigbuf.length == 0);
+ Assert.check(signatureGen.isEmpty());
//- System.out.println(" ? " + type);
- assembleSig(type);
- Name n = sigbuf.toName(names);
- sigbuf.reset();
+ signatureGen.assembleSig(type);
+ Name n = signatureGen.toName();
+ signatureGen.reset();
//- System.out.println(" " + n);
return n;
}
@@ -711,7 +623,7 @@
(flags & (SYNTHETIC|BRIDGE)) != SYNTHETIC &&
(flags & ANONCONSTR) == 0 &&
(!types.isSameType(sym.type, sym.erasure(types)) ||
- hasTypeVar(sym.type.getThrownTypes()))) {
+ signatureGen.hasTypeVar(sym.type.getThrownTypes()))) {
// note that a local class with captured variables
// will get a signature attribute
int alenIdx = writeAttr(names.Signature);
@@ -739,7 +651,7 @@
((int) s.flags() & (FINAL | SYNTHETIC | MANDATED)) |
((int) m.flags() & SYNTHETIC);
databuf.appendChar(pool.put(s.name));
- databuf.appendInt(flags);
+ databuf.appendChar(flags);
}
// Now write the real parameters
for (VarSymbol s : m.params) {
@@ -747,7 +659,7 @@
((int) s.flags() & (FINAL | SYNTHETIC | MANDATED)) |
((int) m.flags() & SYNTHETIC);
databuf.appendChar(pool.put(s.name));
- databuf.appendInt(flags);
+ databuf.appendChar(flags);
}
endAttr(attrIndex);
return 1;
@@ -1730,7 +1642,7 @@
Assert.check((c.flags() & COMPOUND) == 0);
databuf.reset();
poolbuf.reset();
- sigbuf.reset();
+ signatureGen.reset();
pool = c.pool;
innerClasses = null;
innerClassesQueue = null;
@@ -1791,12 +1703,12 @@
if (sigReq) {
Assert.check(source.allowGenerics());
int alenIdx = writeAttr(names.Signature);
- if (typarams.length() != 0) assembleParamsSig(typarams);
- assembleSig(supertype);
+ if (typarams.length() != 0) signatureGen.assembleParamsSig(typarams);
+ signatureGen.assembleSig(supertype);
for (List<Type> l = interfaces; l.nonEmpty(); l = l.tail)
- assembleSig(l.head);
- databuf.appendChar(pool.put(sigbuf.toName(names)));
- sigbuf.reset();
+ signatureGen.assembleSig(l.head);
+ databuf.appendChar(pool.put(signatureGen.toName()));
+ signatureGen.reset();
endAttr(alenIdx);
acount++;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java Tue Mar 12 16:43:53 2013 -0700
@@ -293,6 +293,7 @@
expectedKind = Kinds.MTH;
break;
case ClassFile.REF_invokeStatic:
+ interfaceOwner = true;
staticOk = true;
case ClassFile.REF_invokeVirtual:
case ClassFile.REF_invokeSpecial:
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Tue Mar 12 16:43:53 2013 -0700
@@ -2867,7 +2867,7 @@
* | Identifier "=" AnnotationValue
*/
JCExpression annotationFieldValue() {
- if (token.kind == IDENTIFIER) {
+ if (LAX_IDENTIFIER.accepts(token.kind)) {
mode = EXPR;
JCExpression t1 = term1();
if (t1.hasTag(IDENT) && token.kind == EQ) {
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Mar 12 16:43:53 2013 -0700
@@ -728,6 +728,9 @@
compiler.misc.incompatible.arg.types.in.lambda=\
incompatible parameter types in lambda expression
+compiler.misc.incompatible.arg.types.in.mref=\
+ incompatible parameter types in method reference
+
compiler.err.new.not.allowed.in.annotation=\
''new'' not allowed in an annotation
@@ -763,6 +766,10 @@
compiler.err.not.def.public.cant.access=\
{0} is not public in {1}; cannot be accessed from outside package
+# 0: symbol, 1: symbol
+compiler.misc.not.def.public.cant.access=\
+ {0} is not public in {1}; cannot be accessed from outside package
+
# 0: name
compiler.err.not.loop.label=\
not a loop label: {0}
@@ -1898,6 +1905,10 @@
compiler.misc.non-static.cant.be.ref=\
non-static {0} {1} cannot be referenced from a static context
+# 0: symbol kind, 1: symbol
+compiler.misc.static.method.in.unbound.lookup=\
+ static {0} {1} found in unbound lookup
+
## Both arguments ({0}, {1}) are "kindname"s. {0} is a comma-separated list
## of kindnames (the list should be identical to that provided in source.
compiler.err.unexpected.type=\
@@ -2066,6 +2077,10 @@
{0}\n\
overridden method does not throw {1}
+# 0: symbol
+compiler.warn.override.equals.but.not.hashcode=\
+ Class {0} overrides equals, but neither it nor any superclass overrides hashCode method
+
## The following are all possible strings for the first argument ({0}) of the
## above strings.
# 0: symbol, 1: symbol, 2: symbol, 3: symbol
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java Tue Mar 12 16:43:53 2013 -0700
@@ -1887,6 +1887,7 @@
public Symbol sym;
public Type varargsElement;
public PolyKind refPolyKind;
+ public boolean ownerAccessible;
/**
* Javac-dependent classification for member references, based
--- a/langtools/src/share/classes/com/sun/tools/javac/util/ArrayUtils.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/ArrayUtils.java Tue Mar 12 16:43:53 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
@@ -84,4 +84,18 @@
return result;
}
}
+
+ public static <T> T[] concat(T[] anArr, T[] anotherArr) {
+ int newLength = anArr.length + anotherArr.length;
+ @SuppressWarnings("unchecked")
+ T[] result = (T[]) Array.newInstance(anArr.getClass().getComponentType(), newLength);
+ System.arraycopy(anArr, 0, result, 0, anArr.length);
+ System.arraycopy(anotherArr, 0, result, anArr.length, anotherArr.length);
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T> T[] concatOpen(T[] anArr, T... anotherArr) {
+ return concat(anArr, anotherArr);
+ }
}
--- a/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java Tue Mar 12 16:43:53 2013 -0700
@@ -347,7 +347,8 @@
MANDATORY,
RESOLVE_ERROR,
SYNTAX,
- RECOVERABLE
+ RECOVERABLE,
+ NON_DEFERRABLE,
}
private final DiagnosticType type;
@@ -484,6 +485,10 @@
return getIntEndPosition();
}
+ public DiagnosticPosition getDiagnosticPosition() {
+ return position;
+ }
+
/**
* Get the line number within the source referred to by this diagnostic.
* @return the line number within the source referred to by this diagnostic
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java Tue Mar 12 16:43:53 2013 -0700
@@ -136,10 +136,12 @@
}
public void report(JCDiagnostic diag) {
- if (filter == null || filter.accepts(diag))
+ if (!diag.isFlagSet(JCDiagnostic.DiagnosticFlag.NON_DEFERRABLE) &&
+ (filter == null || filter.accepts(diag))) {
deferred.add(diag);
- else
+ } else {
prev.report(diag);
+ }
}
public Queue<JCDiagnostic> getDiagnostics() {
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Names.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Names.java Tue Mar 12 16:43:53 2013 -0700
@@ -73,6 +73,7 @@
public final Name clone;
public final Name close;
public final Name compareTo;
+ public final Name deserializeLambda;
public final Name desiredAssertionStatus;
public final Name equals;
public final Name error;
@@ -174,6 +175,7 @@
//lambda-related
public final Name lambda;
public final Name metaFactory;
+ public final Name altMetaFactory;
public final Name.Table table;
@@ -207,6 +209,7 @@
clone = fromString("clone");
close = fromString("close");
compareTo = fromString("compareTo");
+ deserializeLambda = fromString("$deserializeLambda$");
desiredAssertionStatus = fromString("desiredAssertionStatus");
equals = fromString("equals");
error = fromString("<error>");
@@ -306,8 +309,9 @@
package_info = fromString("package-info");
//lambda-related
- lambda = fromString("lambda");
+ lambda = fromString("lambda$");
metaFactory = fromString("metaFactory");
+ altMetaFactory = fromString("altMetaFactory");
}
protected Name.Table createTable(Options options) {
--- a/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Tue Mar 12 16:43:53 2013 -0700
@@ -379,8 +379,8 @@
indent(+1);
- if (options.showInternalSignatures)
- println("Signature: " + getValue(f.descriptor));
+ if (options.showDescriptors)
+ println("descriptor: " + getValue(f.descriptor));
if (options.verbose && !options.compat)
writeList("flags: ", flags.getFieldFlags(), "\n");
@@ -475,8 +475,8 @@
indent(+1);
- if (options.showInternalSignatures) {
- println("Signature: " + getValue(m.descriptor));
+ if (options.showDescriptors) {
+ println("descriptor: " + getValue(m.descriptor));
}
if (options.verbose && !options.compat) {
@@ -520,7 +520,7 @@
setPendingNewline(
options.showDisassembled ||
options.showAllAttrs ||
- options.showInternalSignatures ||
+ options.showDescriptors ||
options.showLineAndLocalVariableTables ||
options.verbose);
}
--- a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Tue Mar 12 16:43:53 2013 -0700
@@ -140,6 +140,7 @@
new Option(false, "-v", "-verbose", "-all") {
void process(JavapTask task, String opt, String arg) {
task.options.verbose = true;
+ task.options.showDescriptors = true;
task.options.showFlags = true;
task.options.showAllAttrs = true;
}
@@ -190,7 +191,7 @@
new Option(false, "-s") {
void process(JavapTask task, String opt, String arg) {
- task.options.showInternalSignatures = true;
+ task.options.showDescriptors = true;
}
},
--- a/langtools/src/share/classes/com/sun/tools/javap/Options.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javap/Options.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -81,7 +81,7 @@
public Set<String> accessOptions = new HashSet<String>();
public Set<InstructionDetailWriter.Kind> details = EnumSet.noneOf(InstructionDetailWriter.Kind.class);
public boolean showDisassembled;
- public boolean showInternalSignatures;
+ public boolean showDescriptors;
public boolean showAllAttrs;
public boolean showConstants;
public boolean sysInfo;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/jdeps/Analyzer.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,239 @@
+/*
+ * 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.
+ */
+package com.sun.tools.jdeps;
+
+import com.sun.tools.classfile.Dependency.Location;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+/**
+ * Dependency Analyzer.
+ */
+public class Analyzer {
+ /**
+ * Type of the dependency analysis. Appropriate level of data
+ * will be stored.
+ */
+ public enum Type {
+ SUMMARY,
+ PACKAGE,
+ CLASS,
+ VERBOSE
+ };
+
+ private final Type type;
+ private final List<ArchiveDeps> results = new ArrayList<ArchiveDeps>();
+ private final Map<String, Archive> map = new HashMap<String, Archive>();
+ private final Archive NOT_FOUND
+ = new Archive(JdepsTask.getMessage("artifact.not.found"));
+
+ /**
+ * Constructs an Analyzer instance.
+ *
+ * @param type Type of the dependency analysis
+ */
+ public Analyzer(Type type) {
+ this.type = type;
+ }
+
+ /**
+ * Performs the dependency analysis on the given archives.
+ */
+ public void run(List<Archive> archives) {
+ for (Archive archive : archives) {
+ ArchiveDeps deps;
+ if (type == Type.CLASS || type == Type.VERBOSE) {
+ deps = new ClassVisitor(archive);
+ } else {
+ deps = new PackageVisitor(archive);
+ }
+ archive.visit(deps);
+ results.add(deps);
+ }
+
+ // set the required dependencies
+ for (ArchiveDeps result: results) {
+ for (Set<String> set : result.deps.values()) {
+ for (String target : set) {
+ Archive source = getArchive(target);
+ if (result.archive != source) {
+ if (!result.requiredArchives.contains(source)) {
+ result.requiredArchives.add(source);
+ }
+ // either a profile name or the archive name
+ String tname = getProfile(target);
+ if (tname.isEmpty()){
+ tname = source.toString();
+ }
+ if (!result.targetNames.contains(tname)) {
+ result.targetNames.add(tname);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public interface Visitor {
+ /**
+ * Visits a recorded dependency from origin to target which can be
+ * a fully-qualified classname, a package name, a profile or
+ * archive name depending on the Analyzer's type.
+ */
+ void visit(String origin, String target);
+ /**
+ * Visits the source archive to its destination archive of
+ * a recorded dependency.
+ */
+ void visit(Archive source, Archive dest);
+ }
+
+ public void visitSummary(Visitor v) {
+ for (ArchiveDeps r : results) {
+ for (Archive a : r.requiredArchives) {
+ v.visit(r.archive, a);
+ }
+ for (String name : r.targetNames) {
+ v.visit(r.archive.getFileName(), name);
+ }
+ }
+ }
+
+ public void visit(Visitor v) {
+ for (ArchiveDeps r: results) {
+ for (Archive a : r.requiredArchives) {
+ v.visit(r.archive, a);
+ }
+ for (String origin : r.deps.keySet()) {
+ for (String target : r.deps.get(origin)) {
+ // filter intra-dependency unless in verbose mode
+ if (type == Type.VERBOSE || getArchive(origin) != getArchive(target)) {
+ v.visit(origin, target);
+ }
+ }
+ }
+ }
+ }
+
+ public Archive getArchive(String name) {
+ return map.containsKey(name) ? map.get(name) : NOT_FOUND;
+ }
+
+ public String getArchiveName(String name) {
+ return getArchive(name).getFileName();
+ }
+
+ public String getProfile(String name) {
+ String pn = type == Type.CLASS ? packageOf(name) : name;
+ Archive source = map.get(name);
+ if (source != null && PlatformClassPath.contains(source)) {
+ String profile = PlatformClassPath.getProfileName(pn);
+ if (profile.isEmpty()) {
+ return "JDK internal API (" + source.getFileName() + ")";
+ }
+ return profile;
+ }
+ return "";
+ }
+
+ private abstract class ArchiveDeps implements Archive.Visitor {
+ final Archive archive;
+ final Set<Archive> requiredArchives;
+ final SortedSet<String> targetNames;
+ final SortedMap<String, SortedSet<String>> deps;
+
+ ArchiveDeps(Archive archive) {
+ this.archive = archive;
+ this.requiredArchives = new HashSet<Archive>();
+ this.targetNames = new TreeSet<String>();
+ this.deps = new TreeMap<String, SortedSet<String>>();
+ }
+
+ void add(String loc) {
+ Archive a = map.get(loc);
+ if (a == null) {
+ map.put(loc, archive);
+ } else if (a != archive) {
+ // duplicated class warning?
+ }
+ }
+
+ void add(String origin, String target) {
+ SortedSet<String> set = deps.get(origin);
+ if (set == null) {
+ set = new TreeSet<String>();
+ deps.put(origin, set);
+ }
+ if (!set.contains(target)) {
+ set.add(target);
+ }
+ }
+
+ public abstract void visit(Location o, Location t);
+ }
+
+ private class ClassVisitor extends ArchiveDeps {
+ ClassVisitor(Archive archive) {
+ super(archive);
+ }
+ public void visit(Location l) {
+ add(l.getClassName());
+ }
+ public void visit(Location o, Location t) {
+ add(o.getClassName(), t.getClassName());
+ }
+ }
+
+ private class PackageVisitor extends ArchiveDeps {
+ PackageVisitor(Archive archive) {
+ super(archive);
+ }
+ public void visit(Location o, Location t) {
+ add(packageOf(o), packageOf(t));
+ }
+
+ public void visit(Location l) {
+ add(packageOf(l));
+ }
+
+ private String packageOf(Location loc) {
+ String pkg = loc.getPackageName();
+ return pkg.isEmpty() ? "<unnamed>" : pkg;
+ }
+ }
+
+ private static String packageOf(String cn) {
+ int i = cn.lastIndexOf('.');
+ return (i > 0) ? cn.substring(0, i) : "<unnamed>";
+ }
+}
--- a/langtools/src/share/classes/com/sun/tools/jdeps/Archive.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/jdeps/Archive.java Tue Mar 12 16:43:53 2013 -0700
@@ -24,43 +24,32 @@
*/
package com.sun.tools.jdeps;
-import com.sun.tools.classfile.Dependency;
import com.sun.tools.classfile.Dependency.Location;
import java.io.File;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.SortedMap;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.TreeSet;
/**
* Represents the source of the class files.
*/
public class Archive {
- private static Map<String,Archive> archiveForClass = new HashMap<String,Archive>();
- public static Archive find(Location loc) {
- return archiveForClass.get(loc.getName());
- }
-
private final File file;
private final String filename;
- private final DependencyRecorder recorder;
private final ClassFileReader reader;
+ private final Map<Location, Set<Location>> deps
+ = new HashMap<Location, Set<Location>>();
+
public Archive(String name) {
this.file = null;
this.filename = name;
- this.recorder = new DependencyRecorder();
this.reader = null;
}
public Archive(File f, ClassFileReader reader) {
this.file = f;
this.filename = f.getName();
- this.recorder = new DependencyRecorder();
this.reader = reader;
}
@@ -72,102 +61,37 @@
return filename;
}
- public void addClass(String classFileName) {
- Archive a = archiveForClass.get(classFileName);
- assert(a == null || a == this); // ## issue warning?
- if (!archiveForClass.containsKey(classFileName)) {
- archiveForClass.put(classFileName, this);
+ public void addClass(Location origin) {
+ Set<Location> set = deps.get(origin);
+ if (set == null) {
+ set = new HashSet<Location>();
+ deps.put(origin, set);
}
}
-
- public void addDependency(Dependency d) {
- recorder.addDependency(d);
+ public void addClass(Location origin, Location target) {
+ Set<Location> set = deps.get(origin);
+ if (set == null) {
+ set = new HashSet<Location>();
+ deps.put(origin, set);
+ }
+ set.add(target);
}
- /**
- * Returns a sorted map of a class to its dependencies.
- */
- public SortedMap<Location, SortedSet<Location>> getDependencies() {
- DependencyRecorder.Filter filter = new DependencyRecorder.Filter() {
- public boolean accept(Location origin, Location target) {
- return (archiveForClass.get(origin.getName()) !=
- archiveForClass.get(target.getName()));
- }};
-
- SortedMap<Location, SortedSet<Location>> result =
- new TreeMap<Location, SortedSet<Location>>(locationComparator);
- for (Map.Entry<Location, Set<Location>> e : recorder.dependencies().entrySet()) {
- Location o = e.getKey();
- for (Location t : e.getValue()) {
- if (filter.accept(o, t)) {
- SortedSet<Location> odeps = result.get(o);
- if (odeps == null) {
- odeps = new TreeSet<Location>(locationComparator);
- result.put(o, odeps);
- }
- odeps.add(t);
- }
+ public void visit(Visitor v) {
+ for (Map.Entry<Location,Set<Location>> e: deps.entrySet()) {
+ v.visit(e.getKey());
+ for (Location target : e.getValue()) {
+ v.visit(e.getKey(), target);
}
}
- return result;
- }
-
- /**
- * Returns the set of archives this archive requires.
- */
- public Set<Archive> getRequiredArchives() {
- SortedSet<Archive> deps = new TreeSet<Archive>(new Comparator<Archive>() {
- public int compare(Archive a1, Archive a2) {
- return a1.toString().compareTo(a2.toString());
- }
- });
-
- for (Map.Entry<Location, Set<Location>> e : recorder.dependencies().entrySet()) {
- Location o = e.getKey();
- Archive origin = Archive.find(o);
- for (Location t : e.getValue()) {
- Archive target = Archive.find(t);
- assert(origin != null && target != null);
- if (origin != target) {
- if (!deps.contains(target)) {
- deps.add(target);
- }
- }
- }
- }
- return deps;
}
public String toString() {
return file != null ? file.getPath() : filename;
}
- private static class DependencyRecorder {
- static interface Filter {
- boolean accept(Location origin, Location target);
- }
-
- public void addDependency(Dependency d) {
- Set<Location> odeps = map.get(d.getOrigin());
- if (odeps == null) {
- odeps = new HashSet<Location>();
- map.put(d.getOrigin(), odeps);
- }
- odeps.add(d.getTarget());
- }
-
- public Map<Location, Set<Location>> dependencies() {
- return map;
- }
-
- private final Map<Location, Set<Location>> map =
- new HashMap<Location, Set<Location>>();
+ interface Visitor {
+ void visit(Location loc);
+ void visit(Location origin, Location target);
}
-
- private static Comparator<Location> locationComparator =
- new Comparator<Location>() {
- public int compare(Location o1, Location o2) {
- return o1.toString().compareTo(o2.toString());
- }
- };
}
--- a/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java Tue Mar 12 16:43:53 2013 -0700
@@ -29,7 +29,6 @@
import com.sun.tools.classfile.Dependencies;
import com.sun.tools.classfile.Dependencies.ClassFileError;
import com.sun.tools.classfile.Dependency;
-import com.sun.tools.classfile.Dependency.Location;
import java.io.*;
import java.text.MessageFormat;
import java.util.*;
@@ -42,7 +41,7 @@
class BadArgs extends Exception {
static final long serialVersionUID = 8765093759964640721L;
BadArgs(String key, Object... args) {
- super(JdepsTask.this.getMessage(key, args));
+ super(JdepsTask.getMessage(key, args));
this.key = key;
this.args = args;
}
@@ -105,25 +104,22 @@
new Option(false, "-s", "--summary") {
void process(JdepsTask task, String opt, String arg) {
task.options.showSummary = true;
- task.options.verbose = Options.Verbose.SUMMARY;
+ task.options.verbose = Analyzer.Type.SUMMARY;
}
},
new Option(false, "-v", "--verbose") {
void process(JdepsTask task, String opt, String arg) {
- task.options.verbose = Options.Verbose.VERBOSE;
+ task.options.verbose = Analyzer.Type.VERBOSE;
}
},
new Option(true, "-V", "--verbose-level") {
void process(JdepsTask task, String opt, String arg) throws BadArgs {
- switch (arg) {
- case "package":
- task.options.verbose = Options.Verbose.PACKAGE;
- break;
- case "class":
- task.options.verbose = Options.Verbose.CLASS;
- break;
- default:
- throw task.new BadArgs("err.invalid.arg.for.option", opt);
+ if ("package".equals(arg)) {
+ task.options.verbose = Analyzer.Type.PACKAGE;
+ } else if ("class".equals(arg)) {
+ task.options.verbose = Analyzer.Type.CLASS;
+ } else {
+ throw task.new BadArgs("err.invalid.arg.for.option", opt);
}
}
},
@@ -171,7 +167,6 @@
task.options.fullVersion = true;
}
},
-
};
private static final String PROGNAME = "jdeps";
@@ -216,7 +211,7 @@
showHelp();
return EXIT_CMDERR;
}
- if (options.showSummary && options.verbose != Options.Verbose.SUMMARY) {
+ if (options.showSummary && options.verbose != Analyzer.Type.SUMMARY) {
showHelp();
return EXIT_CMDERR;
}
@@ -236,26 +231,14 @@
}
private final List<Archive> sourceLocations = new ArrayList<Archive>();
- private final Archive NOT_FOUND = new Archive(getMessage("artifact.not.found"));
private boolean run() throws IOException {
findDependencies();
- switch (options.verbose) {
- case VERBOSE:
- case CLASS:
- printClassDeps(log);
- break;
- case PACKAGE:
- printPackageDeps(log);
- break;
- case SUMMARY:
- for (Archive origin : sourceLocations) {
- for (Archive target : origin.getRequiredArchives()) {
- log.format("%-30s -> %s%n", origin, target);
- }
- }
- break;
- default:
- throw new InternalError("Should not reach here");
+ Analyzer analyzer = new Analyzer(options.verbose);
+ analyzer.run(sourceLocations);
+ if (options.verbose == Analyzer.Type.SUMMARY) {
+ printSummary(log, analyzer);
+ } else {
+ printDependencies(log, analyzer);
}
return true;
}
@@ -331,7 +314,7 @@
} catch (ConstantPoolException e) {
throw new ClassFileError(e);
}
- a.addClass(classFileName);
+
if (!doneClasses.contains(classFileName)) {
doneClasses.add(classFileName);
}
@@ -341,7 +324,7 @@
if (!doneClasses.contains(cn) && !deque.contains(cn)) {
deque.add(cn);
}
- a.addDependency(d);
+ a.addClass(d.getOrigin(), d.getTarget());
}
}
}
@@ -367,19 +350,20 @@
} catch (ConstantPoolException e) {
throw new ClassFileError(e);
}
- a.addClass(classFileName);
if (!doneClasses.contains(classFileName)) {
// if name is a fully-qualified class name specified
// from command-line, this class might already be parsed
doneClasses.add(classFileName);
- if (depth > 0) {
- for (Dependency d : finder.findDependencies(cf)) {
- if (filter.accepts(d)) {
- String cn = d.getTarget().getName();
- if (!doneClasses.contains(cn) && !deque.contains(cn)) {
- deque.add(cn);
- }
- a.addDependency(d);
+ for (Dependency d : finder.findDependencies(cf)) {
+ if (depth == 0) {
+ // ignore the dependency
+ a.addClass(d.getOrigin());
+ break;
+ } else if (filter.accepts(d)) {
+ a.addClass(d.getOrigin(), d.getTarget());
+ String cn = d.getTarget().getName();
+ if (!doneClasses.contains(cn) && !deque.contains(cn)) {
+ deque.add(cn);
}
}
}
@@ -388,7 +372,7 @@
}
}
if (cf == null) {
- NOT_FOUND.addClass(name);
+ doneClasses.add(name);
}
}
unresolved = deque;
@@ -396,96 +380,44 @@
} while (!unresolved.isEmpty() && depth-- > 0);
}
- private void printPackageDeps(PrintWriter out) {
- for (Archive source : sourceLocations) {
- SortedMap<Location, SortedSet<Location>> deps = source.getDependencies();
- if (deps.isEmpty())
- continue;
-
- for (Archive target : source.getRequiredArchives()) {
- out.format("%s -> %s%n", source, target);
- }
-
- Map<String, Archive> pkgs = new TreeMap<String, Archive>();
- SortedMap<String, Archive> targets = new TreeMap<String, Archive>();
- String pkg = "";
- for (Map.Entry<Location, SortedSet<Location>> e : deps.entrySet()) {
- String cn = e.getKey().getClassName();
- String p = packageOf(e.getKey());
- Archive origin = Archive.find(e.getKey());
- assert origin != null;
- if (!pkgs.containsKey(p)) {
- pkgs.put(p, origin);
- } else if (pkgs.get(p) != origin) {
- warning("warn.split.package", p, origin, pkgs.get(p));
- }
-
- if (!p.equals(pkg)) {
- printTargets(out, targets);
- pkg = p;
- targets.clear();
- out.format(" %s (%s)%n", p, origin.getFileName());
- }
-
- for (Location t : e.getValue()) {
- p = packageOf(t);
- Archive target = Archive.find(t);
- if (!targets.containsKey(p)) {
- targets.put(p, target);
- }
+ private void printSummary(final PrintWriter out, final Analyzer analyzer) {
+ Analyzer.Visitor visitor = new Analyzer.Visitor() {
+ public void visit(String origin, String profile) {
+ if (options.showProfile) {
+ out.format("%-30s -> %s%n", origin, profile);
}
}
- printTargets(out, targets);
- out.println();
- }
+ public void visit(Archive origin, Archive target) {
+ if (!options.showProfile) {
+ out.format("%-30s -> %s%n", origin, target);
+ }
+ }
+ };
+ analyzer.visitSummary(visitor);
}
- private void printTargets(PrintWriter out, Map<String, Archive> targets) {
- for (Map.Entry<String, Archive> t : targets.entrySet()) {
- String pn = t.getKey();
- out.format(" -> %-40s %s%n", pn, getPackageInfo(pn, t.getValue()));
- }
- }
-
- private String getPackageInfo(String pn, Archive source) {
- if (PlatformClassPath.contains(source)) {
- String name = PlatformClassPath.getProfileName(pn);
- if (name.isEmpty()) {
- return "JDK internal API (" + source.getFileName() + ")";
+ private void printDependencies(final PrintWriter out, final Analyzer analyzer) {
+ Analyzer.Visitor visitor = new Analyzer.Visitor() {
+ private String pkg = "";
+ public void visit(String origin, String target) {
+ if (!origin.equals(pkg)) {
+ pkg = origin;
+ out.format(" %s (%s)%n", origin, analyzer.getArchiveName(origin));
+ }
+ Archive source = analyzer.getArchive(target);
+ String profile = options.showProfile ? analyzer.getProfile(target) : "";
+ out.format(" -> %-50s %s%n", target,
+ PlatformClassPath.contains(source)
+ ? profile
+ : analyzer.getArchiveName(target));
}
- return options.showProfile ? name : "";
- }
- return source.getFileName();
- }
-
- private static String packageOf(Location loc) {
- String pkg = loc.getPackageName();
- return pkg.isEmpty() ? "<unnamed>" : pkg;
+ public void visit(Archive origin, Archive target) {
+ out.format("%s -> %s%n", origin, target);
+ }
+ };
+ analyzer.visit(visitor);
}
- private void printClassDeps(PrintWriter out) {
- for (Archive source : sourceLocations) {
- SortedMap<Location, SortedSet<Location>> deps = source.getDependencies();
- if (deps.isEmpty())
- continue;
-
- for (Archive target : source.getRequiredArchives()) {
- out.format("%s -> %s%n", source, target);
- }
- out.format("%s%n", source);
- for (Map.Entry<Location, SortedSet<Location>> e : deps.entrySet()) {
- String cn = e.getKey().getClassName();
- Archive origin = Archive.find(e.getKey());
- out.format(" %s (%s)%n", cn, origin.getFileName());
- for (Location t : e.getValue()) {
- cn = t.getClassName();
- Archive target = Archive.find(t);
- out.format(" -> %-60s %s%n", cn, getPackageInfo(t.getPackageName(), target));
- }
- }
- out.println();
- }
- }
public void handleOptions(String[] args) throws BadArgs {
// process options
for (int i=0; i < args.length; i++) {
@@ -570,7 +502,7 @@
}
}
- public String getMessage(String key, Object... args) {
+ static String getMessage(String key, Object... args) {
try {
return MessageFormat.format(ResourceBundleHelper.bundle.getString(key), args);
} catch (MissingResourceException e) {
@@ -579,13 +511,6 @@
}
private static class Options {
- enum Verbose {
- CLASS,
- PACKAGE,
- SUMMARY,
- VERBOSE
- };
-
boolean help;
boolean version;
boolean fullVersion;
@@ -596,7 +521,7 @@
String regex;
String classpath = "";
int depth = 1;
- Verbose verbose = Verbose.PACKAGE;
+ Analyzer.Type verbose = Analyzer.Type.PACKAGE;
Set<String> packageNames = new HashSet<String>();
}
--- a/langtools/src/share/classes/com/sun/tools/sjavac/Main.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/Main.java Tue Mar 12 16:43:53 2013 -0700
@@ -443,7 +443,7 @@
out[source_path+1] = out[source_path+1]+File.pathSeparatorChar+args[i+1];
i++;
}
- } else if (args[i].equals("-classpath")) {
+ } else if (args[i].equals("-classpath") || args[i].equals("-cp")) {
if (class_path == -1) {
class_path = j;
out[j] = args[i];
@@ -663,6 +663,7 @@
o.equals("-d") ||
o.equals("-sourcepath") ||
o.equals("-classpath") ||
+ o.equals("-cp") ||
o.equals("-bootclasspath") ||
o.equals("-src");
}
@@ -953,7 +954,8 @@
if (args[i].equals("-src") ||
args[i].equals("-sourcepath") ||
args[i].equals("-modulepath") ||
- args[i].equals("-classpath"))
+ args[i].equals("-classpath") ||
+ args[i].equals("-cp"))
{
// Reset the includes,excludes and excludefiles after they have been used.
includes = new LinkedList<String>();
--- a/langtools/src/share/classes/com/sun/tools/sjavac/comp/Dependencies.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/comp/Dependencies.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2011, 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
@@ -113,9 +113,6 @@
return a.toString().compareTo(b.toString());
}
- public boolean equals(Object obj) {
- return super.equals(obj);
- }
}
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testDocFiles/TestDocFiles.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,67 @@
+/*
+ * 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 8008949
+ * @summary verify that doc-files get copied
+ * @library ../lib/
+ * @build JavadocTester
+ * @build TestDocFiles
+ * @run main TestDocFiles
+ */
+
+public class TestDocFiles extends JavadocTester {
+
+ private static final String BUG_ID = "8008949";
+ private static final String[][] TEST = {
+ {"tmp" + FS + "pkg" + FS + "doc-files" + FS + "test.txt", "test file"}};
+
+ private static final String[] ARGS =
+ new String[] {
+ "-d", "tmp", "-sourcepath", SRC_DIR, "pkg"};
+
+ /**
+ * The entry point of the test.
+ * @param args the array of command line arguments.
+ */
+ public static void main(String[] args) {
+ TestDocFiles tester = new TestDocFiles();
+ run(tester, ARGS, TEST, NO_TEST);
+ tester.printSummary();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getBugId() {
+ return BUG_ID;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getBugName() {
+ return getClass().getName();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testDocFiles/pkg/Test.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2002, 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.
+ */
+
+package pkg;
+
+public class Test { }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testDocFiles/pkg/doc-files/test.txt Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,2 @@
+this is a test file
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testJavaFX/C.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+
+/**
+ * @expert Expert tag text
+ */
+
+public class C {
+
+ /**
+ * @propertySetter Property
+ * @propertyDescription PropertyDescription
+ */
+ public void CC() {}
+
+ /**
+ * @propertyGetter Property
+ * @expert Expert tag text
+ *
+ */
+ public void B() {}
+
+ /**
+ * Method A documentation
+ * @treatAsPrivate
+ */
+ public void A() {}
+
+ /**
+ * Field i
+ * @defaultValue 1.0
+ */
+ public int i;
+
+
+ /**
+ * Defines the direction/speed at which the {@code Timeline} is expected to
+ * be played.
+ * @defaultValue 11
+ */
+ private DoubleProperty rate;
+
+ public final void setRate(double value) {}
+
+ public final double getRate() {}
+
+ public final DoubleProperty rateProperty() {}
+
+ private BooleanProperty paused;
+
+ public final void setPaused(boolean value) {}
+
+ public final double isPaused() {}
+
+ /**
+ * Defines if paused
+ * @defaultValue false
+ */
+ public final BooleanProperty pausedProperty() {}
+
+ class DoubleProperty {}
+
+ class BooleanProperty {}
+
+ public final BooleanProperty setTestMethodProperty() {}
+
+ private class Inner {
+ private BooleanProperty testMethodProperty() {}
+
+ /**
+ * Defines the direction/speed at which the {@code Timeline} is expected to
+ * be played.
+ * @defaultValue 11
+ */
+ private DoubleProperty rate;
+
+ public final void setRate(double value) {}
+
+ public final double getRate() {}
+
+ public final DoubleProperty rateProperty() {}
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testJavaFX/D.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+
+/**
+ * @expert Expert tag text
+ */
+
+public class D extends C {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testJavaFX/TestJavaFX.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2012, 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 7112427
+ * @summary Test of the JavaFX doclet features.
+ * @author jvalenta
+ * @library ../lib/
+ * @build JavadocTester TestJavaFX
+ * @run main TestJavaFX
+ */
+
+public class TestJavaFX extends JavadocTester {
+
+ private static final String BUG_ID = "7112427";
+
+ private static final String[][] TEST =
+ new String[][] {
+ {"./" + BUG_ID + "/C.html",
+ "<dt><span class=\"strong\">See Also:</span></dt><dd><a href=\"C.html#getRate()\"><code>getRate()</code></a>, " + NL +
+ "<a href=\"C.html#setRate(double)\"><code>setRate(double)</code></a></dd>"},
+ {"./" + BUG_ID + "/C.html",
+ "<pre>public final void setRate(double value)</pre>" + NL +
+ "<div class=\"block\">Sets the value of the property rate.</div>" + NL +
+ "<dl><dt><span class=\"strong\">Property description:</span></dt>" },
+ {"./" + BUG_ID + "/C.html",
+ "<pre>public final double getRate()</pre>" + NL +
+ "<div class=\"block\">Gets the value of the property rate.</div>" + NL +
+ "<dl><dt><span class=\"strong\">Property description:</span></dt>" },
+ {"./" + BUG_ID + "/C.html",
+ "<td class=\"colLast\"><code><strong><a href=\"C.html#rateProperty\">rate</a></strong></code>" + NL +
+ "<div class=\"block\">Defines the direction/speed at which the <code>Timeline</code> is expected to"},
+ {"./" + BUG_ID + "/C.html",
+ "<sub id=\"expert\">Expert tag text</sub>"},
+ {"./" + BUG_ID + "/C.html",
+ "<span class=\"strong\">Default value:</span>"},
+ {"./" + BUG_ID + "/C.html",
+ "<P>Sets the value of the property <CODE>Property</CODE>"},
+ {"./" + BUG_ID + "/C.html",
+ "<P>Gets the value of the property <CODE>Property</CODE>"},
+ {"./" + BUG_ID + "/C.html",
+ "<span class=\"strong\">Property description:</span>"},
+ {"./" + BUG_ID + "/C.html",
+ "<td class=\"colLast\"><code><strong><a href=\"C.html#setTestMethodProperty()\">setTestMethodProperty</a></strong>()</code> </td>" },
+ {"./" + BUG_ID + "/C.html",
+ "<h4>isPaused</h4>" + NL +
+ "<pre>public final double isPaused()</pre>" + NL +
+ "<div class=\"block\">Gets the value of the property paused.</div>" },
+ {"./" + BUG_ID + "/D.html",
+ "<h3>Properties inherited from class <a href=\"C.html\" title=\"class in <Unnamed>\">C</a></h3>" + NL +
+ "<code><a href=\"C.html#pausedProperty\">paused</a>, <a href=\"C.html#rateProperty\">rate</a></code></li>" },
+ };
+ private static final String[][] NO_TEST =
+ new String[][] {
+ {"./" + BUG_ID + "/C.html",
+ "A()"},
+ };
+
+
+ private static final String[] ARGS = new String[] {
+ "-d", BUG_ID, "-sourcepath", SRC_DIR, "-private", "-javafx",
+ SRC_DIR + FS + "C.java", SRC_DIR + FS + "D.java"
+ };
+
+ /**
+ * The entry point of the test.
+ * @param args the array of command line arguments.
+ */
+ public static void main(String[] args) {
+ TestJavaFX tester = new TestJavaFX();
+ run(tester, ARGS, TEST, NO_TEST);
+ tester.printSummary();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getBugId() {
+ return BUG_ID;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getBugName() {
+ return getClass().getName();
+ }
+}
--- a/langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java Tue Mar 12 16:43:53 2013 -0700
@@ -63,7 +63,7 @@
"<dl>" + NL + "<dt>Functional Interface:</dt>" + NL +
"<dd>This is a functional interface and can therefore be used as " +
"the assignment target for a lambda expression or method " +
- "reference. </dd>" + NL + "</dl>"}
+ "reference.</dd>" + NL + "</dl>"}
};
private static final String[][] NEGATED_TEST = {
{BUG_ID + FS + "pkg" + FS + "A.html",
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/apt/Basics/CheckAptIsRemovedTest.java Tue Mar 12 16:43:53 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.
+ *
+ * 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 4908512 5024825 4957203 4993280 4996963 6174696 6177059 7041249
+ * @summary Make sure apt is removed and doesn't come back
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main CheckAptIsRemovedTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+//original test: test/tools/apt/Basics/apt.sh
+public class CheckAptIsRemovedTest {
+ //I think this class can be let with the imports only and that should be enough for as test's purpose
+ private static final String NullAPFSrc =
+ "import com.sun.mirror.apt.*;\n" +
+ "import com.sun.mirror.declaration.*;\n" +
+ "import com.sun.mirror.type.*;\n" +
+ "import com.sun.mirror.util.*;\n" +
+ "import java.util.Collection;\n" +
+ "import java.util.Set;\n\n" +
+
+ "public class NullAPF implements AnnotationProcessorFactory {\n" +
+ " static class NullAP implements AnnotationProcessor {\n" +
+ " NullAP(AnnotationProcessorEnvironment ape) {}\n" +
+ " public void process() {return;}\n" +
+ " }\n\n" +
+
+ " static Collection<String> supportedTypes;\n\n" +
+ " static {\n" +
+ " String types[] = {\"*\"};\n" +
+ " supportedTypes = java.util.Arrays.asList(types);\n" +
+ " }\n\n" +
+
+ " public Collection<String> supportedOptions() {\n" +
+ " return java.util.Collections.emptySet();\n" +
+ " }\n\n" +
+
+ " public Collection<String> supportedAnnotationTypes() {\n" +
+ " return supportedTypes;\n" +
+ " }\n\n" +
+
+ " public AnnotationProcessor getProcessorFor(" +
+ " Set<AnnotationTypeDeclaration> atds,\n" +
+ " AnnotationProcessorEnvironment env) {\n" +
+ " return new NullAP(env);\n" +
+ " }\n" +
+ "}";
+
+ public static void main(String[] args) throws Exception {
+ String testJDK = System.getProperty("test.jdk");
+ Path aptLin = Paths.get(testJDK, "bin", "apt");
+ Path aptWin = Paths.get(testJDK, "bin", "apt.exe");
+
+// if [ -f "${TESTJAVA}/bin/apt" -o -f "${TESTJAVA}/bin/apt.exe" ];then
+ if (Files.exists(aptLin) || Files.exists(aptWin)) {
+ throw new AssertionError("apt executable should not exist");
+ }
+
+// JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
+// $JAVAC ${TESTSRC}/NullAPF.java
+ Path classpath = Paths.get(testJDK, "lib", "tools.jar");
+ ToolBox.JavaToolArgs javacArgs =
+ new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
+ .setOptions("-source", "1.5", "-sourcepath", ".",
+ "-classpath", classpath.toString())
+ .setSources(NullAPFSrc);
+ ToolBox.javac(javacArgs);
+ }
+
+}
--- a/langtools/test/tools/apt/Basics/NullAPF.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-import com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-
-public class NullAPF implements AnnotationProcessorFactory {
- static class NullAP implements AnnotationProcessor {
- NullAP(AnnotationProcessorEnvironment ape) {
- }
-
- public void process() {
- return;
- }
- }
-
- static Collection<String> supportedTypes;
-
- static {
- String types[] = {"*"};
- supportedTypes = java.util.Arrays.asList(types);
- }
-
- /*
- * Processor doesn't examine any options.
- */
- public Collection<String> supportedOptions() {
- return java.util.Collections.emptySet();
- }
-
- /*
- * All annotation types are supported.
- */
- public Collection<String> supportedAnnotationTypes() {
- return supportedTypes;
- }
-
- /*
- * Return the same processor independent of what annotations are
- * present, if any.
- */
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env) {
- return new NullAP(env);
- }
-}
--- a/langtools/test/tools/apt/Basics/apt.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2012, 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 4908512 5024825 4957203 4993280 4996963 6174696 6177059 7041249
-# @run shell ../verifyVariables.sh
-# @run shell apt.sh
-# @summary Make sure apt is removed and doesn't come back
-# @author Joseph D. Darcy
-
-OS=`uname -s`;
-case "${OS}" in
- CYGWIN* )
- DIFFOPTS="--strip-trailing-cr"
- ;;
-
- * )
- ;;
-esac
-
-# Verify apt executable does not exist
-if [ -f "${TESTJAVA}/bin/apt" -o -f "${TESTJAVA}/bin/apt.exe" ];then
- echo "apt executable should not exist."
- exit 1
-fi
-
-# Construct path to javac executable
-JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
-
-$JAVAC ${TESTSRC}/NullAPF.java
-RESULT=$?
-
-case "${RESULT}" in
- 0 )
- echo "Compilation of apt-using source passed improperly."
- exit 1
- ;;
-
- * )
- ;;
-esac
--- a/langtools/test/tools/apt/verifyVariables.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 1999, 2002, 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.
-#
-
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-
-
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-
-exit 0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/4846262/CheckEBCDICLocaleTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,99 @@
+/*
+ * 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 4846262
+ * @summary check that javac operates correctly in EBCDIC locale
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main CheckEBCDICLocaleTest
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import com.sun.tools.javac.util.ArrayUtils;
+
+//original test: test/tools/javac/4846262/Test.sh
+public class CheckEBCDICLocaleTest {
+
+ private static final String TestSrc =
+ "public class Test {\n" +
+ " public void test() {\n" +
+ " abcdefg\n" +
+ " }\n" +
+ "}";
+
+ private static final String TestOut =
+ "output/Test.java:3: error: not a statement\n" +
+ " abcdefg\n" +
+ " ^\n" +
+ "output/Test.java:3: error: ';' expected\n" +
+ " abcdefg\n" +
+ " ^\n" +
+ "2 errors\n";
+
+ public static void main(String[] args) throws Exception {
+ new CheckEBCDICLocaleTest().test();
+ }
+
+ public void test() throws Exception {
+ String native2asciiBinary = Paths.get(
+ System.getProperty("test.jdk"),"bin", "native2ascii").toString();
+ String testVMOpts = System.getProperty("test.tool.vm.opts");
+ String[] mainArgs = ToolBox.getJavacBin();
+
+ ToolBox.createJavaFileFromSource(TestSrc);
+ Files.createDirectory(Paths.get("output"));
+
+//"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -reverse -encoding IBM1047 ${TESTSRC}${FS}Test.java Test.java
+ ToolBox.AnyToolArgs nativeCmdParams =
+ new ToolBox.AnyToolArgs()
+ .setAllArgs(native2asciiBinary, testVMOpts,
+ "-reverse", "-encoding", "IBM1047",
+ "Test.java", "output/Test.java");
+ ToolBox.executeCommand(nativeCmdParams);
+
+//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Duser.language=en -J-Duser.region=US -J-Dfile.encoding=IBM1047 Test.java 2>Test.tmp
+ ToolBox.AnyToolArgs javacParams =
+ new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
+ .setAllArgs(ArrayUtils.concatOpen(mainArgs, "-J-Duser.language=en",
+ "-J-Duser.region=US", "-J-Dfile.encoding=IBM1047",
+ "output/Test.java"))
+ .setErrOutput(new File("Test.tmp"));
+ ToolBox.executeCommand(javacParams);
+
+//"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -encoding IBM1047 Test.tmp Test.out
+ nativeCmdParams.setAllArgs(native2asciiBinary, "-encoding", "IBM1047",
+ "Test.tmp", "Test.out");
+ ToolBox.executeCommand(nativeCmdParams);
+
+//diff ${DIFFOPTS} -c "${TESTSRC}${FS}Test.out" Test.out
+ ToolBox.compareLines(Paths.get("Test.out"),
+ Arrays.asList(TestOut.split("\n")), null);
+
+ }
+
+}
--- a/langtools/test/tools/javac/4846262/Test.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-/* /nodynamiccopyright/ */
-public class Test {
- public void test() {
- abcdefg
- }
-}
--- a/langtools/test/tools/javac/4846262/Test.out Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-Test.java:4: error: not a statement
- abcdefg
- ^
-Test.java:4: error: ';' expected
- abcdefg
- ^
-2 errors
--- a/langtools/test/tools/javac/4846262/Test.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-#!/bin/sh -f
-
-#
-# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-#
-# @test
-# @bug 4846262
-# @summary check that javac operates correctly in EBCDIC locale
-
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin )
- FS="/"
- ;;
- CYGWIN* )
- FS="/"
- DIFFOPTS="--strip-trailing-cr"
- ;;
- Windows* )
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-rm -f Test.java Test.out
-
-"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -reverse -encoding IBM1047 ${TESTSRC}${FS}Test.java Test.java
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Duser.language=en -J-Duser.region=US -J-Dfile.encoding=IBM1047 Test.java 2>Test.tmp
-
-"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -encoding IBM1047 Test.tmp Test.out
-
-diff ${DIFFOPTS} -c "${TESTSRC}${FS}Test.out" Test.out
-result=$?
-
-if [ $result -eq 0 ]
-then
- echo "Passed"
-else
- echo "Failed"
-fi
-exit $result
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6302184/HiddenOptionsShouldUseGivenEncodingTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,49 @@
+/*
+ * 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 6302184 6350124 6357979
+ * @summary javac hidden options that generate source should use the given
+ * encoding, if available
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run compile -encoding iso-8859-1 -XD-printsource T6302184.java
+ * @run main HiddenOptionsShouldUseGivenEncodingTest
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/6302184/T6302184.sh
+public class HiddenOptionsShouldUseGivenEncodingTest {
+
+ public static void main(String[] args) throws Exception {
+//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -cp ${TC} -encoding iso-8859-1 -XD-printsource ${TS}${FS}T6302184.java 2>&1
+//diff ${DIFFOPTS} -c ${TC}${FS}T6302184.java ${TS}${FS}T6302184.out
+ Path path1 = Paths.get(System.getProperty("test.classes"), "T6302184.java");
+ Path path2 = Paths.get(System.getProperty("test.src"), "T6302184.out");
+ ToolBox.compareLines(path1, path2, "iso-8859-1");
+ }
+
+}
--- a/langtools/test/tools/javac/6302184/T6302184.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-#! /bin/sh -f
-
-#
-# Copyright (c) 2005, 2009, 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 6302184 6350124 6357979
-# @summary javac hidden options that generate source should use the given encoding, if available
-# @run shell T6302184.sh
-
-TS=${TESTSRC-.}
-TC=${TESTCLASSES-.}
-
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin )
- FS="/"
- ;;
- CYGWIN* )
- FS="/"
- DIFFOPTS="--strip-trailing-cr"
- ;;
- Windows* )
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -cp ${TC} -encoding iso-8859-1 -XD-printsource ${TS}${FS}T6302184.java 2>&1
-diff ${DIFFOPTS} -c ${TC}${FS}T6302184.java ${TS}${FS}T6302184.out
-result=$?
-
-
-if [ $result -eq 0 ]
-then
- echo "Passed"
-else
- echo "Failed"
-fi
-exit $result
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6563143/EqualsHashCodeWarningTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,71 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6563143 8008436 8009138
+ * @summary javac should issue a warning for overriding equals without hashCode
+ * @summary javac should not issue a warning for overriding equals without hasCode
+ * @summary javac, equals-hashCode warning tuning
+ * if hashCode has been overriden by a superclass
+ * @compile/ref=EqualsHashCodeWarningTest.out -Xlint:overrides -XDrawDiagnostics EqualsHashCodeWarningTest.java
+ */
+
+import java.util.Comparator;
+
+public class EqualsHashCodeWarningTest {
+ @Override
+ public boolean equals(Object o) {
+ return o == this;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public Comparator m() {
+ return new Comparator() {
+ @Override
+ public boolean equals(Object o) {return true;}
+
+ @Override
+ public int compare(Object o1, Object o2) {
+ return 0;
+ }
+ };
+ }
+}
+
+class SubClass extends EqualsHashCodeWarningTest {
+ @Override
+ public boolean equals(Object o) {
+ return true;
+ }
+}
+
+@SuppressWarnings("overrides")
+class DontWarnMe {
+ @Override
+ public boolean equals(Object o) {
+ return true;
+ }
+}
+
+class DoWarnMe {
+ @Override
+ public boolean equals(Object o) {
+ return o == this;
+ }
+}
+
+abstract class IamAbstractGetMeOutOfHere {
+ public boolean equals(Object o){return true;}
+}
+
+interface I {
+ public boolean equals(Object o);
+}
+
+enum E {
+ A, B
+}
+
+@interface anno {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6563143/EqualsHashCodeWarningTest.out Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,2 @@
+EqualsHashCodeWarningTest.java:52:1: compiler.warn.override.equals.but.not.hashcode: DoWarnMe
+1 warning
--- a/langtools/test/tools/javac/7167125/DiffResultAfterSameOperationInnerClasses.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/7167125/DiffResultAfterSameOperationInnerClasses.java Tue Mar 12 16:43:53 2013 -0700
@@ -34,27 +34,60 @@
private int j = 1;
public String s1 = "Hi, ";
private String s2 = "Hi, ";
+ public int arr1[] = new int[]{1};
+ public int arr2[] = new int[]{1};
public static void main(String[] args) {
- InnerClass inner =
- new DiffResultAfterSameOperationInnerClasses().new InnerClass();
- if (!inner.test()) {
+ DiffResultAfterSameOperationInnerClasses theTest =
+ new DiffResultAfterSameOperationInnerClasses();
+ InnerClass inner = theTest.new InnerClass();
+ if (!inner.test1()) {
+ throw new AssertionError("Different results after same calculation");
+ }
+
+ theTest.resetVars();
+ if (!inner.test2()) {
throw new AssertionError("Different results after same calculation");
}
}
+ void resetVars() {
+ i = 1;
+ j = 1;
+ s1 = "Hi, ";
+ s2 = "Hi, ";
+ arr1[0] = 1;
+ arr2[0] = 1;
+ }
+
class InnerClass {
- public boolean test() {
+ public boolean test1() {
i += i += 1;
j += j += 1;
+ arr1[0] += arr1[0] += 1;
+ arr2[0] += arr2[0] += 1;
+
s1 += s1 += "dude";
s2 += s2 += "dude";
- System.out.println("s1 = " + s1);
- System.out.println("s2 = " + s2);
+ return (i == j && i == 3 &&
+ arr1[0] == arr2[0] && arr2[0] == 3 &&
+ s1.equals(s2) && s1.endsWith("Hi, Hi, dude"));
+ }
+
+ public boolean test2() {
+ (i) += (i) += 1;
+ (j) += (j) += 1;
+
+ (arr1[0])+= (arr1[0]) += 1;
+ (arr2[0])+= (arr2[0]) += 1;
+
+ (s1) += (s1) += "dude";
+ (s2) += (s2) += "dude";
return (i == j && i == 3 &&
+ arr1[0] == arr2[0] && arr2[0] == 3 &&
s1.equals(s2) && s1.endsWith("Hi, Hi, dude"));
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/8009170/RedundantByteCodeInArrayTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,71 @@
+/*
+ * 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 8009170
+ * @summary Regression: javac generates redundant bytecode in assignop involving
+ * arrays
+ * @run main RedundantByteCodeInArrayTest
+ */
+
+import java.io.File;
+import java.io.IOException;
+
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.Code_attribute.InvalidIndex;
+import com.sun.tools.classfile.ConstantPool;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
+import com.sun.tools.classfile.Method;
+
+public class RedundantByteCodeInArrayTest {
+ public static void main(String[] args)
+ throws IOException, ConstantPoolException, InvalidDescriptor, InvalidIndex {
+ new RedundantByteCodeInArrayTest()
+ .checkClassFile(new File(System.getProperty("test.classes", "."),
+ RedundantByteCodeInArrayTest.class.getName() + ".class"));
+ }
+
+ void arrMethod(int[] array, int p, int inc) {
+ array[p] += inc;
+ }
+
+ void checkClassFile(File file)
+ throws IOException, ConstantPoolException, InvalidDescriptor, InvalidIndex {
+ ClassFile classFile = ClassFile.read(file);
+ ConstantPool constantPool = classFile.constant_pool;
+
+ //lets get all the methods in the class file.
+ for (Method method : classFile.methods) {
+ if (method.getName(constantPool).equals("arrMethod")) {
+ Code_attribute code = (Code_attribute) method.attributes
+ .get(Attribute.Code);
+ if (code.max_locals > 4)
+ throw new AssertionError("Too many locals for method arrMethod");
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/ClassPathTest/ClassPathTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,148 @@
+/*
+ * 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 4241229 4785453
+ * @summary Test -classpath option and classpath defaults.
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main ClassPathTest
+ */
+
+import java.nio.file.Paths;
+import java.util.Map;
+import java.util.TreeMap;
+import com.sun.tools.javac.util.ArrayUtils;
+
+//original test: test/tools/javac/ClassPathTest/ClassPathTest.sh
+public class ClassPathTest {
+
+ private static final String ClassPathTest1Src =
+ "import pkg.*;\n" +
+ "public class ClassPathTest1 {\n" +
+ " ClassPathTestAux1 x;\n" +
+ "}";
+
+ private static final String ClassPathTest2Src =
+ "import pkg.*;\n" +
+ "public class ClassPathTest2 {\n" +
+ " ClassPathTestAux2 x;\n" +
+ "}";
+
+ private static final String ClassPathTest3Src =
+ "import pkg.*;\n" +
+ "public class ClassPathTest3 {\n" +
+ " ClassPathTestAux3 x;\n" +
+ "}";
+
+ private static final String fooPkgClassPathTestAux1Src =
+ "package pkg;\n" +
+ "public class ClassPathTestAux1 {}";
+
+ private static final String barPkgClassPathTestAux2Src =
+ "package pkg;\n" +
+ "public class ClassPathTestAux2 {}";
+
+ private static final String pkgClassPathTestAux3Src =
+ "package pkg;\n" +
+ "public class ClassPathTestAux3 {}";
+
+ ProcessBuilder pb = null;
+
+ public static void main(String[] args) throws Exception {
+ new ClassPathTest().test();
+ }
+
+ public void test() throws Exception {
+ createOutputDirAndSourceFiles();
+ checkCompileCommands();
+ }
+
+ void createOutputDirAndSourceFiles() throws Exception {
+ //dirs and files creation
+ ToolBox.createJavaFileFromSource(ClassPathTest1Src);
+ ToolBox.createJavaFileFromSource(ClassPathTest2Src);
+ ToolBox.createJavaFileFromSource(ClassPathTest3Src);
+ ToolBox.createJavaFileFromSource(Paths.get("foo"),
+ fooPkgClassPathTestAux1Src);
+ ToolBox.createJavaFileFromSource(Paths.get("bar"),
+ barPkgClassPathTestAux2Src);
+ ToolBox.createJavaFileFromSource(pkgClassPathTestAux3Src);
+ }
+
+ void checkCompileCommands() throws Exception {
+ String[] mainArgs = ToolBox.getJavacBin();
+
+// Without the -cp . parameter the command will fail seems like when called
+// from the command line, the current dir is added to the classpath
+// automatically but this is not happening when called using ProcessBuilder
+
+// testJavac success ClassPathTest3.java
+ String[] commonArgs = ArrayUtils.concatOpen(mainArgs, "-cp", ".");
+
+ ToolBox.AnyToolArgs successParams =
+ new ToolBox.AnyToolArgs()
+ .setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest3.java"));
+ ToolBox.executeCommand(successParams);
+
+// testJavac failure ClassPathTest1.java
+ ToolBox.AnyToolArgs failParams =
+ new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
+ .setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest1.java"));
+ ToolBox.executeCommand(failParams);
+
+// This is done inside the executeCommand method
+// CLASSPATH=bar; export CLASSPATH
+
+ Map<String, String> extVars = new TreeMap<>();
+ extVars.put("CLASSPATH", "bar");
+
+// testJavac success ClassPathTest2.java
+ successParams.setAllArgs(ArrayUtils.concatOpen(mainArgs, "ClassPathTest2.java")).set(extVars);
+ ToolBox.executeCommand(successParams);
+
+// testJavac failure ClassPathTest1.java
+ failParams.setAllArgs(ArrayUtils.concatOpen(mainArgs, "ClassPathTest1.java")).set(extVars);
+ ToolBox.executeCommand(failParams);
+
+// testJavac failure ClassPathTest3.java
+ failParams.setAllArgs(ArrayUtils.concatOpen(mainArgs, "ClassPathTest3.java"));
+ ToolBox.executeCommand(failParams);
+
+// testJavac success -classpath foo ClassPathTest1.java
+
+ commonArgs = ArrayUtils.concatOpen(mainArgs, "-cp", "foo");
+ successParams.setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest1.java"));
+ ToolBox.executeCommand(successParams);
+
+// testJavac failure -classpath foo ClassPathTest2.java
+ failParams.setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest2.java"));
+ ToolBox.executeCommand(failParams);
+
+// testJavac failure -classpath foo ClassPathTest3.java
+ failParams.setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest3.java"));
+ ToolBox.executeCommand(failParams);
+ }
+
+}
--- a/langtools/test/tools/javac/ClassPathTest/ClassPathTest.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-
-# @test
-# @bug 4241229 4785453
-# @summary Test -classpath option and classpath defaults.
-# @author maddox
-#
-# @run shell/timeout=180 ClassPathTest.sh
-
-# TODO: Should test sourcepath and classpath separately.
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin | CYGWIN* )
- FS="/"
- ;;
- Windows* )
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-javac="${TESTJAVA}${FS}bin${FS}javac"
-
-cleanup() {
- rm -f *.class pkg${FS}*.class foo${FS}pkg${FS}*.class bar${FS}pkg${FS}*.class
- cp -rf $TESTSRC${FS}* .
-}
-
-fail() {
- echo "FAIL: $1"
- failed="yes"
-}
-
-# report expectedResult $?
-report() {
- if test "$1" = "success" -a "$2" = 0; then
- echo "PASS: succeeded as expected"
- elif test "$1" = "failure" -a "$2" != 0; then
- echo "PASS: failed as expected"
- elif test "$1" = "success" -a "$2" != 0; then
- fail "test failed unexpectedly"
- elif test "$1" = "failure" -a "$2" = 0; then
- fail "test succeeded unexpectedly"
- else
- fail "internal error"
- fi
-}
-
-# testJavac expectedResult javacArgs...
-testJavac() {
- expectedResult="$1"; shift
- cleanup
- echo $javac ${TESTTOOLVMOPTS} "$@"
- "$javac" ${TESTTOOLVMOPTS} "$@"
- report $expectedResult $?
-}
-
-unset CLASSPATH
-
-# classpath should default to current directory
-
-testJavac success ClassPathTest3.java
-testJavac failure ClassPathTest1.java
-
-# if CLASSPATH is set, it should be honored
-
-CLASSPATH=bar; export CLASSPATH
-
-testJavac success ClassPathTest2.java
-testJavac failure ClassPathTest1.java
-testJavac failure ClassPathTest3.java
-
-# -classpath option should override default
-
-testJavac success -classpath foo ClassPathTest1.java
-testJavac failure -classpath foo ClassPathTest2.java
-testJavac failure -classpath foo ClassPathTest3.java
-
-if test -n "$failed"; then
- echo "Some tests failed"
- exit 1
-else
- echo PASS: all tests gave expected results
- exit 0
-fi
--- a/langtools/test/tools/javac/ClassPathTest/ClassPathTest1.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import pkg.*;
-
-public class ClassPathTest1 {
- ClassPathTestAux1 x;
-
-}
--- a/langtools/test/tools/javac/ClassPathTest/ClassPathTest2.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import pkg.*;
-
-public class ClassPathTest2 {
- ClassPathTestAux2 x;
-
-}
--- a/langtools/test/tools/javac/ClassPathTest/ClassPathTest3.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import pkg.*;
-
-public class ClassPathTest3 {
- ClassPathTestAux3 x;
-
-}
--- a/langtools/test/tools/javac/ClassPathTest/bar/pkg/ClassPathTestAux2.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package pkg;
-
-public class ClassPathTestAux2 {}
--- a/langtools/test/tools/javac/ClassPathTest/foo/pkg/ClassPathTestAux1.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package pkg;
-
-public class ClassPathTestAux1 {}
--- a/langtools/test/tools/javac/ClassPathTest/pkg/ClassPathTestAux3.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package pkg;
-
-public class ClassPathTestAux3 {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/ExtDirs/ExtDirTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,176 @@
+/*
+ * 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 4204897 4256097 4785453 4863609
+ * @summary Test that '.jar' files in -extdirs are found.
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main ExtDirTest
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.List;
+
+//original test: test/tools/javac/ExtDirs/ExtDirs.sh
+public class ExtDirTest {
+
+ private static final String ExtDirTestClass1Src =
+ "package pkg1;\n" +
+ "\n" +
+ "public class ExtDirTestClass1 {}";
+
+ private static final String ExtDirTestClass2Src =
+ "package pkg2;\n" +
+ "\n" +
+ "public class ExtDirTestClass2 {}";
+
+ private static final String ExtDirTest_1Src =
+ "import pkg1.*;\n" +
+ "\n" +
+ "public class ExtDirTest_1 {\n" +
+ " ExtDirTestClass1 x;\n" +
+ "}";
+
+ private static final String ExtDirTest_2Src =
+ "import pkg1.*;\n" +
+ "import pkg2.*;\n" +
+ "\n" +
+ "public class ExtDirTest_2 {\n" +
+ " ExtDirTestClass1 x;\n" +
+ " ExtDirTestClass2 y;\n" +
+ "}";
+
+ private static final String ExtDirTest_3Src =
+ "import pkg1.*;\n" +
+ "import pkg2.*;\n" +
+ "\n" +
+ "public class ExtDirTest_3 {\n" +
+ " ExtDirTestClass1 x;\n" +
+ " ExtDirTestClass2 y;\n" +
+ "}";
+
+ private static final String jar1Manifest =
+ "Manifest-Version: 1.0\n" +
+ "\n" +
+ "Name: pkg1/ExtDirTestClass1.class\n" +
+ "Digest-Algorithms: SHA MD5 \n" +
+ "SHA-Digest: 9HEcO9LJmND3cvOlq/AbUsbD9S0=\n" +
+ "MD5-Digest: hffPBwfqcUcnEdNv4PXu1Q==\n" +
+ "\n" +
+ "Name: pkg1/ExtDirTestClass1.java\n" +
+ "Digest-Algorithms: SHA MD5 \n" +
+ "SHA-Digest: 2FQVe6w3n2Ma1ACYpe8a988EBU8=\n" +
+ "MD5-Digest: /Ivr4zVI9MSM26NmqWtZpQ==\n";
+
+ private static final String jar2Manifest =
+ "Manifest-Version: 1.0\n" +
+ "\n" +
+ "Name: pkg2/ExtDirTestClass2.class\n" +
+ "Digest-Algorithms: SHA MD5 \n" +
+ "SHA-Digest: elbPaqWf8hjj1+ZkkdW3PGTsilo=\n" +
+ "MD5-Digest: 57Nn0e2t1yEQfu/4kSw8yg==\n" +
+ "\n" +
+ "Name: pkg2/ExtDirTestClass2.java\n" +
+ "Digest-Algorithms: SHA MD5 \n" +
+ "SHA-Digest: ILJOhwHg5US+yuw1Sc1d+Avu628=\n" +
+ "MD5-Digest: j8wnz8wneEcuJ/gjXBBQNA==\n";
+
+ List<String> ouputDirParam = Arrays.asList("-d", ".");
+
+ public static void main(String args[]) throws Exception {
+ new ExtDirTest().run();
+ }
+
+ void run() throws Exception {
+ createJars();
+ compileWithExtDirs();
+ }
+
+ void createJars() throws Exception {
+
+// for i in 1 2 3; do
+// if test ! -d ext${i}; then mkdir ext${i}; fi
+// cp ${TESTSRC}${FS}ext${i}${FS}*.jar ext${i}
+// done
+ sun.tools.jar.Main jarGenerator =
+ new sun.tools.jar.Main(System.out, System.err, "jar");
+
+ ToolBox.JavaToolArgs javacParams =
+ new ToolBox.JavaToolArgs()
+ .setOptions(ouputDirParam)
+ .setSources(ExtDirTestClass1Src);
+ ToolBox.javac(javacParams);
+
+ ToolBox.writeFile(Paths.get("pkg1", "MANIFEST.MF"), jar1Manifest);
+ jarGenerator.run(new String[] {"cfm", "pkg1.jar", "pkg1/MANIFEST.MF",
+ "pkg1/ExtDirTestClass1.class"});
+
+ javacParams.setSources(ExtDirTestClass2Src);
+ ToolBox.javac(javacParams);
+
+ ToolBox.writeFile(Paths.get("pkg2", "MANIFEST.MF"), jar2Manifest);
+ jarGenerator.run(new String[] {"cfm", "pkg2.jar", "pkg2/MANIFEST.MF",
+ "pkg2/ExtDirTestClass2.class"});
+
+ ToolBox.copyFile(Paths.get("ext1", "pkg1.jar"), Paths.get("pkg1.jar"));
+ ToolBox.copyFile(Paths.get("ext2", "pkg2.jar"), Paths.get("pkg2.jar"));
+ ToolBox.copyFile(Paths.get("ext3", "pkg1.jar"), Paths.get("pkg1.jar"));
+ ToolBox.copyFile(Paths.get("ext3", "pkg2.jar"), Paths.get("pkg2.jar"));
+
+ Files.delete(Paths.get("pkg1.jar"));
+ Files.delete(Paths.get("pkg2.jar"));
+
+ Files.delete(Paths.get("pkg1", "ExtDirTestClass1.class"));
+ Files.delete(Paths.get("pkg1", "MANIFEST.MF"));
+ Files.delete(Paths.get("pkg1"));
+ Files.delete(Paths.get("pkg2", "ExtDirTestClass2.class"));
+ Files.delete(Paths.get("pkg2", "MANIFEST.MF"));
+ Files.delete(Paths.get("pkg2"));
+ }
+
+ void compileWithExtDirs() throws Exception {
+
+//"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1 "${TESTSRC}${FS}ExtDirTest_1.java"
+ ToolBox.JavaToolArgs params =
+ new ToolBox.JavaToolArgs()
+ .setOptions("-d", ".", "-extdirs", "ext1")
+ .setSources(ExtDirTest_1Src);
+ ToolBox.javac(params);
+
+//"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1${PS}ext2 "${TESTSRC}${FS}ExtDirTest_2.java"
+ params.setOptions("-d", ".", "-extdirs", "ext1" + File.pathSeparator + "ext2")
+ .setSources(ExtDirTest_2Src);
+ ToolBox.javac(params);
+
+//"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext3 "${TESTSRC}${FS}ExtDirTest_3.java"
+ params.setOptions("-d", ".", "-extdirs", "ext3")
+ .setSources(ExtDirTest_3Src);
+ ToolBox.javac(params);
+ }
+
+}
--- a/langtools/test/tools/javac/ExtDirs/ExtDirTest_1.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import pkg1.*;
-
-public class ExtDirTest_1 {
- ExtDirTestClass1 x;
-}
--- a/langtools/test/tools/javac/ExtDirs/ExtDirTest_2.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import pkg1.*;
-import pkg2.*;
-
-public class ExtDirTest_2 {
- ExtDirTestClass1 x;
- ExtDirTestClass2 y;
-}
--- a/langtools/test/tools/javac/ExtDirs/ExtDirTest_3.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import pkg1.*;
-import pkg2.*;
-
-public class ExtDirTest_3 {
- ExtDirTestClass1 x;
- ExtDirTestClass2 y;
-}
--- a/langtools/test/tools/javac/ExtDirs/ExtDirs.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-
-# @test
-# @bug 4204897 4256097 4785453 4863609
-# @summary Test that '.jar' files in -extdirs are found.
-# @author maddox
-#
-# @run shell/timeout=180 ExtDirs.sh
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin )
- PS=":"
- FS="/"
- ;;
- CYGWIN* )
- PS=";" # native PS, not Cygwin PS
- FS="/"
- ;;
- Windows* )
- PS=";"
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-fail() {
- echo 'FAIL: unexpected result encountered'
- exit 1
-}
-
-javac="${TESTJAVA}${FS}bin${FS}javac"
-
-for i in 1 2 3; do
- if test ! -d ext${i}; then mkdir ext${i}; fi
- cp ${TESTSRC}${FS}ext${i}${FS}*.jar ext${i}
-done
-
-echo "Test 1"
-"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1 "${TESTSRC}${FS}ExtDirTest_1.java"
-if [ $? -ne 0 ] ; then fail ; fi
-
-echo "Test 2"
-"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1${PS}ext2 "${TESTSRC}${FS}ExtDirTest_2.java"
-if [ $? -ne 0 ] ; then fail ; fi
-
-echo "Test 3"
-"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext3 "${TESTSRC}${FS}ExtDirTest_3.java"
-if [ $? -ne 0 ] ; then fail ; fi
-
-echo PASS: all tests gave expected results
-exit 0
--- a/langtools/test/tools/javac/MethodParameters.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,344 +0,0 @@
-/*
- * Copyright (c) 2012, 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 8004727
- * @summary javac should generate method parameters correctly.
- */
-// key: opt.arg.parameters
-import com.sun.tools.classfile.*;
-import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.main.Main;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.Name;
-import com.sun.tools.javac.util.Names;
-import java.io.*;
-import javax.lang.model.element.*;
-import java.util.*;
-
-public class MethodParameters {
-
- static final String Foo_name = "Foo";
- static final String Foo_contents =
- "public class Foo {\n" +
- " Foo() {}\n" +
- " void foo0() {}\n" +
- " void foo2(int j, int k) {}\n" +
- "}";
- static final String Bar_name = "Bar";
- static final String Bar_contents =
- "public class Bar {\n" +
- " Bar(int i) {}" +
- " Foo foo() { return new Foo(); }\n" +
- "}";
- static final String Baz_name = "Baz";
- static final String Baz_contents =
- "public class Baz {\n" +
- " int baz;" +
- " Baz(int i) {}" +
- "}";
- static final String Qux_name = "Qux";
- static final String Qux_contents =
- "public class Qux extends Baz {\n" +
- " Qux(int i) { super(i); }" +
- "}";
- static final File classesdir = new File("methodparameters");
-
- public static void main(String... args) throws Exception {
- new MethodParameters().run();
- }
-
- void run() throws Exception {
- classesdir.mkdir();
- final File Foo_java =
- writeFile(classesdir, Foo_name + ".java", Foo_contents);
- final File Bar_java =
- writeFile(classesdir, Bar_name + ".java", Bar_contents);
- final File Baz_java =
- writeFile(classesdir, Baz_name + ".java", Baz_contents);
- System.err.println("Test compile with -parameter");
- compile("-parameters", "-d", classesdir.getPath(), Foo_java.getPath());
- // First test: make sure javac doesn't choke to death on
- // MethodParameter attributes
- System.err.println("Test compile with classfile containing MethodParameter attributes");
- compile("-parameters", "-d", classesdir.getPath(),
- "-cp", classesdir.getPath(), Bar_java.getPath());
- System.err.println("Examine class foo");
- checkFoo();
- checkBar();
- System.err.println("Test debug information conflict");
- compile("-g", "-parameters", "-d", classesdir.getPath(),
- "-cp", classesdir.getPath(), Baz_java.getPath());
- System.err.println("Introducing debug information conflict");
- Baz_java.delete();
- modifyBaz(false);
- System.err.println("Checking language model");
- inspectBaz();
- System.err.println("Permuting attributes");
- modifyBaz(true);
- System.err.println("Checking language model");
- inspectBaz();
-
- if(0 != errors)
- throw new Exception("MethodParameters test failed with " +
- errors + " errors");
- }
-
- void inspectBaz() throws Exception {
- final File Qux_java =
- writeFile(classesdir, Qux_name + ".java", Qux_contents);
- final String[] args = { "-XDsave-parameter-names", "-d",
- classesdir.getPath(),
- "-cp", classesdir.getPath(),
- Qux_java.getPath() };
- final StringWriter sw = new StringWriter();
- final PrintWriter pw = new PrintWriter(sw);
-
- // We need to be able to crack open javac and look at its data
- // structures. We'll rig up a compiler instance, but keep its
- // Context, thus allowing us to get at the ClassReader.
- Context context = new Context();
- Main comp = new Main("javac", pw);
- JavacFileManager.preRegister(context);
-
- // Compile Qux, which uses Baz.
- comp.compile(args, context);
- pw.close();
- final String out = sw.toString();
- if (out.length() > 0)
- System.err.println(out);
-
- // Now get the class reader, construct a name for Baz, and load it.
- com.sun.tools.javac.jvm.ClassReader cr =
- com.sun.tools.javac.jvm.ClassReader.instance(context);
- Name name = Names.instance(context).fromString(Baz_name);
-
- // Now walk down the language model and check the name of the
- // parameter.
- final Element baz = cr.loadClass(name);
- for (Element e : baz.getEnclosedElements()) {
- if (e instanceof ExecutableElement) {
- final ExecutableElement ee = (ExecutableElement) e;
- final List<? extends VariableElement> params =
- ee.getParameters();
- if (1 != params.size())
- throw new Exception("Classfile Baz badly formed: wrong number of methods");
- final VariableElement param = params.get(0);
- if (!param.getSimpleName().contentEquals("baz")) {
- errors++;
- System.err.println("javac did not correctly resolve the metadata conflict, parameter's name reads as " + param.getSimpleName());
- } else
- System.err.println("javac did correctly resolve the metadata conflict");
- }
- }
- }
-
- void modifyBaz(boolean flip) throws Exception {
- final File Baz_class = new File(classesdir, Baz_name + ".class");
- final ClassFile baz = ClassFile.read(Baz_class);
- final int ind = baz.constant_pool.getUTF8Index("baz");
- MethodParameters_attribute mpattr = null;
- int mpind = 0;
- Code_attribute cattr = null;
- int cind = 0;
-
- // Find the indexes of the MethodParameters and the Code attributes
- if (baz.methods.length != 1)
- throw new Exception("Classfile Baz badly formed: wrong number of methods");
- if (!baz.methods[0].getName(baz.constant_pool).equals("<init>"))
- throw new Exception("Classfile Baz badly formed: method has name " +
- baz.methods[0].getName(baz.constant_pool));
- for (int i = 0; i < baz.methods[0].attributes.attrs.length; i++) {
- if (baz.methods[0].attributes.attrs[i] instanceof
- MethodParameters_attribute) {
- mpattr = (MethodParameters_attribute)
- baz.methods[0].attributes.attrs[i];
- mpind = i;
- } else if (baz.methods[0].attributes.attrs[i] instanceof
- Code_attribute) {
- cattr = (Code_attribute) baz.methods[0].attributes.attrs[i];
- cind = i;
- }
- }
- if (null == mpattr)
- throw new Exception("Classfile Baz badly formed: no method parameters info");
- if (null == cattr)
- throw new Exception("Classfile Baz badly formed: no local variable table");
-
- int flags = mpattr.method_parameter_table[0].flags;
-
- // Alter the MethodParameters attribute, changing the name of
- // the parameter from i to baz. This requires Black Magic...
- //
- // The (well-designed) classfile library (correctly) does not
- // allow us to mess around with the attribute data structures,
- // or arbitrarily generate new ones.
- //
- // Instead, we install a new subclass of Attribute that
- // hijacks the Visitor pattern and outputs the sequence of
- // bytes that we want. This only works in this particular
- // instance, because we know we'll only every see one kind of
- // visitor.
- //
- // If anyone ever changes the makeup of the Baz class, or
- // tries to install some kind of visitor that gets run prior
- // to serialization, this will break.
- baz.methods[0].attributes.attrs[mpind] =
- new Attribute(mpattr.attribute_name_index,
- mpattr.attribute_length) {
- public <R, D> R accept(Visitor<R, D> visitor, D data) {
- if (data instanceof ByteArrayOutputStream) {
- ByteArrayOutputStream out =
- (ByteArrayOutputStream) data;
- out.write(1);
- out.write((ind >> 8) & 0xff);
- out.write(ind & 0xff);
- out.write((flags >> 24) & 0xff);
- out.write((flags >> 16) & 0xff);
- out.write((flags >> 8) & 0xff);
- out.write(flags & 0xff);
- } else
- throw new RuntimeException("Output stream is of type " + data.getClass() + ", which is not handled by this test. Update the test and it should work.");
- return null;
- }
- };
-
- // Flip the code and method attributes. This is for checking
- // that order doesn't matter.
- if (flip) {
- baz.methods[0].attributes.attrs[mpind] = cattr;
- baz.methods[0].attributes.attrs[cind] = mpattr;
- }
-
- new ClassWriter().write(baz, Baz_class);
- }
-
- // Run a bunch of structural tests on foo to make sure it looks right.
- void checkFoo() throws Exception {
- final File Foo_class = new File(classesdir, Foo_name + ".class");
- final ClassFile foo = ClassFile.read(Foo_class);
- for (int i = 0; i < foo.methods.length; i++) {
- System.err.println("Examine method Foo." + foo.methods[i].getName(foo.constant_pool));
- if (foo.methods[i].getName(foo.constant_pool).equals("foo2")) {
- for (int j = 0; j < foo.methods[i].attributes.attrs.length; j++)
- if (foo.methods[i].attributes.attrs[j] instanceof
- MethodParameters_attribute) {
- MethodParameters_attribute mp =
- (MethodParameters_attribute)
- foo.methods[i].attributes.attrs[j];
- System.err.println("Foo.foo2 should have 2 parameters: j and k");
- if (2 != mp.method_parameter_table_length)
- error("expected 2 method parameter entries in foo2, got " +
- mp.method_parameter_table_length);
- else if (!foo.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index).equals("j"))
- error("expected first parameter to foo2 to be \"j\", got \"" +
- foo.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index) +
- "\" instead");
- else if (!foo.constant_pool.getUTF8Value(mp.method_parameter_table[1].name_index).equals("k"))
- error("expected first parameter to foo2 to be \"k\", got \"" +
- foo.constant_pool.getUTF8Value(mp.method_parameter_table[1].name_index) +
- "\" instead");
- }
- }
- else if (foo.methods[i].getName(foo.constant_pool).equals("<init>")) {
- for (int j = 0; j < foo.methods[i].attributes.attrs.length; j++) {
- if (foo.methods[i].attributes.attrs[j] instanceof
- MethodParameters_attribute)
- error("Zero-argument constructor shouldn't have MethodParameters");
- }
- }
- else if (foo.methods[i].getName(foo.constant_pool).equals("foo0")) {
- for (int j = 0; j < foo.methods[i].attributes.attrs.length; j++)
- if (foo.methods[i].attributes.attrs[j] instanceof
- MethodParameters_attribute)
- error("Zero-argument method shouldn't have MethodParameters");
- }
- else
- error("Unknown method " + foo.methods[i].getName(foo.constant_pool) + " showed up in class Foo");
- }
- }
-
- // Run a bunch of structural tests on Bar to make sure it looks right.
- void checkBar() throws Exception {
- final File Bar_class = new File(classesdir, Bar_name + ".class");
- final ClassFile bar = ClassFile.read(Bar_class);
- for (int i = 0; i < bar.methods.length; i++) {
- System.err.println("Examine method Bar." + bar.methods[i].getName(bar.constant_pool));
- if (bar.methods[i].getName(bar.constant_pool).equals("<init>")) {
- for (int j = 0; j < bar.methods[i].attributes.attrs.length; j++)
- if (bar.methods[i].attributes.attrs[j] instanceof
- MethodParameters_attribute) {
- MethodParameters_attribute mp =
- (MethodParameters_attribute)
- bar.methods[i].attributes.attrs[j];
- System.err.println("Bar constructor should have 1 parameter: i");
- if (1 != mp.method_parameter_table_length)
- error("expected 1 method parameter entries in constructor, got " +
- mp.method_parameter_table_length);
- else if (!bar.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index).equals("i"))
- error("expected first parameter to foo2 to be \"i\", got \"" +
- bar.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index) +
- "\" instead");
- }
- }
- else if (bar.methods[i].getName(bar.constant_pool).equals("foo")) {
- for (int j = 0; j < bar.methods[i].attributes.attrs.length; j++) {
- if (bar.methods[i].attributes.attrs[j] instanceof
- MethodParameters_attribute)
- error("Zero-argument constructor shouldn't have MethodParameters");
- }
- }
- }
- }
-
- String compile(String... args) throws Exception {
- System.err.println("compile: " + Arrays.asList(args));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- int rc = com.sun.tools.javac.Main.compile(args, pw);
- pw.close();
- String out = sw.toString();
- if (out.length() > 0)
- System.err.println(out);
- if (rc != 0)
- error("compilation failed, rc=" + rc);
- return out;
- }
-
- File writeFile(File dir, String path, String body) throws IOException {
- File f = new File(dir, path);
- f.getParentFile().mkdirs();
- FileWriter out = new FileWriter(f);
- out.write(body);
- out.close();
- return f;
- }
-
- void error(String msg) {
- System.err.println("Error: " + msg);
- errors++;
- }
-
- int errors;
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParameters/AnnotationTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,54 @@
+/*
+ * 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 8006582
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters AnnotationTest.java
+ * @run main Tester AnnotationTest
+ */
+
+import java.lang.annotation.*;
+
+/** Test that annotations do not interfere with recording of parameter names */
+class AnnotationTest {
+
+ @Repeatable(Annos.class)
+ @interface Anno {
+ Class f() default int.class;
+ }
+
+ @interface Annos { Anno[] value(); String foo() default "hello"; }
+
+ interface I {
+ int m(@Anno @Anno int i, @Anno int ji);
+ }
+
+ public AnnotationTest(@Anno @Anno I i, @Anno int ji) { }
+ public @Anno String foo(@Anno @Anno I i, int ji) { return null; }
+}
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParameters/AnonymousClass.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,104 @@
+/*
+ * 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 8006582
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters AnonymousClass.java
+ * @run main Tester AnonymousClass
+ */
+
+class AnonymousClass {
+
+ interface I<T> {
+ T m();
+ T m(T x, T yx);
+ }
+
+ private class Inner implements I<String> {
+ public Inner() { }
+ public Inner(String arg, String barg) { }
+ public String m() { return "0"; }
+ public String m(String s, String ts) { return "0"; }
+ }
+
+ public static class Sinner implements I<Long> {
+ public Sinner() { }
+ public Sinner(Long arg, Long barg) { }
+ public Long m() { return 0L; }
+ public Long m(Long s, Long ts) { return s + ts; }
+ }
+
+ /** Inner class in constructor context */
+ public AnonymousClass(final Long a, Long ba) {
+ new I<Long>() {
+ public Long m() { return null; }
+ public Long m(Long i, Long ji) { return i + ji; }
+ }.m(a, ba);
+ new Inner() {
+ public String m() { return null; }
+ public String m(String i, String ji) { return i + ji; }
+ }.m(a.toString(), ba.toString());
+ new Inner(a.toString(), ba.toString()) {
+ public String m() { return null; }
+ public String m(String i, String ji) { return i + ji; }
+ }.m(a.toString(), ba.toString());
+ new Sinner() {
+ public Long m() { return null; }
+ public Long m(Long i, Long ji) { return i + ji; }
+ }.m(a, ba);
+ new Sinner(a, ba) {
+ public Long m() { return null; }
+ public Long m(Long i, Long ji) { return i + ji; }
+ }.m(a, ba);
+ }
+
+ /** Inner class in method context */
+ public void foo(final Long a, Long ba) {
+ new I<Long>() {
+ public Long m() { return null; }
+ public Long m(Long i, Long ji) { return i + ji; }
+ }.m(a, ba);
+ new Inner() {
+ public String m() { return null; }
+ public String m(String i, String ji) { return i + ji; }
+ }.m(a.toString(), ba.toString());
+ new Inner(a.toString(), ba.toString()) {
+ public String m() { return null; }
+ public String m(String i, String ji) { return i + ji; }
+ }.m(a.toString(), ba.toString());
+ new Sinner() {
+ public Long m() { return null; }
+ public Long m(Long i, Long ji) { return i + ji; }
+ }.m(a, ba);
+ new Sinner(a, ba) {
+ public Long m() { return null; }
+ public Long m(Long i, Long ji) { return i + ji; }
+ }.m(a, ba);
+ }
+}
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParameters/AttributeVisitor.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+import com.sun.tools.classfile.*;
+
+/**
+ * Trivial {@code Attribute.Visitor} implementation, to make it easy to
+ * write visitors for specific attributes.
+ */
+class AttributeVisitor<R, P> implements Attribute.Visitor<R, P> {
+ public R visitBootstrapMethods(BootstrapMethods_attribute attr, P p) { return null; }
+ public R visitDefault(DefaultAttribute attr, P p) { return null; }
+ public R visitAnnotationDefault(AnnotationDefault_attribute attr, P p) { return null; }
+ public R visitCharacterRangeTable(CharacterRangeTable_attribute attr, P p) { return null; }
+ public R visitCode(Code_attribute attr, P p) { return null; }
+ public R visitCompilationID(CompilationID_attribute attr, P p) { return null; }
+ public R visitConstantValue(ConstantValue_attribute attr, P p) { return null; }
+ public R visitDeprecated(Deprecated_attribute attr, P p) { return null; }
+ public R visitEnclosingMethod(EnclosingMethod_attribute attr, P p) { return null; }
+ public R visitExceptions(Exceptions_attribute attr, P p) { return null; }
+ public R visitInnerClasses(InnerClasses_attribute attr, P p) { return null; }
+ public R visitLineNumberTable(LineNumberTable_attribute attr, P p) { return null; }
+ public R visitLocalVariableTable(LocalVariableTable_attribute attr, P p) { return null; }
+ public R visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, P p) { return null; }
+ public R visitMethodParameters(MethodParameters_attribute attr, P p) { return null; }
+ public R visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, P p) { return null; }
+ public R visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, P p) { return null; }
+ public R visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, P p) { return null; }
+ public R visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute attr, P p) { return null; }
+ public R visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute attr, P p) { return null; }
+ public R visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute attr, P p) { return null; }
+ public R visitSignature(Signature_attribute attr, P p) { return null; }
+ public R visitSourceDebugExtension(SourceDebugExtension_attribute attr, P p) { return null; }
+ public R visitSourceFile(SourceFile_attribute attr, P p) { return null; }
+ public R visitSourceID(SourceID_attribute attr, P p) { return null; }
+ public R visitStackMap(StackMap_attribute attr, P p) { return null; }
+ public R visitStackMapTable(StackMapTable_attribute attr, P p) { return null; }
+ public R visitSynthetic(Synthetic_attribute attr, P p) { return null; }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParameters/ClassFileVisitor.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,387 @@
+/*
+ * 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.
+ */
+
+import com.sun.tools.classfile.*;
+import java.io.*;
+import javax.lang.model.element.*;
+import java.util.*;
+
+/**
+ * The {@code ClassFileVisitor} reads a class file using the
+ * {@code com.sun.tools.classfile} library. It iterates over the methods
+ * in a class, and checks MethodParameters attributes against JLS
+ * requirements, as well as assumptions about the javac implementations.
+ * <p>
+ * It enforces the following rules:
+ * <ul>
+ * <li>All non-synthetic methods with arguments must have the
+ * MethodParameters attribute. </li>
+ * <li>At most one MethodParameters attribute per method.</li>
+ * <li>An empty MethodParameters attribute is not allowed (i.e. no
+ * attribute for methods taking no parameters).</li>
+ * <li>The number of recorded parameter names much equal the number
+ * of parameters, including any implicit or synthetic parameters generated
+ * by the compiler.</li>
+ * <li>Although the spec allow recording parameters with no name, the javac
+ * implementation is assumed to record a name for all parameters. That is,
+ * the Methodparameters attribute must record a non-zero, valid constant
+ * pool index for each parameter.</li>
+ * <li>Check presence, expected names (e.g. this$N, $enum$name, ...) and flags
+ * (e.g. ACC_SYNTHETIC, ACC_MANDATED) for compiler generated parameters.</li>
+ * <li>Names of explicit parameters must reflect the names in the Java source.
+ * This is checked by assuming a design pattern where any name is permitted
+ * for the first explicit parameter. For subsequent parameters the following
+ * rule is checked: <i>param[n] == ++param[n-1].charAt(0) + param[n-1]</i>
+ * </ul>
+ */
+class ClassFileVisitor extends Tester.Visitor {
+
+ Tester tester;
+
+ public String cname;
+ public boolean isEnum;
+ public boolean isInterface;
+ public boolean isInner;
+ public boolean isPublic;
+ public boolean isStatic;
+ public boolean isAnon;
+ public ClassFile classFile;
+
+
+ public ClassFileVisitor(Tester tester) {
+ super(tester);
+ }
+
+ public void error(String msg) {
+ super.error("classfile: " + msg);
+ }
+
+ public void warn(String msg) {
+ super.warn("classfile: " + msg);
+ }
+
+ /**
+ * Read the class and determine some key characteristics, like if it's
+ * an enum, or inner class, etc.
+ */
+ void visitClass(final String cname, final File cfile, final StringBuilder sb)
+ throws Exception {
+ this.cname = cname;
+ classFile = ClassFile.read(cfile);
+ isEnum = classFile.access_flags.is(AccessFlags.ACC_ENUM);
+ isInterface = classFile.access_flags.is(AccessFlags.ACC_INTERFACE);
+ isPublic = classFile.access_flags.is(AccessFlags.ACC_PUBLIC);
+ isInner = false;
+ isStatic = true;
+ isAnon = false;
+
+ Attribute attr = classFile.getAttribute("InnerClasses");
+ if (attr != null) attr.accept(new InnerClassVisitor(), null);
+ isAnon = isInner & isAnon;
+
+ sb.append(isStatic ? "static " : "")
+ .append(isPublic ? "public " : "")
+ .append(isEnum ? "enum " : isInterface ? "interface " : "class ")
+ .append(cname).append(" -- ")
+ .append(isInner? "inner " : "" )
+ .append(isAnon ? "anon" : "")
+ .append("\n");;
+
+ for (Method method : classFile.methods) {
+ new MethodVisitor().visitMethod(method, sb);
+ }
+ }
+
+ /**
+ * Used to visit InnerClasses_attribute of a class,
+ * to determne if this class is an local class, and anonymous
+ * inner class or a none-static member class. These types of
+ * classes all have an containing class instances field that
+ * requires an implicit or synthetic constructor argument.
+ */
+ class InnerClassVisitor extends AttributeVisitor<Void, Void> {
+ public Void visitInnerClasses(InnerClasses_attribute iattr, Void v) {
+ try{
+ for (InnerClasses_attribute.Info info : iattr.classes) {
+ if (info.getInnerClassInfo(classFile.constant_pool) == null) continue;
+ String in = info.getInnerClassInfo(classFile.constant_pool).getName();
+ if (in == null || !cname.equals(in)) continue;
+ isInner = true;
+ isAnon = null == info.getInnerName(classFile.constant_pool);
+ isStatic = info.inner_class_access_flags.is(AccessFlags.ACC_STATIC);
+ break;
+ }
+ } catch(Exception e) {
+ throw new IllegalStateException(e);
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Check the MethodParameters attribute of a method.
+ */
+ class MethodVisitor extends AttributeVisitor<Void, StringBuilder> {
+
+ public String mName;
+ public Descriptor mDesc;
+ public int mParams;
+ public int mAttrs;
+ public int mNumParams;
+ public boolean mSynthetic;
+ public boolean mIsConstructor;
+ public String prefix;
+
+ void visitMethod(Method method, StringBuilder sb) throws Exception {
+
+ mName = method.getName(classFile.constant_pool);
+ mDesc = method.descriptor;
+ mParams = mDesc.getParameterCount(classFile.constant_pool);
+ mAttrs = method.attributes.attrs.length;
+ mNumParams = -1; // no MethodParameters attribute found
+ mSynthetic = method.access_flags.is(AccessFlags.ACC_SYNTHETIC);
+ mIsConstructor = mName.equals("<init>");
+ prefix = cname + "." + mName + "() - ";
+
+ sb.append(cname).append(".").append(mName).append("(");
+
+ for (Attribute a : method.attributes) {
+ a.accept(this, sb);
+ }
+ if (mNumParams == -1) {
+ if (mSynthetic) {
+ sb.append("<none>)!!");
+ } else {
+ sb.append("<none>)");
+ }
+ }
+ sb.append("\n");
+
+ // IMPL: methods with arguments must have a MethodParameters
+ // attribute, except possibly some synthetic methods.
+ if (mNumParams == -1 && mParams > 0 && ! mSynthetic) {
+ error(prefix + "missing MethodParameters attribute");
+ }
+ }
+
+ public Void visitMethodParameters(MethodParameters_attribute mp,
+ StringBuilder sb) {
+
+ // SPEC: At most one MethodParameters attribute allowed
+ if (mNumParams != -1) {
+ error(prefix + "Multiple MethodParameters attributes");
+ return null;
+ }
+
+ mNumParams = mp.method_parameter_table_length;
+
+ // SPEC: An empty attribute is not allowed!
+ if (mNumParams == 0) {
+ error(prefix + "0 length MethodParameters attribute");
+ return null;
+ }
+
+ // SPEC: one name per parameter.
+ if (mNumParams != mParams) {
+ error(prefix + "found " + mNumParams +
+ " parameters, expected " + mParams);
+ return null;
+ }
+
+ // IMPL: Whether MethodParameters attributes will be generated
+ // for some synthetics is unresolved. For now, assume no.
+ if (mSynthetic) {
+ warn(prefix + "synthetic has MethodParameter attribute");
+ }
+
+ String sep = "";
+ String userParam = null;
+ for (int x = 0; x < mNumParams; x++) {
+
+ // IMPL: Assume all parameters are named, something.
+ int cpi = mp.method_parameter_table[x].name_index;
+ if (cpi == 0) {
+ error(prefix + "name expected, param[" + x + "]");
+ return null;
+ }
+
+ // SPEC: a non 0 index, must be valid!
+ String param = null;
+ try {
+ param = classFile.constant_pool.getUTF8Value(cpi);
+ sb.append(sep).append(param);
+ sep = ", ";
+ } catch(ConstantPoolException e) {
+ error(prefix + "invalid index " + cpi + " for param["
+ + x + "]");
+ return null;
+ }
+
+
+ // Check availability, flags and special names
+ int check = checkParam(mp, param, x, sb);
+ if (check < 0) {
+ return null;
+ }
+
+ // TEST: check test assumptions about parameter name.
+ // Expected names are calculated starting with the
+ // 2nd explicit (user given) parameter.
+ // param[n] == ++param[n-1].charAt(0) + param[n-1]
+ String expect = null;
+ if (userParam != null) {
+ char c = userParam.charAt(0);
+ expect = (++c) + userParam;
+ }
+ if (check > 0) {
+ userParam = param;
+ }
+ if (expect != null && !param.equals(expect)) {
+ error(prefix + "param[" + x + "]='"
+ + param + "' expected '" + expect + "'");
+ return null;
+ }
+ }
+ if (mSynthetic) {
+ sb.append(")!!");
+ } else {
+ sb.append(")");
+ }
+ return null;
+ }
+
+ /*
+ * Check a parameter for conformity to JLS and javac specific
+ * assumptions.
+ * Return -1, if an error is detected. Otherwise, return 0, if
+ * the parameter is compiler generated, or 1 for an (presumably)
+ * explicitly declared parameter.
+ */
+ int checkParam(MethodParameters_attribute mp, String param, int index,
+ StringBuilder sb) {
+
+ boolean synthetic = (mp.method_parameter_table[index].flags
+ & AccessFlags.ACC_SYNTHETIC) != 0;
+ boolean mandated = (mp.method_parameter_table[index].flags
+ & AccessFlags.ACC_MANDATED) != 0;
+
+ // Setup expectations for flags and special names
+ String expect = null;
+ boolean allowMandated = false;
+ boolean allowSynthetic = false;
+ if (mSynthetic || synthetic) {
+ // not an implementation gurantee, but okay for now
+ expect = "arg" + index; // default
+ }
+ if (mIsConstructor) {
+ if (isEnum) {
+ if (index == 0) {
+ expect = "\\$enum\\$name";
+ allowSynthetic = true;
+ } else if(index == 1) {
+ expect = "\\$enum\\$ordinal";
+ allowSynthetic = true;
+ }
+ } else if (index == 0) {
+ if (isAnon) {
+ allowMandated = true;
+ expect = "this\\$[0-n]*";
+ } else if (isInner && !isStatic) {
+ allowMandated = true;
+ if (!isPublic) {
+ // some but not all non-public inner classes
+ // have synthetic argument. For now we give
+ // the test a bit of slack and allow either.
+ allowSynthetic = true;
+ }
+ expect = "this\\$[0-n]*";
+ }
+ } else if (isAnon) {
+ // not an implementation gurantee, but okay for now
+ expect = "x[0-n]*";
+ }
+ } else if (isEnum && mNumParams == 1 && index == 0 && mName.equals("valueOf")) {
+ expect = "name";
+ allowMandated = true;
+ }
+ if (mandated) sb.append("!");
+ if (synthetic) sb.append("!!");
+
+ // IMPL: our rules a somewhat fuzzy, sometimes allowing both mandated
+ // and synthetic. However, a parameters cannot be both.
+ if (mandated && synthetic) {
+ error(prefix + "param[" + index + "] == \"" + param
+ + "\" ACC_SYNTHETIC and ACC_MANDATED");
+ return -1;
+ }
+ // ... but must be either, if both "allowed".
+ if (!(mandated || synthetic) && allowMandated && allowSynthetic) {
+ error(prefix + "param[" + index + "] == \"" + param
+ + "\" expected ACC_MANDATED or ACC_SYNTHETIC");
+ return -1;
+ }
+
+ // ... if only one is "allowed", we meant "required".
+ if (!mandated && allowMandated && !allowSynthetic) {
+ error(prefix + "param[" + index + "] == \"" + param
+ + "\" expected ACC_MANDATED");
+ return -1;
+ }
+ if (!synthetic && !allowMandated && allowSynthetic) {
+ error(prefix + "param[" + index + "] == \"" + param
+ + "\" expected ACC_SYNTHETIC");
+ return -1;
+ }
+
+ // ... and not "allowed", means prohibited.
+ if (mandated && !allowMandated) {
+ error(prefix + "param[" + index + "] == \"" + param
+ + "\" unexpected, is ACC_MANDATED");
+ return -1;
+ }
+ if (synthetic && !allowSynthetic) {
+ error(prefix + "param[" + index + "] == \"" + param
+ + "\" unexpected, is ACC_SYNTHETIC");
+ return -1;
+ }
+
+ // Test special name expectations
+ if (expect != null) {
+ if (param.matches(expect)) {
+ return 0;
+ }
+ error(prefix + "param[" + index + "]='" + param +
+ "' expected '" + expect + "'");
+ return -1;
+ }
+
+ // No further checking for synthetic methods.
+ if (mSynthetic) {
+ return 0;
+ }
+
+ // Otherwise, do check test parameter naming convention.
+ return 1;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParameters/Constructors.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,41 @@
+/*
+ * 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 8006582
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters Constructors.java
+ * @run main Tester Constructors
+ */
+
+public class Constructors {
+ public Constructors() {}
+ Constructors(final Object a, final String... ba) { }
+ protected Constructors(Object a, final Object ba, final String... cba) { }
+ private Constructors(int a, Object ba, final Object cba, final String... dcba) { }
+}
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParameters/EnumTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,45 @@
+/*
+ * 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 8006582 8008658
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters EnumTest.java
+ * @run main Tester EnumTest
+ */
+
+/** Test that parameter names are recorded for enum methods */
+enum EnumTest {
+ E1(0), E2(1, "x"), E3(2, "x", "y"), E4;
+
+ EnumTest() { }
+ EnumTest(int a, String... ba) { }
+ boolean ok(int c, String... dc) { return true; }
+
+ int valueOf(EnumTest A, EnumTest BA) { return 0; }
+}
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParameters/InstanceMethods.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,46 @@
+/*
+ * 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 8006582
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters InstanceMethods.java
+ * @run main Tester InstanceMethods
+ */
+
+public class InstanceMethods {
+ public void empty() {}
+ final void def(Object a, final Object ba, final String... cba) { }
+ final public void pub(Object d, final Object ed, final String... fed) { }
+ protected boolean prot(Object g, final Object hg, final String... ihg) { return true; }
+ private boolean priv(Object j, final Object kj, final String... lkj) { return true; }
+ void def(int A, Object BA, final Object CBA, final String... DCBA) { }
+ public void pub(int B, Object CB, final Object DCB, final String... EDCB) { }
+ final protected boolean prot(int C, Object DC, final Object EDC, final String... FEDC) { return true; }
+ final private boolean priv(int D, Object ED, final Object FED, final String... GFED) { return true; }
+}
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParameters/LambdaTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,51 @@
+/*
+ * 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 8006582
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters LambdaTest.java
+ * @run main Tester LambdaTest
+ */
+
+/**
+ * Parameter names are not recorded for lambdas. This test verifies
+ * that there are no MethodParameters attribute for lambdas.
+ */
+class LambdaTest {
+
+ interface I {
+ int m(int x);
+ }
+
+ static int foo(I i) { return i.m(0); }
+
+ static {
+ foo((int x1) -> { return foo((int x2) -> { return x1 + x2; }); });
+ }
+}
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParameters/LocalClassTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,50 @@
+/*
+ * 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 8006582 8008658
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters LocalClassTest.java
+ * @run main Tester LocalClassTest
+ */
+
+class LocalClassTest {
+ void foo() {
+ class Local_default_constructor {
+ public void foo() {}
+ public void foo(int m, int nm) {}
+ }
+ class Local_has_constructor {
+ public Local_has_constructor() {}
+ public Local_has_constructor(int a, int ba) {}
+ public void foo() {}
+ public void foo(int m, int nm) {}
+ }
+ new LocalClassTest().foo();
+ }
+}
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParameters/MemberClassTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,86 @@
+/*
+ * 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 8006582 8008658
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters MemberClassTest.java
+ * @run main Tester MemberClassTest
+ */
+
+class MemberClassTest {
+
+ interface I {
+ Long m();
+ Long m(Long x, Long yx);
+ }
+
+ public class Member implements I {
+ public class Member_Member {
+ public Member_Member() {}
+ public Member_Member(String x, String yx) {}
+ }
+
+ public Member() { }
+ public Member(Long a, Long ba) { }
+ public Long m() { return 0L; }
+ public Long m(Long s, Long ts) { return 0L; }
+ }
+
+ static class Static_Member implements I {
+ public class Static_Member_Member {
+ public Static_Member_Member() {}
+ public Static_Member_Member(String x, String yx) {}
+ }
+
+ public static class Static_Member_Static_Member {
+ public Static_Member_Static_Member() {}
+ public Static_Member_Static_Member(String x, String yx) {}
+ }
+ public Static_Member() { }
+ public Static_Member(Long arg, Long barg) { }
+ public Long m() { return 0L; }
+ public Long m(Long s, Long ts) { return s + ts; }
+ }
+
+ public MemberClassTest() {
+ }
+ public MemberClassTest(final Long a, Long ba) {
+ }
+
+ public void foo() {
+
+ new I() {
+
+ class Anonymous_Member {
+ public Anonymous_Member() {}
+ public Anonymous_Member(String x, String yx) {}
+ }
+
+ public Long m() { return 0L; }
+ public Long m(Long s, Long ts) { return s + ts; }
+ }.m();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParameters/ReflectionVisitor.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,270 @@
+/*
+ * 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.
+ */
+
+import java.io.*;
+import java.util.*;
+import java.net.*;
+import java.lang.reflect.*;
+
+/**
+ * Test MethodParameter attributs by reflection API
+ */
+public class ReflectionVisitor extends Tester.Visitor {
+
+ public ReflectionVisitor(Tester tester) {
+ super(tester);
+ }
+
+ public void error(String msg) {
+ super.error("reflection: " + msg);
+ }
+
+ public void warn(String msg) {
+ super.warn("reflection: " + msg);
+ }
+
+ boolean isEnum;
+ boolean isInterface;
+ boolean isAnon;
+ boolean isLocal;
+ boolean isMember;
+ boolean isStatic;
+ boolean isPublic;
+ Class clazz;
+ StringBuilder sb;
+
+ /**
+ * Read class using {@code ClassFile}, and generate a list of methods
+ * with parameter names as available in the MethodParameters attribute.
+ */
+ void visitClass(final String cl, final File cfile, final StringBuilder sb)
+ throws Exception {
+
+ this.sb = sb;
+ clazz = Class.forName(cl);
+ isEnum = clazz.isEnum();
+ isInterface = clazz.isInterface();
+ isAnon = clazz.isAnonymousClass();
+ isLocal = clazz.isLocalClass();
+ isMember = clazz.isMemberClass();
+ isStatic = ((clazz.getModifiers() & Modifier.STATIC) != 0);
+ isPublic = ((clazz.getModifiers() & Modifier.PUBLIC) != 0);
+
+ sb.append(isStatic ? "static " : "")
+ .append(isPublic ? "public " : "")
+ .append(isEnum ? "enum " : isInterface ? "interface " : "class ")
+ .append(cl).append(" -- ")
+ .append(isMember? "member " : "" )
+ .append(isLocal? "local " : "" )
+ .append(isAnon ? "anon" : "")
+ .append("\n");
+
+ for (Constructor c : clazz.getDeclaredConstructors()) {
+ testConstructor(c);
+ }
+
+ for (Method m :clazz.getDeclaredMethods()) {
+
+ testMethod(m);
+ }
+ }
+
+ void testConstructor(Constructor c) {
+
+ String prefix = clazz.getName() + "." + c.getName() + "() - ";
+
+ // Parameters must match parameter types
+ Parameter params[] = c.getParameters();
+ int paramTypes = c.getParameterTypes().length;
+ if (paramTypes != params.length) {
+ error(prefix + "number of parameter types (" + paramTypes
+ + ") != number of parameters (" + params.length + ")");
+ return;
+ }
+
+ sb.append(clazz.getName()).append(".").append("<init>").append("(");
+ String sep = "";
+
+ // Some paramters are expected
+ if (params.length < 2 && isEnum) {
+ error(prefix + "enum constuctor, two arguments expected");
+ } else if (params.length < 1 && (isAnon || isLocal ||
+ (isMember && !isStatic ))) {
+ error(prefix + "class constuctor,expected implicit argument");
+ }
+
+ int i = -1;
+ String param = null;
+ for (Parameter p : c.getParameters()) {
+ i++;
+ String pname = p.getName();
+ sb.append(sep).append(pname);
+ if (p.isImplicit()) sb.append("!");
+ if (p.isSynthetic()) sb.append("!!");
+ sep = ", ";
+
+ // Set expectations
+ String expect = null;
+ boolean allowImplicit = false;
+ boolean allowSynthetic = false;
+ if (isEnum) {
+ if (i == 0) {
+ expect = "\\$enum\\$name";
+ allowSynthetic = true;
+ } else if(i == 1) {
+ expect = "\\$enum\\$ordinal";
+ allowSynthetic = true;
+ }
+ } else if (i == 0) {
+ if (isAnon) {
+ allowImplicit = true;
+ } else if (isLocal) {
+ allowImplicit = true;
+ expect = "this\\$[0-n]*";
+ } else if ((isMember && !isStatic)) {
+ allowImplicit = true;
+ if (!isPublic) {
+ // some but not all non-public inner classes
+ // have synthetic argument. For now we give
+ // the test a bit of slack and allow either.
+ allowSynthetic = true;
+ }
+ expect = "this\\$[0-n]*";
+ }
+ } else if (isAnon) {
+ // not an implementation gurantee, but okay for now
+ expect = "x[0-n]*";
+ }
+
+ // Check expected flags
+ if (p.isSynthetic() && p.isImplicit()) {
+ error(prefix + "param[" + i + "]='" + pname +
+ "' both isImplicit() and isSynthetic()");
+ break;
+ }
+ if (allowImplicit && allowSynthetic &&
+ !(p.isSynthetic() || p.isImplicit())) {
+ error(prefix + "param[" + i + "]='" + pname +
+ "' isImplicit() or isSynthetic() expected");
+ break;
+ }
+
+ if (allowImplicit && !allowSynthetic && !p.isImplicit()) {
+ error(prefix + "param[" + i + "]='" + pname +
+ "' isImplicit() expected");
+ break;
+ }
+ if (!allowImplicit && allowSynthetic && !p.isSynthetic()) {
+ error(prefix + "param[" + i + "]='" + pname +
+ "' isSynthetic() expected");
+ break;
+ }
+
+ if (!allowImplicit && p.isImplicit()) {
+ error(prefix + "param[" + i + "]='" + pname +
+ "' isImplicit() unexpected");
+ break;
+ }
+
+ if (!allowSynthetic && p.isSynthetic()) {
+ error(prefix + "param[" + i + "]='" + pname +
+ "' isSynthetic() unexpected");
+ break;
+ }
+
+ // Check expected names
+ if (expect != null) {
+ if (pname.matches(expect)) continue;
+ error(prefix + "param[" + i + "]='" + pname +
+ "' expected '" + expect + "'");
+ break;
+ }
+
+ // Test naming convention for explicit parameters.
+ boolean fidelity = !isAnon;
+ if (param != null && fidelity) {
+ char ch = param.charAt(0);
+ expect = (++ch) + param;
+ }
+
+ if (pname != null && fidelity) {
+ param = pname;
+ }
+
+ if (expect != null && !expect.equals(pname)) {
+ error(prefix + "param[" + i + "]='" + pname +
+ "' expected '" + expect + "'");
+ break;
+ }
+ }
+ if (c.isSynthetic()) {
+ sb.append(")!!\n");
+ } else {
+ sb.append(")\n");
+ }
+ }
+
+ void testMethod(Method m) {
+
+ String prefix = clazz.getName() + "." + m.getName() + "() - ";
+
+ // Parameters must match parameter types
+ int paramTypes = m.getParameterTypes().length;
+ int params = m.getParameters().length;
+ if (paramTypes != params) {
+ error(prefix + "number of parameter types (" + paramTypes
+ + ") != number of parameters (" + params + ")");
+ return;
+ }
+
+ sb.append(clazz.getName()).append(".").append(m.getName()).append("(");
+ String sep = "";
+ String param = null;
+ int i = -1;
+ // For methods we expect all parameters to follow
+ // the test-case design pattern, except synthetic methods.
+ for (Parameter p : m.getParameters()) {
+ i++;
+ if (param == null) {
+ param = p.getName();
+ sb.append(sep).append(param);
+ } else {
+ char c = param.charAt(0);
+ String expect = m.isSynthetic() ? ("arg" + i) : ((++c) + param);
+ param = p.getName();
+ sb.append(sep).append(param);
+ if (!expect.equals(param)) {
+ error(prefix + "param[" + i + "]='"
+ + param + "' expected '" + expect + "'");
+ break;
+ }
+ }
+ sep = ", ";
+ }
+ if (m.isSynthetic()) {
+ sb.append(")!!\n");
+ } else {
+ sb.append(")\n");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParameters/StaticMethods.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,46 @@
+/*
+ * 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 8006582
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters StaticMethods.java
+ * @run main Tester StaticMethods
+ */
+
+public class StaticMethods {
+ static public void empty() {}
+ static final void def(Object a, final Object ba, final String... cba) { }
+ static final public void pub(Object d, final Object ed, final String... fed) { }
+ static protected boolean prot(Object g, final Object hg, final String... ihg) { return true; }
+ static private boolean priv(Object j, final Object kj, final String... lkj) { return true; }
+ static void def(int a, Object ba, final Object cba, final String... dcba) { }
+ static public void pub(int a, Object ba, final Object cba , final String... dcba) { }
+ static final protected boolean prot(int aa, Object baa, final Object cbaa, final String... dcbaa) { return true; }
+ static final private boolean priv(int abc, Object babc, final Object cbabc, final String... dcbabc) { return true; }
+}
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParameters/Tester.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,162 @@
+/*
+ * 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.
+ */
+
+import java.io.*;
+import java.util.*;
+import java.lang.reflect.Constructor;
+
+/**
+ * Test driver for MethodParameters testing.
+ * <p>
+ * The intended use of this driver is to run it, giving the name of
+ * a single class compiled with -parameters as argument. The driver
+ * will test the specified class, and any nested classes it finds.
+ * <p>
+ * Each class is tested in two way. By refelction, and by directly
+ * checking MethodParameters attributes in the classfile. The checking
+ * is done using two visitor classes {@link ClassFileVisitor} and
+ * {@link ReflectionVisitor}.
+ * <p>
+ * The {@code ReflectionVisitor} test logically belongs with library tests.
+ * we wish to reuse the same test-cases, so both test are committed together,
+ * under langtools. The tests, may be duplicated in the jdk repository.
+ */
+public class Tester {
+
+ final static File classesdir = new File(System.getProperty("test.classes", "."));
+
+ /**
+ * The visitor classes that does the actual checking are referenced
+ * statically, to force compilations, without having to reference
+ * them in individual test cases.
+ * <p>
+ * This makes it easy to change the set of visitors, without
+ * complicating the design with dynamic discovery and compilation
+ * of visitor classes.
+ */
+ static final Class visitors[] = {
+ ClassFileVisitor.class,
+ ReflectionVisitor.class
+ };
+
+ /**
+ * Test-driver expect a single classname as argument.
+ */
+ public static void main(String... args) throws Exception {
+ if (args.length != 1) {
+ throw new Error("A single class name is expected as argument");
+ }
+ final String pattern = args[0] + ".*\\.class";
+ File files[] = classesdir.listFiles(new FileFilter() {
+ public boolean accept(File f) {
+ return f.getName().matches(pattern);
+ }
+ });
+ if (files.length == 0) {
+ File file = new File(classesdir, args[0] + ".class");
+ throw new Error(file.getPath() + " not found");
+ }
+
+ new Tester(args[0], files).run();
+ }
+
+ public Tester(String name, File files[]) {
+ this.classname = name;
+ this.files = files;
+ }
+
+ void run() throws Exception {
+
+ // Test with each visitor
+ for (Class<Visitor> vclass : visitors) {
+ try {
+ String vname = vclass.getName();
+ Constructor c = vclass.getConstructor(Tester.class);
+
+ info("\nRun " + vname + " for " + classname + "\n");
+ StringBuilder sb = new StringBuilder();
+ for (File f : files) {
+ String fname = f.getName();
+ fname = fname.substring(0, fname.length() - 6);
+ Visitor v = (Visitor) c.newInstance(this);
+ try {
+ v.visitClass(fname, f, sb);
+ } catch(Exception e) {
+ error("Uncaught exception in visitClass()");
+ e.printStackTrace();
+ }
+ }
+ info(sb.toString());
+ } catch(ReflectiveOperationException e) {
+ warn("Class " + vclass.getName() + " ignored, not a Visitor");
+ continue;
+ }
+ }
+
+ if(0 != warnings)
+ System.err.println("Test generated " + warnings + " warnings");
+
+ if(0 != errors)
+ throw new Exception("Tester test failed with " +
+ errors + " errors");
+ }
+
+ abstract static class Visitor {
+ Tester tester;
+ File classesdir;
+
+ public Visitor(Tester tester) {
+ this.tester = tester;
+ }
+
+ abstract void visitClass(final String classname, final File cfile,
+ final StringBuilder sb) throws Exception;
+
+ public void error(String msg) {
+ tester.error(msg);
+ }
+
+ public void warn(String msg) {
+ tester.warn(msg);
+ }
+ }
+
+ void error(String msg) {
+ System.err.println("Error: " + msg);
+ errors++;
+ }
+
+ void warn(String msg) {
+ System.err.println("Warning: " + msg);
+ warnings++;
+ }
+
+ void info(String msg) {
+ System.out.println(msg);
+ }
+
+ int errors;
+ int warnings;
+ String classname;
+ File files[];
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParameters/UncommonParamNames.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,68 @@
+/*
+ * 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 8006582
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters UncommonParamNames.java
+ * @run main Tester UncommonParamNames
+ */
+
+/** Test uncommon parameter names */
+class UncommonParamNames {
+ public UncommonParamNames(int _x) { }
+ public UncommonParamNames(short $1) { }
+ public UncommonParamNames(long \u0061) { }
+ public UncommonParamNames(char zero\u0000zero\u0000) { }
+ public UncommonParamNames(String zero\u0000zero\u0000seven\u0007) { }
+ public UncommonParamNames(Object zero\u0000zero\u0000eight\u0008) { }
+ public UncommonParamNames(Object aLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName,
+ Object baLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName,
+ Object cbaLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName) { }
+ public UncommonParamNames(int a, int ba, int cba, int dcba, int edcba, int fedcba, int gfedcba,
+ int hgfedcba, int ihgfedcba, int jihgfedcba, int kjihgfedcba, int lkjihgfedcba,
+ int mlkjihgfedcba, int nmlkjihgfedcba, int onmlkjihgfedcba, int ponmlkjihgfedcba,
+ int qponmlkjihgfedcba, int rqponmlkjihgfedcba, int srqponmlkjihgfedcba,
+ int tsrqponmlkjihgfedcba, int utsrqponmlkjihgfedcba, int vutsrqponmlkjihgfedcba,
+ int wvutsrqponmlkjihgfedcba, int xwvutsrqponmlkjihgfedcba,
+ int yxwvutsrqponmlkjihgfedcba, int zyxwvutsrqponmlkjihgfedcba) { }
+
+ public void foo(int _x) { }
+ public void foo(short $1) { }
+ public void foo(long \u0061) { }
+ public void foo(char zero\u0000zero\u0000) { }
+ public void foo(String zero\u0000zero\u0000seven\u0007) { }
+ public void foo(Object zero\u0000zero\u0000eight\u0008) { }
+ public void foo(Object aLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName,
+ Object baLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName,
+ Object cbaLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName) { }
+ public void foo(int a, int ba, int cba, int dcba, int edcba, int fedcba, int gfedcba,
+ int hgfedcba, int ihgfedcba, int jihgfedcba, int kjihgfedcba, int lkjihgfedcba,
+ int mlkjihgfedcba, int nmlkjihgfedcba, int onmlkjihgfedcba, int ponmlkjihgfedcba,
+ int qponmlkjihgfedcba, int rqponmlkjihgfedcba, int srqponmlkjihgfedcba,
+ int tsrqponmlkjihgfedcba, int utsrqponmlkjihgfedcba, int vutsrqponmlkjihgfedcba,
+ int wvutsrqponmlkjihgfedcba, int xwvutsrqponmlkjihgfedcba,
+ int yxwvutsrqponmlkjihgfedcba, int zyxwvutsrqponmlkjihgfedcba) { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParametersTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,344 @@
+/*
+ * Copyright (c) 2012, 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 8004727
+ * @summary javac should generate method parameters correctly.
+ */
+// key: opt.arg.parameters
+import com.sun.tools.classfile.*;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.main.Main;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
+import java.io.*;
+import javax.lang.model.element.*;
+import java.util.*;
+
+public class MethodParametersTest {
+
+ static final String Foo_name = "Foo";
+ static final String Foo_contents =
+ "public class Foo {\n" +
+ " Foo() {}\n" +
+ " void foo0() {}\n" +
+ " void foo2(int j, int k) {}\n" +
+ "}";
+ static final String Bar_name = "Bar";
+ static final String Bar_contents =
+ "public class Bar {\n" +
+ " Bar(int i) {}" +
+ " Foo foo() { return new Foo(); }\n" +
+ "}";
+ static final String Baz_name = "Baz";
+ static final String Baz_contents =
+ "public class Baz {\n" +
+ " int baz;" +
+ " Baz(int i) {}" +
+ "}";
+ static final String Qux_name = "Qux";
+ static final String Qux_contents =
+ "public class Qux extends Baz {\n" +
+ " Qux(int i) { super(i); }" +
+ "}";
+ static final File classesdir = new File("methodparameters");
+
+ public static void main(String... args) throws Exception {
+ new MethodParametersTest().run();
+ }
+
+ void run() throws Exception {
+ classesdir.mkdir();
+ final File Foo_java =
+ writeFile(classesdir, Foo_name + ".java", Foo_contents);
+ final File Bar_java =
+ writeFile(classesdir, Bar_name + ".java", Bar_contents);
+ final File Baz_java =
+ writeFile(classesdir, Baz_name + ".java", Baz_contents);
+ System.err.println("Test compile with -parameter");
+ compile("-parameters", "-d", classesdir.getPath(), Foo_java.getPath());
+ // First test: make sure javac doesn't choke to death on
+ // MethodParameter attributes
+ System.err.println("Test compile with classfile containing MethodParameter attributes");
+ compile("-parameters", "-d", classesdir.getPath(),
+ "-cp", classesdir.getPath(), Bar_java.getPath());
+ System.err.println("Examine class foo");
+ checkFoo();
+ checkBar();
+ System.err.println("Test debug information conflict");
+ compile("-g", "-parameters", "-d", classesdir.getPath(),
+ "-cp", classesdir.getPath(), Baz_java.getPath());
+ System.err.println("Introducing debug information conflict");
+ Baz_java.delete();
+ modifyBaz(false);
+ System.err.println("Checking language model");
+ inspectBaz();
+ System.err.println("Permuting attributes");
+ modifyBaz(true);
+ System.err.println("Checking language model");
+ inspectBaz();
+
+ if(0 != errors)
+ throw new Exception("MethodParameters test failed with " +
+ errors + " errors");
+ }
+
+ void inspectBaz() throws Exception {
+ final File Qux_java =
+ writeFile(classesdir, Qux_name + ".java", Qux_contents);
+ final String[] args = { "-XDsave-parameter-names", "-d",
+ classesdir.getPath(),
+ "-cp", classesdir.getPath(),
+ Qux_java.getPath() };
+ final StringWriter sw = new StringWriter();
+ final PrintWriter pw = new PrintWriter(sw);
+
+ // We need to be able to crack open javac and look at its data
+ // structures. We'll rig up a compiler instance, but keep its
+ // Context, thus allowing us to get at the ClassReader.
+ Context context = new Context();
+ Main comp = new Main("javac", pw);
+ JavacFileManager.preRegister(context);
+
+ // Compile Qux, which uses Baz.
+ comp.compile(args, context);
+ pw.close();
+ final String out = sw.toString();
+ if (out.length() > 0)
+ System.err.println(out);
+
+ // Now get the class reader, construct a name for Baz, and load it.
+ com.sun.tools.javac.jvm.ClassReader cr =
+ com.sun.tools.javac.jvm.ClassReader.instance(context);
+ Name name = Names.instance(context).fromString(Baz_name);
+
+ // Now walk down the language model and check the name of the
+ // parameter.
+ final Element baz = cr.loadClass(name);
+ for (Element e : baz.getEnclosedElements()) {
+ if (e instanceof ExecutableElement) {
+ final ExecutableElement ee = (ExecutableElement) e;
+ final List<? extends VariableElement> params =
+ ee.getParameters();
+ if (1 != params.size())
+ throw new Exception("Classfile Baz badly formed: wrong number of methods");
+ final VariableElement param = params.get(0);
+ if (!param.getSimpleName().contentEquals("baz")) {
+ errors++;
+ System.err.println("javac did not correctly resolve the metadata conflict, parameter's name reads as " + param.getSimpleName());
+ } else
+ System.err.println("javac did correctly resolve the metadata conflict");
+ }
+ }
+ }
+
+ void modifyBaz(boolean flip) throws Exception {
+ final File Baz_class = new File(classesdir, Baz_name + ".class");
+ final ClassFile baz = ClassFile.read(Baz_class);
+ final int ind = baz.constant_pool.getUTF8Index("baz");
+ MethodParameters_attribute mpattr = null;
+ int mpind = 0;
+ Code_attribute cattr = null;
+ int cind = 0;
+
+ // Find the indexes of the MethodParameters and the Code attributes
+ if (baz.methods.length != 1)
+ throw new Exception("Classfile Baz badly formed: wrong number of methods");
+ if (!baz.methods[0].getName(baz.constant_pool).equals("<init>"))
+ throw new Exception("Classfile Baz badly formed: method has name " +
+ baz.methods[0].getName(baz.constant_pool));
+ for (int i = 0; i < baz.methods[0].attributes.attrs.length; i++) {
+ if (baz.methods[0].attributes.attrs[i] instanceof
+ MethodParameters_attribute) {
+ mpattr = (MethodParameters_attribute)
+ baz.methods[0].attributes.attrs[i];
+ mpind = i;
+ } else if (baz.methods[0].attributes.attrs[i] instanceof
+ Code_attribute) {
+ cattr = (Code_attribute) baz.methods[0].attributes.attrs[i];
+ cind = i;
+ }
+ }
+ if (null == mpattr)
+ throw new Exception("Classfile Baz badly formed: no method parameters info");
+ if (null == cattr)
+ throw new Exception("Classfile Baz badly formed: no local variable table");
+
+ int flags = mpattr.method_parameter_table[0].flags;
+
+ // Alter the MethodParameters attribute, changing the name of
+ // the parameter from i to baz. This requires Black Magic...
+ //
+ // The (well-designed) classfile library (correctly) does not
+ // allow us to mess around with the attribute data structures,
+ // or arbitrarily generate new ones.
+ //
+ // Instead, we install a new subclass of Attribute that
+ // hijacks the Visitor pattern and outputs the sequence of
+ // bytes that we want. This only works in this particular
+ // instance, because we know we'll only every see one kind of
+ // visitor.
+ //
+ // If anyone ever changes the makeup of the Baz class, or
+ // tries to install some kind of visitor that gets run prior
+ // to serialization, this will break.
+ baz.methods[0].attributes.attrs[mpind] =
+ new Attribute(mpattr.attribute_name_index,
+ mpattr.attribute_length) {
+ public <R, D> R accept(Visitor<R, D> visitor, D data) {
+ if (data instanceof ByteArrayOutputStream) {
+ ByteArrayOutputStream out =
+ (ByteArrayOutputStream) data;
+ out.write(1);
+ out.write((ind >> 8) & 0xff);
+ out.write(ind & 0xff);
+ out.write((flags >> 24) & 0xff);
+ out.write((flags >> 16) & 0xff);
+ out.write((flags >> 8) & 0xff);
+ out.write(flags & 0xff);
+ } else
+ throw new RuntimeException("Output stream is of type " + data.getClass() + ", which is not handled by this test. Update the test and it should work.");
+ return null;
+ }
+ };
+
+ // Flip the code and method attributes. This is for checking
+ // that order doesn't matter.
+ if (flip) {
+ baz.methods[0].attributes.attrs[mpind] = cattr;
+ baz.methods[0].attributes.attrs[cind] = mpattr;
+ }
+
+ new ClassWriter().write(baz, Baz_class);
+ }
+
+ // Run a bunch of structural tests on foo to make sure it looks right.
+ void checkFoo() throws Exception {
+ final File Foo_class = new File(classesdir, Foo_name + ".class");
+ final ClassFile foo = ClassFile.read(Foo_class);
+ for (int i = 0; i < foo.methods.length; i++) {
+ System.err.println("Examine method Foo." + foo.methods[i].getName(foo.constant_pool));
+ if (foo.methods[i].getName(foo.constant_pool).equals("foo2")) {
+ for (int j = 0; j < foo.methods[i].attributes.attrs.length; j++)
+ if (foo.methods[i].attributes.attrs[j] instanceof
+ MethodParameters_attribute) {
+ MethodParameters_attribute mp =
+ (MethodParameters_attribute)
+ foo.methods[i].attributes.attrs[j];
+ System.err.println("Foo.foo2 should have 2 parameters: j and k");
+ if (2 != mp.method_parameter_table_length)
+ error("expected 2 method parameter entries in foo2, got " +
+ mp.method_parameter_table_length);
+ else if (!foo.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index).equals("j"))
+ error("expected first parameter to foo2 to be \"j\", got \"" +
+ foo.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index) +
+ "\" instead");
+ else if (!foo.constant_pool.getUTF8Value(mp.method_parameter_table[1].name_index).equals("k"))
+ error("expected first parameter to foo2 to be \"k\", got \"" +
+ foo.constant_pool.getUTF8Value(mp.method_parameter_table[1].name_index) +
+ "\" instead");
+ }
+ }
+ else if (foo.methods[i].getName(foo.constant_pool).equals("<init>")) {
+ for (int j = 0; j < foo.methods[i].attributes.attrs.length; j++) {
+ if (foo.methods[i].attributes.attrs[j] instanceof
+ MethodParameters_attribute)
+ error("Zero-argument constructor shouldn't have MethodParameters");
+ }
+ }
+ else if (foo.methods[i].getName(foo.constant_pool).equals("foo0")) {
+ for (int j = 0; j < foo.methods[i].attributes.attrs.length; j++)
+ if (foo.methods[i].attributes.attrs[j] instanceof
+ MethodParameters_attribute)
+ error("Zero-argument method shouldn't have MethodParameters");
+ }
+ else
+ error("Unknown method " + foo.methods[i].getName(foo.constant_pool) + " showed up in class Foo");
+ }
+ }
+
+ // Run a bunch of structural tests on Bar to make sure it looks right.
+ void checkBar() throws Exception {
+ final File Bar_class = new File(classesdir, Bar_name + ".class");
+ final ClassFile bar = ClassFile.read(Bar_class);
+ for (int i = 0; i < bar.methods.length; i++) {
+ System.err.println("Examine method Bar." + bar.methods[i].getName(bar.constant_pool));
+ if (bar.methods[i].getName(bar.constant_pool).equals("<init>")) {
+ for (int j = 0; j < bar.methods[i].attributes.attrs.length; j++)
+ if (bar.methods[i].attributes.attrs[j] instanceof
+ MethodParameters_attribute) {
+ MethodParameters_attribute mp =
+ (MethodParameters_attribute)
+ bar.methods[i].attributes.attrs[j];
+ System.err.println("Bar constructor should have 1 parameter: i");
+ if (1 != mp.method_parameter_table_length)
+ error("expected 1 method parameter entries in constructor, got " +
+ mp.method_parameter_table_length);
+ else if (!bar.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index).equals("i"))
+ error("expected first parameter to foo2 to be \"i\", got \"" +
+ bar.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index) +
+ "\" instead");
+ }
+ }
+ else if (bar.methods[i].getName(bar.constant_pool).equals("foo")) {
+ for (int j = 0; j < bar.methods[i].attributes.attrs.length; j++) {
+ if (bar.methods[i].attributes.attrs[j] instanceof
+ MethodParameters_attribute)
+ error("Zero-argument constructor shouldn't have MethodParameters");
+ }
+ }
+ }
+ }
+
+ String compile(String... args) throws Exception {
+ System.err.println("compile: " + Arrays.asList(args));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ int rc = com.sun.tools.javac.Main.compile(args, pw);
+ pw.close();
+ String out = sw.toString();
+ if (out.length() > 0)
+ System.err.println(out);
+ if (rc != 0)
+ error("compilation failed, rc=" + rc);
+ return out;
+ }
+
+ File writeFile(File dir, String path, String body) throws IOException {
+ File f = new File(dir, path);
+ f.getParentFile().mkdirs();
+ FileWriter out = new FileWriter(f);
+ out.write(body);
+ out.close();
+ return f;
+ }
+
+ void error(String msg) {
+ System.err.println("Error: " + msg);
+ errors++;
+ }
+
+ int errors;
+}
--- a/langtools/test/tools/javac/MissingInclude.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2001, 2002, 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 4509051 4785453
- * @summary javac <AT>sourcefiles should catch Exception, when sourcefiles doesn't exist.
- * @author gafter
- *
- * @run shell MissingInclude.sh
- */
-
-class MissingInclude {}
--- a/langtools/test/tools/javac/MissingInclude.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2001, 2009, 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.
-#
-
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin | CYGWIN* )
- FS="/"
- ;;
- Windows* )
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-TMP1=OUTPUT.txt
-
-cp "${TESTSRC}${FS}MissingInclude.java" .
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} @/nonexistent_file MissingInclude.java 2> ${TMP1}
-result=$?
-cat ${TMP1}
-rm ${TMP1}
-
-if [ $result -eq 0 ]
-then
- echo "Failed"
- exit 1
-else
- echo "Passed"
- exit 0
-fi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MissingInclude/MissingIncludeTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,50 @@
+/*
+ * 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 4509051 4785453
+ * @summary javac <AT>sourcefiles should catch Exception, when sourcefiles
+ * doesn't exist.
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main MissingIncludeTest
+ */
+
+//original test: test/tools/javac/MissingInclude.sh
+public class MissingIncludeTest {
+
+ private static final String MissingIncludeSrc =
+ "class MissingInclude {}";
+
+ public static void main(String[] args) throws Exception {
+ ToolBox.createJavaFileFromSource(MissingIncludeSrc);
+
+// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} @/nonexistent_file MissingInclude.java 2> ${TMP1}
+ ToolBox.JavaToolArgs params =
+ new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
+ .setAllArgs("@/nonexistent_file", "MissingInclude.java");
+ ToolBox.javac(params);
+ }
+
+}
--- a/langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-#
-# Copyright (c) 1998, 2012, 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 4087314 4800342
-# @summary Verify allowed access to protected class from another package.
-# @author William Maddox (maddox)
-#
-# @run shell ProtectedInnerClass.sh
-
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin )
- PS=":"
- FS="/"
- ;;
- CYGWIN* )
- PS=";" # native PS, not Cygwin PS
- FS="/"
- ;;
- Windows* )
- PS=";"
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-rm -f ${TESTCLASSES}${FS}p1${FS}*.class ${TESTCLASSES}${FS}p2${FS}*.class
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TESTCLASSES}" "${TESTSRC}${FS}p1${FS}ProtectedInnerClass1.java" "${TESTSRC}${FS}p2${FS}ProtectedInnerClass2.java"
-"${TESTJAVA}${FS}bin${FS}java" ${TESTVMOPTS} -classpath "${CLASSPATH}${PS}${TESTCLASSES}" p2.ProtectedInnerClass2
-result=$?
-if [ $result -eq 0 ]
-then
- echo "Passed"
-else
- echo "Failed"
-fi
-exit $result
--- a/langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass_2.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2000, 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 4307565
- * @summary Verify that access to inaccessable protected inner class is rejected.
- * @author William Maddox (maddox)
- *
- * @run compile p1/ProtectedInnerClass1.java
- * @run compile/fail p2/ProtectedInnerClass3.java
- */
-class Dummy {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClassesTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,115 @@
+/*
+ * 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 4087314 4800342 4307565
+ * @summary Verify allowed access to protected class from another package
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main ProtectedInnerClassesTest
+ */
+
+//original tests: test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh
+//and test/tools/javac/ProtectedInnerClass/ProtectedInnerClass_2.java
+public class ProtectedInnerClassesTest {
+
+ private static final String protectedInnerClass1Src =
+ "package p1;\n" +
+ "\n" +
+ "public class ProtectedInnerClass1 {\n" +
+ " protected class Foo {\n" +
+ " public String getBar() { return \"bar\"; }\n" +
+ " }\n" +
+ "}";
+
+ private static final String protectedInnerClass2Src =
+ "package p2;\n" +
+ "\n" +
+ "public class ProtectedInnerClass2 extends p1.ProtectedInnerClass1\n" +
+ "{\n" +
+ " class Bug extends Foo {\n" +
+ " String getBug() { return getBar(); }\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(String[] args) {\n" +
+ " ProtectedInnerClass2 x = new ProtectedInnerClass2();\n" +
+ " Bug y = x.new Bug();\n" +
+ " System.out.println(y.getBug());\n" +
+ " }\n" +
+ "}";
+
+ private static final String protectedInnerClass3Src =
+ "package p2;\n" +
+ "\n" +
+ "public class ProtectedInnerClass3 {\n" +
+ "\n" +
+ " void test() {\n" +
+ " p1.ProtectedInnerClass1.Foo x;\n" +
+ " }\n" +
+ "\n" +
+ "}";
+
+ public static void main(String args[]) throws Exception {
+ new ProtectedInnerClassesTest().run();
+ }
+
+ void run() throws Exception {
+ compileAndExecute();
+ compileOnly();
+ }
+
+ void compileAndExecute() throws Exception {
+//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TESTCLASSES}" "${TESTSRC}${FS}p1${FS}ProtectedInnerClass1.java" "${TESTSRC}${FS}p2${FS}ProtectedInnerClass2.java"
+ ToolBox.JavaToolArgs javacParams =
+ new ToolBox.JavaToolArgs()
+ .setOptions("-d", ".")
+ .setSources(protectedInnerClass1Src, protectedInnerClass2Src);
+
+ ToolBox.javac(javacParams);
+
+//"${TESTJAVA}${FS}bin${FS}java" ${TESTVMOPTS} -classpath "${CLASSPATH}${PS}${TESTCLASSES}" p2.ProtectedInnerClass2
+ ToolBox.AnyToolArgs javaParams =
+ new ToolBox.AnyToolArgs()
+ .setAllArgs(ToolBox.javaBinary, "-classpath", System.getProperty("user.dir"),
+ "p2.ProtectedInnerClass2");
+ ToolBox.executeCommand(javaParams);
+ }
+
+//from test/tools/javac/ProtectedInnerClass/ProtectedInnerClass_2.java
+ void compileOnly() throws Exception {
+//@run compile p1/ProtectedInnerClass1.java
+ ToolBox.JavaToolArgs javacParams =
+ new ToolBox.JavaToolArgs()
+ .setOptions("-d", ".")
+ .setSources(protectedInnerClass1Src);
+
+ ToolBox.javac(javacParams);
+
+//@run compile/fail p2/ProtectedInnerClass3.java
+ javacParams.setSources(protectedInnerClass3Src)
+ .set(ToolBox.Expect.FAIL);
+ ToolBox.javac(javacParams);
+ }
+
+}
--- a/langtools/test/tools/javac/ProtectedInnerClass/p1/ProtectedInnerClass1.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 1997, 2000, 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.
- */
-
-/*
- * Auxiliary file for test for 4087314.
- * Verify allowed access to protected class from another package.
- * This file must be compiled prior to compiling p2.ProtectedInnerClass2.
- * It is that compilation that will either succeed or fail.
- */
-
-package p1;
-
-public class ProtectedInnerClass1 {
- protected class Foo {
- public String getBar() { return "bar"; }
- }
-}
--- a/langtools/test/tools/javac/ProtectedInnerClass/p2/ProtectedInnerClass2.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 1997, 2000, 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.
- */
-
-/*
- * Auxiliary file for test for 4087314.
- * Verify allowed access to protected class from another package.
- *
- * This file should compile and run successfully.
- * Note that class p1.ProtectedInnerClass1 must be compiled first.
- */
-
-package p2;
-
-public class ProtectedInnerClass2 extends p1.ProtectedInnerClass1
-{
- class Bug extends Foo {
- String getBug() { return getBar(); }
- }
-
- public static void main(String[] args) {
- ProtectedInnerClass2 x = new ProtectedInnerClass2();
- Bug y = x.new Bug();
- System.out.println(y.getBug());
- }
-}
--- a/langtools/test/tools/javac/ProtectedInnerClass/p2/ProtectedInnerClass3.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2000, 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.
- */
-
-/*
- * Auxiliary file for ProtectedInnerClass_2.java (bugid 4307565)
- */
-
-package p2;
-
-public class ProtectedInnerClass3 {
-
- void test() {
- p1.ProtectedInnerClass1.Foo x;
- }
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T5090006/AssertionFailureTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,69 @@
+/*
+ * 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 5090006
+ * @summary javac fails with assertion error
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main AssertionFailureTest
+ */
+
+import java.io.File;
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/T5090006/compiler.sh
+public class AssertionFailureTest {
+
+ private static final String testSrc =
+ "import stub_tie_gen.wsdl_hello_lit.client.*;\n" +
+ "import junit.framework.*;\n" +
+ "import testutil.ClientServerTestUtil;\n" +
+ "\n" +
+ "public class Test {\n" +
+ "\n" +
+ " void getStub() throws Exception {\n" +
+ " Hello_PortType_Stub x = null;\n" +
+ " new ClientServerTestUtil().setTransport(x, null, null, null);\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(\"FISK\");\n" +
+ " }\n" +
+ "}";
+
+ public static void main(String args[]) throws Exception {
+ String classpath = Paths.get(System.getProperty("test.src"), "broken.jar")
+ .toString();
+ classpath = new StringBuilder(classpath)
+ .append(File.pathSeparator).append(".").toString();
+// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -verbose -d "${TESTCLASSES}" -cp "${TESTSRC}${FS}broken.jar" "${TESTSRC}${FS}$1"
+ ToolBox.JavaToolArgs params =
+ new ToolBox.JavaToolArgs()
+ .setOptions("-cp", classpath)
+ .setSources(testSrc);
+ ToolBox.javac(params);
+ }
+
+}
--- a/langtools/test/tools/javac/T5090006/T5090006.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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 5090006
- * @summary javac fails with assertion error
- * @author Peter von der Ah\u00e9
- * @run shell compiler.sh T5090006.java
- * @run main T5090006
- */
-
-import stub_tie_gen.wsdl_hello_lit.client.*;
-import junit.framework.*;
-import testutil.ClientServerTestUtil;
-
-public class T5090006 {
-
- void getStub() throws Exception {
- Hello_PortType_Stub x = null;
- new ClientServerTestUtil().setTransport(x, null, null, null);
- }
-
- public static void main(String[] args) {
- System.out.println("FISK");
- }
-}
--- a/langtools/test/tools/javac/T5090006/compiler.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2009, 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.
-#
-
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin | CYGWIN* )
- FS="/"
- ;;
- Windows* )
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -verbose -d "${TESTCLASSES}" -cp "${TESTSRC}${FS}broken.jar" "${TESTSRC}${FS}$1"
-
-result=$?
-
-if [ $result -eq 0 ]
-then
- echo "Passed"
-else
- echo "Failed"
-fi
-exit $result
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T6181889/EmptyFinallyTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,67 @@
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.file.Paths;
+
+/*
+ * 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 6181889
+ * @summary Empty try/finally results in bytecodes being generated
+ */
+
+public class EmptyFinallyTest {
+ private static final String assertionErrorMsg =
+ "No \"Exception table\" should be generated in this case";
+
+ public static void main(String[] args) {
+ new EmptyFinallyTest().run();
+ }
+
+ void run() {
+ check("-c", Paths.get(System.getProperty("test.classes"),
+ "EmptyFinally.class").toString());
+ }
+
+ void check(String... params) {
+ StringWriter s;
+ String out;
+ try (PrintWriter pw = new PrintWriter(s = new StringWriter())) {
+ com.sun.tools.javap.Main.run(params, pw);
+ out = s.toString();
+ }
+ if (out.contains("Exception table")) {
+ throw new AssertionError(assertionErrorMsg);
+ }
+ }
+}
+
+class EmptyFinally {
+ void m() {
+ try {
+ System.out.println("EMPTY TRY!");
+ } finally {}
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8004969.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,103 @@
+/*
+ * 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 8004969
+@summary Lambda deserialization
+
+*/
+
+import java.io.*;
+
+public class T8004969 implements Serializable {
+
+ static int assertionCount = 0;
+
+ static void assertTrue(boolean cond) {
+ assertionCount++;
+ if (!cond)
+ throw new AssertionError();
+ }
+
+ static String mm(String s) { return "mref" + s; }
+
+ String aField = "aF";
+
+ public static void main(String[] args) throws Exception {
+ (new T8004969()).doit();
+ }
+
+ public void doit() throws Exception {
+ String aLocal = "aL";
+ int anInt = 99;
+
+ try {
+ // Write lambdas out
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutput out = new ObjectOutputStream(baos);
+
+ write(out, z -> "[" + z + "]" );
+ write(out, z -> { String x = z + z; return x + x; } );
+ write(out, T8004969::mm );
+ write(out, z -> (new LSI() { public String convert(String x) { return "*"+x; }} ).convert(z) );
+ write(out, z -> aField + z );
+ write(out, z -> aLocal + z );
+ write(out, z -> z + anInt );
+ out.flush();
+ out.close();
+
+ // Read them back
+ ByteArrayInputStream bais =
+ new ByteArrayInputStream(baos.toByteArray());
+ ObjectInputStream in = new ObjectInputStream(bais);
+ readAssert(in, "[X]");
+ readAssert(in, "XXXX");
+ readAssert(in, "mrefX");
+ readAssert(in, "*X");
+ readAssert(in, "aFX");
+ readAssert(in, "aLX");
+ readAssert(in, "X99");
+ in.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw e;
+ }
+ assertTrue(assertionCount == 7);
+ }
+
+ static void write(ObjectOutput out, LSI lamb) throws IOException {
+ out.writeObject(lamb);
+ }
+
+ static void readAssert(ObjectInputStream in, String expected) throws IOException, ClassNotFoundException {
+ LSI ls = (LSI) in.readObject();
+ String result = ls.convert("X");
+ System.out.printf("Result: %s\n", result);
+ assertTrue(result.equals(expected));
+ }
+}
+
+interface LSI extends Serializable {
+ String convert(String x);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/DuplicateErrors.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,37 @@
+/*
+ * 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 7196531
+ * @compile/fail/ref=DuplicateErrors.out -XDrawDiagnostics DuplicateErrors.java
+ */
+
+
+@interface Foo {}
+
+@Foo
+@Foo
+@Foo
+public class DuplicateErrors {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/DuplicateErrors.out Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,3 @@
+DuplicateErrors.java:34:1: compiler.err.duplicate.annotation.missing.container: Foo, java.lang.annotation.Repeatable
+DuplicateErrors.java:35:1: compiler.err.duplicate.annotation.missing.container: Foo, java.lang.annotation.Repeatable
+2 errors
--- a/langtools/test/tools/javac/annotations/repeatingAnnotations/MissingContainer.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/MissingContainer.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,6 +1,6 @@
/**
* @test /nodynamiccopyright/
- * @bug 7169362
+ * @bug 7169362 8001114
* @author sogoel
* @summary ContainerAnnotation does not have FooContainer.class specified
* @compile/fail/ref=MissingContainer.out -XDrawDiagnostics MissingContainer.java
--- a/langtools/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,6 +1,6 @@
/**
* @test /nodynamiccopyright/
- * @bug 7169362
+ * @bug 7169362 8001114
* @author sogoel
* @summary Default case not specified for other methods in container annotation
* @compile/fail/ref=MissingDefaultCase1.out -XDrawDiagnostics MissingDefaultCase1.java
--- a/langtools/test/tools/javac/annotations/repeatingAnnotations/NoRepeatableAnno.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/NoRepeatableAnno.out Tue Mar 12 16:43:53 2013 -0700
@@ -1,3 +1,2 @@
-NoRepeatableAnno.java:11:1: compiler.err.duplicate.annotation.missing.container: Foo, java.lang.annotation.Repeatable
NoRepeatableAnno.java:11:6: compiler.err.duplicate.annotation.missing.container: Foo, java.lang.annotation.Repeatable
-2 errors
+1 error
--- a/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java Tue Mar 12 16:43:53 2013 -0700
@@ -21,40 +21,51 @@
* questions.
*/
+import java.io.File;
+import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
+import java.util.Iterator;
+
+import javax.tools.Diagnostic;
import javax.tools.DiagnosticCollector;
import javax.tools.JavaCompiler;
+import javax.tools.JavaCompiler.CompilationTask;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
import javax.tools.ToolProvider;
-import javax.tools.JavaCompiler.CompilationTask;
+
+import com.sun.source.util.JavacTask;
public class Helper {
enum ContentVars {
+
IMPORTCONTAINERSTMTS("\nimport java.lang.annotation.Repeatable;\n"),
IMPORTDEPRECATED("import java.lang.Deprecated;\n"),
IMPORTDOCUMENTED("import java.lang.annotation.Documented;\n"),
IMPORTINHERITED("import java.lang.annotation.Inherited;\n"),
- IMPORTRETENTION("import java.lang.annotation.Retention;\n" +
- "\nimport java.lang.annotation.RetentionPolicy;\n"),
+ IMPORTRETENTION("import java.lang.annotation.Retention;\n"
+ + "\nimport java.lang.annotation.RetentionPolicy;\n"),
IMPORTSTMTS("import java.lang.annotation.*;\n"),
+ IMPORTEXPECTED("import expectedFiles.*;\n"),
REPEATABLE("\n@Repeatable(FooContainer.class)\n"),
- CONTAINER("@interface FooContainer {\n" +" Foo[] value();\n}\n"),
+ CONTAINER("@interface FooContainer {\n" + " Foo[] value();\n}\n"),
BASE("@interface Foo {}\n"),
BASEANNO("@Foo"),
+ LEGACYCONTAINER("@FooContainer(value = {@Foo, @Foo})\n"),
REPEATABLEANNO("\n@Foo() @Foo()"),
DEPRECATED("\n@Deprecated"),
DOCUMENTED("\n@Documented"),
INHERITED("\n@Inherited"),
+ TARGET("\n@Target(#VAL)\n"),
RETENTION("@Retention(RetentionPolicy.#VAL)\n"),
- TARGET("\n@Target(#VAL)\n");
-
+ RETENTIONRUNTIME("@Retention(RetentionPolicy.RUNTIME)\n");
private String val;
-
private ContentVars(String val) {
this.val = val;
}
@@ -64,49 +75,6 @@
}
}
- /* String template where /*<TYPE>*/ /*gets replaced by repeating anno
- * Used to generate test src for combo tests
- * - BasicSyntaxCombo.java
- * - TargetAnnoCombo.java
- */
- public static final String template =
- "/*PACKAGE*/\n" +
- "//pkg test;\n\n" +
- "/*ANNODATA*/\n" + // import statements, declaration of Foo/FooContainer
- "/*TYPE*/ //class\n" +
- "class #ClassName {\n" +
- " /*FIELD*/ //instance var\n" +
- " public int x = 0;\n\n" +
- " /*FIELD*/ //Enum constants\n" +
- " TestEnum testEnum;\n\n" +
- " /*FIELD*/ // Static field\n" +
- " public static int num;\n\n" +
- " /*STATIC_INI*/\n" +
- " static { \n" + "num = 10; \n }\n\n" +
- " /*CONSTRUCTOR*/\n" +
- " #ClassName() {}\n\n" +
- " /*INSTANCE_INI*/\n" +
- " { \n x = 10; \n }" +
- " /*INNER_CLASS*/\n" +
- " class innerClass {}\n" +
- " /*METHOD*/\n" +
- " void bar(/*PARAMETER*/ int baz) {\n" +
- " /*LOCAL_VARIABLE*/\n" +
- " int y = 0;\n" +
- " }\n" +
- "}\n\n" +
- "/*TYPE*/ //Enum\n" +
- "enum TestEnum {}\n\n" +
- "/*TYPE*/ //Interface\n" +
- "interface TestInterface {}\n\n" +
- "/*TYPE*/\n" +
- "/*ANNOTATION_TYPE*/\n" +
- "@interface TestAnnotationType{}\n" +
- "class TestPkg {}\n" +
- "class TestTypeAnno </*TYPE_PARAMETER*/ T extends Object> {\n" +
- " String /*TYPE_USE*/[] arr;\n" +
- "}";
-
// Create and compile FileObject using values for className and contents
public static boolean compileCode(String className, String contents,
DiagnosticCollector<JavaFileObject> diagnostics) {
@@ -122,21 +90,96 @@
CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, compilationUnit);
ok = task.call();
return ok;
-
}
+ // Compile a list of FileObjects
+ // Used when packages are needed and classes need to be loaded at runtime
+ static File destDir = new File(System.getProperty("user.dir"));
- // Compile a list of FileObjects
public static boolean compileCode(DiagnosticCollector<JavaFileObject> diagnostics, Iterable<? extends JavaFileObject> files) {
+ boolean ok = false;
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
if (compiler == null) {
throw new RuntimeException("can't get javax.tools.JavaCompiler!");
}
- CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, files);
- boolean ok = task.call();
+ StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
+
+ // Assuming filesCount can maximum be 2 and if true, one file is package-info.java
+ if (isPkgInfoPresent(files)) {
+ JavacTask task = (JavacTask) compiler.getTask(null, fm, diagnostics, null, null, files);
+ try {
+ fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir));
+ task.generate();
+ } catch (IOException ioe) {
+ throw new RuntimeException("Compilation failed for package level tests", ioe);
+ }
+ int err = 0;
+ for (Diagnostic<? extends JavaFileObject> d : diagnostics.getDiagnostics()) {
+ if(d.getKind() == Diagnostic.Kind.ERROR) {
+ err++;
+ }
+ }
+ ok = (err == 0);
+ } else {
+ CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, files);
+ ok = task.call();
+ }
return ok;
}
+ static private boolean isPkgInfoPresent(Iterable<? extends JavaFileObject> files) {
+ Iterator<? extends JavaFileObject> itr = files.iterator();
+ while (itr.hasNext()) {
+ String name = itr.next().getName();
+ if (name.contains("package-info")) {
+ return true;
+ }
+ }
+ return false;
+ }
+ /* String template where /*<TYPE>*/ /*gets replaced by repeating anno
+ * Used to generate test src for combo tests
+ * - BasicSyntaxCombo.java
+ * - TargetAnnoCombo.java
+ */
+
+ public static final String template =
+ "/*PACKAGE*/\n"
+ + "//pkg test;\n\n"
+ + "/*TYPE*/ //class\n"
+ + "class #ClassName {\n"
+ + " /*FIELD*/ //instance var\n"
+ + " public int x = 0;\n\n"
+ + " /*FIELD*/ //Enum constants\n"
+ + " TestEnum testEnum;\n\n"
+ + " /*FIELD*/ // Static field\n"
+ + " public static int num;\n\n"
+ + " /*STATIC_INI*/\n"
+ + " static { \n" + "num = 10; \n }\n\n"
+ + " /*CONSTRUCTOR*/\n"
+ + " #ClassName() {}\n\n"
+ + " /*INSTANCE_INI*/\n"
+ + " { \n x = 10; \n }"
+ + " /*INNER_CLASS*/\n"
+ + " class innerClass {}\n"
+ + " /*METHOD*/\n"
+ + " void bar(/*PARAMETER*/ int baz) {\n"
+ + " /*LOCAL_VARIABLE*/\n"
+ + " int y = 0;\n"
+ + " }\n"
+ + "}\n\n"
+ + "/*TYPE*/ //Enum\n"
+ + "enum TestEnum {}\n\n"
+ + "/*TYPE*/ //Interface\n"
+ + "interface TestInterface {}\n\n"
+ + "/*TYPE*/\n"
+ + "/*ANNOTATION_TYPE*/\n"
+ + "@interface TestAnnotationType{}\n"
+ + "class TestPkg {}\n"
+ + "class TestTypeAnno </*TYPE_PARAMETER*/ T extends Object> {\n"
+ + " String /*TYPE_USE*/[] arr;\n"
+ + "}";
+
static JavaFileObject getFile(String name, String code) {
JavaFileObject o = null;
try {
@@ -146,16 +189,19 @@
}
return o;
}
+
static class JavaStringFileObject extends SimpleJavaFileObject {
+
final String theCode;
+
public JavaStringFileObject(String fileName, String theCode) throws URISyntaxException {
- super(new URI("string:///" + fileName.replace('.','/') + ".java"), Kind.SOURCE);
+ super(new URI("string:///" + fileName.replace('.', '/') + ".java"), Kind.SOURCE);
this.theCode = theCode;
}
+
@Override
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
return theCode;
}
}
}
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/ReflectionTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,2932 @@
+/*
+ * 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 8001457
+ * @author sogoel
+ * @summary Reflection api tests
+ * @build Helper
+ * @compile expectedFiles/ExpectedBase.java expectedFiles/ExpectedContainer.java
+ * @run main ReflectionTest
+ */
+import java.io.File;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaFileObject;
+
+import expectedFiles.ExpectedBase;
+import expectedFiles.ExpectedContainer;
+
+/*
+ * Objective:
+ * Test the following 6 methods from java.lang.reflect.AnnotatedElement:
+ * - getAnnotation(Class<T>)
+ * - getAnnotations()
+ * - getDeclaredAnnotations()
+ * - getDeclaredAnnotation(Class<T>) // new method in JDK8
+ * - getAnnotationsByType(Class<T>) // new method in JDK8
+ * - getDeclaredAnnotationsByType(Class<T>) // new method in JDK8
+ * for multiple test cases, for example, BasicNonRepeatable case, BasicRepeatable case
+ * for each of the src types - class, method, field, package
+ *
+ * This test uses following three enums:
+ * 1. TestCase - Defines the ExpectedBase/ExpectedContainer values for each testCase
+ * - getTestFiles() - Creates list of JavaFileObjects for the primary
+ * src types (class, method, field, package)
+ * - Each testCase is a new scenario with a combination of @Repeatable
+ * relationship present/absent in conjunction with @Inherited.
+ * For eg: BasicNonRepeatable_Legacy - It is a pre-JDK8 way of writing a single
+ * annotation on a given srcType( class, method, field, package)
+ * BasicRepeatable - It is a JDK8 way of writing repeating annotations
+ * on a given srcType with a @Repeatable relationship
+ * defined between Foo and FooContainer.
+ *
+ * 2. SrcType - Defines templates used in creation of test src
+ * - Defines getExpectedBase() and getExpectedContainer() for primary src types
+ * 3. TestMethod - Defines getActualAnnoBase(), getActualAnnoContainer(), getExpectedAnnoBase(),
+ * and getExpectedAnnoContainer() for each of the 6 methods that are being tested
+ * in java.lang.reflect.AnnotatedElement
+ *
+ * Test execution flow:
+ * - Loop over each of the src types and each test cases
+ * - Creates test src for each flow, compile it, load the class object
+ * - Run all 6 methods on this class object
+ * - Get expected and actual annotations for each object and compare them.
+ * - Increment the error counter if the annotations don't match.
+ *
+ * The test fails if the number of errors is greater than 0.
+ */
+public class ReflectionTest {
+
+ static int errors = 0;
+ // Variables used in creating test src for a given testcase/testSrcType
+ static final String TESTPKG = "testpkg";
+ static final String TESTMETHOD = "testMethod";
+ static final String TESTFIELD = "testField";
+ static final String PKGINFONAME = TESTPKG + ".package-info";
+ static final String SUPERCLASS = "SuperClass";
+ static final String TESTINTERFACE = "TestInterface";
+ /*
+ * Set it to true to get more debug information
+ */
+ static final boolean DEBUG = false;
+
+ public static void main(String args[]) throws Exception {
+ ReflectionTest test = new ReflectionTest();
+ test.runTest();
+ }
+
+ public void runTest() throws Exception {
+
+ ClassLoader parentClassLoader = getLoader();
+ String className = "";
+ Iterable<? extends JavaFileObject> files = null;
+
+ for (SrcType srcType : SrcType.getSrcTypes()) {
+ for (TestCase testCase : TestCase.values()) {
+ className = testCase + "_" + srcType;
+ debugPrint("*****************************************");
+ System.out.println("Running Test for ClassName: " + className);
+
+ // @Inherited only applicable for class, exclude cases for
+ // package, method, field
+ if (testCase.name().contains("Inherited")
+ && (srcType != SrcType.CLASS)) {
+ continue;
+ }
+
+ // Get list of JavaFileObjects to be compiled
+ files = testCase.getTestFiles(srcType, className);
+ if (srcType == SrcType.PACKAGE) {
+ className = TESTPKG + "." + className;
+ }
+ DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
+
+ // Compile the list of JavaFileObjects
+ try {
+ Helper.compileCode(diagnostics, files);
+ } catch (Exception ex) {
+ printTestSrc(files);
+ throw new RuntimeException(
+ "Exception when compiling class " + className, ex);
+ }
+
+ // Get Class object for the compiled class
+ Class<?> c = loadClass(className, parentClassLoader, Helper.destDir);
+ if (c != null) {
+ // For the loaded class object, compare expected and actual annotation values
+ // for each of the methods under test from java.lang.reflect.AnnotatedElement
+ checkAnnoValues(srcType, c);
+ } else {
+ error("Could not load className = " + c);
+ }
+ }
+ }
+
+ if (getNumErrors() > 0) {
+ System.err.println("Test failed with " + getNumErrors() + " errors");
+ throw new RuntimeException();
+ }
+ }
+
+ /*
+ * Each test case in this enum has the following:
+ * - Define each test case with its @ExpectedBase and @ExpectedContainer annotations
+ * - Override getTestFiles() that creates list of JavaFileObjects for each case
+ * based on the src type.
+ */
+ enum TestCase {
+ BasicNonRepeatable_Legacy(
+ "@ExpectedBase(value=Foo.class, "
+ + "getAnnotationVal = \"Foo\", "
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+ + "getDeclAnnoVal = \"Foo\", "
+ + "getAnnosArgs = {\"Foo\"}, "
+ + "getDeclAnnosArgs = {\"Foo\"}) ",
+ "@ExpectedContainer") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String testSrc = "";
+ String pkgInfoContents = "";
+ String contents = "";
+
+ JavaFileObject pkgFileObj = null;
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = new StringBuilder();
+ anno = Helper.ContentVars.BASEANNO.getVal();
+ commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+ .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.BASE.getVal());
+ switch (srcType) {
+ case PACKAGE:
+ /*
+ Sample package-info.java
+ @ExpectedBase
+ @ExpectedContainer
+ @Foo
+ package testpkg;
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface Foo {}
+
+ Sample testSrc:
+ package testpkg;
+ class A {}
+ */
+ testSrc = srcType.getTemplate().replace("#CN", className);
+ contents = testSrc;
+ srcFileObj = Helper.getFile(className, contents);
+
+ replaceVal = expectedVals + "\n" + anno;
+ pkgInfoContents = SrcType.PKGINFO.getTemplate()
+ .replace("#REPLACE1", replaceVal)
+ .replace("#REPLACE2", commonStmts);
+ pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
+
+ files = Arrays.asList(pkgFileObj, srcFileObj);
+ break;
+ default:
+ // class, method, field
+ /*
+ Sample testSrc for class
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface Foo {}
+
+ @ExpectedBase
+ @ExpectedContainer
+ @Foo
+ class A {}
+ */
+ replaceVal = expectedVals + anno;
+ testSrc = srcType.getTemplate().replace("#CN", className)
+ .replace("#REPLACE", replaceVal);
+ contents = commonStmts + testSrc;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ SingleAnnoInherited_Legacy(
+ "@ExpectedBase(value=Foo.class, "
+ + "getAnnotationVal = \"Foo\", "
+ + "getAnnotationsVals = {\"Foo\", \"ExpectedBase\", \"ExpectedContainer\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
+ + "getDeclAnnoVal = \"NULL\", "
+ + "getAnnosArgs = {\"Foo\"}, "
+ + "getDeclAnnosArgs = {})",
+ "@ExpectedContainer") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String contents = "";
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = new StringBuilder();
+
+ /*
+ Sample testSrc:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface Foo {}
+
+ @Foo
+ class SuperClass { }
+
+ @ExpectedBase
+ @ExpectedContainer
+ class SubClass extends SuperClass {}
+ */
+
+ // @Inherited only works for classes, no switch cases for
+ // method, field, package
+ anno = Helper.ContentVars.BASEANNO.getVal();
+ commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+ .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.INHERITED.getVal())
+ .append(Helper.ContentVars.BASE.getVal());
+
+ if (srcType == SrcType.CLASS) {
+ // Contents for SuperClass
+ replaceVal = commonStmts + "\n" + anno;
+ String superClassContents = srcType.getTemplate()
+ .replace("#CN", SUPERCLASS).replace("#REPLACE", replaceVal);
+
+ // Contents for SubClass that extends SuperClass
+ replaceVal = expectedVals;
+ String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+ .replace("#CN", className).replace("#SN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ contents = superClassContents + subClassContents;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ InheritedAnnoOnInterface_Legacy(
+ "@ExpectedBase(value=Foo.class, "
+ + "getAnnotationVal = \"NULL\", "
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"},"
+ + "getDeclAnnoVal = \"NULL\"," + "getAnnosArgs = {},"
+ + "getDeclAnnosArgs = {})",
+ "@ExpectedContainer") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String contents = "";
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = new StringBuilder();
+
+ /*
+ Sample test src:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface Foo {}
+
+ @Foo
+ interface TestInterface { }
+
+ @ExpectedBase
+ @ExpectedContainer
+ class A implements TestInterface {}
+ */
+ anno = Helper.ContentVars.BASEANNO.getVal();
+ commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+ .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.INHERITED.getVal())
+ .append(Helper.ContentVars.BASE.getVal());
+
+ if (srcType == SrcType.CLASS) {
+ // Contents for TestInterface
+ replaceVal = commonStmts + "\n" + anno;
+ String interfaceContents = SrcType.INTERFACE.getTemplate()
+ .replace("#IN", TESTINTERFACE)
+ .replace("#REPLACE", replaceVal);
+
+ // Contents for class implementing TestInterface
+ replaceVal = expectedVals;
+ String classContents = SrcType.INTERFACEIMPL.getTemplate()
+ .replace("#CN", className).replace("#IN", TESTINTERFACE)
+ .replace("#REPLACE", replaceVal);
+
+ contents = interfaceContents + classContents;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ AnnoOnSuperAndSubClass_Inherited_Legacy(
+ "@ExpectedBase(value=Foo.class, "
+ + "getAnnotationVal = \"Foo\", "
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+ + // override every annotation on superClass
+ "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+ + // ignores inherited annotations
+ "getDeclAnnoVal = \"Foo\", " // ignores inherited
+ + "getAnnosArgs = {\"Foo\"}, "
+ + "getDeclAnnosArgs = { \"Foo\" })", // ignores inherited
+ "@ExpectedContainer(value=FooContainer.class, "
+ + "getAnnotationVal = \"NULL\", "
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+ + // ignores inherited annotations
+ "getDeclAnnoVal = \"NULL\", " + // ignores inherited
+ "getAnnosArgs = {}, " + "getDeclAnnosArgs = {})") { // ignores inherited
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String contents = "";
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = new StringBuilder();
+
+ /*
+ Sample test src
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface Foo {}
+
+ @Inherited
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ @Foo
+ class SuperClass { }
+
+ @ExpectedBase
+ @ExpectedContainer
+ @Foo
+ class SubClass extends SuperClass {}
+ */
+ // @Inherited only works for classes, no switch cases for
+ // method, field, package
+ commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+ .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.INHERITED.getVal())
+ .append(Helper.ContentVars.BASE.getVal())
+ .append(Helper.ContentVars.INHERITED.getVal())
+ .append(Helper.ContentVars.CONTAINER.getVal());
+
+ if (srcType == SrcType.CLASS) {
+ // Contents for SuperClass
+ anno = Helper.ContentVars.BASEANNO.getVal();
+ replaceVal = commonStmts + "\n" + anno;
+ String superClassContents = srcType.getTemplate()
+ .replace("#CN", SUPERCLASS).replace("#REPLACE", replaceVal);
+
+ // Contents for SubClass that extends SuperClass
+ replaceVal = expectedVals + "\n" + anno;
+ String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+ .replace("#CN", className).replace("#SN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ contents = superClassContents + subClassContents;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ BasicContainer_Legacy(
+ "@ExpectedBase(value = Foo.class, "
+ + "getAnnotationVal = \"NULL\","
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+ + "getDeclAnnoVal = \"NULL\", " + "getAnnosArgs = {}, "
+ + "getDeclAnnosArgs = {} )",
+ "@ExpectedContainer(value=FooContainer.class, "
+ + "getAnnotationVal = \"FooContainer\", "
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+ + "getDeclAnnoVal = \"FooContainer\", "
+ + "getAnnosArgs = {\"FooContainer\"}, "
+ + "getDeclAnnosArgs = {\"FooContainer\"} )") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String testSrc = "";
+ String pkgInfoContents = "";
+ String contents = "";
+
+ JavaFileObject pkgFileObj = null;
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = new StringBuilder();
+
+ anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+ commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+ .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.BASE.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.CONTAINER.getVal());
+ switch (srcType) {
+ case PACKAGE:
+ /*
+ Sample package-info.java
+ @ExpectedBase
+ @ExpectedContainer
+ @FooContainer(value = {@Foo, @Foo})
+ package testpkg;
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ Sample testSrc:
+ package testpkg;
+ class A {}
+ */
+ testSrc = srcType.getTemplate().replace("#CN", className);
+ contents = testSrc;
+ srcFileObj = Helper.getFile(className, contents);
+
+ replaceVal = "\n" + expectedVals + "\n" + anno;
+ pkgInfoContents = SrcType.PKGINFO.getTemplate()
+ .replace("#REPLACE1", replaceVal)
+ .replace("#REPLACE2", commonStmts);
+ pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
+ files = Arrays.asList(pkgFileObj, srcFileObj);
+ break;
+ default:
+ /*
+ Sample testSrc for class:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ @ExpectedBase
+ @ExpectedContainer
+ @FooContainer(value = {@Foo, @Foo})
+ class A {}
+ */
+ replaceVal = expectedVals + anno;
+ testSrc = srcType.getTemplate().replace("#CN", className)
+ .replace("#REPLACE", replaceVal);
+ contents = commonStmts + testSrc;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ SingleAndContainerOnSuper_Legacy(
+ "@ExpectedBase(value = Foo.class, "
+ + "getAnnotationVal = \"Foo\","
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+ + "getDeclAnnoVal = \"Foo\", "
+ + "getAnnosArgs = {\"Foo\"}, "
+ + "getDeclAnnosArgs = {\"Foo\"} )",
+ "@ExpectedContainer(value=FooContainer.class, "
+ + "getAnnotationVal = \"FooContainer\", "
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+ + "getDeclAnnoVal = \"FooContainer\", "
+ + "getAnnosArgs = {\"FooContainer\"}, "
+ + "getDeclAnnosArgs = {\"FooContainer\"} )") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String testSrc = "";
+ String pkgInfoContents = "";
+ String contents = "";
+
+ JavaFileObject pkgFileObj = null;
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = new StringBuilder();
+
+ anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
+ + Helper.ContentVars.BASEANNO.getVal();
+ commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+ .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.BASE.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.CONTAINER.getVal());
+ switch (srcType) {
+ case PACKAGE:
+ /*
+ Sample package-info.java
+ @ExpectedBase
+ @ExpectedContainer
+ @Foo
+ @FooContainer(value = {@Foo, @Foo})
+ package testpkg;
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ Sample testSrc:
+ package testpkg;
+ class A {}
+ */
+ testSrc = srcType.getTemplate().replace("#CN", className);
+ contents = testSrc;
+
+ srcFileObj = Helper.getFile(className, contents);
+
+ replaceVal = "\n" + expectedVals + "\n" + anno;
+ pkgInfoContents = SrcType.PKGINFO.getTemplate()
+ .replace("#REPLACE1", replaceVal)
+ .replace("#REPLACE2", commonStmts);
+ pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
+ files = Arrays.asList(pkgFileObj, srcFileObj);
+ break;
+ default:
+ /*
+ Sample testSrc for class:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ @ExpectedBase
+ @ExpectedContainer
+ @Foo
+ @FooContainer(value = {@Foo, @Foo})
+ class A {}
+ */
+ replaceVal = expectedVals + anno;
+ testSrc = srcType.getTemplate().replace("#CN", className)
+ .replace("#REPLACE", replaceVal);
+ contents = commonStmts + testSrc;
+
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ BasicContainer_Inherited_Legacy(
+ "@ExpectedBase(value = Foo.class, "
+ + "getAnnotationVal = \"NULL\","
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
+ + "getDeclAnnoVal = \"NULL\", "
+ + "getAnnosArgs = {}, "
+ + "getDeclAnnosArgs = {} )",
+ "@ExpectedContainer(value=FooContainer.class, "
+ + "getAnnotationVal = \"FooContainer\", "
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
+ + "getDeclAnnoVal = \"NULL\", "
+ + "getAnnosArgs = {\"FooContainer\"}, "
+ + "getDeclAnnosArgs = {} )") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String contents = "";
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = getCommonStmts(false);
+
+ /*
+ Sample testSrc:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ @FooContainer(value = {@Foo, @Foo})
+ class SuperClass { }
+
+ @ExpectedBase
+ @ExpectedContainer
+ class SubClass extends SuperClass {}
+ */
+ // @Inherited only works for classes, no switch cases for
+ // method, field, package
+
+ if (srcType == SrcType.CLASS) {
+ // Contents for SuperClass
+ anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+ replaceVal = commonStmts + "\n" + anno;
+ String superClassContents = srcType.getTemplate()
+ .replace("#CN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ // Contents for SubClass that extends SuperClass
+ replaceVal = expectedVals;
+ String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+ .replace("#CN", className)
+ .replace("#SN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ contents = superClassContents + subClassContents;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ ContainerOnSuperSingleOnSub_Inherited_Legacy(
+ "@ExpectedBase(value=Foo.class, "
+ + "getAnnotationVal = \"Foo\", "
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+ + "getDeclAnnoVal = \"Foo\","
+ + "getAnnosArgs = {\"Foo\"},"
+ + "getDeclAnnosArgs = {\"Foo\"})",
+ "@ExpectedContainer(value=FooContainer.class, "
+ + "getAnnotationVal = \"FooContainer\", "
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+ + "getDeclAnnoVal = \"NULL\","
+ + "getAnnosArgs = {\"FooContainer\"},"
+ + "getDeclAnnosArgs = {})") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String contents = "";
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = getCommonStmts(false);
+
+ /*
+ Sample testSrc:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ @FooContainer(value = {@Foo, @Foo})
+ class SuperClass { }
+
+ @ExpectedBase
+ @ExpectedContainer
+ @Foo
+ class SubClass extends SuperClass {}
+ */
+ // @Inherited only works for classes, no switch cases for
+ // method, field, package
+
+ if (srcType == SrcType.CLASS) {
+ // Contents for SuperClass
+ anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+ replaceVal = commonStmts + "\n" + anno;
+ String superClassContents = srcType.getTemplate()
+ .replace("#CN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ // Contents for SubClass that extends SuperClass
+ anno = Helper.ContentVars.BASEANNO.getVal();
+ replaceVal = expectedVals + "\n" + anno;
+ String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+ .replace("#CN", className)
+ .replace("#SN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ contents = superClassContents + subClassContents;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ ContainerAndSingleOnSuperSingleOnSub_Inherited_Legacy(
+ "@ExpectedBase(value=Foo.class, "
+ + "getAnnotationVal = \"Foo\", "
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+ + "getDeclAnnoVal = \"Foo\","
+ + "getAnnosArgs = {\"Foo\"},"
+ + "getDeclAnnosArgs = {\"Foo\"})",
+ "@ExpectedContainer(value=FooContainer.class, "
+ + "getAnnotationVal = \"FooContainer\", "
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+ + "getDeclAnnoVal = \"NULL\","
+ + "getAnnosArgs = {\"FooContainer\"},"
+ + "getDeclAnnosArgs = {})") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String contents = "";
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = getCommonStmts(false);
+
+ /*
+ Sample testSrc:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ @FooContainer(value = {@Foo, @Foo}) @Foo
+ class SuperClass { }
+
+ @ExpectedBase
+ @ExpectedContainer
+ @Foo
+ class SubClass extends SuperClass {}
+ */
+ // @Inherited only works for classes, no switch cases for
+ // method, field, package
+
+ if (srcType == SrcType.CLASS) {
+ // Contents for SuperClass
+ anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
+ + Helper.ContentVars.BASEANNO.getVal();
+ replaceVal = commonStmts + "\n" + anno;
+ String superClassContents = srcType.getTemplate()
+ .replace("#CN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ // Contents for SubClass that extends SuperClass
+ anno = Helper.ContentVars.BASEANNO.getVal();
+ replaceVal = expectedVals + "\n" + anno;
+ String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+ .replace("#CN", className).replace("#SN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ contents = superClassContents + subClassContents;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ SingleOnSuperContainerOnSub_Inherited_Legacy(
+ "@ExpectedBase(value=Foo.class, "
+ + "getAnnotationVal = \"Foo\", "
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+ + "getDeclAnnoVal = \"NULL\","
+ + "getAnnosArgs = {\"Foo\"},"
+ + "getDeclAnnosArgs = {})",
+ "@ExpectedContainer(value=FooContainer.class, "
+ + "getAnnotationVal = \"FooContainer\", "
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+ + "getDeclAnnoVal = \"FooContainer\","
+ + "getAnnosArgs = {\"FooContainer\"},"
+ + "getDeclAnnosArgs = {\"FooContainer\"})") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String contents = "";
+
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = getCommonStmts(false);
+
+ /*
+ Sample testSrc:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ @Foo
+ class SuperClass { }
+
+ @ExpectedBase
+ @ExpectedContainer
+ @FooContainer(value = {@Foo, @Foo})
+ class SubClass extends SuperClass {}
+ */
+
+ if (srcType == SrcType.CLASS) {
+ //Contents for SuperClass
+ anno = Helper.ContentVars.BASEANNO.getVal();
+ replaceVal = commonStmts + "\n" + anno;
+ String superClassContents = srcType.getTemplate()
+ .replace("#CN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ //Contents for SubClass that extends SuperClass
+ anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+ replaceVal = expectedVals + "\n" + anno;
+ String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+ .replace("#CN", className).replace("#SN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ contents = superClassContents + subClassContents;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ SingleOnSuperContainerAndSingleOnSub_Inherited_Legacy(
+ "@ExpectedBase(value=Foo.class, "
+ + "getAnnotationVal = \"Foo\", "
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
+ + "getDeclAnnoVal = \"Foo\","
+ + "getAnnosArgs = {\"Foo\"},"
+ + "getDeclAnnosArgs = {\"Foo\"})",
+ "@ExpectedContainer(value=FooContainer.class, "
+ + "getAnnotationVal = \"FooContainer\", "
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
+ + "getDeclAnnoVal = \"FooContainer\","
+ + "getAnnosArgs = {\"FooContainer\"},"
+ + "getDeclAnnosArgs = {\"FooContainer\"})") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String contents = "";
+
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = getCommonStmts(false);
+
+ /*
+ Sample testSrc:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ @Foo
+ class SuperClass { }
+
+ @ExpectedBase
+ @ExpectedContainer
+ @FooContainer(value = {@Foo, @Foo}) @Foo
+ class SubClass extends SuperClass {}
+ */
+
+ if (srcType == SrcType.CLASS) {
+ //Contents for SuperClass
+ anno = Helper.ContentVars.BASEANNO.getVal();
+ replaceVal = commonStmts + "\n" + anno;
+ String superClassContents = srcType.getTemplate()
+ .replace("#CN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ //Contents for SubClass that extends SuperClass
+ anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
+ + Helper.ContentVars.BASEANNO.getVal();
+ replaceVal = expectedVals + "\n" + anno;
+ String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+ .replace("#CN", className).replace("#SN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ contents = superClassContents + subClassContents;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ BasicRepeatable(
+ "@ExpectedBase(value=Foo.class, "
+ + "getAnnotationVal = \"NULL\", "
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\" }, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+ + "getDeclAnnoVal = \"NULL\","
+ + "getAnnosArgs = {\"Foo\", \"Foo\"},"
+ + "getDeclAnnosArgs = {\"Foo\", \"Foo\"})",
+ "@ExpectedContainer(value=FooContainer.class, "
+ + "getAnnotationVal = \"FooContainer\","
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+ + "getDeclAnnoVal = \"FooContainer\","
+ + "getAnnosArgs = {\"FooContainer\"},"
+ + "getDeclAnnosArgs = {\"FooContainer\"} )") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String testSrc = "";
+ String pkgInfoContents = "";
+ String contents = "";
+
+ JavaFileObject pkgFileObj = null;
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = new StringBuilder();
+
+ anno = Helper.ContentVars.REPEATABLEANNO.getVal();
+ commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+ .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.REPEATABLE.getVal())
+ .append(Helper.ContentVars.BASE.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.CONTAINER.getVal());
+ switch (srcType) {
+ case PACKAGE:
+ /*
+ Sample package-info.java
+ @ExpectedBase
+ @ExpectedContainer
+ @Foo() @Foo()
+ package testpkg;
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Repeatable(FooContainer.class)
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ Sample testSrc:
+ package testpkg;
+ class A {}
+ */
+ testSrc = srcType.getTemplate().replace("#CN", className);
+ contents = testSrc;
+ srcFileObj = Helper.getFile(className, contents);
+
+ replaceVal = expectedVals + "\n" + anno;
+ pkgInfoContents = SrcType.PKGINFO.getTemplate()
+ .replace("#REPLACE1", replaceVal)
+ .replace("#REPLACE2", commonStmts);
+ pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
+ files = Arrays.asList(pkgFileObj, srcFileObj);
+ break;
+ default:
+ /*
+ Sample testSrc for class:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Repeatable(FooContainer.class)
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ @ExpectedBase
+ @ExpectedContainer
+ @Foo @Foo
+ class A { }
+ */
+ replaceVal = expectedVals + anno;
+ testSrc = srcType.getTemplate().replace("#CN", className)
+ .replace("#REPLACE", replaceVal);
+ contents = commonStmts + testSrc;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ BasicContainerRepeatable(
+ "@ExpectedBase(value=Foo.class, "
+ + "getAnnotationVal = \"NULL\", "
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+ + "getDeclAnnoVal = \"NULL\","
+ + "getAnnosArgs = {\"Foo\", \"Foo\"},"
+ + "getDeclAnnosArgs = {\"Foo\", \"Foo\"})",
+ "@ExpectedContainer(value=FooContainer.class, "
+ + "getAnnotationVal = \"FooContainer\","
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+ + "getDeclAnnosVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+ + "getDeclAnnoVal = \"FooContainer\","
+ + "getAnnosArgs = {\"FooContainer\"},"
+ + "getDeclAnnosArgs = {\"FooContainer\"} )") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String testSrc = "";
+ String pkgInfoContents = "";
+ String contents = "";
+
+ JavaFileObject pkgFileObj = null;
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = new StringBuilder();
+
+ anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+ commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+ .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.REPEATABLE.getVal())
+ .append(Helper.ContentVars.BASE.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.CONTAINER.getVal());
+ switch (srcType) {
+ case PACKAGE:
+ /*
+ Sample package-info.java
+ @ExpectedBase
+ @ExpectedContainer
+ @FooContainer(value = {@Foo, @Foo})
+ package testpkg;
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Repeatable(FooContainer.class)
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ Sample testSrc:
+ package testpkg;
+ class A {}
+ */
+ testSrc = srcType.getTemplate().replace("#CN", className);
+ contents = testSrc;
+ srcFileObj = Helper.getFile(className, contents);
+
+ replaceVal = expectedVals + "\n" + anno;
+ pkgInfoContents = SrcType.PKGINFO.getTemplate()
+ .replace("#REPLACE1", replaceVal)
+ .replace("#REPLACE2", commonStmts);
+ pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
+ files = Arrays.asList(pkgFileObj, srcFileObj);
+ break;
+ default:
+ /*
+ Sample testSrc for class:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Repeatable(FooContainer.class)
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ @ExpectedBase
+ @ExpectedContainer
+ @FooContainer(value = {@Foo, @Foo})
+ class A { }
+ */
+ replaceVal = expectedVals + anno;
+ testSrc = srcType.getTemplate().replace("#CN", className)
+ .replace("#REPLACE", replaceVal);
+ contents = commonStmts + testSrc;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ BasicContainerRepeatable_Inherited(
+ "@ExpectedBase(value=Foo.class, "
+ + "getAnnotationVal = \"NULL\", "
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
+ + "getDeclAnnoVal = \"NULL\", "
+ + "getAnnosArgs = {\"Foo\", \"Foo\"}, "
+ + "getDeclAnnosArgs = {})",
+ "@ExpectedContainer(value=FooContainer.class, "
+ + "getAnnotationVal = \"FooContainer\", "
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = { \"ExpectedBase\", \"ExpectedContainer\"}, "
+ + "getDeclAnnoVal = \"NULL\", "
+ + "getAnnosArgs = {\"FooContainer\"}, "
+ + "getDeclAnnosArgs = {})") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String contents = "";
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = getCommonStmts(true);
+ /*
+ Sample testSrc:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @Repeatable(FooContainer.class)
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ @FooContainer(value = {@Foo, @Foo})
+ class SuperClass { }
+
+ @ExpectedBase
+ @ExpectedContainer
+ class SubClass extends SuperClass { }
+ */
+ // @Inherited only works for classes, no switch cases for
+ // method, field, package
+ anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+
+ if (srcType == SrcType.CLASS) {
+ // Contents for SuperClass
+ replaceVal = commonStmts + "\n" + anno;
+ String superClassContents = srcType.getTemplate()
+ .replace("#CN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ // Contents for SubClass that extends SuperClass
+ replaceVal = expectedVals;
+ String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+ .replace("#CN", className)
+ .replace("#SN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ contents = superClassContents + subClassContents;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ RepeatableAnnoInherited(
+ "@ExpectedBase(value=Foo.class, "
+ + "getAnnotationVal = \"NULL\", "
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
+ + // ignores inherited annotations
+ "getDeclAnnoVal = \"NULL\", "
+ + // ignores inherited
+ "getAnnosArgs = {\"Foo\", \"Foo\"}, "
+ + "getDeclAnnosArgs = {})", // ignores inherited
+ "@ExpectedContainer(value=FooContainer.class, "
+ + "getAnnotationVal = \"FooContainer\", "
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = { \"ExpectedBase\", \"ExpectedContainer\"}, "
+ + // ignores inherited annotations
+ "getDeclAnnoVal = \"NULL\", "
+ + // ignores inherited
+ "getAnnosArgs = {\"FooContainer\"}, "
+ + "getDeclAnnosArgs = {})") { // ignores inherited
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String contents = "";
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = getCommonStmts(true);
+ /*
+ Sample testSrc:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @Repeatable(FooContainer.class)
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ @Foo() @Foo()
+ class SuperClass { }
+
+ @ExpectedBase
+ @ExpectedContainer
+ class SubClass extends SuperClass { }
+ */
+ // @Inherited only works for classes, no switch cases for
+ // method, field, package
+ anno = Helper.ContentVars.REPEATABLEANNO.getVal();
+
+ if (srcType == SrcType.CLASS) {
+ // Contents for SuperClass
+ replaceVal = commonStmts + "\n" + anno;
+ String superClassContents = srcType.getTemplate()
+ .replace("#CN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ // Contents for SubClass that extends SuperClass
+ replaceVal = expectedVals;
+ String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+ .replace("#CN", className)
+ .replace("#SN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ contents = superClassContents + subClassContents;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ SingleAnnoWithContainer(
+ "@ExpectedBase(value=Foo.class, "
+ + "getAnnotationVal = \"Foo\", "
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
+ + "getDeclAnnosVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
+ + "getDeclAnnoVal = \"Foo\","
+ + "getAnnosArgs = {\"Foo\", \"Foo\", \"Foo\"},"
+ + "getDeclAnnosArgs = {\"Foo\", \"Foo\",\"Foo\"})",
+ "@ExpectedContainer(value=FooContainer.class, "
+ + "getAnnotationVal = \"FooContainer\", "
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
+ + "getDeclAnnosVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+ + "getDeclAnnoVal = \"FooContainer\","
+ + "getDeclAnnosArgs = {\"FooContainer\"},"
+ + "getAnnosArgs = {\"FooContainer\"})") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String testSrc = "";
+ String pkgInfoContents = "";
+ String contents = "";
+
+ JavaFileObject pkgFileObj = null;
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = new StringBuilder();
+
+ anno = Helper.ContentVars.BASEANNO.getVal() + " "
+ + Helper.ContentVars.LEGACYCONTAINER.getVal();
+ commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+ .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.REPEATABLE.getVal())
+ .append(Helper.ContentVars.BASE.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.CONTAINER.getVal());
+ switch (srcType) {
+ case PACKAGE:
+ /*
+ Sample package-info.java
+ @ExpectedBase
+ @ExpectedContainer
+ @Foo @FooContainer(value = {@Foo, @Foo})
+ package testpkg;
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Repeatable(FooContainer.class)
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ Sample testSrc:
+ package testpkg;
+ class A {}
+ */
+ testSrc = srcType.getTemplate().replace("#CN", className);
+ contents = testSrc;
+ srcFileObj = Helper.getFile(className, contents);
+
+ replaceVal = expectedVals + "\n" + anno;
+ pkgInfoContents = SrcType.PKGINFO.getTemplate()
+ .replace("#REPLACE1", replaceVal)
+ .replace("#REPLACE2", commonStmts);
+ pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
+ files = Arrays.asList(pkgFileObj, srcFileObj);
+ break;
+ default:
+ /*
+ Sample testSrc:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @Repeatable(FooContainer.class)
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ @ExpectedBase
+ @ExpectedContainer
+ @Foo @FooContainer(value = {@Foo, @Foo})
+ class A { }
+ */
+ replaceVal = expectedVals + anno;
+ testSrc = srcType.getTemplate()
+ .replace("#CN", className)
+ .replace("#REPLACE", replaceVal);
+ contents = commonStmts + testSrc;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+ AnnoOnSuperAndSubClass_Inherited(
+ "@ExpectedBase(value=Foo.class, "
+ + "getAnnotationVal = \"Foo\", "
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\" }, "
+ + // override every annotation on superClass
+ "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+ + // ignores inherited annotations
+ "getDeclAnnoVal = \"Foo\", " // ignores inherited
+ + "getAnnosArgs = {\"Foo\"}, "
+ + "getDeclAnnosArgs = { \"Foo\" })", // ignores inherited
+ "@ExpectedContainer(value=FooContainer.class, "
+ + "getAnnotationVal = \"NULL\", "
+ + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\" }, "
+ + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+ + // ignores inherited annotations
+ "getDeclAnnoVal = \"NULL\", " + // ignores inherited
+ "getAnnosArgs = {}, " + "getDeclAnnosArgs = {})") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String contents = "";
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = getCommonStmts(true);
+
+ /*
+ Sample testSrc:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @Repeatable(FooContainer.class)
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ @Foo()
+ class SuperClass { }
+
+ @ExpectedBase
+ @ExpectedContainer
+ @Foo
+ class SubClass extends SuperClass { }
+ */
+ // @Inherited only works for classes, no switch cases for
+ // method, field, package
+
+ if (srcType == SrcType.CLASS) {
+ // Contents for SuperClass
+ anno = Helper.ContentVars.BASEANNO.getVal();
+ replaceVal = commonStmts + "\n" + anno;
+ String superClassContents = srcType.getTemplate()
+ .replace("#CN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ // Contents for SubClass that extends SuperClass
+ replaceVal = expectedVals + "\n" + anno;
+ String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+ .replace("#CN", className)
+ .replace("#SN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ contents = superClassContents + subClassContents;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+// // Testcase not working as expected, JDK-8004912
+// RepeatableOnSuperSingleOnSub_Inherited(
+// "@ExpectedBase(value=Foo.class, "
+// + "getAnnotationVal = \"Foo\", "
+// + "getAnnotationsVals = {"
+// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+// + //override every annotation on superClass
+// "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+// + // ignores inherited annotations
+// "getDeclAnnoVal = \"Foo\", " // ignores inherited
+// + "getAnnosArgs = {\"Foo\"}, "
+// + "getDeclAnnosArgs = { \"Foo\" })", // ignores inherited
+// "@ExpectedContainer(value=FooContainer.class, "
+// + "getAnnotationVal = \"FooContainer\", "
+// + "getAnnotationsVals = {"
+// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+// + // ignores inherited annotations
+// "getDeclAnnoVal = \"NULL\", "
+// + "getAnnosArgs = {\"FooContainer\"}, "
+// + "getDeclAnnosArgs = {}) // ignores inherited ") {
+
+// @Override
+// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+// String className) {
+// String anno = "";
+// String replaceVal = "";
+// String contents = "";
+// JavaFileObject srcFileObj = null;
+// Iterable<? extends JavaFileObject> files = null;
+
+// String expectedVals = "\n" + getExpectedBase() + "\n"
+// + getExpectedContainer() + "\n";
+// StringBuilder commonStmts = getCommonStmts(true);
+
+// /*
+// Sample testSrc:
+// @Retention(RetentionPolicy.RUNTIME)
+// @Inherited
+// @Repeatable(FooContainer.class)
+// @interface Foo {}
+
+// @Retention(RetentionPolicy.RUNTIME)
+// @Inherited
+// @interface FooContainer {
+// Foo[] value();
+// }
+
+// @Foo() @Foo
+// class SuperClass { }
+
+// @ExpectedBase
+// @ExpectedContainer
+// @Foo
+// class SubClass extends SuperClass { }
+// */
+// //@Inherited only works for classes, no switch cases for method, field, package
+
+// if (srcType == SrcType.CLASS) {
+// //Contents for SuperClass
+// anno = Helper.ContentVars.REPEATABLEANNO.getVal();
+// replaceVal = commonStmts + "\n" + anno;
+// String superClassContents = srcType.getTemplate()
+// .replace("#CN", SUPERCLASS)
+// .replace("#REPLACE", replaceVal);
+
+// //Contents for SubClass that extends SuperClass
+// anno = Helper.ContentVars.BASEANNO.getVal();
+// replaceVal = expectedVals + "\n" + anno;
+// String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+// .replace("#CN", className)
+// .replace("#SN", SUPERCLASS)
+// .replace("#REPLACE", replaceVal);
+// contents = superClassContents + subClassContents;
+// srcFileObj = Helper.getFile(className, contents);
+// files = Arrays.asList(srcFileObj);
+// }
+// return files;
+// }
+// },
+// //Testcase not working as expected, JDK-8004912
+// SingleOnSuperRepeatableOnSub_Inherited(
+// "@ExpectedBase(value=Foo.class, "
+// + "getAnnotationVal = \"Foo\", "
+// + "getAnnotationsVals = {"
+// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+// + //override every annotation on superClass
+// "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+// + // ignores inherited annotations
+// "getDeclAnnoVal = \"NULL\","// ignores inherited
+// + "getAnnosArgs = {\"Foo\", \"Foo\"}, "
+// + "getDeclAnnosArgs = { \"Foo\", \"Foo\"})",
+// "@ExpectedContainer(value=FooContainer.class, "
+// + "getAnnotationVal = \"FooContainer\", "
+// + "getAnnotationsVals = {"
+// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+// + // ignores inherited annotations
+// "getDeclAnnoVal = \"FooContainer\", "// ignores inherited
+// + "getAnnosArgs = {\"FooContainer\"}, "
+// + "getDeclAnnosArgs = {\"FooContainer\"})") {
+
+// @Override
+// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+// String className) {
+// String anno = "";
+// String replaceVal = "";
+// String contents = "";
+// JavaFileObject srcFileObj = null;
+// Iterable<? extends JavaFileObject> files = null;
+
+// String expectedVals = "\n" + getExpectedBase() + "\n"
+// + getExpectedContainer() + "\n";
+// StringBuilder commonStmts = getCommonStmts(true);
+
+// /*
+// Sample testSrc:
+// @Retention(RetentionPolicy.RUNTIME)
+// @Inherited
+// @Repeatable(FooContainer.class)
+// @interface Foo {}
+
+// @Retention(RetentionPolicy.RUNTIME)
+// @Inherited
+// @interface FooContainer {
+// Foo[] value();
+// }
+
+// @Foo()
+// class SuperClass { }
+
+// @ExpectedBase
+// @ExpectedContainer
+// @Foo @Foo
+// class SubClass extends SuperClass { }
+// */
+
+// //@Inherited only works for classes, no switch cases for method, field, package
+// if (srcType == SrcType.CLASS) {
+// //Contents for SuperClass
+// anno = Helper.ContentVars.BASEANNO.getVal();
+// replaceVal = commonStmts + "\n" + anno;
+// String superClassContents = srcType.getTemplate()
+// .replace("#CN", SUPERCLASS)
+// .replace("#REPLACE", replaceVal);
+
+// //Contents for SubClass that extends SuperClass
+// anno = Helper.ContentVars.REPEATABLEANNO.getVal();
+// replaceVal = expectedVals + "\n" + anno;
+// String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+// .replace("#CN", className)
+// .replace("#SN", SUPERCLASS)
+// .replace("#REPLACE", replaceVal);
+
+// contents = superClassContents + subClassContents;
+// srcFileObj = Helper.getFile(className, contents);
+// files = Arrays.asList(srcFileObj);
+// }
+// return files;
+// }
+// },
+// //Testcase not working as expected, JDK-8004912
+// ContainerOnSuperSingleOnSub_Inherited(
+// "@ExpectedBase(value=Foo.class, "
+// + "getAnnotationVal = \"Foo\", "
+// + "getAnnotationsVals = {"
+// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+// + "getDeclAnnoVal = \"Foo\","
+// + "getAnnosArgs = {\"Foo\"},"
+// + "getDeclAnnosArgs = {\"Foo\"})",
+// "@ExpectedContainer(value=FooContainer.class, "
+// + "getAnnotationVal = \"FooContainer\", "
+// + "getAnnotationsVals = {"
+// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+// + "getDeclAnnoVal = \"NULL\","
+// + "getAnnosArgs = {\"FooContainer\"},"
+// + "getDeclAnnosArgs = {})") {
+
+// @Override
+// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+// String className) {
+// String anno = "";
+// String replaceVal = "";
+// String contents = "";
+// JavaFileObject srcFileObj = null;
+// Iterable<? extends JavaFileObject> files = null;
+
+// String expectedVals = "\n" + getExpectedBase() + "\n"
+// + getExpectedContainer() + "\n";
+// StringBuilder commonStmts = getCommonStmts(true);
+
+// /*
+// Sample testSrc:
+// @Retention(RetentionPolicy.RUNTIME)
+// @Inherited
+// @Repeatable(FooContainer.class)
+// @interface Foo {}
+
+// @Retention(RetentionPolicy.RUNTIME)
+// @Inherited
+// @interface FooContainer {
+// Foo[] value();
+// }
+
+// @FooContainer(value = {@Foo, @Foo})
+// class SuperClass { }
+
+// @ExpectedBase
+// @ExpectedContainer
+// @Foo
+// class SubClass extends SuperClass { }
+// */
+
+// //@Inherited only works for classes, no switch cases for method, field, package
+// if (srcType == SrcType.CLASS) {
+// //Contents for SuperClass
+// anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+// replaceVal = commonStmts + "\n" + anno;
+// String superClassContents = srcType.getTemplate()
+// .replace("#CN", SUPERCLASS)
+// .replace("#REPLACE", replaceVal);
+
+// //Contents for SubClass that extends SuperClass
+// anno = Helper.ContentVars.BASEANNO.getVal();
+// replaceVal = expectedVals + "\n" + anno;
+// String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+// .replace("#CN", className)
+// .replace("#SN", SUPERCLASS)
+// .replace("#REPLACE", replaceVal);
+
+// contents = superClassContents + subClassContents;
+// srcFileObj = Helper.getFile(className, contents);
+// files = Arrays.asList(srcFileObj);
+// }
+// return files;
+// }
+// },
+// // TestCase not working as expected, JDK-8004912
+// SingleOnSuperContainerOnSub_Inherited(
+// "@ExpectedBase(value=Foo.class, "
+// + "getAnnotationVal = \"Foo\", "
+// + "getAnnotationsVals = {"
+// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+// + "getDeclAnnoVal = \"NULL\","
+// + "getAnnosArgs = {\"Foo\", \"Foo\"},"
+// + "getDeclAnnosArgs = {\"Foo\", \"Foo\"})",
+// "@ExpectedContainer(value=FooContainer.class, "
+// + "getAnnotationVal = \"FooContainer\", "
+// + "getAnnotationsVals = {"
+// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+// + "getDeclAnnoVal = \"FooContainer\","
+// + "getAnnosArgs = {\"FooContainer\"},"
+// + "getDeclAnnosArgs = {\"FooContainer\"})") {
+
+// @Override
+// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+// String className) {
+// String anno = "";
+// String replaceVal = "";
+// String contents = "";
+// JavaFileObject srcFileObj = null;
+// Iterable<? extends JavaFileObject> files = null;
+
+// String expectedVals = "\n" + getExpectedBase() + "\n"
+// + getExpectedContainer() + "\n";
+// StringBuilder commonStmts = getCommonStmts(true);
+
+// /*
+// Sample testSrc:
+// @Retention(RetentionPolicy.RUNTIME)
+// @Inherited
+// @Repeatable(FooContainer.class)
+// @interface Foo {}
+
+// @Retention(RetentionPolicy.RUNTIME)
+// @Inherited
+// @interface FooContainer {
+// Foo[] value();
+// }
+
+// @Foo
+// class SuperClass { }
+
+// @ExpectedBase
+// @ExpectedContainer
+// @FooContainer(value = {@Foo, @Foo})
+// class SubClass extends SuperClass { }
+// */
+
+// //@Inherited only works for classes, no switch cases for method, field, package
+// if (srcType == SrcType.CLASS) {
+// //Contents for SuperClass
+// anno = Helper.ContentVars.BASEANNO.getVal();
+// replaceVal = commonStmts + "\n" + anno;
+// String superClassContents = srcType.getTemplate()
+// .replace("#CN", SUPERCLASS)
+// .replace("#REPLACE", replaceVal);
+
+// //Contents for SubClass that extends SuperClass
+// anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+// replaceVal = expectedVals + "\n" + anno;
+// String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+// .replace("#CN", className)
+// .replace("#SN", SUPERCLASS)
+// .replace("#REPLACE", replaceVal);
+
+// contents = superClassContents + subClassContents;
+// srcFileObj = Helper.getFile(className, contents);
+// files = Arrays.asList(srcFileObj);
+// }
+// return files;
+// }
+// },
+ SingleOnSuperContainerAndSingleOnSub_Inherited(
+ "@ExpectedBase(value=Foo.class, "
+ + "getAnnotationVal = \"Foo\", "
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
+ + "getDeclAnnoVal = \"Foo\","
+ + "getAnnosArgs = {\"Foo\", \"Foo\", \"Foo\"},"
+ + "getDeclAnnosArgs = {\"Foo\", \"Foo\", \"Foo\"})",
+ "@ExpectedContainer(value=FooContainer.class, "
+ + "getAnnotationVal = \"FooContainer\", "
+ + "getAnnotationsVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+ + "getDeclAnnosVals = {"
+ + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
+ + "getDeclAnnoVal = \"FooContainer\","
+ + "getAnnosArgs = {\"FooContainer\"},"
+ + "getDeclAnnosArgs = {\"FooContainer\"})") {
+
+ @Override
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ String anno = "";
+ String replaceVal = "";
+ String contents = "";
+ JavaFileObject srcFileObj = null;
+ Iterable<? extends JavaFileObject> files = null;
+ String expectedVals = "\n" + getExpectedBase() + "\n"
+ + getExpectedContainer() + "\n";
+ StringBuilder commonStmts = getCommonStmts(true);
+
+ /*
+ Sample testSrc:
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @interface Foo {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ @Repeatable(FooContainer.class)
+ @interface FooContainer {
+ Foo[] value();
+ }
+
+ @Foo
+ class SuperClass { }
+
+ @ExpectedBase
+ @ExpectedContainer
+ @FooContainer(value = {@Foo, @Foo}) @Foo
+ class SubClass extends SuperClass {}
+ */
+
+ if (srcType == SrcType.CLASS) {
+ //Contents for SuperClass
+ anno = Helper.ContentVars.BASEANNO.getVal();
+ replaceVal = commonStmts + "\n" + anno;
+ String superClassContents = srcType.getTemplate()
+ .replace("#CN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ //Contents for SubClass that extends SuperClass
+ anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
+ + Helper.ContentVars.BASEANNO.getVal();
+ replaceVal = expectedVals + "\n" + anno;
+ String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+ .replace("#CN", className)
+ .replace("#SN", SUPERCLASS)
+ .replace("#REPLACE", replaceVal);
+
+ contents = superClassContents + subClassContents;
+ srcFileObj = Helper.getFile(className, contents);
+ files = Arrays.asList(srcFileObj);
+ }
+ return files;
+ }
+ },
+// // TestCase not working as expected, JDK-8004912
+// ContainerAndSingleOnSuperSingleOnSub_Inherited(
+// "@ExpectedBase(value=Foo.class, "
+// + "getAnnotationVal = \"Foo\", "
+// + "getAnnotationsVals = {"
+// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+// + "getDeclAnnoVal = \"Foo\","
+// + "getAnnosArgs = {\"Foo\"},"
+// + "getDeclAnnosArgs = {\"Foo\"})",
+// "@ExpectedContainer(value=FooContainer.class, "
+// + "getAnnotationVal = \"FooContainer\", "
+// + "getAnnotationsVals = {"
+// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+// + "getDeclAnnoVal = \"NULL\","
+// + "getAnnosArgs = {\"FooContainer\"},"
+// + "getDeclAnnosArgs = {})") {
+
+// @Override
+// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+// String className) {
+// String anno = "";
+// String replaceVal = "";
+// String contents = "";
+// JavaFileObject srcFileObj = null;
+// Iterable<? extends JavaFileObject> files = null;
+
+// String expectedVals = "\n" + getExpectedBase() + "\n"
+// + getExpectedContainer() + "\n";
+// StringBuilder commonStmts = getCommonStmts(true);
+
+// /*
+// Sample testSrc:
+// @Retention(RetentionPolicy.RUNTIME)
+// @Inherited
+// @Repeatable(FooContainer.class)
+// @interface Foo {}
+
+// @Retention(RetentionPolicy.RUNTIME)
+// @Inherited
+// @interface FooContainer {
+// Foo[] value();
+// }
+
+// @FooContainer(value = {@Foo, @Foo})
+// @Foo
+// class SuperClass { }
+
+// @ExpectedBase
+// @ExpectedContainer
+// @Foo
+// class SubClass extends SuperClass { }
+// */
+
+// //@Inherited only works for classes, no switch cases for method, field, package
+// if (srcType == SrcType.CLASS) {
+// //Contents for SuperClass
+// anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
+// + Helper.ContentVars.BASEANNO.getVal();
+// replaceVal = commonStmts + "\n" + anno;
+// String superClassContents = srcType.getTemplate()
+// .replace("#CN", SUPERCLASS)
+// .replace("#REPLACE", replaceVal);
+
+// //Contents for SubClass that extends SuperClass
+// anno = Helper.ContentVars.BASEANNO.getVal();
+// replaceVal = expectedVals + "\n" + anno;
+// String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+// .replace("#CN", className)
+// .replace("#SN", SUPERCLASS)
+// .replace("#REPLACE", replaceVal);
+
+// contents = superClassContents + subClassContents;
+// srcFileObj = Helper.getFile(className, contents);
+// files = Arrays.asList(srcFileObj);
+// }
+// return files;
+// }
+// }
+ ;
+ private String expectedBase, expectedContainer;
+
+ private TestCase(String expectedBase, String expectedContainer) {
+ this.expectedBase = expectedBase;
+ this.expectedContainer = expectedContainer;
+ }
+
+ public String getExpectedBase() {
+ return expectedBase;
+ }
+
+ public String getExpectedContainer() {
+ return expectedContainer;
+ }
+
+ // Each enum element should override this method
+ public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+ String className) {
+ return null;
+ }
+ }
+
+ /*
+ * Each srctype has its template defined used for test src generation
+ * Primary src types: class, method, field, package define
+ * getExpectedBase() and getExpectedContainer()
+ */
+ enum SrcType {
+
+ CLASS("\n#REPLACE\nclass #CN { } ") {
+
+ @Override
+ public ExpectedBase getExpectedBase(Class<?> c) {
+ return c.getAnnotation(ExpectedBase.class);
+ }
+
+ @Override
+ public ExpectedContainer getExpectedContainer(Class<?> c) {
+ return c.getAnnotation(ExpectedContainer.class);
+ }
+ },
+ METHOD("class #CN {\n" + " " + "#REPLACE\n" + " void "
+ + TESTMETHOD + "() {} \n" + "}\n") {
+
+ @Override
+ public ExpectedBase getExpectedBase(Class<?> c) {
+ ExpectedBase ret = null;
+ try {
+ ret = c.getDeclaredMethod(TESTMETHOD).getAnnotation(
+ ExpectedBase.class);
+ } catch (NoSuchMethodException nme) {
+ error("Could not get " + TESTMETHOD + " for className "
+ + c.getName() + " Exception:\n" + nme);
+ }
+ return ret;
+ }
+
+ @Override
+ public ExpectedContainer getExpectedContainer(Class<?> c) {
+ ExpectedContainer ret = null;
+ try {
+ ret = c.getDeclaredMethod(TESTMETHOD).getAnnotation(
+ ExpectedContainer.class);
+ } catch (NoSuchMethodException nme) {
+ error("Could not get " + TESTMETHOD + " for className "
+ + c.getName() + " Exception:\n" + nme);
+ }
+ return ret;
+
+ }
+ },
+ FIELD("class #CN {\n" + " " + "#REPLACE\n" + " int " + TESTFIELD
+ + " = 0; \n" + "}\n") {
+
+ @Override
+ public ExpectedBase getExpectedBase(Class<?> c) {
+ ExpectedBase ret = null;
+ try {
+ ret = c.getDeclaredField(TESTFIELD).getAnnotation(
+ ExpectedBase.class);
+ } catch (NoSuchFieldException nme) {
+ error("Could not get " + TESTFIELD + " for className "
+ + c.getName() + " Exception:\n" + nme);
+ }
+ return ret;
+ }
+
+ @Override
+ public ExpectedContainer getExpectedContainer(Class<?> c) {
+ ExpectedContainer ret = null;
+ try {
+ ret = c.getDeclaredField(TESTFIELD).getAnnotation(
+ ExpectedContainer.class);
+ } catch (NoSuchFieldException nme) {
+ error("Could not get " + TESTFIELD + " for className "
+ + c.getName() + " Exception:\n" + nme);
+ }
+ return ret;
+
+ }
+ },
+ PACKAGE("package " + TESTPKG + "; \n" + "class #CN {}") {
+
+ @Override
+ public ExpectedBase getExpectedBase(Class<?> c) {
+ return c.getPackage().getAnnotation(ExpectedBase.class);
+ }
+
+ @Override
+ public ExpectedContainer getExpectedContainer(Class<?> c) {
+ return c.getPackage().getAnnotation(ExpectedContainer.class);
+ }
+ },
+ PKGINFO("#REPLACE1\npackage " + TESTPKG + "; \n" + "#REPLACE2"),
+ INTERFACE("#REPLACE\ninterface #IN { } "),
+ INTERFACEIMPL("#REPLACE\nclass #CN implements #IN {}"),
+ CLASSEXTENDS("#REPLACE\nclass #CN extends #SN {}");
+ String template;
+
+ private SrcType(String template) {
+ this.template = template;
+ }
+
+ public String getTemplate() {
+ return template;
+ }
+
+ // Elements should override
+ public ExpectedBase getExpectedBase(Class<?> c) {
+ return null;
+ }
+
+ public ExpectedContainer getExpectedContainer(Class<?> c) {
+ return null;
+ }
+
+ /*
+ * Returns only primary src types ;
+ */
+ public static SrcType[] getSrcTypes() {
+ return new SrcType[]{CLASS, PACKAGE, METHOD, FIELD};
+ }
+ }
+
+ /*
+ * Each enum constant is one of the 6 methods from AnnotatedElement interface
+ * that needs to be tested.
+ * Each enum constant overrides these 4 methods:
+ * - getActualAnnoBase(SrcType srcType, Class<?> c)
+ * - getActualAnnoContainer(SrcType srcType, Class<?> c)
+ * - getExpectedAnnoBase(SrcType srcType, Class<?> c)
+ * - getExpectedAnnoContainer(SrcType srcType, Class<?> c)
+ */
+ enum TestMethod {
+
+ GET_ANNO("getAnnotation") {
+
+ @Override
+ public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
+ Annotation[] actualAnno = new Annotation[1];
+ switch (srcType) {
+ case CLASS:
+ actualAnno[0] = c.getAnnotation(srcType.getExpectedBase(c).value());
+ break;
+ case PACKAGE:
+ actualAnno[0] = c.getPackage().getAnnotation(
+ srcType.getExpectedBase(c).value());
+ break;
+ case METHOD:
+ try {
+ actualAnno[0] = c.getDeclaredMethod(TESTMETHOD).getAnnotation(
+ srcType.getExpectedBase(c).value());
+ } catch (NoSuchMethodException nme) {
+ error("Could not get " + TESTMETHOD
+ + " for className = " + c.getName()
+ + "Exception = " + nme);
+ }
+ break;
+ case FIELD:
+ try {
+ actualAnno[0] = c.getDeclaredField(TESTFIELD).getAnnotation(
+ srcType.getExpectedBase(c).value());
+ } catch (NoSuchFieldException nfe) {
+ error("Could not get " + TESTFIELD
+ + " for className = " + c.getName()
+ + "Exception = " + nfe);
+ }
+ break;
+ }
+ return actualAnno;
+ }
+
+ @Override
+ public Annotation[] getActualAnnoContainer(SrcType srcType,
+ Class<?> c) {
+ Annotation[] actualAnno = new Annotation[1];
+ switch (srcType) {
+ case CLASS:
+ actualAnno[0] = c.getAnnotation(srcType.getExpectedContainer(c).value());
+ break;
+ case PACKAGE:
+ actualAnno[0] = c.getPackage().getAnnotation(
+ srcType.getExpectedContainer(c).value());
+ break;
+ case METHOD:
+ try {
+ actualAnno[0] = c.getDeclaredMethod(TESTMETHOD).getAnnotation(
+ srcType.getExpectedContainer(c).value());
+ } catch (NoSuchMethodException nme) {
+ error("Could not get " + TESTMETHOD
+ + " for className = " + c.getName()
+ + "Exception = " + nme);
+ }
+ break;
+ case FIELD:
+ try {
+ actualAnno[0] = c.getDeclaredField(TESTFIELD).getAnnotation(
+ srcType.getExpectedContainer(c).value());
+ } catch (NoSuchFieldException nfe) {
+ error("Could not get " + TESTFIELD
+ + " for className = " + c.getName()
+ + "Exception = " + nfe);
+ }
+ break;
+ }
+ return actualAnno;
+ }
+
+ @Override
+ public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
+ String[] expAnno = {srcType.getExpectedBase(c).getAnnotationVal()};
+ return expAnno;
+ }
+
+ @Override
+ public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
+ String[] expAnno = {srcType.getExpectedContainer(c).getAnnotationVal()};
+ return expAnno;
+ }
+ },
+ GET_ANNOS("getAnnotations") {
+
+ @Override
+ public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
+ Annotation[] actualAnnos = null;
+ switch (srcType) {
+ case CLASS:
+ actualAnnos = c.getAnnotations();
+ break;
+ case PACKAGE:
+ actualAnnos = c.getPackage().getAnnotations();
+ break;
+ case METHOD:
+ try {
+ actualAnnos = c.getDeclaredMethod(TESTMETHOD).getAnnotations();
+ } catch (NoSuchMethodException nme) {
+ error("Could not get " + TESTMETHOD
+ + " for className = " + c.getName()
+ + "Exception = " + nme);
+ }
+ break;
+ case FIELD:
+ try {
+ actualAnnos = c.getDeclaredField(TESTFIELD).getAnnotations();
+ } catch (NoSuchFieldException nfe) {
+ error("Could not get " + TESTFIELD
+ + " for className = " + c.getName()
+ + "Exception = " + nfe);
+ }
+ break;
+ }
+ return actualAnnos;
+ }
+
+ @Override
+ public Annotation[] getActualAnnoContainer(SrcType srcType,
+ Class<?> c) {
+ Annotation[] actualAnnos = null;
+ switch (srcType) {
+ case CLASS:
+ actualAnnos = c.getAnnotations();
+ break;
+ case PACKAGE:
+ actualAnnos = c.getPackage().getAnnotations();
+ break;
+ case METHOD:
+ try {
+ actualAnnos = c.getDeclaredMethod(TESTMETHOD).getAnnotations();
+ } catch (NoSuchMethodException nme) {
+ error("Could not get " + TESTMETHOD
+ + " for className = " + c.getName()
+ + "Exception = " + nme);
+ }
+ break;
+ case FIELD:
+ try {
+ actualAnnos = c.getDeclaredField(TESTFIELD).getAnnotations();
+ } catch (NoSuchFieldException nfe) {
+ error("Could not get " + TESTFIELD
+ + " for className = " + c.getName()
+ + "Exception = " + nfe);
+ }
+ break;
+ }
+ return actualAnnos;
+ }
+
+ @Override
+ public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
+ return srcType.getExpectedBase(c).getAnnotationsVals();
+ }
+
+ @Override
+ public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
+ return srcType.getExpectedContainer(c).getAnnotationsVals();
+ }
+ },
+ GET_DECL_ANNOS("getDeclaredAnnotations") {
+
+ @Override
+ public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
+ Annotation[] actualDeclAnnos = null;
+ switch (srcType) {
+ case CLASS:
+ actualDeclAnnos = c.getDeclaredAnnotations();
+ break;
+ case PACKAGE:
+ actualDeclAnnos = c.getPackage().getDeclaredAnnotations();
+ break;
+ case METHOD:
+ try {
+ actualDeclAnnos = c.getDeclaredMethod(TESTMETHOD)
+ .getDeclaredAnnotations();
+ } catch (NoSuchMethodException nme) {
+ error("Could not get " + TESTMETHOD
+ + " for className = " + c.getName()
+ + "Exception = " + nme);
+ }
+ break;
+ case FIELD:
+ try {
+ actualDeclAnnos = c.getDeclaredField(TESTFIELD)
+ .getDeclaredAnnotations();
+ } catch (NoSuchFieldException nfe) {
+ error("Could not get " + TESTFIELD
+ + " for className = " + c.getName()
+ + "Exception = " + nfe);
+ }
+ break;
+ }
+ return actualDeclAnnos;
+ }
+
+ @Override
+ public Annotation[] getActualAnnoContainer(SrcType srcType,
+ Class<?> c) {
+ Annotation[] actualDeclAnnos = null;
+ switch (srcType) {
+ case CLASS:
+ actualDeclAnnos = c.getDeclaredAnnotations();
+ break;
+ case PACKAGE:
+ actualDeclAnnos = c.getPackage().getDeclaredAnnotations();
+ break;
+ case METHOD:
+ try {
+ actualDeclAnnos = c.getDeclaredMethod(TESTMETHOD)
+ .getDeclaredAnnotations();
+ } catch (NoSuchMethodException nme) {
+ error("Could not get " + TESTMETHOD
+ + " for className = " + c.getName()
+ + "Exception = " + nme);
+ }
+ break;
+ case FIELD:
+ try {
+ actualDeclAnnos = c.getDeclaredField(TESTFIELD)
+ .getDeclaredAnnotations();
+ } catch (NoSuchFieldException nfe) {
+ error("Could not get " + TESTFIELD
+ + " for className = " + c.getName()
+ + "Exception = " + nfe);
+ }
+ break;
+ }
+ return actualDeclAnnos;
+ }
+
+ @Override
+ public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
+ return srcType.getExpectedBase(c).getDeclAnnosVals();
+ }
+
+ @Override
+ public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
+ return srcType.getExpectedContainer(c).getDeclAnnosVals();
+ }
+ },
+ GET_DECL_ANNO("getDeclaredAnnotation") {
+
+ @Override
+ public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
+ Annotation[] actualDeclAnno = new Annotation[1];
+ switch (srcType) {
+ case CLASS:
+ actualDeclAnno[0] = c.getDeclaredAnnotation(
+ srcType.getExpectedBase(c).value());
+ break;
+ case PACKAGE:
+ actualDeclAnno[0] = c.getPackage().getDeclaredAnnotation(
+ srcType.getExpectedBase(c).value());
+ break;
+ case METHOD:
+ try {
+ actualDeclAnno[0] = c.getDeclaredMethod(TESTMETHOD)
+ .getDeclaredAnnotation(
+ srcType.getExpectedBase(c).value());
+ } catch (NoSuchMethodException nme) {
+ error("Could not get " + TESTMETHOD
+ + " for className = " + c.getName()
+ + "Exception = " + nme);
+ }
+ break;
+ case FIELD:
+ try {
+ actualDeclAnno[0] = c.getDeclaredField(TESTFIELD)
+ .getDeclaredAnnotation(
+ srcType.getExpectedBase(c).value());
+ } catch (NoSuchFieldException nfe) {
+ error("Could not get " + TESTFIELD
+ + " for className = " + c.getName()
+ + "Exception = " + nfe);
+ }
+ break;
+ }
+ return actualDeclAnno;
+ }
+
+ @Override
+ public Annotation[] getActualAnnoContainer(SrcType srcType,
+ Class<?> c) {
+ Annotation[] actualDeclAnno = new Annotation[1];
+ switch (srcType) {
+ case CLASS:
+ actualDeclAnno[0] = c.getDeclaredAnnotation(
+ srcType.getExpectedContainer(c).value());
+ break;
+ case PACKAGE:
+ actualDeclAnno[0] = c.getPackage().getDeclaredAnnotation(
+ srcType.getExpectedContainer(c).value());
+ break;
+ case METHOD:
+ try {
+ actualDeclAnno[0] = c.getDeclaredMethod(TESTMETHOD)
+ .getDeclaredAnnotation(
+ srcType.getExpectedContainer(c).value());
+ } catch (NoSuchMethodException nme) {
+ error("Could not get " + TESTMETHOD
+ + " for className = " + c.getName()
+ + "Exception = " + nme);
+ }
+ break;
+ case FIELD:
+ try {
+ actualDeclAnno[0] = c.getDeclaredField(TESTFIELD)
+ .getDeclaredAnnotation(
+ srcType.getExpectedContainer(c).value());
+ } catch (NoSuchFieldException nfe) {
+ error("Could not get " + TESTFIELD
+ + " for className = " + c.getName()
+ + "Exception = " + nfe);
+ }
+ break;
+ }
+ return actualDeclAnno;
+ }
+
+ @Override
+ public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
+ String[] expAnno = {srcType.getExpectedBase(c).getDeclAnnoVal()};
+ return expAnno;
+ }
+
+ @Override
+ public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
+ String[] expAnno = {srcType.getExpectedContainer(c).getDeclAnnoVal()};
+ return expAnno;
+ }
+ }, // new
+ GET_ANNOS_ARG("getAnnotationsArg") {
+
+ @Override
+ public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
+ Annotation[] actualAnnoArgs = null;
+ switch (srcType) {
+ case CLASS:
+ actualAnnoArgs = c.getAnnotationsByType(srcType.getExpectedBase(c).value());
+ break;
+ case PACKAGE:
+ actualAnnoArgs = c.getPackage().getAnnotationsByType(
+ srcType.getExpectedBase(c).value());
+ break;
+ case METHOD:
+ try {
+ actualAnnoArgs = c.getDeclaredMethod(TESTMETHOD)
+ .getAnnotationsByType(
+ srcType.getExpectedBase(c).value());
+ } catch (NoSuchMethodException nme) {
+ error("Could not get " + TESTMETHOD
+ + " for className = " + c.getName()
+ + "Exception = " + nme);
+ }
+ break;
+ case FIELD:
+ try {
+ actualAnnoArgs = c.getDeclaredField(TESTFIELD)
+ .getAnnotationsByType(
+ srcType.getExpectedBase(c).value());
+ } catch (NoSuchFieldException nfe) {
+ error("Could not get " + TESTFIELD
+ + " for className = " + c.getName()
+ + "Exception = " + nfe);
+ }
+ break;
+ }
+ return actualAnnoArgs;
+ }
+
+ @Override
+ public Annotation[] getActualAnnoContainer(SrcType srcType,
+ Class<?> c) {
+ Annotation[] actualAnnoArgs = null;
+ switch (srcType) {
+ case CLASS:
+ actualAnnoArgs = c.getAnnotationsByType(srcType.getExpectedContainer(c).value());
+ break;
+ case PACKAGE:
+ actualAnnoArgs = c.getPackage().getAnnotationsByType(
+ srcType.getExpectedContainer(c).value());
+ break;
+ case METHOD:
+ try {
+ actualAnnoArgs = c.getDeclaredMethod(TESTMETHOD)
+ .getAnnotationsByType(
+ srcType.getExpectedContainer(c).value());
+ } catch (NoSuchMethodException nme) {
+ error("Could not get " + TESTMETHOD
+ + " for className = " + c.getName()
+ + "Exception = " + nme);
+ }
+ break;
+ case FIELD:
+ try {
+ actualAnnoArgs = c.getDeclaredField(TESTFIELD)
+ .getAnnotationsByType(
+ srcType.getExpectedContainer(c).value());
+ } catch (NoSuchFieldException nfe) {
+ error("Could not get " + TESTFIELD
+ + " for className = " + c.getName()
+ + "Exception = " + nfe);
+ }
+ break;
+ }
+ return actualAnnoArgs;
+ }
+
+ @Override
+ public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
+ return srcType.getExpectedBase(c).getAnnosArgs();
+ }
+
+ @Override
+ public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
+ return srcType.getExpectedContainer(c).getAnnosArgs();
+ }
+ }, // new
+ GET_DECL_ANNOS_ARG("getDeclAnnosArg") {
+
+ @Override
+ public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
+ Annotation[] actualDeclAnnosArgs = null;
+ switch (srcType) {
+ case CLASS:
+ actualDeclAnnosArgs = c.getDeclaredAnnotationsByType(
+ srcType.getExpectedBase(c).value());
+ break;
+ case PACKAGE:
+ actualDeclAnnosArgs = c.getPackage().getDeclaredAnnotationsByType(
+ srcType.getExpectedBase(c).value());
+ break;
+ case METHOD:
+ try {
+ actualDeclAnnosArgs = c.getDeclaredMethod(TESTMETHOD)
+ .getDeclaredAnnotationsByType(
+ srcType.getExpectedBase(c).value());
+ } catch (NoSuchMethodException nme) {
+ error("Could not get " + TESTMETHOD
+ + " for className = " + c.getName()
+ + "Exception = " + nme);
+ }
+ break;
+ case FIELD:
+ try {
+ actualDeclAnnosArgs = c.getDeclaredField(TESTFIELD)
+ .getDeclaredAnnotationsByType(
+ srcType.getExpectedBase(c).value());
+ } catch (NoSuchFieldException nfe) {
+ error("Could not get " + TESTFIELD
+ + " for className = " + c.getName()
+ + "Exception = " + nfe);
+ }
+ break;
+ }
+ return actualDeclAnnosArgs;
+ }
+
+ @Override
+ public Annotation[] getActualAnnoContainer(SrcType srcType,
+ Class<?> c) {
+ Annotation[] actualDeclAnnosArgs = null;
+ switch (srcType) {
+ case CLASS:
+ actualDeclAnnosArgs = c.getDeclaredAnnotationsByType(
+ srcType.getExpectedContainer(c).value());
+ break;
+ case PACKAGE:
+ actualDeclAnnosArgs = c.getPackage().getDeclaredAnnotationsByType(
+ srcType.getExpectedContainer(c).value());
+ break;
+ case METHOD:
+ try {
+ actualDeclAnnosArgs = c.getDeclaredMethod(TESTMETHOD)
+ .getDeclaredAnnotationsByType(
+ srcType.getExpectedContainer(c).value());
+ } catch (NoSuchMethodException nme) {
+ error("Could not get " + TESTMETHOD
+ + " for className = " + c.getName()
+ + "Exception = " + nme);
+ }
+ break;
+ case FIELD:
+ try {
+ actualDeclAnnosArgs = c.getDeclaredField(TESTFIELD)
+ .getDeclaredAnnotationsByType(
+ srcType.getExpectedContainer(c).value());
+ } catch (NoSuchFieldException nfe) {
+ error("Could not get " + TESTFIELD
+ + " for className = " + c.getName()
+ + "Exception = " + nfe);
+ }
+ break;
+ }
+ return actualDeclAnnosArgs;
+ }
+
+ @Override
+ public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
+ return srcType.getExpectedBase(c).getDeclAnnosArgs();
+ }
+
+ @Override
+ public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
+ return srcType.getExpectedContainer(c).getDeclAnnosArgs();
+ }
+ }; // new
+ String name;
+
+ private TestMethod(String name) {
+ this.name = name;
+ }
+
+ public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
+ return null;
+ }
+
+ public Annotation[] getActualAnnoContainer(SrcType srcType, Class<?> c) {
+ return null;
+ }
+
+ public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
+ return null;
+ }
+
+ public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
+ return null;
+ }
+ }
+
+ /*
+ * For a given srcType and class object, compare expectedBase and actualBase
+ * annotations as well as expectedContainer and actualContainer annotations.
+ *
+ * Return true if both comparisons are true else return false.
+ *
+ */
+ protected static void checkAnnoValues(SrcType srcType, Class<?> c) {
+
+ // Load @ExpectedBase and @ExpectedContainer
+ ExpectedBase eb = srcType.getExpectedBase(c);
+ ExpectedContainer ec = srcType.getExpectedContainer(c);
+ if (eb == null) {
+ error("Did not find ExpectedBase Annotation, Test will exit");
+ throw new RuntimeException();
+ }
+ if (ec == null) {
+ error("Did not find ExpectedContainer Annotation, Test will exit");
+ throw new RuntimeException();
+ }
+
+ for (TestMethod testMethod : TestMethod.values()) {
+ debugPrint("---------------------------------------------");
+ debugPrint("Test method = " + testMethod);
+ boolean isBasePass = true;
+ boolean isConPass = true;
+ // ExpectedBase = Annotation, no annotation is defined, skip comparison
+ if (!eb.value().getSimpleName().equalsIgnoreCase("Annotation")) {
+ isBasePass = compareAnnotations(
+ testMethod.getActualAnnoBase(srcType, c),
+ testMethod.getExpectedAnnoBase(srcType, c));
+ }
+
+ // ExpectedContainer = Annotation, no annotation is defined, skip comparison
+ if (!ec.value().getSimpleName().equalsIgnoreCase("Annotation")) {
+ isConPass = compareAnnotations(
+ testMethod.getActualAnnoContainer(srcType, c),
+ testMethod.getExpectedAnnoContainer(srcType, c));
+ }
+ if (isBasePass && isConPass) {
+ debugPrint("Testcase passed for " + testMethod +
+ " for className = " + c.getName());
+ } else {
+ debugPrint("Testcase failed for " + testMethod +
+ " for className = " + c.getName());
+ }
+ }
+ }
+
+ // Annotation comparison: Length should be same and all expected values
+ // should be present in actualAnno[].
+ private static boolean compareAnnotations(Annotation[] actualAnnos,
+ String[] expectedAnnos) {
+ // Length is different
+ if (actualAnnos.length != expectedAnnos.length) {
+ error("Length not same, Actual length = " + actualAnnos.length
+ + " Expected length = " + expectedAnnos.length);
+ printArrContents(actualAnnos);
+ printArrContents(expectedAnnos);
+ return false;
+ } else {
+ int i = 0;
+ // Length is same and 0
+ if (actualAnnos.length == 0) {
+ // Expected/actual lengths already checked for
+ // equality; no more checks do to
+ return true;
+ }
+ // Expected annotation should be NULL
+ if (actualAnnos[0] == null) {
+ if (expectedAnnos[0].equals("NULL")) {
+ debugPrint("Arr values are NULL as expected");
+ return true;
+ } else {
+ error("Array values are not NULL");
+ printArrContents(actualAnnos);
+ printArrContents(expectedAnnos);
+ return false;
+ }
+ }
+ // Lengths are same, compare array contents
+ String[] actualArr = new String[actualAnnos.length];
+ for (Annotation a : actualAnnos) {
+ actualArr[i++] = a.annotationType().getSimpleName();
+ }
+
+ List<String> actualList = Arrays.asList(actualArr);
+ List<String> expectedList = Arrays.asList(expectedAnnos);
+
+ if (!actualList.containsAll(expectedList)) {
+ error("Array values are not same");
+ printArrContents(actualAnnos);
+ printArrContents(expectedAnnos);
+ return false;
+ } else {
+ debugPrint("Arr values are same as expected");
+ }
+ }
+ return true;
+ }
+
+ private static void printArrContents(Annotation[] actualAnnos) {
+ System.out.print("Actual Arr Values: ");
+ for (Annotation a : actualAnnos) {
+ if (a != null && a.annotationType() != null) {
+ System.out.print("[" + a.annotationType().getSimpleName() + "]");
+ } else {
+ System.out.println("[null]");
+ }
+ }
+ System.out.println();
+ }
+
+ private static void printArrContents(String[] expectedAnnos) {
+ System.out.print("Expected Arr Values: ");
+ for (String s : expectedAnnos) {
+ System.out.print("[" + s + "]");
+ }
+ System.out.println();
+ }
+
+ private ClassLoader getLoader() {
+ return getClass().getClassLoader();
+ }
+
+ private static Class<?> loadClass(String className, ClassLoader parentClassLoader, File... destDirs) {
+ try {
+ List<URL> list = new ArrayList<>();
+ for (File f : destDirs) {
+ list.add(new URL("file:" + f.toString().replace("\\", "/") + "/"));
+ }
+ return Class.forName(className, true, new URLClassLoader(
+ list.toArray(new URL[list.size()]), parentClassLoader));
+ } catch (ClassNotFoundException | MalformedURLException e) {
+ throw new RuntimeException("Error loading class " + className, e);
+ }
+ }
+
+ private static void printTestSrc(Iterable<? extends JavaFileObject> files) {
+ for (JavaFileObject f : files) {
+ System.out.println("Test file " + f.getName() + ":");
+ try {
+ System.out.println("" + f.getCharContent(true));
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "Exception when printing test src contents for class " +
+ f.getName(), e);
+ }
+ }
+
+ }
+
+ public static StringBuilder getCommonStmts(boolean isRepeatable) {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+ .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.INHERITED.getVal());
+ if(isRepeatable) {
+ sb.append(Helper.ContentVars.REPEATABLE.getVal());
+ }
+ sb.append(Helper.ContentVars.BASE.getVal())
+ .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+ .append(Helper.ContentVars.INHERITED.getVal())
+ .append(Helper.ContentVars.CONTAINER.getVal());
+ return sb;
+ }
+
+ private static int getNumErrors() {
+ return errors;
+ }
+
+ private static void error(String msg) {
+ System.out.println("error: " + msg);
+ errors++;
+ }
+
+ private static void debugPrint(String string) {
+ if(DEBUG)
+ System.out.println(string);
+ }
+}
--- a/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java Tue Mar 12 16:43:53 2013 -0700
@@ -26,6 +26,7 @@
* @bug 7195131
* @author sogoel
* @summary Combo test for all possible combinations for Target values
+ * @ignore 8008339 Test TargetAnnoCombo.java is broken
* @build Helper
* @compile TargetAnnoCombo.java TestCaseGenerator.java
* @run main TargetAnnoCombo
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/expectedFiles/ExpectedBase.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package expectedFiles;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ExpectedBase {
+ Class<? extends Annotation> value() default Annotation.class;
+ String getAnnotationVal() default "";
+ String[] getAnnotationsVals() default {};
+ String[] getDeclAnnosVals() default {};
+ // JDK8 methods
+ String getDeclAnnoVal() default "";
+ String[] getAnnosArgs() default{};
+ String[] getDeclAnnosArgs() default {};
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/expectedFiles/ExpectedContainer.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package expectedFiles;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ExpectedContainer {
+ Class<? extends Annotation> value() default Annotation.class;
+ String getAnnotationVal() default "";
+ String[] getAnnotationsVals() default {};
+ String[] getDeclAnnosVals() default {};
+ // JDK8 methods
+ String getDeclAnnoVal() default "";
+ String[] getAnnosArgs() default{};
+ String[] getDeclAnnosArgs() default {};
+}
+
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.out Tue Mar 12 16:43:53 2013 -0700
@@ -1,3 +1,2 @@
-DuplicateTypeAnnotation.java:11:12: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
DuplicateTypeAnnotation.java:11:15: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
-2 errors
+1 error
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.out Tue Mar 12 16:43:53 2013 -0700
@@ -1,3 +1,2 @@
-DuplicateTypeAnnotation.java:11:17: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
DuplicateTypeAnnotation.java:11:20: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
-2 errors
+1 error
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.out Tue Mar 12 16:43:53 2013 -0700
@@ -1,3 +1,2 @@
-DuplicateTypeAnnotation.java:11:29: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
DuplicateTypeAnnotation.java:11:32: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
-2 errors
+1 error
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.out Tue Mar 12 16:43:53 2013 -0700
@@ -1,3 +1,2 @@
-DuplicateTypeAnnotation.java:9:35: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
DuplicateTypeAnnotation.java:9:38: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
-2 errors
\ No newline at end of file
+1 error
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.out Tue Mar 12 16:43:53 2013 -0700
@@ -1,3 +1,2 @@
-DuplicateTypeAnnotation.java:10:13: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
DuplicateTypeAnnotation.java:10:16: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
-2 errors
+1 error
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.out Tue Mar 12 16:43:53 2013 -0700
@@ -1,3 +1,2 @@
-DuplicateTypeAnnotation.java:11:9: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
DuplicateTypeAnnotation.java:11:12: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
-2 errors
\ No newline at end of file
+1 error
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.out Tue Mar 12 16:43:53 2013 -0700
@@ -1,3 +1,2 @@
-DuplicateTypeAnnotation.java:10:21: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
DuplicateTypeAnnotation.java:10:24: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
-2 errors
\ No newline at end of file
+1 error
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.out Tue Mar 12 16:43:53 2013 -0700
@@ -1,3 +1,2 @@
-DuplicateTypeAnnotation.java:9:25: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
DuplicateTypeAnnotation.java:9:28: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
-2 errors
\ No newline at end of file
+1 error
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.out Tue Mar 12 16:43:53 2013 -0700
@@ -1,3 +1,2 @@
-DuplicateTypeAnnotation.java:10:21: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
DuplicateTypeAnnotation.java:10:24: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
-2 errors
\ No newline at end of file
+1 error
--- a/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/RepeatingTypeAnnotations.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/RepeatingTypeAnnotations.out Tue Mar 12 16:43:53 2013 -0700
@@ -1,53 +1,28 @@
-RepeatingTypeAnnotations.java:39:21: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:39:25: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:41:21: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:41:25: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:42:21: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:42:25: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:50:22: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:50:31: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:52:20: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:52:24: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:61:17: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:61:21: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:63:34: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:63:38: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:65:20: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:65:24: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:72:17: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:72:21: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:77:24: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:77:28: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:79:17: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:79:21: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:79:32: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:79:36: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:81:15: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:81:19: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:85:15: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:85:19: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:85:30: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:85:34: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:89:14: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:89:18: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:89:29: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:89:33: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:93:15: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:93:19: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:93:31: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:93:35: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:97:30: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:97:34: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:97:15: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:97:19: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:101:22: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:101:26: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:101:33: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:101:37: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:101:68: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:101:72: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
-RepeatingTypeAnnotations.java:101:52: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
RepeatingTypeAnnotations.java:101:56: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
- compiler.note.unchecked.filename: RepeatingTypeAnnotations.java
- compiler.note.unchecked.recompile
-50 errors
\ No newline at end of file
+25 errors
--- a/langtools/test/tools/javac/constDebug/ConstDebug.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2002, 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 4645152 4785453
- * @summary javac compiler incorrectly inserts <clinit> when -g is specified
- * @author gafter
- *
- * @run shell ConstDebug.sh ConstDebug
- */
-
-public class ConstDebug {
- public static final long l = 12;
-}
--- a/langtools/test/tools/javac/constDebug/ConstDebug.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2009, 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.
-#
-
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin )
- PS=":"
- FS="/"
- ;;
- CYGWIN* )
- PS=";" # Platform PS, not Cygwin PS
- FS="/"
- ;;
- Windows* )
- PS=";"
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-TMP1=OUTPUT.txt
-
-cp "${TESTSRC}${FS}$1.java" .
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -g -d . -classpath .${PS}${TESTSRC} $1.java 2> ${TMP1}
-result=$?
-if [ $result -ne 0 ]; then exit $result; fi
-if "${TESTJAVA}${FS}bin${FS}javap" $1.class | grep clinit; then
- echo "Failed"
- exit 1;
-else
- echo "Passed"
- exit 0;
-fi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/constDebug/ConstDebugTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,51 @@
+/*
+ * 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 4645152 4785453
+ * @summary javac compiler incorrectly inserts <clinit> when -g is specified
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run compile -g ConstDebugTest.java
+ * @run main ConstDebugTest
+ */
+
+//original test: test/tools/javac/constDebug/ConstDebug.sh
+public class ConstDebugTest {
+
+ public static final long l = 12;
+
+ public static void main(String args[]) throws Exception {
+// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -g -d . -classpath .${PS}${TESTSRC} $1.java 2> ${TMP1}
+// if "${TESTJAVA}${FS}bin${FS}javap" $1.class | grep clinit; then fail
+ ToolBox.JavaToolArgs javapArgs =
+ new ToolBox.JavaToolArgs().setAllArgs("-v",
+ "-classpath", System.getProperty("test.classes"), "ConstDebugTest.class");
+ if (ToolBox.javap(javapArgs).contains("clinit")) {
+ throw new AssertionError(
+ "javac should not create a <clinit> method for ConstDebugTest class");
+ }
+ }
+
+}
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt Tue Mar 12 16:43:53 2013 -0700
@@ -110,4 +110,5 @@
compiler.warn.unexpected.archive.file # Paths: zip file with unknown extn
compiler.warn.unknown.enum.constant # in bad class file
compiler.warn.unknown.enum.constant.reason # in bad class file
+compiler.warn.override.equals.but.not.hashcode # when a class overrides equals but not hashCode method from Object
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleArgTypesInMethodRef.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.cant.apply.symbol
+// key: compiler.misc.infer.no.conforming.assignment.exists
+// key: compiler.misc.incompatible.arg.types.in.mref
+
+class IncompatibleArgTypesInMethodRef {
+ interface SAM<X> {
+ void m(X x);
+ }
+
+ void g(String s, Integer i) { }
+
+ <Z> void m(SAM<Z> s) { }
+
+ void test() {
+ m(this::g);
+ }
+}
--- a/langtools/test/tools/javac/diags/examples/NonStaticCantBeRefFragment.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/NonStaticCantBeRefFragment.java Tue Mar 12 16:43:53 2013 -0700
@@ -21,9 +21,8 @@
* questions.
*/
-// key: compiler.err.prob.found.req
// key: compiler.misc.non-static.cant.be.ref
-// key: compiler.misc.invalid.mref
+// key: compiler.err.invalid.mref
class NonStaticCantBeRefFragment {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefPublicCantAccessFragment/NotDefPublicCantAccessFragment.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.prob.found.req
+// key: compiler.misc.invalid.mref
+// key: compiler.misc.not.def.public.cant.access
+
+class NotDefPublicCantAccessFragment {
+ interface SAM {
+ void m();
+ }
+
+ void test (p.C c) {
+ SAM s = c::m;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefPublicCantAccessFragment/p/C.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+package p;
+
+public class C {
+ void m() { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/StaticMethodInUnboundLookup.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.invalid.mref
+// key: compiler.misc.static.method.in.unbound.lookup
+
+class StaticBoundMref {
+
+ interface SAM {
+ void m(StaticBoundMref m);
+ }
+
+ SAM s = StaticBoundMref::m;
+
+ static void m() { }
+}
--- a/langtools/test/tools/javac/fatalErrors/NoJavaLang.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 1999, 2002, 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 4263768 4785453
- * @summary Verify that the compiler does not crash when java.lang is not
- * found.
- * @author iag
- *
- * @run shell NoJavaLang.sh
- */
-
-public class NoJavaLang {
- private String s;
-
- public String s() {
- return s;
- }
-}
--- a/langtools/test/tools/javac/fatalErrors/NoJavaLang.out Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-Fatal Error: Unable to find package java.lang in classpath or bootclasspath
--- a/langtools/test/tools/javac/fatalErrors/NoJavaLang.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 1999, 2009, 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.
-#
-
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-printf '%s' "TESTSRC=${TESTSRC}" ; echo
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-printf '%s' "TESTJAVA=${TESTJAVA}" ; echo
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-printf '%s' "TESTCLASSES=${TESTCLASSES}" ; echo
-printf '%s' "CLASSPATH=${CLASSPATH}" ; echo
-echo
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin )
- FS="/"
- ;;
- CYGWIN* )
- FS="/"
- DIFFOPTS="--strip-trailing-cr"
- ;;
- Windows* )
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-TMP1=OUTPUT.txt
-
-cp "${TESTSRC}${FS}NoJavaLang.java" .
-
-echo "- verifing that fatal error is not produced in the regular case"
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} NoJavaLang.java 2> "${TMP1}"
-result=$?
-
-if [ $result -eq 0 ]
-then
- echo "Passed - base compilation successful"
-else
- echo "Failed - unable to compile test"
- exit $result
-fi
-
-echo
-
-echo "- verifing the fatal error is produced"
-rm "${TMP1}"
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -bootclasspath . NoJavaLang.java 2> "${TMP1}"
-
-# return code should be EXIT_SYSERR
-result=$?
-if [ $result -ne 3 ]
-then
- echo "Failed - unexpected return code"
- exit $result
-else
- echo "Passed - expected return code"
-fi
-
-# expected message
-cat "${TMP1}"
-diff ${DIFFOPTS} -c "${TESTSRC}${FS}NoJavaLang.out" "${TMP1}"
-result=$?
-rm "${TMP1}"
-
-if [ $result -eq 0 ]
-then
- echo "Passed - expected message"
-else
- echo "Failed - unexpected message"
- exit $result
-
-fi
-
-exit
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/fatalErrors/NoJavaLangTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,76 @@
+/*
+ * 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 4263768 4785453
+ * @summary Verify that the compiler does not crash when java.lang is not
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main NoJavaLangTest
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+//original test: test/tools/javac/fatalErrors/NoJavaLang.sh
+public class NoJavaLangTest {
+
+ private static final String noJavaLangSrc =
+ "public class NoJavaLang {\n" +
+ " private String s;\n" +
+ "\n" +
+ " public String s() {\n" +
+ " return s;\n" +
+ " }\n" +
+ "}";
+
+ private static final String compilerErrorMessage =
+ "Fatal Error: Unable to find package java.lang in classpath or bootclasspath";
+
+ public static void main(String[] args) throws Exception {
+// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} NoJavaLang.java 2> "${TMP1}"
+ ToolBox.JavaToolArgs javacSuccessArgs =
+ new ToolBox.JavaToolArgs().setSources(noJavaLangSrc);
+ ToolBox.javac(javacSuccessArgs);
+
+// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -bootclasspath . NoJavaLang.java 2> "${TMP1}"
+ List<String> output = new ArrayList<>();
+ ToolBox.JavaToolArgs javacFailArgs =
+ new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
+ .setOptions("-bootclasspath", ".")
+ .setSources(noJavaLangSrc)
+ .setErrOutput(output);
+
+ int cr = ToolBox.javac(javacFailArgs);
+ if (cr != 3) {
+ throw new AssertionError("Compiler exit result should be 3");
+ }
+
+// diff ${DIFFOPTS} -c "${TESTSRC}${FS}NoJavaLang.out" "${TMP1}"
+ if (!(output.size() == 1 && output.get(0).equals(compilerErrorMessage))) {
+ throw new AssertionError("javac generated error output is not correct");
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,39 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6939780 7020044 8009459
+ *
+ * @summary add a warning to detect diamond sites
+ * @author mcimadamore
+ * @compile/ref=T6939780_7.out -Xlint:-options -source 7 T6939780.java -XDrawDiagnostics -XDfindDiamond
+ * @compile/ref=T6939780_8.out T6939780.java -XDrawDiagnostics -XDfindDiamond
+ *
+ */
+
+class T6939780 {
+
+ static class Foo<X extends Number> {
+ Foo() {}
+ Foo(X x) {}
+ }
+
+ void testAssign() {
+ Foo<Number> f1 = new Foo<Number>(1);
+ Foo<?> f2 = new Foo<Number>();
+ Foo<?> f3 = new Foo<Integer>();
+ Foo<Number> f4 = new Foo<Number>(1) {};
+ Foo<?> f5 = new Foo<Number>() {};
+ Foo<?> f6 = new Foo<Integer>() {};
+ }
+
+ void testMethod() {
+ gn(new Foo<Number>(1));
+ gw(new Foo<Number>());
+ gw(new Foo<Integer>());
+ gn(new Foo<Number>(1) {});
+ gw(new Foo<Number>() {});
+ gw(new Foo<Integer>() {});
+ }
+
+ void gw(Foo<?> fw) { }
+ void gn(Foo<Number> fn) { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_7.out Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,4 @@
+T6939780.java:21:28: compiler.warn.diamond.redundant.args: T6939780.Foo<java.lang.Number>, T6939780.Foo<java.lang.Number>
+T6939780.java:22:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:30:19: compiler.warn.diamond.redundant.args: T6939780.Foo<java.lang.Number>, T6939780.Foo<java.lang.Number>
+3 warnings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_8.out Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,7 @@
+T6939780.java:20:33: compiler.warn.diamond.redundant.args: T6939780.Foo<java.lang.Number>, T6939780.Foo<java.lang.Number>
+T6939780.java:21:28: compiler.warn.diamond.redundant.args: T6939780.Foo<java.lang.Number>, T6939780.Foo<java.lang.Number>
+T6939780.java:22:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:29:19: compiler.warn.diamond.redundant.args: T6939780.Foo<java.lang.Number>, T6939780.Foo<java.lang.Number>
+T6939780.java:30:19: compiler.warn.diamond.redundant.args: T6939780.Foo<java.lang.Number>, T6939780.Foo<java.lang.Number>
+T6939780.java:31:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+6 warnings
--- a/langtools/test/tools/javac/generics/diamond/T6939780.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6939780 7020044
- *
- * @summary add a warning to detect diamond sites
- * @author mcimadamore
- * @compile/ref=T6939780.out T6939780.java -XDrawDiagnostics -XDfindDiamond
- *
- */
-
-class T6939780 {
-
- void test() {
- class Foo<X extends Number> {
- Foo() {}
- Foo(X x) {}
- }
- Foo<Number> f1 = new Foo<Number>(1);
- Foo<?> f2 = new Foo<Number>();
- Foo<?> f3 = new Foo<Integer>();
- Foo<Number> f4 = new Foo<Number>(1) {};
- Foo<?> f5 = new Foo<Number>() {};
- Foo<?> f6 = new Foo<Integer>() {};
- }
-}
--- a/langtools/test/tools/javac/generics/diamond/T6939780.out Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-T6939780.java:18:33: compiler.warn.diamond.redundant.args: Foo<java.lang.Number>, Foo<java.lang.Number>
-T6939780.java:19:28: compiler.warn.diamond.redundant.args: Foo<java.lang.Number>, Foo<java.lang.Number>
-T6939780.java:20:28: compiler.warn.diamond.redundant.args.1: Foo<java.lang.Integer>, Foo<java.lang.Number>
-3 warnings
--- a/langtools/test/tools/javac/innerClassFile/Driver.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2009, 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 4491755 4785453
-# @summary Prob w/static inner class with same name as a regular class
-# @author gafter
-#
-# @run shell Driver.sh
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin | CYGWIN* )
- FS="/"
- ;;
- Windows* )
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-set -x
-mkdir src
-cp -r ${TESTSRC}${FS}* src
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath . -sourcepath src src/x/B.java src/x/C.java src/y/Main.java
-rm y/R3.class
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath . -sourcepath src src/y/Main.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/innerClassFile/InnerClassFileTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,127 @@
+/*
+ * 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 4491755 4785453
+ * @summary Prob w/static inner class with same name as a regular class
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main InnerClassFileTest
+ */
+
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/innerClassFile/Driver.sh
+public class InnerClassFileTest {
+
+ private static final String BSrc =
+ "package x;\n" +
+ "\n" +
+ "import x.*;\n" +
+ "\n" +
+ "public class B {\n" +
+ " public static class C {}\n" +
+ "}";
+
+ private static final String CSrc =
+ "package x;\n" +
+ "\n" +
+ "import x.*;\n" +
+ "\n" +
+ "public class C {}";
+
+ private static final String MainSrc =
+ "package y;\n" +
+ "\n" +
+ "class Main {\n" +
+ " private R1 a;\n" +
+ " private R2 b;\n" +
+ " private R3 c;\n" +
+ "}";
+
+ private static final String R1Src =
+ "package y;\n" +
+ "\n" +
+ "public final class R1 {\n" +
+ " x.B.C a = null;\n" +
+ " x.C b = null;\n" +
+ " R2 c = new R2();\n" +
+ "}";
+
+ private static final String R2Src =
+ "package y;\n" +
+ "\n" +
+ "public final class R2 {\n" +
+ " x.B.C a = null;\n" +
+ " x.C b = null;\n" +
+ "}";
+
+ private static final String R3Src =
+ "package y;\n" +
+ "\n" +
+ "public final class R3 {\n" +
+ " x.B.C a = null;\n" +
+ " x.C b = null;\n" +
+ " R1 c = new R1();\n" +
+ "}";
+
+ public static void main(String args[]) throws Exception {
+ new InnerClassFileTest().run();
+ }
+
+ void run() throws Exception {
+ createFiles();
+ compileFiles();
+ }
+
+ void createFiles() throws Exception {
+// mkdir src
+// cp -r ${TESTSRC}${FS}* src
+ ToolBox.createJavaFileFromSource(Paths.get("src"), BSrc);
+ ToolBox.createJavaFileFromSource(Paths.get("src"), CSrc);
+ ToolBox.createJavaFileFromSource(Paths.get("src"), MainSrc);
+ ToolBox.createJavaFileFromSource(Paths.get("src"), R1Src);
+ ToolBox.createJavaFileFromSource(Paths.get("src"), R2Src);
+ ToolBox.createJavaFileFromSource(Paths.get("src"), R3Src);
+ }
+
+ void compileFiles() throws Exception {
+// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath .
+// -sourcepath src src/x/B.java src/x/C.java src/y/Main.java
+ ToolBox.JavaToolArgs args =
+ new ToolBox.JavaToolArgs()
+ .setAllArgs("-d", ".", "-cp" , ".", "-sourcepath", "src",
+ "src/x/B.java", "src/x/C.java", "src/y/Main.java");
+ ToolBox.javac(args);
+
+// rm y/R3.class
+ ToolBox.rm(Paths.get("y", "R3.class"));
+
+// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath .
+// -sourcepath src src/y/Main.java
+ args.setAllArgs("-d", ".", "-cp", ".", "-sourcepath", "src", "src/y/Main.java");
+ ToolBox.javac(args);
+ }
+
+}
--- a/langtools/test/tools/javac/innerClassFile/x/B.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package x;
-
-import x.*;
-
-public class B {
- public static class C {}
-}
--- a/langtools/test/tools/javac/innerClassFile/x/C.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package x;
-
-import x.*;
-
-public class C {}
--- a/langtools/test/tools/javac/innerClassFile/y/Main.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package y;
-
-class Main {
- private R1 a;
- private R2 b;
- private R3 c;
-}
--- a/langtools/test/tools/javac/innerClassFile/y/R1.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package y;
-
-public final class R1 {
- x.B.C a = null;
- x.C b = null;
- R2 c = new R2();
-}
--- a/langtools/test/tools/javac/innerClassFile/y/R2.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package y;
-
-public final class R2 {
- x.B.C a = null;
- x.C b = null;
-}
--- a/langtools/test/tools/javac/innerClassFile/y/R3.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package y;
-
-public final class R3 {
- x.B.C a = null;
- x.C b = null;
- R1 c = new R1();
-}
--- a/langtools/test/tools/javac/javazip/A.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2005, 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.
- */
-
-// A class that references another
-class A {
- B b;
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/javazip/JavaZipTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,126 @@
+/*
+ * 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 4098712 6304984 6388453
+ * @summary check that source files inside zip files on the class path are ignored
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main JavaZipTest
+ */
+
+import java.io.File;
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/javazip/Test.sh
+public class JavaZipTest {
+
+ private static final String ASrc =
+ "class A {\n" +
+ " B b;\n" +
+ "}";
+
+ private static final String BGoodSrc =
+ "public class B {}";
+
+ private static final String BBadSrc =
+ "class B";
+
+ private static final String[][] jarArgs = {
+ {"cf", "good.jar", "-C", "good", "B.java"},
+ {"cf", "good.zip", "-C", "good", "B.java"},
+ {"cf", "bad.jar", "-C", "bad", "B.java"},
+ {"cf", "bad.zip", "-C", "bad", "B.java"},
+ };
+
+ private static final String[][] successfulCompilationArgs = {
+ {"-d", "output", "A.java", "good/B.java"},
+ {"-d", "output", "-cp", "good", "A.java"},
+ {"-d", "output", "-sourcepath", "good", "A.java"},
+ {"-d", "output", "-cp", "good.zip", "A.java"},
+ {"-d", "output", "-cp", "good.jar", "A.java"},
+ };
+
+ private static final String[][] unSuccessfulCompilationArgs = {
+ {"-d", "output", "A.java", "bad/B.java"},
+ {"-d", "output", "-cp", "bad", "A.java"},
+ {"-d", "output", "-sourcepath", "bad", "A.java"},
+ {"-d", "output", "-sourcepath", "bad.zip", "A.java"},
+ {"-d", "output", "-sourcepath", "bad.jar", "A.java"},
+ };
+
+ public static void main(String[] args) throws Exception {
+ new JavaZipTest().test();
+ }
+
+ public void test() throws Exception {
+ createOutputDirAndSourceFiles();
+ createZipsAndJars();
+ check(ToolBox.Expect.SUCCESS, successfulCompilationArgs);
+ check(ToolBox.Expect.FAIL, unSuccessfulCompilationArgs);
+ }
+
+ void createOutputDirAndSourceFiles() throws Exception {
+ //create output dir
+ new File("output").mkdir();
+
+ //source file creation
+ ToolBox.createJavaFileFromSource(Paths.get("good"), BGoodSrc);
+ ToolBox.createJavaFileFromSource(Paths.get("bad"), BBadSrc);
+ ToolBox.createJavaFileFromSource(ASrc);
+ }
+
+ void createZipsAndJars() throws Exception {
+ //jar and zip creation
+// check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.jar" -C "${TESTSRC}${FS}good" B.java
+// check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.zip" -C "${TESTSRC}${FS}good" B.java
+// check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.jar" -C "${TESTSRC}${FS}bad" B.java
+// check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.zip" -C "${TESTSRC}${FS}bad" B.java
+ for (String[] args: jarArgs) {
+ ToolBox.jar(args);
+ }
+ }
+
+ void check(ToolBox.Expect whatToExpect, String[][] theArgs) throws Exception {
+// check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}good${FS}B.java"
+// check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}good" "${TESTSRC}${FS}A.java"
+// check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}good" "${TESTSRC}${FS}A.java"
+// check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.zip" "${TESTSRC}${FS}A.java"
+// check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.jar" "${TESTSRC}${FS}A.java"
+
+// check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}bad${FS}B.java"
+// check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}bad" "${TESTSRC}${FS}A.java"
+// check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}bad" "${TESTSRC}${FS}A.java"
+// check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.zip" "${TESTSRC}${FS}A.java"
+// check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.jar" "${TESTSRC}${FS}A.java"
+ ToolBox.JavaToolArgs args =
+ new ToolBox.JavaToolArgs(whatToExpect);
+
+ for (String[] allArgs: theArgs) {
+ args.setAllArgs(allArgs);
+ ToolBox.javac(args);
+ }
+ }
+
+}
--- a/langtools/test/tools/javac/javazip/Test.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-#! /bin/sh -f
-
-#
-# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4098712 6304984 6388453
-# @summary check that source files inside zip files on the class path are ignored
-# @run shell Test.sh
-
-TS=${TESTSRC-.}
-TC=${TESTCLASSES-.}
-SCR=`pwd`
-
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin )
- FS="/"
- SCR=`pwd`
- ;;
- CYGWIN* )
- FS="/"
- SCR=`pwd | cygpath -d -f -`
- ;;
- Windows* )
- FS="\\"
- SCR=`pwd`
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-check() {
- expected=$1
- shift
-
- # clean old classes
- rm -f ${TC}${FS}*.class
-
- echo "$@"
- if "$@" 2>&1 ; then
- actual=ok
- else
- actual=err
- fi
- if [ "$actual" != "$expected" ]; then
- case "$actual" in
- ok ) echo "error: unexpected result: command succeeded" ;;
- err ) echo "error: unexpected result: command failed"
- esac
- exit 1
- else
- case "$actual" in
- ok ) echo "command succeeded as expected" ;;
- err ) echo "command failed as expected."
- esac
- fi
-
- echo
-}
-
-echo "# create zip/jar files with source code"
-check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.jar" -C "${TESTSRC}${FS}good" B.java
-check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.zip" -C "${TESTSRC}${FS}good" B.java
-check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.jar" -C "${TESTSRC}${FS}bad" B.java
-check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.zip" -C "${TESTSRC}${FS}bad" B.java
-
-echo "# control tests, with no paths"
-check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}good${FS}B.java"
-check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}bad${FS}B.java"
-
-echo "# test that source files are found in directories on path"
-check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}good" "${TESTSRC}${FS}A.java"
-check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}good" "${TESTSRC}${FS}A.java"
-check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}bad" "${TESTSRC}${FS}A.java"
-check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}bad" "${TESTSRC}${FS}A.java"
-
-echo "# test that source files are found in zip/jar files on path"
-check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.zip" "${TESTSRC}${FS}A.java"
-check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.jar" "${TESTSRC}${FS}A.java"
-check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.zip" "${TESTSRC}${FS}A.java"
-check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.jar" "${TESTSRC}${FS}A.java"
--- a/langtools/test/tools/javac/javazip/bad/B.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2005, 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.
- */
-
-// this class is invalid
-class B
--- a/langtools/test/tools/javac/javazip/good/B.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2005, 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.
- */
-
-// this is a valid class
-public class B {
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/FunctionalInterfaceAnno02.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,38 @@
+/*
+ * 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 8007535
+ * @summary Compiler crashes on FunctionalInterface used on interface with two inherited methods with same signatures
+ * @compile FunctionalInterfaceAnno02.java
+ */
+class FunctionalInterfaceAnno02 {
+ interface Foo<T, N extends Number> {
+ void m(T arg);
+ void m(N arg);
+ }
+
+ @FunctionalInterface
+ interface Baz extends Foo<Integer, Integer> { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/GenericMethodRefImplClass.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,81 @@
+/*
+ * 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 8009582
+ * @summary Method reference generic constructor gives: IllegalArgumentException: Invalid lambda deserialization
+ * @author Robert Field
+ * @run main GenericMethodRefImplClass
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class GenericMethodRefImplClass {
+
+ static int assertionCount = 0;
+
+ static void assertTrue(boolean cond) {
+ assertionCount++;
+ if (!cond)
+ throw new AssertionError();
+ }
+
+ public static void main(String[] args) throws Exception {
+ try {
+ // Write lambdas out
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutput out = new ObjectOutputStream(baos);
+
+ write(out, HashMap::new );
+ out.flush();
+ out.close();
+
+ // Read them back
+ ByteArrayInputStream bais =
+ new ByteArrayInputStream(baos.toByteArray());
+ ObjectInputStream in = new ObjectInputStream(bais);
+ readIt(in);
+ in.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw e;
+ }
+ assertTrue(assertionCount == 1);
+ }
+
+ static void write(ObjectOutput out, GenericMethodRefImplClassLSI lamb) throws IOException {
+ out.writeObject(lamb);
+ }
+
+ static void readIt(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ GenericMethodRefImplClassLSI ls = (GenericMethodRefImplClassLSI) in.readObject();
+ Map result = ls.convert();
+ assertTrue(result.getClass().getName().equals("java.util.HashMap"));
+ }
+}
+
+interface GenericMethodRefImplClassLSI extends Serializable {
+ Map convert();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/IdentifierTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,182 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8007401 8007427
+ * @author sogoel
+ * @summary Test generation of warnings when '_' is used an identifier
+ * @compile/fail/ref=IdentifierTest.out -Werror -XDrawDiagnostics IdentifierTest.java
+ */
+
+import java.util.List;
+
+/*
+ * This test checks for the generation of warnings when '_' is used as an
+ * identifier in following cases:
+ * package name, class name, class member names including constructor
+ * cass members access using class object or this
+ * loops: for, enhanced-for, while, do-while
+ * arrays,
+ * switch,
+ * annotations, element=value pair
+ * try-catch,
+ * enum
+ * break + identifier
+ * continue + identifier
+ * type-bounds
+ * Above cases for identifier occurrences have been identified from JLS v3.
+ *
+ */
+
+// Test class
+public class IdentifierTest {
+ class _UnderscorePrefix {}
+ class Underscore_Infix {}
+ class UnderscorePostfix_ {}
+ class __ {}
+
+ static final int _prefix = 10;
+ List<String> postfix_;
+
+ // Test: class with name as '_'
+ class _ {
+ String in_fix;
+ //Test: Constructor, "_", local variable, value
+ public _() {
+ String _ = "_";
+ in_fix = _;
+ }
+
+ public void testClassMembersAccess(String[] _args) {
+ // Instance creation
+ _ _ = new _();
+ //Method invocation
+ _.testTryCatch();
+ //Field access
+ _.in_fix = "__";
+ }
+
+ // Test: try-catch
+ public void testTryCatch() {
+ try {
+ int _ = 30/0;
+ } catch (ArithmeticException _) {
+ System.out.println("Got Arithmentic exception " + _);
+ }
+ }
+ }
+
+ // Test: class member access using class object '_', use of this.
+ class TestMisc {
+ int _;
+ void _ () {
+ this._ = 5;
+ }
+
+ public void testClassMemberAccess(String[] args) {
+ // Instance creation
+ TestMisc _ = new TestMisc();
+ //Field access
+ _._ = 10;
+ //Method access
+ _._();
+ }
+ }
+
+ //Test: Type Bounds
+ class TestTypeBounds {
+ //Type bounds
+ <_ extends Object> void test(_ t) {}
+ }
+
+ // Test: enum and switch case
+ static class TestEnum {
+ // Enum
+ enum _ {
+ _MONDAY, _TUESDAY, _WEDNESDAY, _THURSDAY, _FRIDAY,
+ _SATURDAY, _SUNDAY;
+ }
+
+ void foo() {
+ // switch-case
+ for(_ _day : _.values()) {
+ switch(_day) {
+ case _SATURDAY:
+ case _SUNDAY:
+ System.out.println("Weekend is here!");
+ break;
+ default:
+ System.out.println("Weekday is here!");
+ break;
+ }
+ }
+ }
+ }
+
+ // Test: Annotation
+ static class TestAnno {
+ // Annotation with name as _
+ @interface _ {
+ String _name();
+ int _id();
+ }
+ // Element-Value pair
+ @_(_name ="m",_id=1)
+ public void m(int arg) {}
+
+ //Annotation with _ as one of the elements
+ @interface MyAnno {
+ int _();
+ }
+ // Element Value pair
+ @MyAnno(_='1')
+ public void m2() {}
+ }
+
+ // Test: for loop, while loop, do-while loop, increment/decrement op, condition, print
+ public void testLoop() {
+ // for loop
+ for(int _ = 0; _ < 5; ++_) {
+ System.out.println("_=" + _ + " ");
+ }
+
+ // while loop
+ int _ = 0;
+ while(_ <= 5) {
+ _++;
+ }
+
+ //do-while loop
+ do {
+ --_;
+ } while(_ > 0);
+ }
+
+ // Test: Array and enhanced for loop
+ public void testArraysEnhancedForLoop() {
+ // Arrays
+ String _[] = {"A","B","C","D"};
+
+ for(String _s : _ ) {
+ System.out.println("_s="+_s);
+ }
+ }
+
+ // Test: Labels in break, continue
+ public void testLabels() {
+ // break/continue with labels
+ int j = 0;
+ _:
+ for (int i = 0; i <= 5; i++) {
+ while( j > 4 ) {
+ j++;
+ continue _;
+ }
+ break _;
+ }
+ }
+}
+
+//interface
+interface _ {
+ void mI();
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/IdentifierTest.out Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,47 @@
+IdentifierTest.java:40:11: compiler.warn.underscore.as.identifier
+IdentifierTest.java:43:16: compiler.warn.underscore.as.identifier
+IdentifierTest.java:44:20: compiler.warn.underscore.as.identifier
+IdentifierTest.java:45:22: compiler.warn.underscore.as.identifier
+IdentifierTest.java:50:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:50:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:50:23: compiler.warn.underscore.as.identifier
+IdentifierTest.java:52:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:54:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:60:21: compiler.warn.underscore.as.identifier
+IdentifierTest.java:61:42: compiler.warn.underscore.as.identifier
+IdentifierTest.java:62:67: compiler.warn.underscore.as.identifier
+IdentifierTest.java:69:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:70:14: compiler.warn.underscore.as.identifier
+IdentifierTest.java:71:18: compiler.warn.underscore.as.identifier
+IdentifierTest.java:76:22: compiler.warn.underscore.as.identifier
+IdentifierTest.java:78:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:78:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:80:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:80:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:87:10: compiler.warn.underscore.as.identifier
+IdentifierTest.java:87:38: compiler.warn.underscore.as.identifier
+IdentifierTest.java:93:14: compiler.warn.underscore.as.identifier
+IdentifierTest.java:100:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:100:26: compiler.warn.underscore.as.identifier
+IdentifierTest.java:117:20: compiler.warn.underscore.as.identifier
+IdentifierTest.java:122:10: compiler.warn.underscore.as.identifier
+IdentifierTest.java:127:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:130:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:137:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:137:24: compiler.warn.underscore.as.identifier
+IdentifierTest.java:137:33: compiler.warn.underscore.as.identifier
+IdentifierTest.java:138:39: compiler.warn.underscore.as.identifier
+IdentifierTest.java:142:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:143:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:144:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:149:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:150:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:156:16: compiler.warn.underscore.as.identifier
+IdentifierTest.java:158:25: compiler.warn.underscore.as.identifier
+IdentifierTest.java:167:5: compiler.warn.underscore.as.identifier
+IdentifierTest.java:171:26: compiler.warn.underscore.as.identifier
+IdentifierTest.java:173:19: compiler.warn.underscore.as.identifier
+IdentifierTest.java:179:11: compiler.warn.underscore.as.identifier
+- compiler.err.warnings.and.werror
+1 error
+44 warnings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaCapture07.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,60 @@
+/*
+ * 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 8004962
+ * @summary Code generation crash with lambda and local classes
+ */
+public class LambdaCapture07 {
+
+ static int assertionCount = 0;
+
+ static void assertTrue(boolean cond) {
+ assertionCount++;
+ if (!cond)
+ throw new AssertionError();
+ }
+
+ interface SAM {
+ void m();
+ }
+
+ void test(int i) {
+ class Local { Local() { assertTrue(i == 42); } }
+ class LocalSub extends Local { }
+ SAM s_sup = ()->new Local();
+ s_sup.m();
+ SAM s_sub = ()->new LocalSub();
+ s_sub.m();
+ SAM s_sup_nested = ()->{ SAM s = ()->new Local(); s.m(); };
+ s_sup_nested.m();
+ SAM s_sub_nested = ()->{ SAM s = ()->new LocalSub(); s.m(); };
+ s_sub_nested.m();
+ }
+
+ public static void main(String[] args) {
+ new LambdaCapture07().test(42);
+ assertTrue(assertionCount == 4);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv25.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that merged inherited descriptors preservers type-parameters
+ * @compile/fail/ref=LambdaConv25.out -XDrawDiagnostics LambdaConv25.java
+ */
+class LambdaConv25 {
+
+ interface A {
+ <X> void m();
+ }
+
+ interface B {
+ <X> void m();
+ }
+
+ interface C extends A, B { }
+
+ void test() {
+ C c = ()->{}; //should fail
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv25.out Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,2 @@
+LambdaConv25.java:19:15: compiler.err.prob.found.req: (compiler.misc.invalid.generic.lambda.target: <X>()void, kindname.interface, LambdaConv25.C)
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv26.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,41 @@
+/*
+ * 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 8006749
+ * @summary compiler does not allow Object protected methods to be used in lambda
+ * @compile LambdaConv26.java
+ */
+public class LambdaConv26 {
+ interface I {
+ Object clone();
+ }
+
+ Object m() { return null; }
+
+ void test() {
+ I i1 = ()->null;
+ I i2 = this::m;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv27.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,40 @@
+/*
+ * 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 8008227
+ * @summary Mixing lambdas with anonymous classes leads to NPE thrown by compiler
+ * @run main LambdaConv27
+ */
+public class LambdaConv27 {
+
+ public static void main(String[] args) {
+ SAM s = ()-> { SAM s2 = ()->{ new Object() { }; }; s2.m(); };
+ s.m();
+ }
+
+ interface SAM {
+ void m();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaInnerTypeVarArgs.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,80 @@
+/*
+ * 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 8005653
+ * @summary A lambda containing an inner class referencing an external type var in class parameter type
+ * @author Robert Field
+ * @run main LambdaInnerTypeVarArgs
+ */
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.ArrayList;
+
+public class LambdaInnerTypeVarArgs {
+
+ static int assertionCount = 0;
+
+ static void assertTrue(boolean cond) {
+ assertionCount++;
+ if (!cond)
+ throw new AssertionError();
+ }
+
+ interface I {
+ C doit();
+ }
+
+ abstract class C {
+ abstract Object it();
+ }
+
+ class TV {
+ C go() {
+ List<String> ls = new ArrayList<>();
+ ls.add("Oh");
+ ls.add("my");
+ return foo(ls).doit();
+ }
+
+ <RRRRR> I foo(List<RRRRR> r) {
+ return () -> new C() {
+ List<RRRRR> xxxxx = r;
+ @Override
+ Object it() { return xxxxx; };
+ };
+ }
+ }
+
+ void test1() {
+ assertTrue(((List<String>)(new TV().go().it())).get(0).equals("Oh"));
+ }
+
+ public static void main(String[] args) {
+ LambdaInnerTypeVarArgs t = new LambdaInnerTypeVarArgs();
+ t.test1();
+ assertTrue(assertionCount == 1);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaInnerTypeVarArgsSerialize.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,80 @@
+/*
+ * 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 8005653
+ * @summary A serialized lambda containing an inner class referencing an external type var in class parameter type
+ * @author Robert Field
+ * @run main LambdaInnerTypeVarArgsSerialize
+ */
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.ArrayList;
+
+public class LambdaInnerTypeVarArgsSerialize {
+
+ static int assertionCount = 0;
+
+ static void assertTrue(boolean cond) {
+ assertionCount++;
+ if (!cond)
+ throw new AssertionError();
+ }
+
+ interface I extends Serializable {
+ C doit();
+ }
+
+ abstract class C {
+ abstract Object it();
+ }
+
+ class TV {
+ C go() {
+ List<String> ls = new ArrayList<>();
+ ls.add("Oh");
+ ls.add("my");
+ return foo(ls).doit();
+ }
+
+ <RRRRR> I foo(List<RRRRR> r) {
+ return () -> new C() {
+ List<RRRRR> xxxxx = r;
+ @Override
+ Object it() { return xxxxx; };
+ };
+ }
+ }
+
+ void test1() {
+ assertTrue(((List<String>)(new TV().go().it())).get(0).equals("Oh"));
+ }
+
+ public static void main(String[] args) {
+ LambdaInnerTypeVarArgsSerialize t = new LambdaInnerTypeVarArgsSerialize();
+ t.test1();
+ assertTrue(assertionCount == 1);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaInnerTypeVarReflect.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,86 @@
+/*
+ * 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 8005653
+ * @summary A lambda containing an inner class referencing an external type var
+ * @author Robert Field
+ * @run main LambdaInnerTypeVarReflect
+ */
+
+import java.io.StringWriter;
+import java.io.PrintWriter;
+import java.io.IOException;
+
+public class LambdaInnerTypeVarReflect {
+
+ static int assertionCount = 0;
+
+ static void assertTrue(boolean cond) {
+ assertionCount++;
+ if (!cond)
+ throw new AssertionError();
+ }
+
+ interface I {
+ C doit();
+ }
+
+ abstract class C {
+ abstract Object it();
+ }
+
+ class TV {
+ C go() {
+ return foo("Frump").doit();
+ }
+
+ <RRRRR> I foo(RRRRR r) {
+ return () -> new C() {
+ public RRRRR xxxxx = r;
+ @Override
+ Object it() { return xxxxx; };
+ };
+ }
+ }
+
+ void test1() throws IOException {
+ char[] buffer = new char[1024];
+ String innerName = new TV().go().getClass().getName();
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ int exitCode = com.sun.tools.javap.Main.run(new String[] {innerName}, pw);
+ assertTrue(exitCode == 0);
+
+ String javapOut = sw.toString();
+ assertTrue(javapOut.contains(innerName));
+ assertTrue(!javapOut.contains("RRRRR"));
+ }
+
+ public static void main(String[] args) throws IOException {
+ LambdaInnerTypeVarReflect t = new LambdaInnerTypeVarReflect();
+ t.test1();
+ assertTrue(assertionCount == 3);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaInnerTypeVarSerialize.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,75 @@
+/*
+ * 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 8005653
+ * @summary A serialized lambda containing an inner class referencing an external type var
+ * @author Robert Field
+ * @run main LambdaInnerTypeVarSerialize
+ */
+
+import java.io.Serializable;
+
+public class LambdaInnerTypeVarSerialize {
+
+ static int assertionCount = 0;
+
+ static void assertTrue(boolean cond) {
+ assertionCount++;
+ if (!cond)
+ throw new AssertionError();
+ }
+
+ interface I extends Serializable {
+ C doit();
+ }
+
+ abstract class C {
+ abstract Object it();
+ }
+
+ class TV {
+ C go() {
+ return foo("Frump").doit();
+ }
+
+ <RRRRR> I foo(RRRRR r) {
+ return () -> new C() {
+ RRRRR xxxxx = r;
+ @Override
+ Object it() { return xxxxx; };
+ };
+ }
+ }
+
+ void test1() {
+ assertTrue(new TV().go().it().equals("Frump"));
+ }
+
+ public static void main(String[] args) {
+ LambdaInnerTypeVarSerialize t = new LambdaInnerTypeVarSerialize();
+ t.test1();
+ assertTrue(assertionCount == 1);
+ }
+}
--- a/langtools/test/tools/javac/lambda/MethodReference22.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/lambda/MethodReference22.java Tue Mar 12 16:43:53 2013 -0700
@@ -48,19 +48,19 @@
}
static void test2() {
- SAM2 s1 = MethodReference22::m1; //ok
- call2(MethodReference22::m1); //ok
- SAM2 s2 = MethodReference22::m2; //ok
- call2(MethodReference22::m2); //ok
- SAM2 s3 = MethodReference22::m3; //fail
- call2(MethodReference22::m3); //fail
- SAM2 s4 = MethodReference22::m4; //fail
- call2(MethodReference22::m4); //fail
+ SAM2 s1 = MethodReference22::m1; //ambiguous
+ call2(MethodReference22::m1); //ambiguous
+ SAM2 s2 = MethodReference22::m2; //ambiguous
+ call2(MethodReference22::m2); //ambiguous
+ SAM2 s3 = MethodReference22::m3; //ambiguous
+ call2(MethodReference22::m3); //ambiguous
+ SAM2 s4 = MethodReference22::m4; //ambiguous
+ call2(MethodReference22::m4); //ambiguous
}
static void test3() {
- call3(MethodReference22::m1); //ok
- call3(MethodReference22::m2); //ambiguous
+ call3(MethodReference22::m1); //fail
+ call3(MethodReference22::m2); //ok
call3(MethodReference22::m3); //ok
call3(MethodReference22::m4); //fail
}
--- a/langtools/test/tools/javac/lambda/MethodReference22.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/lambda/MethodReference22.out Tue Mar 12 16:43:53 2013 -0700
@@ -1,11 +1,15 @@
-MethodReference22.java:40:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String)))
-MethodReference22.java:41:9: compiler.err.cant.apply.symbol: kindname.method, call1, MethodReference22.SAM1, @999, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String))))
-MethodReference22.java:46:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String)))
-MethodReference22.java:47:9: compiler.err.cant.apply.symbol: kindname.method, call1, MethodReference22.SAM1, @1270, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))))
-MethodReference22.java:55:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m3(MethodReference22,java.lang.String)))
-MethodReference22.java:56:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1574, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m3(MethodReference22,java.lang.String))))
+MethodReference22.java:40:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String))
+MethodReference22.java:41:15: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String))
+MethodReference22.java:46:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))
+MethodReference22.java:47:15: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))
+MethodReference22.java:51:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m1, kindname.method, m1(MethodReference22,java.lang.String), MethodReference22, kindname.method, m1(java.lang.String), MethodReference22))
+MethodReference22.java:52:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1401, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m1, kindname.method, m1(MethodReference22,java.lang.String), MethodReference22, kindname.method, m1(java.lang.String), MethodReference22)))
+MethodReference22.java:53:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m2, kindname.method, m2(MethodReference22,java.lang.String), MethodReference22, kindname.method, m2(java.lang.String), MethodReference22))
+MethodReference22.java:54:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1504, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m2, kindname.method, m2(MethodReference22,java.lang.String), MethodReference22, kindname.method, m2(java.lang.String), MethodReference22)))
+MethodReference22.java:55:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m3, kindname.method, m3(MethodReference22,java.lang.String), MethodReference22, kindname.method, m3(java.lang.String), MethodReference22))
+MethodReference22.java:56:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1607, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m3, kindname.method, m3(MethodReference22,java.lang.String), MethodReference22, kindname.method, m3(java.lang.String), MethodReference22)))
MethodReference22.java:57:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22))
-MethodReference22.java:58:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1667, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22)))
-MethodReference22.java:63:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference22.SAM1), MethodReference22, kindname.method, call3(MethodReference22.SAM2), MethodReference22
-MethodReference22.java:65:9: compiler.err.cant.apply.symbols: kindname.method, call3, @1881,{(compiler.misc.inapplicable.method: kindname.method, MethodReference22, call3(MethodReference22.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))))),(compiler.misc.inapplicable.method: kindname.method, MethodReference22, call3(MethodReference22.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22))))}
-10 errors
+MethodReference22.java:58:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1710, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22)))
+MethodReference22.java:62:15: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String))
+MethodReference22.java:65:15: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))
+14 errors
--- a/langtools/test/tools/javac/lambda/MethodReference28.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/lambda/MethodReference28.out Tue Mar 12 16:43:53 2013 -0700
@@ -1,7 +1,7 @@
MethodReference28.java:31:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, static_m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
MethodReference28.java:32:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, static_m3, java.lang.String, int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
MethodReference28.java:33:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, static_m4, java.lang.String[], int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: int, java.lang.String))))
-MethodReference28.java:37:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.Integer)))
+MethodReference28.java:37:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.Integer))
MethodReference28.java:38:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
MethodReference28.java:39:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m3, java.lang.String, int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
MethodReference28.java:40:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m4, java.lang.String[], int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: int, java.lang.String))))
--- a/langtools/test/tools/javac/lambda/MethodReference38.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/lambda/MethodReference38.out Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
-MethodReference38.java:24:18: compiler.err.abstract.cant.be.instantiated
-MethodReference38.java:25:18: compiler.err.abstract.cant.be.instantiated
-MethodReference38.java:26:18: compiler.err.abstract.cant.be.instantiated
+MethodReference38.java:24:18: compiler.err.abstract.cant.be.instantiated: MethodReference38.A
+MethodReference38.java:25:18: compiler.err.abstract.cant.be.instantiated: MethodReference38.I
+MethodReference38.java:26:18: compiler.err.abstract.cant.be.instantiated: MethodReference38.AC
MethodReference38.java:27:18: compiler.err.enum.cant.be.instantiated
4 errors
--- a/langtools/test/tools/javac/lambda/MethodReference51.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/lambda/MethodReference51.out Tue Mar 12 16:43:53 2013 -0700
@@ -2,6 +2,6 @@
MethodReference51.java:40:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, f, java.lang.String, int, kindname.class, MethodReference51, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
MethodReference51.java:41:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbols: kindname.method, g, int,{(compiler.misc.inapplicable.method: kindname.method, MethodReference51, g(java.lang.Integer,java.lang.Number), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, MethodReference51, g(java.lang.Number,java.lang.Integer), (compiler.misc.arg.length.mismatch))}))
MethodReference51.java:42:32: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: g, kindname.method, g(java.lang.Integer,java.lang.Number), MethodReference51, kindname.method, g(java.lang.Number,java.lang.Integer), MethodReference51))
-MethodReference51.java:43:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, h(int)))
+MethodReference51.java:43:21: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, h(int))
MethodReference51.java:44:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.not.def.access.class.intf.cant.access: j(int), MethodReference51.Foo))
6 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference61.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,43 @@
+/*
+ * 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 8006763
+ * @summary super in method reference used in anonymous class
+ */
+public class MethodReference61 {
+ interface SAM {
+ void m();
+ }
+
+ static class MyTester {
+ public void ifoo() { }
+ }
+
+ public static void main(String args[]) {
+ MyTester t = new MyTester() {
+ SAM s = super::ifoo;
+ };
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference62.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8007285
+ * @summary AbstractMethodError instead of compile-time error when method reference with super and abstract
+ * @compile/fail/ref=MethodReference62.out -XDrawDiagnostics MethodReference62.java
+ */
+class MethodReference62 {
+ interface SAM {
+ int m();
+ }
+
+ static abstract class Sup {
+ abstract int foo() ;
+ }
+
+ static abstract class Sub extends Sup {
+ abstract int foo() ;
+ void test() {
+ SAM s = super::foo;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference62.out Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,2 @@
+MethodReference62.java:19:21: compiler.err.abstract.cant.be.accessed.directly: kindname.method, foo(), MethodReference62.Sup
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference63.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,43 @@
+/*
+ * 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 8005183
+ * @summary Missing accessor for constructor reference pointing to private inner class ctor
+ */
+public class MethodReference63 {
+
+ interface SAM {
+ void m();
+ }
+
+ static class Foo {
+ private Foo() { }
+ }
+
+ public static void main(String[] args) {
+ SAM s = Foo::new;
+ s.m();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference64.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,46 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8008540 8008539 8008538
+ * @summary Constructor reference to non-reifiable array should be rejected
+ * @compile/fail/ref=MethodReference64.out -XDrawDiagnostics MethodReference64.java
+ */
+class MethodReference64 {
+ interface ClassFactory {
+ Object m();
+ }
+
+ interface ArrayFactory {
+ Object m(int i);
+ }
+
+ @interface Anno { }
+
+ enum E { }
+
+ interface I { }
+
+ static class Foo<X> { }
+
+ void m(ClassFactory cf) { }
+ void m(ArrayFactory cf) { }
+
+ void testAssign() {
+ ClassFactory c1 = Anno::new; //error
+ ClassFactory c2 = E::new; //error
+ ClassFactory c3 = I::new; //error
+ ClassFactory c4 = Foo<?>::new; //error
+ ClassFactory c5 = 1::new; //error
+ ArrayFactory a1 = Foo<?>[]::new; //ok
+ ArrayFactory a2 = Foo<? extends String>[]::new; //error
+ }
+
+ void testMethod() {
+ m(Anno::new); //error
+ m(E::new); //error
+ m(I::new); //error
+ m(Foo<?>::new); //error
+ m(1::new); //error
+ m(Foo<?>[]::new); //ok - resolves to m(ArrayFactory)
+ m(Foo<? extends String>[]::new); //error
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference64.out Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,13 @@
+MethodReference64.java:28:27: compiler.err.abstract.cant.be.instantiated: MethodReference64.Anno
+MethodReference64.java:29:27: compiler.err.enum.cant.be.instantiated
+MethodReference64.java:30:27: compiler.err.abstract.cant.be.instantiated: MethodReference64.I
+MethodReference64.java:31:30: compiler.err.type.found.req: ?, (compiler.misc.type.req.exact)
+MethodReference64.java:32:27: compiler.err.unexpected.type: kindname.class, kindname.value
+MethodReference64.java:34:48: compiler.err.generic.array.creation
+MethodReference64.java:38:11: compiler.err.abstract.cant.be.instantiated: MethodReference64.Anno
+MethodReference64.java:39:11: compiler.err.enum.cant.be.instantiated
+MethodReference64.java:40:11: compiler.err.abstract.cant.be.instantiated: MethodReference64.I
+MethodReference64.java:41:14: compiler.err.type.found.req: ?, (compiler.misc.type.req.exact)
+MethodReference64.java:42:11: compiler.err.unexpected.type: kindname.class, kindname.value
+MethodReference64.java:44:32: compiler.err.generic.array.creation
+12 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference65.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,41 @@
+/*
+ * 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 8009154
+ * @summary Missing cast in method reference bridge leads to NoSuchMethodError
+ */
+public class MethodReference65 {
+
+ interface SAM<X> {
+ void m(X ss, String s);
+ }
+
+ void m(String... s) { }
+
+ public static void main(String[] args) {
+ SAM<MethodReference65> st = MethodReference65::m;
+ st.m(new MethodReference65(), "");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference66.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,52 @@
+/*
+ * 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 8009299
+ * @summary Javac crashes when compiling method reference to static interface method
+ * @run main/othervm -Xverify:none MethodReference66
+ */
+public class MethodReference66 {
+
+ static int assertionCount = 0;
+
+ static void assertTrue(boolean cond) {
+ assertionCount++;
+ if (!cond)
+ throw new AssertionError();
+ }
+
+ interface SAM {
+ void m(int i);
+ }
+
+ interface I {
+ static void f(int i) { assertTrue(i == 42); }
+ }
+ public static void main(String[] args) {
+ SAM s = I::f;
+ s.m(42);
+ assertTrue(assertionCount == 1);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific08.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,62 @@
+/*
+ * 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 8008813
+ * @summary Structural most specific fails when method reference is passed to overloaded method
+ * @compile MostSpecific08.java
+ */
+class MostSpecific08 {
+
+ static class C {
+ int getInt() { return -1; }
+ Integer getInteger() { return -1; }
+ }
+
+ interface IntResult { }
+ interface ReferenceResult<X> { }
+
+ interface PrimitiveFunction {
+ int f(C c);
+ }
+
+ interface ReferenceFunction<X> {
+ X f(C c);
+ }
+
+ interface Tester {
+ IntResult apply(PrimitiveFunction p);
+ <Z> ReferenceResult<Z> apply(ReferenceFunction<Z> p);
+ }
+
+ void testMref(Tester t) {
+ IntResult pr = t.apply(C::getInt);
+ ReferenceResult<Integer> rr = t.apply(C::getInteger);
+ }
+
+ void testLambda(Tester t) {
+ IntResult pr = t.apply(c->c.getInt());
+ ReferenceResult<Integer> rr = t.apply(c->c.getInteger());
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/SerializedLambdaInInit.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,118 @@
+/*
+ * 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 8009742
+@summary Bad method name: Serialized lambda in a constructor or class init
+*/
+
+import java.io.*;
+import java.lang.reflect.Method;
+
+public class SerializedLambdaInInit {
+ static int assertionCount = 0;
+
+ static void assertTrue(boolean cond) {
+ assertionCount++;
+ if (!cond)
+ throw new AssertionError();
+ }
+
+ static LSI cvisi = z -> "[" + z + "]";
+ static LSI cisi;
+
+ static {
+ cisi = z -> z + z;
+ }
+
+ LSI ivsi = z -> "blah";
+ LSI iisi;
+
+ SerializedLambdaInInit() {
+ iisi = z -> "*" + z;
+ }
+
+ public static void main(String[] args) throws Exception {
+ try {
+ // Write lambdas out
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutput out = new ObjectOutputStream(baos);
+ SerializedLambdaInInit slii = new SerializedLambdaInInit();
+
+ write(out, cvisi );
+ write(out, cisi );
+ write(out, slii.ivsi );
+ write(out, slii.iisi );
+ out.flush();
+ out.close();
+
+ // Read them back
+ ByteArrayInputStream bais =
+ new ByteArrayInputStream(baos.toByteArray());
+ ObjectInputStream in = new ObjectInputStream(bais);
+ readAssert(in, "[X]");
+ readAssert(in, "XX");
+ readAssert(in, "blah");
+ readAssert(in, "*X");
+ in.close();
+
+ // Reflectively test for valid method names
+ for (Method meth : slii.getClass().getDeclaredMethods()) {
+ checkIdentifier(meth.getName());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw e;
+ }
+ assertTrue(assertionCount == 4);
+ }
+
+ static void write(ObjectOutput out, LSI lamb) throws IOException {
+ out.writeObject(lamb);
+ }
+
+ static void readAssert(ObjectInputStream in, String expected) throws IOException, ClassNotFoundException {
+ LSI ls = (LSI) in.readObject();
+ String result = ls.convert("X");
+ System.out.printf("Result: %s\n", result);
+ assertTrue(result.equals(expected));
+ }
+
+ public static void checkIdentifier(String str) throws Exception {
+ // null and zero length identifers will throw their own exceptions
+ char[] chars = str.toCharArray();
+ if (!Character.isJavaIdentifierStart(chars[0])) {
+ throw new IllegalArgumentException(str + ": bad identifier start character: '" + chars[0] + "'");
+ }
+ for (char ch : chars) {
+ if (!Character.isJavaIdentifierPart(ch)) {
+ throw new IllegalArgumentException(str + ": bad identifier character: '" + ch + "'");
+ }
+ }
+ }
+}
+
+interface LSI extends Serializable {
+ String convert(String x);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/StaticMethodNegTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,26 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 8008337
+ * @author sogoel
+ * @summary static method is called via super
+ * @compile/fail/ref=StaticMethodNegTest.out -XDrawDiagnostics StaticMethodNegTest.java
+ */
+
+interface A {
+ static String m() {
+ return "A";
+ }
+}
+
+interface B {
+ static String m() {
+ return "B";
+ }
+}
+
+interface AB extends A, B {
+ static String m() {
+ return A.super.m();
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/StaticMethodNegTest.out Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,2 @@
+StaticMethodNegTest.java:23:12: compiler.err.not.encl.class: A
+1 error
--- a/langtools/test/tools/javac/lambda/TargetType28.out Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/lambda/TargetType28.out Tue Mar 12 16:43:53 2013 -0700
@@ -1,2 +1,2 @@
-TargetType28.java:20:32: compiler.err.prob.found.req: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String,X, java.lang.Object,java.lang.Number)
+TargetType28.java:20:32: compiler.err.prob.found.req: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String,R, java.lang.Object,java.lang.Number)
1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType60.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,65 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8007462
+ * @summary Fix provisional applicability for method references
+ * @compile/fail/ref=TargetType60.out -XDrawDiagnostics TargetType60.java
+ */
+class TargetType60 {
+
+ interface Sam0 {
+ void m();
+ }
+
+ interface Sam1<X> {
+ void m(X x);
+ }
+
+ interface Sam2<X,Y> {
+ void m(X x, Y y);
+ }
+
+ void m0() { }
+ void m1(String s) { }
+ void m2(String s1, String s2) { }
+
+ void m01() { }
+ void m01(String s) { }
+
+ void m012() { }
+ void m012(String s) { }
+ void m012(String s1, String s2) { }
+
+ void n0() { }
+ void n1(String s) { }
+ void n2(TargetType60 rec, String s2) { }
+
+ void n01() { }
+ void n01(String s) { }
+
+ void n012() { }
+ void n012(String s) { }
+ void n012(TargetType60 rec, String s2) { }
+
+ static String g(Sam0 s) { return null; }
+ static <U> U g(Sam1<U> s) { return null; }
+ static <U> U g(Sam2<U,String> s) { return null; }
+
+ static <U> U u(Sam1<U> s) { return null; }
+ static <U> U u(Sam2<U,String> s) { return null; }
+
+ void testBound() {
+ String s1 = g(this::m0); //ok - resolves to g(Sam0)
+ String s2 = g(this::m1); //ok - resolves to g(Sam1)
+ String s3 = g(this::m2); //ok - resolves to g(Sam2)
+ String s4 = g(this::m01);//ambiguous (g(Sam0), g(Sam1) apply)
+ String s5 = g(this::m012);//ambiguous (g(Sam0), g(Sam1), g(Sam2) apply)
+ }
+
+ static void testUnbound() {
+ TargetType60 s1 = u(TargetType60::n0); //ok - resolves to u(Sam1)
+ TargetType60 s2 = u(TargetType60::n1); //ambiguous (u(Sam1), u(Sam2) apply)
+ TargetType60 s3 = u(TargetType60::n2); //none is applicable
+ TargetType60 s4 = u(TargetType60::n01);//ambiguous (u(Sam1), u(Sam2) apply)
+ TargetType60 s5 = u(TargetType60::n012);//ambiguous (u(Sam1), u(Sam2) apply)
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType60.out Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,8 @@
+TargetType60.java:54:21: compiler.err.ref.ambiguous: g, kindname.method, g(TargetType60.Sam0), TargetType60, kindname.method, <U>g(TargetType60.Sam1<U>), TargetType60
+TargetType60.java:55:21: compiler.err.ref.ambiguous: g, kindname.method, <U>g(TargetType60.Sam1<U>), TargetType60, kindname.method, <U>g(TargetType60.Sam2<U,java.lang.String>), TargetType60
+TargetType60.java:60:27: compiler.err.ref.ambiguous: u, kindname.method, <U>u(TargetType60.Sam1<U>), TargetType60, kindname.method, <U>u(TargetType60.Sam2<U,java.lang.String>), TargetType60
+TargetType60.java:60:28: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, n1, java.lang.String, TargetType60, kindname.class, TargetType60, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: TargetType60, java.lang.String)))))
+TargetType60.java:61:29: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, n2(TargetType60,java.lang.String))
+TargetType60.java:62:27: compiler.err.ref.ambiguous: u, kindname.method, <U>u(TargetType60.Sam1<U>), TargetType60, kindname.method, <U>u(TargetType60.Sam2<U,java.lang.String>), TargetType60
+TargetType60.java:63:27: compiler.err.ref.ambiguous: u, kindname.method, <U>u(TargetType60.Sam1<U>), TargetType60, kindname.method, <U>u(TargetType60.Sam2<U,java.lang.String>), TargetType60
+7 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType64.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,41 @@
+/*
+ * 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 8008293
+ * @summary Declared bounds not considered when functional interface containing unbound wildcards is instantiated
+ * @compile TargetType64.java
+ */
+class TargetType64 {
+ interface SAM<X extends Number> {
+ void m(X x);
+ }
+
+ void g(Object o) { }
+
+ void test() {
+ SAM<?> s1 = (x)->{};
+ SAM<?> s2 = this::g;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType65.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,58 @@
+/*
+ * 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 8008723
+ * @summary Graph Inference: bad graph calculation leads to assertion error
+ * @compile TargetType65.java
+ */
+class TargetType65 {
+ interface Predicate<X> {
+ boolean accepts(X x);
+ }
+
+ static class Optional<T> {
+ public boolean isPresent() { return false; }
+ public static<E> Optional<E> empty() { return null; }
+ }
+
+ interface Supplier<X> {
+ X make();
+ }
+
+ static class Sink<O, T> { }
+
+ static class SubSink<R> extends Sink<R, Optional<R>> { }
+
+ static class Tester<T, O> {
+ public static <F> Tester<F, Optional<F>> makeRef() {
+ return new Tester<>(Optional.empty(), Optional::isPresent, SubSink::new);
+ }
+
+ private Tester(O emptyValue,
+ Predicate<O> presentPredicate,
+ Supplier<Sink<T, O>> sinkSupplier) {
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/abort/CompletionFailure.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,137 @@
+/*
+ * 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 8009227
+ * @summary Certain diagnostics should not be deferred
+ */
+
+import com.sun.source.util.JavacTask;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class CompletionFailure {
+
+ public static void main(String... args) throws Exception {
+
+ String SCRATCH_DIR = System.getProperty("user.dir");
+ JavaCompiler javacTool = ToolProvider.getSystemJavaCompiler();
+ File scratchDir = new File(SCRATCH_DIR);
+
+ sourceA.dumpTo(scratchDir);
+ sourceB.dumpTo(scratchDir);
+
+ JavacTask ct = (JavacTask)javacTool.getTask(null, null, null,
+ null, null, Arrays.asList(sourceA.asJFO(scratchDir), sourceB.asJFO(scratchDir)));
+
+ ct.generate();
+
+ remove(scratchDir, "A.java");
+ remove(scratchDir, "B.java");
+ remove(scratchDir, "A.class");
+
+ sourceC.dumpTo(scratchDir);
+ sourceD.dumpTo(scratchDir);
+
+ DiagnosticChecker diagChecker = new DiagnosticChecker();
+ ct = (JavacTask)javacTool.getTask(null, null, diagChecker,
+ Arrays.asList("-XDrawDiagnostics", "-cp", scratchDir.getAbsolutePath()),
+ null, Arrays.asList(sourceC.asJFO(scratchDir), sourceD.asJFO(scratchDir)));
+ try {
+ ct.analyze();
+ } catch (Throwable ex) {
+ //ignore abort exception thrown by javac
+ }
+
+ if (!diagChecker.errorFound) {
+ throw new AssertionError("Missing diagnostic");
+ }
+ }
+
+ static void remove(File dir, String fileName) {
+ File fileToRemove = new File(dir, fileName);
+ fileToRemove.delete();
+ }
+
+ static class JavaSource {
+ String contents;
+ String filename;
+
+ public JavaSource(String filename, String contents) {
+ this.filename = filename;
+ this.contents = contents;
+ }
+
+ void dumpTo(java.io.File loc) throws Exception {
+ File file = new File(loc, filename);
+ BufferedWriter bw = new java.io.BufferedWriter(new FileWriter(file));
+ bw.append(contents);
+ bw.close();
+ }
+
+ SimpleJavaFileObject asJFO(java.io.File dir) {
+ return new SimpleJavaFileObject(new File(dir, filename).toURI(), JavaFileObject.Kind.SOURCE) {
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+ return contents;
+ }
+ };
+ }
+ }
+
+ static JavaSource sourceA = new JavaSource("A.java", "public interface A { }\n");
+
+ static JavaSource sourceB = new JavaSource("B.java", "public class B implements A {\n" +
+ " public static Object n() { return null; }\n" +
+ "}\n");
+
+ static JavaSource sourceC = new JavaSource("C.java", "public class C {\n" +
+ " void test(B b) {\n" +
+ " D.m(B.n());\n" +
+ "} }\n");
+
+ static JavaSource sourceD = new JavaSource("D.java", "public class D {\n" +
+ " static void m(Object o) { }\n" +
+ "}\n");
+
+ static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+ boolean errorFound;
+
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ if (diagnostic.getKind() == Diagnostic.Kind.ERROR &&
+ diagnostic.getCode().contains("compiler.err.cant.access")) {
+ errorFound = true;
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/inaccessibleMref01/InaccessibleMref01.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,39 @@
+/*
+ * 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 8003280
+ * @summary Add lambda tests
+ * check that classfiles with member ref CP entries are read correctly
+ * @compile/fail/ref=InaccessibleMref01.out -XDrawDiagnostics InaccessibleMref01.java
+ */
+class InaccessibleMref01 {
+ interface SAM {
+ void m();
+ }
+
+ void test(p1.C c) {
+ SAM s = c::m;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/inaccessibleMref01/InaccessibleMref01.out Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,2 @@
+InaccessibleMref01.java:37:17: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.not.def.public.cant.access: m(), p1.C))
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/inaccessibleMref01/p1/C.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+package p1;
+
+public class C {
+ void m() { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/inaccessibleMref02/InaccessibleMref02.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,40 @@
+/*
+ * 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 8003280
+ * @summary Add lambda tests
+ * check that classfiles with member ref CP entries are read correctly
+ */
+public class InaccessibleMref02 {
+ interface SAM {
+ void m();
+ }
+
+ public static void main(String[] args) {
+ p1.C c = new p1.C();
+ SAM s = c::m;
+ s.m();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/inaccessibleMref02/p1/C.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+package p1;
+
+class Sup {
+ public void m() { }
+}
+
+public class C extends Sup { }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/separate/Foo.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+interface Foo<X extends Number> {
+ void m(X x);
+}
+
+class FooLib {
+ void m1(Foo<?> uf) { }
+ void m2(Foo<? extends Object> uf) { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/separate/Test.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012, 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
+ * @compile Foo.java
+ * @compile Test.java
+ */
+class Test {
+ void test(FooLib fl) {
+ fl.m1(x->{});
+ fl.m2(x->{});
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/speculative/MissingError.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8008276
+ * @summary assertion error in com.sun.tools.javac.comp.TransTypes.visitApply
+ * @compile/fail/ref=MissingError.out -XDrawDiagnostics MissingError.java
+ */
+class MissingError {
+ void test() {
+ mtest(new Bad(){ Integer i = ""; });
+ }
+
+ void mtest(Bad t){ }
+}
+
+class Bad {
+ String s = 1;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/speculative/MissingError.out Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,3 @@
+MissingError.java:16:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: int, java.lang.String)
+MissingError.java:9:37: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer)
+2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lib/ToolBox.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,911 @@
+/*
+ * 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.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTaskImpl;
+
+import sun.tools.jar.Main;
+
+import static java.nio.file.StandardCopyOption.*;
+
+/**
+ * Toolbox for jtreg tests.
+ */
+
+public class ToolBox {
+
+ public static final String lineSeparator = System.getProperty("line.separator");
+ public static final String jdkUnderTest = System.getProperty("test.jdk");
+ public static final String testVMOpts = System.getProperty("test.tool.vm.opts");
+ public static final String javaBinary = Paths.get(jdkUnderTest, "bin", "java").toString();
+ //why this one private. Because the function which provide also the test options should be used
+ private static final String javacBinary = Paths.get(jdkUnderTest, "bin", "javac").toString();
+
+ private static final Charset defaultCharset = Charset.defaultCharset();
+
+ static final JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+
+ /**
+ * The expected result of command-like method execution.
+ */
+ public enum Expect {SUCCESS, FAIL}
+
+ enum AcceptedParams {
+ EXPECT,
+ SOURCES,
+ OPTIONS,
+ STD_OUTPUT,
+ ERR_OUTPUT,
+ EXTRA_ENV,
+ }
+
+ enum OutputKind {STD, ERR}
+
+ /**
+ * Helper class to abstract the processing of command's output.
+ */
+ static abstract class WriterHelper {
+ OutputKind kind;
+ public abstract void pipeOutput(ProcessBuilder pb);
+ public abstract void readFromStream(Process p) throws IOException;
+ public abstract void addAll(Collection<? extends String> c) throws IOException;
+ }
+
+ /**
+ * Helper class for redirecting command's output to a file.
+ */
+ static class FileWriterHelper extends WriterHelper {
+ File file;
+
+ FileWriterHelper(File file, OutputKind kind) {
+ this.file = file;
+ this.kind = kind;
+ }
+
+ @Override
+ public void pipeOutput(ProcessBuilder pb) {
+ if (file != null) {
+ switch (kind) {
+ case STD:
+ pb.redirectInput(file);
+ break;
+ case ERR:
+ pb.redirectError(file);
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void readFromStream(Process p) throws IOException {}
+
+ @Override
+ public void addAll(Collection<? extends String> c) throws IOException {
+ if (file.exists())
+ Files.write(file.toPath(), c, defaultCharset,
+ StandardOpenOption.WRITE, StandardOpenOption.APPEND);
+ else
+ Files.write(file.toPath(), c, defaultCharset);
+ }
+ }
+
+ /**
+ * Helper class for redirecting command's output to a String list.
+ */
+ static class ListWriterHelper extends WriterHelper {
+ List<String> list;
+
+ public ListWriterHelper(List<String> list, OutputKind kind) {
+ this.kind = kind;
+ this.list = list;
+ }
+
+ @Override
+ public void pipeOutput(ProcessBuilder pb) {}
+
+ @Override
+ public void readFromStream(Process p) throws IOException {
+ BufferedReader br = null;
+ switch (kind) {
+ case STD:
+ br = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ break;
+ case ERR:
+ br = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ break;
+ }
+ String line;
+ while ((line = br.readLine()) != null) {
+ list.add(line);
+ }
+ }
+
+ public void addAll(Collection<? extends String> c) {
+ list.addAll(c);
+ }
+ }
+
+ /**
+ * Simple factory class for creating a WriterHelper instance.
+ */
+ static class WriterHelperFactory {
+ static WriterHelper make(File file, OutputKind kind) {
+ return new FileWriterHelper(file, kind);
+ }
+
+ static WriterHelper make(List<String> list, OutputKind kind) {
+ return new ListWriterHelper(list, kind);
+ }
+ }
+
+ /**
+ * A generic class for holding command's arguments.
+ */
+ public static abstract class GenericArgs <T extends GenericArgs> {
+ protected static List<Set<AcceptedParams>> minAcceptedParams;
+
+ protected Set<AcceptedParams> currentParams =
+ EnumSet.<AcceptedParams>noneOf(AcceptedParams.class);
+
+ protected Expect whatToExpect;
+ protected WriterHelper stdOutput;
+ protected WriterHelper errOutput;
+ protected List<String> options;
+ protected String[] optionsArr;
+
+ protected GenericArgs() {
+ set(Expect.SUCCESS);
+ }
+
+ public T set(Expect whatToExpt) {
+ currentParams.add(AcceptedParams.EXPECT);
+ this.whatToExpect = whatToExpt;
+ return (T)this;
+ }
+
+ public T setStdOutput(List<String> stdOutput) {
+ currentParams.add(AcceptedParams.STD_OUTPUT);
+ this.stdOutput = WriterHelperFactory.make(stdOutput, OutputKind.STD);
+ return (T)this;
+ }
+
+ public T setStdOutput(File output) {
+ currentParams.add(AcceptedParams.STD_OUTPUT);
+ this.stdOutput = WriterHelperFactory.make(output, OutputKind.STD);
+ return (T)this;
+ }
+
+ public T setErrOutput(List<String> errOutput) {
+ currentParams.add(AcceptedParams.ERR_OUTPUT);
+ this.errOutput = WriterHelperFactory.make(errOutput, OutputKind.ERR);
+ return (T)this;
+ }
+
+ public T setErrOutput(File errOutput) {
+ currentParams.add(AcceptedParams.ERR_OUTPUT);
+ this.errOutput = WriterHelperFactory.make(errOutput, OutputKind.ERR);
+ return (T)this;
+ }
+
+ public T setAllArgs(String... args) {
+ currentParams.add(AcceptedParams.OPTIONS);
+ this.optionsArr = args;
+ return (T)this;
+ }
+
+ public T setOptions(List<String> options) {
+ currentParams.add(AcceptedParams.OPTIONS);
+ this.options = options;
+ return (T)this;
+ }
+
+ public T setOptions(String... options) {
+ currentParams.add(AcceptedParams.OPTIONS);
+ this.options = Arrays.asList(options);
+ return (T)this;
+ }
+
+ public boolean hasMinParams() {
+ for (Set<AcceptedParams> minSet : minAcceptedParams) {
+ if (currentParams.containsAll(minSet)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ /**
+ * A more specific class for holding javac-like command's arguments.
+ */
+ public static class JavaToolArgs extends GenericArgs<JavaToolArgs> {
+
+ static {
+ minAcceptedParams = new ArrayList<>();
+ minAcceptedParams.add(EnumSet.<AcceptedParams>of(
+ AcceptedParams.EXPECT, AcceptedParams.OPTIONS));
+ minAcceptedParams.add(EnumSet.<AcceptedParams>of(
+ AcceptedParams.EXPECT, AcceptedParams.SOURCES));
+ }
+
+ protected List<? extends JavaFileObject> sources;
+
+ public JavaToolArgs() {
+ super();
+ }
+
+ public JavaToolArgs(Expect whatToExpt) {
+ super.set(whatToExpt);
+ }
+
+ public JavaToolArgs setSources(List<? extends JavaFileObject> sources) {
+ currentParams.add(AcceptedParams.SOURCES);
+ this.sources = sources;
+ return this;
+ }
+
+ public JavaToolArgs setSources(JavaSource... sources) {
+ return setSources(Arrays.asList(sources));
+ }
+
+ public JavaToolArgs setSources(String... sources) {
+ List<JavaSource> javaSrcs = new ArrayList<>();
+ for (String source : sources) {
+ javaSrcs.add(new JavaSource(source));
+ }
+ return setSources(javaSrcs);
+ }
+ }
+
+ /**
+ * A more specific class for holding any command's arguments.
+ */
+ public static class AnyToolArgs extends GenericArgs<AnyToolArgs> {
+
+ static {
+ minAcceptedParams = new ArrayList<>();
+ minAcceptedParams.add(EnumSet.<AcceptedParams>of(
+ AcceptedParams.EXPECT, AcceptedParams.OPTIONS));
+ }
+
+ Map<String, String> extraEnv;
+
+ public AnyToolArgs() {
+ super();
+ }
+
+ public AnyToolArgs(Expect whatToExpt) {
+ set(whatToExpt);
+ }
+
+ public AnyToolArgs set(Map<String, String> extraEnv) {
+ currentParams.add(AcceptedParams.EXTRA_ENV);
+ this.extraEnv = extraEnv;
+ return this;
+ }
+ }
+
+ /**
+ * Custom exception for bad command execution.
+ */
+ public static class CommandExecutionException extends Exception {
+ CommandExecutionException(List<String> command, Expect whatToExpt) {
+ super(createMessage(command, whatToExpt));
+ }
+
+ CommandExecutionException(Expect whatToExpt, String... command) {
+ this(Arrays.asList(command), whatToExpt);
+ }
+
+ private static String createMessage(List<String> command, Expect whatToExpt) {
+ StringBuilder sb = new StringBuilder().append("Command : ");
+ sb.append(command.toString()).append(lineSeparator);
+ switch (whatToExpt) {
+ case SUCCESS:
+ sb.append(" has unexpectedly failed");
+ break;
+ case FAIL:
+ sb.append(" has been unexpectedly successful");
+ break;
+ }
+ return sb.toString();
+ }
+ }
+
+ /**
+ * Custom exception for not equal resources.
+ */
+ public static class ResourcesNotEqualException extends Exception {
+ public ResourcesNotEqualException() {
+ super("The resources provided for comparison are different");
+ }
+
+ public ResourcesNotEqualException(Path path1, Path path2) {
+ super(createMessage(path1, path2));
+ }
+
+ private static String createMessage(Path path1, Path path2) {
+ return new StringBuilder()
+ .append("The resources provided for comparison in paths \n")
+ .append(path1.toString()).append(" and \n")
+ .append(path2.toString()).append("are different").toString();
+ }
+ }
+
+ /**
+ * Method to get the a path to the javac command available at the jdk being
+ * tested along with the test vm options.
+ * @return a String[] with the two components mentioned.
+ */
+ public static String[] getJavacBin() {
+ return new String[]{javacBinary, testVMOpts};
+ }
+
+ /**
+ * A javac compiler caller method.
+ */
+ public static int javac(JavaToolArgs params)
+ throws CommandExecutionException, IOException {
+ if (params.hasMinParams()) {
+ if (params.optionsArr != null) {
+ return genericJavaCMD(JavaCMD.JAVAC, params);
+ } else {
+ return genericJavaCMD(JavaCMD.JAVAC_API, params);
+ }
+ }
+ throw new AssertionError("javac command has been invoked with less parameters than needed");
+ }
+
+ /**
+ * A javap calling method.
+ */
+ public static String javap(JavaToolArgs params)
+ throws CommandExecutionException, IOException {
+ if (params.hasMinParams()) {
+ List<String> list = new ArrayList<>();
+ params.setErrOutput(list);
+ genericJavaCMD(JavaCMD.JAVAP, params);
+ return listToString(list);
+ }
+ throw new AssertionError("javap command has been invoked with less parameters than needed");
+ }
+
+ /**
+ * A javah calling method.
+ */
+ public static int javah(JavaToolArgs params)
+ throws CommandExecutionException, IOException {
+ if (params.hasMinParams()) {
+ return genericJavaCMD(JavaCMD.JAVAH, params);
+ }
+ throw new AssertionError("javah command has been invoked with less parameters than needed");
+ }
+
+ /**
+ * A enum class for langtools commands.
+ */
+ enum JavaCMD {
+ JAVAC {
+ @Override
+ int run(JavaToolArgs params, PrintWriter pw) {
+ return com.sun.tools.javac.Main.compile(params.optionsArr, pw);
+ }
+ },
+ JAVAC_API {
+ @Override
+ int run(JavaToolArgs params, PrintWriter pw) {
+ JavacTask ct = (JavacTask)comp.getTask(pw, null, null,
+ params.options, null, params.sources);
+ return ((JavacTaskImpl)ct).doCall().exitCode;
+ }
+
+ @Override
+ String getName() {
+ return "javac";
+ }
+
+ @Override
+ List<String> getExceptionMsgContent(JavaToolArgs params) {
+ List<String> result = super.getExceptionMsgContent(params);
+ for (JavaFileObject source : params.sources) {
+ if (source instanceof JavaSource) {
+ result.add(((JavaSource)source).name);
+ }
+ }
+ return result;
+ }
+ },
+ JAVAH {
+ @Override
+ int run(JavaToolArgs params, PrintWriter pw) {
+ return com.sun.tools.javah.Main.run(params.optionsArr, pw);
+ }
+ },
+ JAVAP {
+ @Override
+ int run(JavaToolArgs params, PrintWriter pw) {
+ return com.sun.tools.javap.Main.run(params.optionsArr, pw);
+ }
+ };
+
+ abstract int run(JavaToolArgs params, PrintWriter pw);
+
+ String getName() {
+ return this.name().toLowerCase();
+ }
+
+ List<String> getExceptionMsgContent(JavaToolArgs params) {
+ List<String> result = new ArrayList<>();
+ result.add(getName());
+ result.addAll(params.optionsArr != null ?
+ Arrays.asList(params.optionsArr) :
+ params.options);
+ return result;
+ }
+ }
+
+ /**
+ * A helper method for executing langtools commands.
+ */
+ private static int genericJavaCMD(
+ JavaCMD cmd,
+ JavaToolArgs params)
+ throws CommandExecutionException, IOException {
+ int rc = 0;
+ StringWriter sw = null;
+ try (PrintWriter pw = (params.errOutput == null) ?
+ null : new PrintWriter(sw = new StringWriter())) {
+ rc = cmd.run(params, pw);
+ }
+ String out = (sw == null) ? null : sw.toString();
+
+ if (params.errOutput != null && (out != null) && !out.isEmpty()) {
+ params.errOutput.addAll(splitLines(out));
+ }
+
+ if ( (rc == 0 && params.whatToExpect == Expect.SUCCESS) ||
+ (rc != 0 && params.whatToExpect == Expect.FAIL) ) {
+ return rc;
+ }
+
+ throw new CommandExecutionException(cmd.getExceptionMsgContent(params),
+ params.whatToExpect);
+ }
+
+ /**
+ * A jar calling method.
+ */
+ public static boolean jar(String... params) throws CommandExecutionException {
+ Main jarGenerator = new Main(System.out, System.err, "jar");
+ boolean result = jarGenerator.run(params);
+ if (!result) {
+ List<String> command = new ArrayList<>();
+ command.add("jar");
+ command.addAll(Arrays.asList(params));
+ throw new CommandExecutionException(command, Expect.SUCCESS);
+ }
+ return result;
+ }
+
+ /**
+ * A general command calling method.
+ */
+ public static int executeCommand(AnyToolArgs params)
+ throws CommandExecutionException, IOException, InterruptedException {
+ if (params.hasMinParams()) {
+ List<String> cmd = (params.options != null) ?
+ params.options :
+ Arrays.asList(params.optionsArr);
+ return executeCommand(cmd, params.extraEnv, params.stdOutput,
+ params.errOutput, params.whatToExpect);
+ }
+ throw new AssertionError("command has been invoked with less parameters than needed");
+ }
+
+ /**
+ * A helper method for calling a general command.
+ */
+ private static int executeCommand(
+ List<String> command,
+ Map<String, String> extraEnv,
+ WriterHelper stdOutput,
+ WriterHelper errOutput,
+ Expect whatToExpt)
+ throws IOException, InterruptedException, CommandExecutionException {
+ ProcessBuilder pb = new ProcessBuilder(command);
+
+ if (stdOutput != null) stdOutput.pipeOutput(pb);
+ if (errOutput != null) errOutput.pipeOutput(pb);
+
+ if (extraEnv != null) {
+ pb.environment().putAll(extraEnv);
+ }
+
+ Process p = pb.start();
+
+ if (stdOutput != null) stdOutput.readFromStream(p);
+ if (errOutput != null) errOutput.readFromStream(p);
+
+ int result = p.waitFor();
+ if ( (result == 0 && whatToExpt == Expect.SUCCESS) ||
+ (result != 0 && whatToExpt == Expect.FAIL) ) {
+ return result;
+ }
+
+ throw new CommandExecutionException(command, whatToExpt);
+ }
+
+ /**
+ * This set of methods can be used instead of diff when the only needed
+ * result is the equality or inequality of the two given resources.
+ *
+ * A resource can be a file or a String list.
+ */
+ public static void compareLines(Path aPath, Path otherPath, String encoding)
+ throws FileNotFoundException, IOException, ResourcesNotEqualException {
+ compareLines(aPath, otherPath, encoding, false);
+ }
+
+ public static void compareLines(
+ Path aPath, Path otherPath, String encoding, boolean trim)
+ throws FileNotFoundException, IOException, ResourcesNotEqualException {
+ Charset charset = encoding != null ?
+ Charset.forName(encoding) :
+ defaultCharset;
+ List<String> list1 = Files.readAllLines(aPath, charset);
+ List<String> list2 = Files.readAllLines(otherPath, charset);
+ compareLines(list1, list2, trim);
+ }
+
+ public static void compareLines(Path path, List<String> strings, String encoding)
+ throws FileNotFoundException, IOException, ResourcesNotEqualException {
+ compareLines(path, strings, encoding, false);
+ }
+
+ public static void compareLines(Path path, List<String> strings,
+ String encoding, boolean trim)
+ throws FileNotFoundException, IOException, ResourcesNotEqualException {
+ Charset charset = encoding != null ?
+ Charset.forName(encoding) :
+ defaultCharset;
+ List<String> list = Files.readAllLines(path, charset);
+ compareLines(list, strings, trim);
+ }
+
+ public static void compareLines(List<String> list1, List<String> list2)
+ throws ResourcesNotEqualException {
+ compareLines(list1, list2, false);
+ }
+
+ public static void compareLines(List<String> list1,
+ List<String> list2, boolean trim) throws ResourcesNotEqualException {
+ if ((list1 == list2) || (list1 == null && list2 == null)) return;
+ if (list1.size() != list2.size())
+ throw new ResourcesNotEqualException();
+ int i = 0;
+ int j = 0;
+ while (i < list1.size() &&
+ j < list2.size() &&
+ equals(list1.get(i), list2.get(j), trim)) {
+ i++; j++;
+ }
+ if (!(i == list1.size() && j == list2.size()))
+ throw new ResourcesNotEqualException();
+ }
+
+ private static boolean equals(String s1, String s2, boolean trim) {
+ return (trim ? s1.trim().equals(s2.trim()) : s1.equals(s2));
+ }
+
+ /**
+ * A set of simple grep-like methods, looks for regExpr in text.
+ * The content of text is split using the new line character as a pattern
+ * and later the regExpr is seek in every split line. If a match is found,
+ * the whole line is added to the result.
+ */
+ public static List<String> grep(String regExpr, String text) {
+ return grep(regExpr, splitLines(text));
+ }
+
+ public static List<String> grep(String regExpr, List<String> text) {
+ List<String> result = new ArrayList<>();
+ Pattern pattern = Pattern.compile(regExpr);
+ for (String s : text) {
+ if (pattern.matcher(s).find()) {
+ result.add(s);
+ }
+ }
+ return result;
+ }
+
+ public static List<String> grep(String regExpr, File f)
+ throws IOException {
+ List<String> lines = Files.readAllLines(f.toPath(), defaultCharset);
+ return grep(regExpr, lines);
+ }
+
+ /**
+ * A touch-like method.
+ */
+ public static boolean touch(String fileName) {
+ File file = new File(fileName);
+ return touch(file);
+ }
+
+ public static boolean touch(File file) {
+ if (file.exists()) {
+ file.setLastModified(System.currentTimeMillis());
+ return true;
+ }
+ return false;
+ }
+
+ public static void createJavaFile(File outFile) throws IOException {
+ createJavaFile(outFile, null);
+ }
+
+ /**
+ * A method for creating a valid but very simple java file.
+ */
+ public static void createJavaFile(File outFile, File superClass)
+ throws IOException {
+ String srcStr = "public class " + getSimpleName(outFile) + " ";
+ if (superClass != null) {
+ srcStr = srcStr.concat("extends " + getSimpleName(superClass) + " ");
+ }
+ srcStr = srcStr.concat("{}");
+ try (PrintWriter ps = new PrintWriter(new FileWriter(outFile))) {
+ ps.println(srcStr);
+ }
+ }
+
+ /**
+ * Creates a java file name given its source.
+ * The file is created in the working directory, creating a directory
+ * tree if there is a package declaration.
+ */
+ public static void createJavaFileFromSource(String source) throws IOException {
+ createJavaFileFromSource(null, source);
+ }
+
+ /**
+ * Creates a java file name given its source.
+ * The file is created in the working directory, creating a directory
+ * tree if there is a package declaration or the argument initialPath
+ * has a valid path.
+ *
+ * e.i. if initialPath is foo/ and the source is:
+ * package bar;
+ *
+ * public class bazz {}
+ *
+ * this method will create the file foo/bar/bazz.java in the working
+ * directory.
+ */
+ public static void createJavaFileFromSource(Path initialPath,
+ String source) throws IOException {
+ String fileName = getJavaFileNameFromSource(source);
+ String dirTree = getDirTreeFromSource(source);
+ Path path = (dirTree != null) ?
+ Paths.get(dirTree, fileName) :
+ Paths.get(fileName);
+ path = (initialPath != null) ?
+ initialPath.resolve(path):
+ path;
+ writeFile(path, source);
+ }
+
+ static Pattern publicClassPattern =
+ Pattern.compile("public\\s+(?:class|enum|interface){1}\\s+(\\w+)");
+ static Pattern packageClassPattern =
+ Pattern.compile("(?:class|enum|interface){1}\\s+(\\w+)");
+
+ /**
+ * Extracts the java file name from the class declaration.
+ * This method is intended for simple files and uses regular expressions,
+ * so comments matching the pattern can make the method fail.
+ */
+ private static String getJavaFileNameFromSource(String source) {
+ String className = null;
+ Matcher matcher = publicClassPattern.matcher(source);
+ if (matcher.find()) {
+ className = matcher.group(1) + ".java";
+ } else {
+ matcher = packageClassPattern.matcher(source);
+ if (matcher.find()) {
+ className = matcher.group(1) + ".java";
+ } else {
+ throw new AssertionError("Could not extract the java class " +
+ "name from the provided source");
+ }
+ }
+ return className;
+ }
+
+ static Pattern packagePattern =
+ Pattern.compile("package\\s+(((?:\\w+\\.)*)(?:\\w+))");
+
+ /**
+ * Extracts the path from the package declaration if present.
+ * This method is intended for simple files and uses regular expressions,
+ * so comments matching the pattern can make the method fail.
+ */
+ private static String getDirTreeFromSource(String source) {
+ Matcher matcher = packagePattern.matcher(source);
+ return matcher.find() ?
+ matcher.group(1).replace(".", File.separator) :
+ null;
+ }
+
+ /**
+ * A method for creating a jar's manifest file with supplied data.
+ */
+ public static void mkManifestWithClassPath(String mainClass,
+ String... classes) throws IOException {
+ List <String> lines = new ArrayList<>();
+
+ StringBuilder sb = new StringBuilder("Class-Path: ".length() +
+ classes[0].length()).append("Class-Path: ").append(classes[0]);
+ for (int i = 1; i < classes.length; i++) {
+ sb.append(" ").append(classes[i]);
+ }
+ lines.add(sb.toString());
+ if (mainClass != null) {
+ lines.add(new StringBuilder("Main-Class: ".length() +
+ mainClass.length())
+ .append("Main-Class: ")
+ .append(mainClass).toString());
+ }
+ Files.write(Paths.get("MANIFEST.MF"), lines, null);
+ }
+
+ /**
+ * A utility method to obtain the file name.
+ */
+ static String getSimpleName(File inFile) {
+ return inFile.toPath().getFileName().toString();
+ }
+
+ /**
+ * A method to write to a file, the directory tree is created if needed.
+ */
+ public static File writeFile(Path path, String body) throws IOException {
+ File result;
+ if (path.getParent() != null) {
+ Files.createDirectories(path.getParent());
+ }
+ try (FileWriter out = new FileWriter(result = path.toAbsolutePath().toFile())) {
+ out.write(body);
+ }
+ return result;
+ }
+
+ public static File writeFile(String path, String body) throws IOException {
+ return writeFile(Paths.get(path), body);
+ }
+
+ /**
+ * A rm-like method, the file is deleted only if it exists.
+ */
+ public static void rm(Path path) throws Exception {
+ Files.deleteIfExists(path);
+ }
+
+ public static void rm(String filename) throws Exception {
+ rm(Paths.get(filename));
+ }
+
+ public static void rm(File f) throws Exception {
+ rm(f.toPath());
+ }
+
+ /**
+ * Copy source file to destination file.
+ */
+ public static void copyFile(File destfile, File srcfile)
+ throws IOException {
+ copyFile(destfile.toPath(), srcfile.toPath());
+ }
+
+ public static void copyFile(Path destPath, Path srcPath)
+ throws IOException {
+ Files.createDirectories(destPath);
+ Files.copy(srcPath, destPath, REPLACE_EXISTING);
+ }
+
+ /**
+ * Splits a String using the System's line separator character as splitting point.
+ */
+ public static List<String> splitLines(String lines) {
+ return Arrays.asList(lines.split(lineSeparator));
+ }
+
+ /**
+ * Converts a String list into one String by appending the System's line separator
+ * character after each component.
+ */
+ private static String listToString(List<String> lines) {
+ StringBuilder sb = new StringBuilder();
+ for (String s : lines) {
+ sb.append(s).append(lineSeparator);
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Class representing an in-memory java source file. It is able to extract
+ * the file name from simple source codes using regular expressions.
+ */
+ public static class JavaSource extends SimpleJavaFileObject {
+ String source;
+ String name;
+
+ public JavaSource(String className, String source) {
+ super(URI.create(className),
+ JavaFileObject.Kind.SOURCE);
+ this.name = className;
+ this.source = source;
+ }
+
+ public JavaSource(String source) {
+ super(URI.create(getJavaFileNameFromSource(source)),
+ JavaFileObject.Kind.SOURCE);
+ this.name = getJavaFileNameFromSource(source);
+ this.source = source;
+ }
+
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+ return source;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/links/LinksTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,63 @@
+/*
+ * 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 4266026
+ * @summary javac no longer follows symlinks
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main LinksTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/links/links.sh
+public class LinksTest {
+
+ private static final String BSrc =
+ "package a;\n" +
+ "\n" +
+ "public class B {}";
+
+ private static final String TSrc =
+ "class T extends a.B {}";
+
+ public static void main(String args[])
+ throws Exception {
+// mkdir tmp
+// cp ${TESTSRC}/b/B.java tmp
+ ToolBox.writeFile(Paths.get("tmp", "B.java"), BSrc);
+
+// ln -s `pwd`/tmp "${TESTCLASSES}/a"
+ Files.createSymbolicLink(Paths.get("a"), Paths.get("tmp"));
+//
+////"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1
+ ToolBox.JavaToolArgs javacArgs =
+ new ToolBox.JavaToolArgs()
+ .setOptions("-sourcepath", ".", "-d", ".").setSources(TSrc);
+ ToolBox.javac(javacArgs);
+ }
+
+}
--- a/langtools/test/tools/javac/links/T.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2001, 2008, 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.
- */
-
-class T extends a.B {}
--- a/langtools/test/tools/javac/links/b/B.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package a;
-
-public class B {}
--- a/langtools/test/tools/javac/links/links.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2001, 2008, 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 4266026
-# @summary javac no longer follows symlinks
-#
-# @run shell links.sh
-
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin )
- NULL=/dev/null
- PS=":"
- FS="/"
- ;;
- * )
- echo "Unrecognized system - test skipped."
- exit 0;
- ;;
-esac
-
-mkdir tmp
-cp ${TESTSRC}/b/B.java tmp
-
-rm -rf T.class B.class b/B.class "${TESTCLASSES}/a" "${TESTCLASSES}/classes"
-ln -s `pwd`/tmp "${TESTCLASSES}/a"
-mkdir "${TESTCLASSES}/classes"
-
-"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/newlines/NewLineTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,62 @@
+/*
+ * 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 4110560 4785453
+ * @summary portability : javac.properties
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main NewLineTest
+ */
+
+import java.io.File;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.List;
+import com.sun.tools.javac.util.ArrayUtils;
+
+//original test: test/tools/javac/newlines/Newlines.sh
+public class NewLineTest {
+
+ public static void main(String args[]) throws Exception {
+ String[] mainArgs = ToolBox.getJavacBin();
+
+// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Dline.separator='@' > ${TMP1} 2>&1
+ File javacErrOutput = new File("output.txt");
+ ToolBox.AnyToolArgs cmdArgs =
+ new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
+ .setAllArgs(ArrayUtils.concatOpen(mainArgs, "-J-Dline.separator='@'"))
+ .setErrOutput(javacErrOutput);
+ ToolBox.executeCommand(cmdArgs);
+
+// result=`cat ${TMP1} | wc -l`
+// if [ "$result" -eq 0 ] passed
+ List<String> lines = Files.readAllLines(javacErrOutput.toPath(),
+ Charset.defaultCharset());
+ if (lines.size() != 1) {
+ throw new AssertionError("The compiler output should have one line only");
+ }
+ }
+
+}
--- a/langtools/test/tools/javac/newlines/Newlines.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-#
-# Copyright (c) 2002, 2012, 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 4110560 4785453
-# @summary portability : javac.properties
-#
-# @run shell Newlines.sh
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin | CYGWIN* )
- FS="/"
- ;;
- Windows* )
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-TMP1=OUTPUT.txt
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Dline.separator='@' > ${TMP1} 2>&1
-cat ${TMP1}
-result=`cat ${TMP1} | wc -l`
-if [ "$result" -eq 0 ]
-then
- echo "Passed"
-else
- echo "Failed"
-fi
-exit $result
--- a/langtools/test/tools/javac/resolve/Pos.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/resolve/Pos.java Tue Mar 12 16:43:53 2013 -0700
@@ -28,4 +28,4 @@
long line() default -1;
long col() default -1;
boolean userDefined() default true;
-}
\ No newline at end of file
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/resolve/tests/InnerOverOuter.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+@TraceResolve
+class Test {
+
+ //no annotation here - this should NOT even be considered!
+ void m(Integer i1, Integer i2) { }
+
+ //no annotation here - this should NOT even be considered!
+ void m(Object... o) { }
+
+ @TraceResolve(keys={"compiler.err.cant.apply.symbol"})
+ class Inner {
+ @Candidate
+ void m(String s) {
+ m(1, 1); //should fail
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/stackmap/StackMapTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,65 @@
+/*
+ * 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 4955930
+ * @summary The "method0" StackMap attribute should have two entries instead of three
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run compile -source 6 -target 6 StackMapTest.java
+ * @run main StackMapTest
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/stackmap/T4955930.sh
+public class StackMapTest {
+
+ class Test {
+ void method0(boolean aboolean) throws Exception {
+ label_0:
+ while (true) {
+ if (aboolean) ;
+ else break label_0;
+ }
+ }
+ }
+
+ public static void main(String args[]) throws Exception {
+// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -source 6 -target 6 T4955930.java
+
+// "${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -verbose T4955930 > ${TMP1}
+ Path pathToClass = Paths.get(System.getProperty("test.classes"),
+ "StackMapTest$Test.class");
+ ToolBox.JavaToolArgs javapArgs =
+ new ToolBox.JavaToolArgs().setAllArgs("-v", pathToClass.toString());
+
+// grep "StackMapTable: number_of_entries = 2" ${TMP1}
+ if (!ToolBox.javap(javapArgs).contains("StackMapTable: number_of_entries = 2"))
+ throw new AssertionError("The number of entries of the stack map "
+ + "table should be equal to 2");
+ }
+
+}
--- a/langtools/test/tools/javac/stackmap/T4955930.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2005, 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 4955930
- * @summary The "method0" StackMap attribute should have two entries instead of three
- * @author wtao
- *
- * @run shell T4955930.sh
- */
-
-public class T4955930 {
-
- void method0(boolean aboolean) throws Exception {
- label_0:
- while (true) {
- if (aboolean) {
- ;
- }
- else {
- break label_0;
- }
- System.out.println("");
- }
- }
-}
--- a/langtools/test/tools/javac/stackmap/T4955930.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2005, 2009, 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.
-#
-
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin | CYGWIN* )
- FS="/"
- ;;
- Windows_95 | Windows_98 | Windows_NT )
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-TMP1=T4955930.javap
-
-cp "${TESTSRC}${FS}T4955930.java" .
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -source 6 -target 6 T4955930.java
-result=$?
-if [ $result -ne 0 ]
-then
- exit $result
-fi
-
-"${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -verbose T4955930 > ${TMP1}
-grep "StackMapTable: number_of_entries = 2" ${TMP1}
-result=$?
-
-if [ $result -eq 0 ]
-then
- echo "Passed"
-else
- echo "Failed"
-fi
-exit $result
--- a/langtools/test/tools/javac/unicode/SupplementaryJavaID6.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javac/unicode/SupplementaryJavaID6.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -21,12 +21,20 @@
* questions.
*/
+/*
+ * @test
+ * @bug 4914724 4973116 5014511
+ * @summary Ensure that a supplementary character can be used as part/whole of a
+ * class name on platforms that have Unicode aware filesystems.
+ * @run main SupplementaryJavaID6
+ */
+
public class SupplementaryJavaID6 {
public static void main(String[] s) {
- new SupplementaryJavaID6();
+ new SupplementaryJavaID6().test();
}
- public SupplementaryJavaID6() {
+ void test() {
\ud801\udc00 instance = new \ud801\udc00();
instance.\ud801\udc01();
}
--- a/langtools/test/tools/javac/unicode/SupplementaryJavaID6.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2009, 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 4914724 4973116 5014511
-# @summary Ensure that a supplementary character can be used as part/whole of a class
-# name on platforms that have Unicode aware filesystems.
-# @author Naoto Sato
-# @run shell SupplementaryJavaID6.sh SupplementaryJavaID6
-
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin )
- if [ -d /usr/lib/locale/en_US.UTF-8 -o -d /usr/lib/locale/en_US.utf8 ]
- then
- ENV="env LANG=en_US.UTF-8"
- PS=":"
- FS="/"
- else
- echo "As there is no en_US.UTF-8 locale available on this system, the compilation of the test case may or may not fail. Ignoring this test."
- exit 0;
- fi
- ;;
- Windows_98 | Windows_ME )
- echo "As Windows 98/Me do not provide Unicode-aware file system, the compilation of the test case is expected to fail on these platforms. Ignoring this test."
- exit 0;
- ;;
- Windows* )
- ENV=""
- PS=";"
- FS="\\"
- ;;
- CYGWIN* )
- ENV=""
- PS=";" # platform PS, not cygwin PS
- FS="/"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-# compile
-cp "${TESTSRC}${FS}$1.java" .
-${ENV} "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath ".${PS}${TESTSRC}" $1.java
-result=$?
-
-if [ $result -ne 0 ]
-then
- echo "Failed"
- exit $result
-fi
-
-# run
-${ENV} "${TESTJAVA}${FS}bin${FS}java" ${TESTVMOPTS} $1
-result=$?
-
-if [ $result -eq 0 ]
-then
- echo "Passed"
-else
- echo "Failed"
-fi
-
-# Cleanup
-${ENV} rm -f ./$1*.class
-
-exit $result
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javah/6257087/T6257087.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,81 @@
+/*
+ * 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 6257087
+ * @summary javah doesn't produce proper signatures for inner class native methods
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main T6257087
+ */
+
+import java.nio.file.Paths;
+
+//original test: test/tools/javah/6257087/foo.sh
+public class T6257087 {
+
+ private static final String fooBarGoldenFile =
+ "/* DO NOT EDIT THIS FILE - it is machine generated */\n" +
+ "#include <jni.h>\n" +
+ "/* Header for class foo_bar */\n" +
+ "\n" +
+ "#ifndef _Included_foo_bar\n" +
+ "#define _Included_foo_bar\n" +
+ "#ifdef __cplusplus\n" +
+ "extern \"C\" {\n" +
+ "#endif\n" +
+ "/*\n" +
+ " * Class: foo_bar\n" +
+ " * Method: aardvark\n" +
+ " * Signature: ()V\n" +
+ " */\n" +
+ "JNIEXPORT void JNICALL Java_foo_00024bar_aardvark\n" +
+ " (JNIEnv *, jobject);\n" +
+ "\n" +
+ "#ifdef __cplusplus\n" +
+ "}\n" +
+ "#endif\n" +
+ "#endif";
+
+ public static void main(String[] args) throws Exception {
+// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TC}" "${TS}${FS}foo.java"
+
+// "${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} -classpath "${TC}" -d "${TC}" foo
+ ToolBox.JavaToolArgs javahArgs =
+ new ToolBox.JavaToolArgs()
+ .setAllArgs("-cp", System.getProperty("test.classes"), "foo");
+ ToolBox.javah(javahArgs);
+
+// diff ${DIFFOPTS} -c "${TS}${FS}foo_bar.h" "${TC}${FS}foo_bar.h"
+ ToolBox.compareLines(Paths.get("foo_bar.h"),
+ ToolBox.splitLines(fooBarGoldenFile), null);
+ }
+
+}
+
+class foo {
+ class bar {
+ public native void aardvark();
+ }
+}
--- a/langtools/test/tools/javah/6257087/foo.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2006, 2007, 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.
- */
-
-
-class foo {
- class bar {
- public native void aardvark();
- }
-}
--- a/langtools/test/tools/javah/6257087/foo.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-#! /bin/sh -f
-
-#
-# Copyright (c) 2006, 2009, 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 6257087
-# @run shell foo.sh
-
-
-TS=${TESTSRC-.}
-TC=${TESTCLASSES-.}
-
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin )
- PS=":"
- FS="/"
- ;;
- CYGWIN* )
- PS=":"
- FS="/"
- DIFFOPTS="--strip-trailing-cr"
- ;;
- Windows* )
- PS=";"
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TC}" "${TS}${FS}foo.java"
-"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} -classpath "${TC}" -d "${TC}" foo
-diff ${DIFFOPTS} -c "${TS}${FS}foo_bar.h" "${TC}${FS}foo_bar.h"
-result=$?
-
-if [ $result -eq 0 ]
-then
- echo "Passed"
-else
- echo "Failed"
-fi
-exit $result
--- a/langtools/test/tools/javah/6257087/foo_bar.h Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class foo_bar */
-
-#ifndef _Included_foo_bar
-#define _Included_foo_bar
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class: foo_bar
- * Method: aardvark
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_foo_00024bar_aardvark
- (JNIEnv *, jobject);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
--- a/langtools/test/tools/javah/ConstMacroTest.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2003, 2009, 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 4786406 4781221 4780341 6214324
-
-# Validates rewritten javah handling of class defined constants
-# and ensures that the appropriate macro definitions are placed
-# in the generated header file.
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-EXPECTED_JAVAH_OUT_FILE=SubClassConsts.out
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin )
- PS=":"
- FS="/"
- ;;
- CYGWIN* )
- PS=":"
- FS="/"
- DIFFOPTS="--strip-trailing-cr"
- EXPECTED_JAVAH_OUT_FILE=SubClassConsts.win
- ;;
- Windows* )
- PS=";"
- FS="\\"
- EXPECTED_JAVAH_OUT_FILE=SubClassConsts.win
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
- esac
-
-GENERATED_HEADER_FILE=SubClassConsts.h
-HEADER_FILE_FILTERED=SubClassConsts.h.linefeed-filtered
-
-rm -rf SuperClassConsts.class SubClassConsts.class
-
-cp "${TESTSRC}${FS}SuperClassConsts.java" .
-cp "${TESTSRC}${FS}SubClassConsts.java" .
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}SubClassConsts.java"
-
-"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} SubClassConsts
-
-diff ${DIFFOPTS} "${TESTSRC}${FS}${EXPECTED_JAVAH_OUT_FILE}" "${GENERATED_HEADER_FILE}"
-result=$?
-rm ${GENERATED_HEADER_FILE}
-
-if [ $result -eq 0 ]
-then
- echo "Passed"
-else
- echo "Failed"
-fi
-exit $result
--- a/langtools/test/tools/javah/MissingParamClassException.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2003, 2007, 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.
- */
-
-
-/*
- * ParamClassTest has a native method param which subclasses
- * this class
- *
- */
-
-public class MissingParamClassException extends Exception {
- public MissingParamClassException() {
- System.out.println("MissingParamClassException constructor called");
- }
-}
--- a/langtools/test/tools/javah/MissingParamClassTest.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2003, 2009, 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 4942232
-
-#
-# Verifies that javah won't attempt to generate a header file
-# if a native method in a supplied class contains a parameter
-# type whose corresponding class is missing or not in the
-# classpath
-
-TMP1=OUTPUT.txt
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin | CYGWIN* )
- PS=":"
- FS="/"
- ;;
- Windows* )
- PS=";"
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
- esac
-
-GENERATED_HEADER_FILE=ParamClassTest.h
-
-rm -f ParamClassTest.class MissingParamClassException.class ParamClassTest.h
-rm -f ${TMP1}
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
-
-# Before running javah remove dependent class file
-rm -f MissingParamClassException.class
-
-"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
-
-if [ -f $GENERATED_HEADER_FILE ]; then
- echo "1-- Failed: $GENERATED_HEADER_FILE found"
- rc=1
-fi
-if [ ! -s ${TMP1} ]; then
- echo "1-- Failed: ${TMP1} is empty"
- rc=1
-fi
-
-# Clean out work dir
-rm -f MissingParamClassException.class ParamClassTest.class
-rm -f $GENERATED_HEADER_FILE $TMP1
-
-# Re-compile everything
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
-
-
-# Before re-run of javah remove dependent class file Param.class
-rm -f Param.class
-
-"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
-
-if [ -f $GENERATED_HEADER_FILE ]; then
- echo "2-- Failed: $GENERATED_HEADER_FILE found"
- rc=1
-fi
-if [ ! -s ${TMP1} ]; then
- echo "2-- Failed: ${TMP1} is empty"
- rc=1
-fi
-
-if [ "$rc" = "" ]; then
- echo Passed
-else
- echo Failed
- exit 1
-fi
--- a/langtools/test/tools/javah/ParamClassTest.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2003, 2007, 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.
- */
-
-
-/*
- * Class containing a native method which contains a native
- * method with non primitive type
- */
-
-public class ParamClassTest {
- public native void method(Param s);
-
- public static void main(String args[]) {
- }
-}
-
-class Param extends MissingParamClassException {
- Param() {
- System.out.println("Param constructor");
- }
-}
--- a/langtools/test/tools/javah/SubClassConsts.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2003, 2007, 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.
- */
-
-
-/*
- * Subclass defines its own set of constants
- * It is itself serializable by virtue of extending SuperClassConsts
- *
- */
-public class SubClassConsts extends SuperClassConsts {
-
- private final static int SUB_INT_CONSTANT = 2;
- private final static double SUB_DOUBLE_CONSTANT = 2.25;
- private final static float SUB_FLOAT_CONSTANT = 7.90f;
- private final static boolean SUB_BOOLEAN_CONSTANT = true;
-
- public SubClassConsts(String p) {
- super(p);
- }
-}
--- a/langtools/test/tools/javah/SubClassConsts.out Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class SubClassConsts */
-
-#ifndef _Included_SubClassConsts
-#define _Included_SubClassConsts
-#ifdef __cplusplus
-extern "C" {
-#endif
-#undef SubClassConsts_serialVersionUID
-#define SubClassConsts_serialVersionUID 6733861379283244755LL
-#undef SubClassConsts_SUPER_INT_CONSTANT
-#define SubClassConsts_SUPER_INT_CONSTANT 3L
-#undef SubClassConsts_SUPER_FLOAT_CONSTANT
-#define SubClassConsts_SUPER_FLOAT_CONSTANT 99.3f
-#undef SubClassConsts_SUPER_DOUBLE_CONSTANT
-#define SubClassConsts_SUPER_DOUBLE_CONSTANT 33.2
-#undef SubClassConsts_SUPER_BOOLEAN_CONSTANT
-#define SubClassConsts_SUPER_BOOLEAN_CONSTANT 0L
-#undef SubClassConsts_SUB_INT_CONSTANT
-#define SubClassConsts_SUB_INT_CONSTANT 2L
-#undef SubClassConsts_SUB_DOUBLE_CONSTANT
-#define SubClassConsts_SUB_DOUBLE_CONSTANT 2.25
-#undef SubClassConsts_SUB_FLOAT_CONSTANT
-#define SubClassConsts_SUB_FLOAT_CONSTANT 7.9f
-#undef SubClassConsts_SUB_BOOLEAN_CONSTANT
-#define SubClassConsts_SUB_BOOLEAN_CONSTANT 1L
-#ifdef __cplusplus
-}
-#endif
-#endif
--- a/langtools/test/tools/javah/SubClassConsts.win Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class SubClassConsts */
-
-#ifndef _Included_SubClassConsts
-#define _Included_SubClassConsts
-#ifdef __cplusplus
-extern "C" {
-#endif
-#undef SubClassConsts_serialVersionUID
-#define SubClassConsts_serialVersionUID 6733861379283244755i64
-#undef SubClassConsts_SUPER_INT_CONSTANT
-#define SubClassConsts_SUPER_INT_CONSTANT 3L
-#undef SubClassConsts_SUPER_FLOAT_CONSTANT
-#define SubClassConsts_SUPER_FLOAT_CONSTANT 99.3f
-#undef SubClassConsts_SUPER_DOUBLE_CONSTANT
-#define SubClassConsts_SUPER_DOUBLE_CONSTANT 33.2
-#undef SubClassConsts_SUPER_BOOLEAN_CONSTANT
-#define SubClassConsts_SUPER_BOOLEAN_CONSTANT 0L
-#undef SubClassConsts_SUB_INT_CONSTANT
-#define SubClassConsts_SUB_INT_CONSTANT 2L
-#undef SubClassConsts_SUB_DOUBLE_CONSTANT
-#define SubClassConsts_SUB_DOUBLE_CONSTANT 2.25
-#undef SubClassConsts_SUB_FLOAT_CONSTANT
-#define SubClassConsts_SUB_FLOAT_CONSTANT 7.9f
-#undef SubClassConsts_SUB_BOOLEAN_CONSTANT
-#define SubClassConsts_SUB_BOOLEAN_CONSTANT 1L
-#ifdef __cplusplus
-}
-#endif
-#endif
--- a/langtools/test/tools/javah/SuperClassConsts.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2003, 2007, 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.
- */
-
-
-/*
- * Parent class implements serializable and provides static initializers
- * for a bunch of primitive type class constants
- * (required for regtest 4786406, 4780341)
- */
-
-import java.io.*;
-
-public class SuperClassConsts implements Serializable {
-
- // Define class constant values, base class is serializable
-
- private static final long serialVersionUID = 6733861379283244755L;
- public static final int SUPER_INT_CONSTANT = 3;
- public final static float SUPER_FLOAT_CONSTANT = 99.3f;
- public final static double SUPER_DOUBLE_CONSTANT = 33.2;
- public final static boolean SUPER_BOOLEAN_CONSTANT = false;
-
- // A token instance field
- int instanceField;
-
- public SuperClassConsts(String p) {
- }
-
- public native int numValues();
-
- private void writeObject(ObjectOutputStream s)
- throws IOException
- {
- System.err.println("writing state");
- }
-
- /**
- * readObject is called to restore the state of the FilePermission from
- * a stream.
- */
- private void readObject(ObjectInputStream s)
- throws IOException, ClassNotFoundException
- {
- System.err.println("reading back state");
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javah/T4942232/MissingParamClassTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,89 @@
+/*
+ * 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 4942232
+ * @summary Verifies that javah won't attempt to generate a header file if a
+ * native method in a supplied class contains a parameter type whose corresponding
+ * class is missing or not in the classpath
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run compile MissingParamClassTest.java
+ * @clean MissingParamClassException
+ * @run main MissingParamClassTest
+ * @run compile MissingParamClassTest.java
+ * @clean Param
+ * @run main MissingParamClassTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+//original test: test/tools/javah/MissingParamClassTest.sh
+public class MissingParamClassTest {
+
+ public static void main(String[] args) throws Exception {
+ //first steps done now by jtreg
+//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
+//rm -f MissingParamClassException.class
+
+//"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
+ List<String> errOutput = new ArrayList<>();
+ ToolBox.JavaToolArgs javahParams =
+ new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
+ .setAllArgs("-classpath", System.getProperty("test.classes"), "ParamClassTest")
+ .setErrOutput(errOutput);
+ ToolBox.javah(javahParams);
+
+//if [ -f $GENERATED_HEADER_FILE ]; then fail
+//if [ ! -s ${TMP1} ]; then fail
+ if (Files.exists(Paths.get("ParamClassTest.h")) || errOutput.size() == 0)
+ throw new AssertionError("The only output generated by javah must be an error message");
+ //jtreg again
+//rm -f MissingParamClassException.class ParamClassTest.class
+//rm -f $GENERATED_HEADER_FILE $TMP1
+ }
+
+}
+
+class MissingParamClassException extends Exception {
+ public MissingParamClassException() {
+ System.out.println("MissingParamClassException constructor called");
+ }
+}
+
+class ParamClassTest {
+ public native void method(Param s);
+
+ public static void main(String args[]) {
+ }
+}
+
+class Param extends MissingParamClassException {
+ Param() {
+ System.out.println("Param constructor");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javah/constMacroTest/ConstMacroTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,112 @@
+/*
+ * 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 4786406 4781221 4780341 6214324
+ * @summary Validates rewritten javah handling of class defined constants and
+ * ensures that the appropriate macro definitions are placed in the generated
+ * header file.
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main ConstMacroTest
+ */
+
+import java.io.*;
+import java.nio.file.Paths;
+
+//original test: test/tools/javah/ConstMacroTest.sh
+public class ConstMacroTest {
+
+ private static final String SubClassConstsGoldenFile =
+ "/* DO NOT EDIT THIS FILE - it is machine generated */\n" +
+ "#include <jni.h>\n" +
+ "/* Header for class SubClassConsts */\n" +
+ "\n" +
+ "#ifndef _Included_SubClassConsts\n" +
+ "#define _Included_SubClassConsts\n" +
+ "#ifdef __cplusplus\n" +
+ "extern \"C\" {\n" +
+ "#endif\n" +
+ "#undef SubClassConsts_serialVersionUID\n" +
+ "#define SubClassConsts_serialVersionUID 6733861379283244755LL\n" +
+ "#undef SubClassConsts_SUPER_INT_CONSTANT\n" +
+ "#define SubClassConsts_SUPER_INT_CONSTANT 3L\n" +
+ "#undef SubClassConsts_SUPER_FLOAT_CONSTANT\n" +
+ "#define SubClassConsts_SUPER_FLOAT_CONSTANT 99.3f\n" +
+ "#undef SubClassConsts_SUPER_DOUBLE_CONSTANT\n" +
+ "#define SubClassConsts_SUPER_DOUBLE_CONSTANT 33.2\n" +
+ "#undef SubClassConsts_SUPER_BOOLEAN_CONSTANT\n" +
+ "#define SubClassConsts_SUPER_BOOLEAN_CONSTANT 0L\n" +
+ "#undef SubClassConsts_SUB_INT_CONSTANT\n" +
+ "#define SubClassConsts_SUB_INT_CONSTANT 2L\n" +
+ "#undef SubClassConsts_SUB_DOUBLE_CONSTANT\n" +
+ "#define SubClassConsts_SUB_DOUBLE_CONSTANT 2.25\n" +
+ "#undef SubClassConsts_SUB_FLOAT_CONSTANT\n" +
+ "#define SubClassConsts_SUB_FLOAT_CONSTANT 7.9f\n" +
+ "#undef SubClassConsts_SUB_BOOLEAN_CONSTANT\n" +
+ "#define SubClassConsts_SUB_BOOLEAN_CONSTANT 1L\n" +
+ "#ifdef __cplusplus\n" +
+ "}\n" +
+ "#endif\n" +
+ "#endif";
+
+ public static void main(String[] args) throws Exception {
+ //first steps are now done by jtreg
+// cp "${TESTSRC}${FS}SuperClassConsts.java" .
+// cp "${TESTSRC}${FS}SubClassConsts.java" .
+
+// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}SubClassConsts.java"
+
+// "${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} SubClassConsts
+ ToolBox.JavaToolArgs successParams =
+ new ToolBox.JavaToolArgs()
+ .setAllArgs("-cp", System.getProperty("test.classes"), "SubClassConsts");
+ ToolBox.javah(successParams);
+
+// diff ${DIFFOPTS} "${TESTSRC}${FS}${EXPECTED_JAVAH_OUT_FILE}" "${GENERATED_HEADER_FILE}"
+ ToolBox.compareLines(Paths.get("SubClassConsts.h"),
+ ToolBox.splitLines(SubClassConstsGoldenFile), null);
+ }
+
+}
+
+class SuperClassConsts implements Serializable {
+ // Define class constant values, base class is serializable
+ private static final long serialVersionUID = 6733861379283244755L;
+ public static final int SUPER_INT_CONSTANT = 3;
+ public final static float SUPER_FLOAT_CONSTANT = 99.3f;
+ public final static double SUPER_DOUBLE_CONSTANT = 33.2;
+ public final static boolean SUPER_BOOLEAN_CONSTANT = false;
+ // A token instance field
+ int instanceField;
+
+ public native int numValues();
+}
+
+class SubClassConsts extends SuperClassConsts {
+ private final static int SUB_INT_CONSTANT = 2;
+ private final static double SUB_DOUBLE_CONSTANT = 2.25;
+ private final static float SUB_FLOAT_CONSTANT = 7.90f;
+ private final static boolean SUB_BOOLEAN_CONSTANT = true;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/4798312/JavapShouldLoadClassesFromRTJarTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,43 @@
+/*
+ * 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 4798312
+ * @summary In Windows, javap doesnt load classes from rt.jar
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main JavapShouldLoadClassesFromRTJarTest
+ */
+public class JavapShouldLoadClassesFromRTJarTest {
+
+ public static void main(String[] args) throws Exception {
+// "${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} java.lang.String
+ ToolBox.JavaToolArgs params =
+ new ToolBox.JavaToolArgs().
+ setAllArgs("-v", "java.lang.String");
+ if (ToolBox.javap(params).isEmpty())
+ throw new AssertionError("javap generated no output");
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/4866831/PublicInterfaceTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,52 @@
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/*
+ * 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 4866831
+ * @summary Verify that javap marks public interfaces as public
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main PublicInterfaceTest
+ */
+
+//original test: test/tools/javap/PublicInterfaceTest.sh
+public class PublicInterfaceTest {
+ public interface Test {}
+
+ public static void main(String[] args) throws Exception {
+// "$JAVAP" ${TESTTOOLVMOPTS} -classpath "${TESTCLASSES}" NotPackagePrivateInterface | grep public
+ Path pathToClass = Paths.get(System.getProperty("test.classes"),
+ "PublicInterfaceTest$Test.class");
+ ToolBox.JavaToolArgs javapParams =
+ new ToolBox.JavaToolArgs()
+ .setAllArgs(pathToClass.toString());
+ if (!ToolBox.javap(javapParams).contains("public"))
+ throw new AssertionError("The javap output does not contain \"public\"");
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/DescriptorTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,91 @@
+/*
+ * 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 8007052
+ * @summary javap should include the descriptor for a method in verbose mode
+ */
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.regex.Pattern;
+
+public class DescriptorTest {
+ public static void main(String... args) throws Exception {
+ new DescriptorTest().run();
+ }
+
+ void run() throws Exception {
+ File srcDir = new File("src");
+ srcDir.mkdirs();
+ File classesDir = new File("classes");
+ classesDir.mkdirs();
+
+ File f = writeFile(new File(srcDir, "E.java"), "enum E { A, B }");
+ javac("-d", classesDir.getPath(), f.getPath());
+ String out = javap("-p", "-v", new File(classesDir, "E.class").getPath());
+ Pattern expect = Pattern.compile("\\Qprivate E();\\E\\s+\\Qdescriptor: (Ljava/lang/String;I)V\\E");
+ checkContains(out, expect);
+ }
+
+ File writeFile(File f, String body) throws IOException {
+ try (FileWriter out = new FileWriter(f)) {
+ out.write(body);
+ }
+ return f;
+ }
+
+ void javac(String... args) throws Exception {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ int rc = com.sun.tools.javac.Main.compile(args, pw);
+ pw.flush();
+ String out = sw.toString();
+ if (!out.isEmpty())
+ System.err.println(out);
+ if (rc != 0)
+ throw new Exception("compilation failed");
+ }
+
+ String javap(String... args) throws Exception {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ int rc = com.sun.tools.javap.Main.run(args, pw);
+ pw.flush();
+ String out = sw.toString();
+ if (!out.isEmpty())
+ System.err.println(out);
+ if (rc != 0)
+ throw new Exception("javap failed");
+ return out;
+ }
+
+ void checkContains(String s, Pattern p) throws Exception {
+ if (!p.matcher(s).find())
+ throw new Exception("expected pattern not found: " + p);
+ }
+}
--- a/langtools/test/tools/javap/MethodParameters.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/javap/MethodParameters.java Tue Mar 12 16:43:53 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -40,8 +40,10 @@
" void foo0() {}\n" +
" void foo2(int j, int k) {}\n" +
"}").replaceAll(" +", " ");
+
static final String Init0_expected =
(" Foo();\n" +
+ " descriptor: ()V\n" +
" flags: \n" +
" Code:\n" +
" stack=1, locals=1, args_size=1\n" +
@@ -50,8 +52,10 @@
" 4: return \n" +
" LineNumberTable:\n" +
" line 2: 0").replaceAll(" +", " ");
+
static final String Init1_expected =
(" Foo(int);\n" +
+ " descriptor: (I)V\n" +
" flags: \n" +
" Code:\n" +
" stack=1, locals=2, args_size=2\n" +
@@ -63,16 +67,20 @@
" MethodParameters:\n" +
" Name Flags\n" +
" i").replaceAll(" +", " ");
+
static final String foo0_expected =
(" void foo0();\n" +
+ " descriptor: ()V\n" +
" flags: \n" +
" Code:\n" +
" stack=0, locals=1, args_size=1\n" +
" 0: return \n" +
" LineNumberTable:\n" +
" line 4: 0").replaceAll(" +", " ");
+
static final String foo2_expected =
(" void foo2(int, int);\n" +
+ " descriptor: (II)V\n" +
" flags: \n" +
" Code:\n" +
" stack=0, locals=3, args_size=3\n" +
--- a/langtools/test/tools/javap/NotPackagePrivateInterface.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2003, 2007, 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.
- */
-
-
-/*
- * This class is used by PublicInterfaceTest.sh to generate a class
- * file with a public interface to verify javap will output the
- * "public" modifier for such interfaces. (At the vm level, the only
- * access control properties an interface can can have are public and
- * package private.)
- */
-
-public interface NotPackagePrivateInterface {
-}
--- a/langtools/test/tools/javap/PublicInterfaceTest.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2003, 2007, 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 4866831
-# @build NotPackagePrivateInterface
-# @run shell PublicInterfaceTest.sh
-# @summary Verify that javap marks public interfaces as public
-# @author Joseph D. Darcy
-
-# Verify directory context variables are set
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-
-JAVAP="${TESTJAVA}/bin/javap"
-
-"$JAVAP" ${TESTTOOLVMOPTS} -classpath "${TESTCLASSES}" NotPackagePrivateInterface | grep public
-
-# If the exit status of grep is 0, then "public" was correctly found
-# in the output of javap.
-
-RESULT=$?
-case "$RESULT" in
- 0 )
- exit 0;
- ;;
-
- * )
- echo "The javap tool did not output \"public\" for a public interface."
- exit 1
-esac
--- a/langtools/test/tools/javap/pathsep.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2003, 2009, 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 4798312
-# @summary In Windows, javap doesnt load classes from rt.jar
-# @author gafter
-#
-# @run shell pathsep.sh
-
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin | CYGWIN* )
- FS="/"
- ;;
- Windows* )
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-"${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} java.lang.String
-result=$?
-if [ $result -eq 0 ]
-then
- echo "Passed"
-else
- echo "Failed"
-fi
-exit $result
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/stackmap/StackmapTest.java Tue Mar 12 16:43:53 2013 -0700
@@ -0,0 +1,97 @@
+/*
+ * 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 6271292
+ * @summary Verify that javap prints StackMapTable attribute contents
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main StackmapTest
+ */
+
+import java.util.Arrays;
+import java.util.List;
+
+//original test: test/tools/javap/stackmap/T6271292.sh
+public class StackmapTest {
+
+ private static final String TestSrc =
+ "public class Test extends SuperClass {\n" +
+ " public static void main(String[] args) {\n" +
+ " new SuperClass((args[0].equals(\"0\")) ? 0 : 1)\n" +
+ " .test();\n" +
+ " }\n" +
+ " Test(boolean b) {\n" +
+ " super(b ? 1 : 2);\n" +
+ " }\n" +
+ "}\n" +
+ "class SuperClass {\n" +
+ " double d;\n" +
+ " SuperClass(double dd) { d = dd; }\n" +
+ " double test() {\n" +
+ " if (d == 0)\n" +
+ " return d;\n" +
+ " else\n" +
+ " return d > 0 ? d++ : d--;\n" +
+ " }\n" +
+ "}\n";
+
+ private static final String goldenOut =
+ "frame_type = 255 /* full_frame */\n" +
+ "frame_type = 255 /* full_frame */\n" +
+ "frame_type = 73 /* same_locals_1_stack_item */\n" +
+ "frame_type = 255 /* full_frame */\n" +
+ "offset_delta = 19\n" +
+ "offset_delta = 0\n" +
+ "offset_delta = 2\n" +
+ "stack = [ uninitialized 0, uninitialized 0 ]\n" +
+ "stack = [ uninitialized 0, uninitialized 0, double ]\n" +
+ "stack = [ this ]\n" +
+ "stack = [ this, double ]\n" +
+ "locals = [ class \"[Ljava/lang/String;\" ]\n" +
+ "locals = [ class \"[Ljava/lang/String;\" ]\n" +
+ "locals = [ this, int ]\n";
+
+ public static void main(String[] args) throws Exception {
+ // @compile T6271292.java
+ ToolBox.JavaToolArgs javacParams =
+ new ToolBox.JavaToolArgs().setSources(TestSrc);
+ ToolBox.javac(javacParams);
+
+// "${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -classpath "${TESTCLASSES}" -verbose T6271292 > "${JAVAPFILE}"
+ ToolBox.JavaToolArgs javapParams =
+ new ToolBox.JavaToolArgs()
+ .setAllArgs("-v", "Test.class");
+ String out = ToolBox.javap(javapParams);
+ List<String> grepResult = ToolBox.grep("frame_type", out);
+ grepResult.addAll(ToolBox.grep("offset_delta", out));
+ grepResult.addAll(ToolBox.grep("stack = ", out));
+ grepResult.addAll(ToolBox.grep("locals = ", out));
+ List<String> goldenList = Arrays.asList(goldenOut.split("\n"));
+
+// diff -w "${OUTFILE}" "${TESTSRC}${FS}T6271292.out"
+ ToolBox.compareLines(goldenList, grepResult, true);
+ }
+
+}
--- a/langtools/test/tools/javap/stackmap/T6271292.java Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2005, 2007, 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 T6271292 extends SuperClass {
-
- public static void main(String[] args) {
- SuperClass s = new SuperClass((args[0].equals("0")) ? 0 : 1);
- s.test();
- }
- T6271292(boolean b) {
- super(b ? 1 : 2);
- }
-}
-
-class SuperClass {
- double d;
- SuperClass(double dd) { d = dd; }
-
- double test() {
- if (d == 0) {
- return d;
- } else if (d > 0) {
- return d++;
- } else {
- return d--;
- }
- }
-}
--- a/langtools/test/tools/javap/stackmap/T6271292.out Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
- frame_type = 255 /* full_frame */
- frame_type = 255 /* full_frame */
- frame_type = 73 /* same_locals_1_stack_item */
- frame_type = 255 /* full_frame */
- offset_delta = 19
- offset_delta = 0
- offset_delta = 2
- stack = [ uninitialized 0, uninitialized 0 ]
- stack = [ uninitialized 0, uninitialized 0, double ]
- stack = [ this ]
- stack = [ this, double ]
- locals = [ class "[Ljava/lang/String;" ]
- locals = [ class "[Ljava/lang/String;" ]
- locals = [ this, int ]
--- a/langtools/test/tools/javap/stackmap/T6271292.sh Wed Jul 05 18:43:54 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2005, 2009, 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 6271292
-# @compile T6271292.java
-# @run shell T6271292.sh
-# @summary Verify that javap prints StackMapTable attribute contents
-# @author Wei Tao
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-printf 'TESTSRC="%s"' "${TESTSRC}" >&2 ; echo >&2
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-printf 'TESTJAVA="%s"' "${TESTJAVA}" >&2 ; echo >&2
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-printf 'TESTCLASSES="%s"' "${TESTCLASSES}" >&2 ; echo >&2
-printf 'CLASSPATH="%s"' "${CLASSPATH}" >&2 ; echo >&2
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- Windows* )
- FS="\\"
- ;;
- * )
- FS="/"
- ;;
-esac
-
-JAVAPFILE=T6271292.javap
-OUTFILE=outfile
-
-"${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -classpath "${TESTCLASSES}" -verbose T6271292 > "${JAVAPFILE}"
-result="$?"
-if [ "$result" -ne 0 ]
-then
- exit "$result"
-fi
-
-grep "frame_type" "${JAVAPFILE}" > "${OUTFILE}"
-grep "offset_delta" "${JAVAPFILE}" >> "${OUTFILE}"
-grep "stack = " "${JAVAPFILE}" >> "${OUTFILE}"
-grep "locals = " "${JAVAPFILE}" >> "${OUTFILE}"
-diff -w "${OUTFILE}" "${TESTSRC}${FS}T6271292.out"
-result="$?"
-if [ "$result" -eq 0 ]
-then
- echo "Passed"
-else
- echo "Failed"
-fi
-exit "$result"
-
-
--- a/langtools/test/tools/jdeps/Basic.java Wed Jul 05 18:43:54 2017 +0200
+++ b/langtools/test/tools/jdeps/Basic.java Tue Mar 12 16:43:53 2013 -0700
@@ -68,11 +68,15 @@
test(new File(testDir, "Test.class"),
new String[] {"java.lang"},
new String[] {"-V", "package", "-e", "java\\.lang\\..*"});
- // test -classpath and -all options
+ // test -classpath and wildcard options
test(null,
new String[] {"com.sun.tools.jdeps", "java.lang", "java.util",
- "java.util.regex", "java.io", "p"},
+ "java.util.regex", "java.io"},
new String[] {"--classpath", testDir.getPath(), "*"});
+ // -v shows intra-dependency
+ test(new File(testDir, "Test.class"),
+ new String[] {"java.lang.Object", "p.Foo"},
+ new String[] {"-v", "--classpath", testDir.getPath(), "Test.class"});
return errors;
}