Merge
This commit is contained in:
commit
1fd46874aa
@ -53,7 +53,15 @@ public interface MethodTree extends Tree {
|
||||
Tree getReturnType();
|
||||
List<? extends TypeParameterTree> getTypeParameters();
|
||||
List<? extends VariableTree> getParameters();
|
||||
|
||||
/**
|
||||
* Return an explicit receiver parameter ("this" parameter).
|
||||
*
|
||||
* @return an explicit receiver parameter ("this" parameter)
|
||||
* @since 1.8
|
||||
*/
|
||||
VariableTree getReceiverParameter();
|
||||
|
||||
List<? extends ExpressionTree> getThrows();
|
||||
BlockTree getBody();
|
||||
Tree getDefaultValue(); // for annotation types
|
||||
|
@ -36,6 +36,8 @@ import javax.lang.model.element.Name;
|
||||
* <em>name</em>
|
||||
*
|
||||
* <em>name</em> extends <em>bounds</em>
|
||||
*
|
||||
* <em>annotations</em> <em>name</em>
|
||||
* </pre>
|
||||
*
|
||||
* @jls section 4.4
|
||||
@ -48,5 +50,17 @@ import javax.lang.model.element.Name;
|
||||
public interface TypeParameterTree extends Tree {
|
||||
Name getName();
|
||||
List<? extends Tree> getBounds();
|
||||
|
||||
/**
|
||||
* Return annotations on the type parameter declaration.
|
||||
*
|
||||
* Annotations need Target meta-annotations of
|
||||
* {@link java.lang.annotation.ElementType#TYPE_PARAMETER} or
|
||||
* {@link java.lang.annotation.ElementType#TYPE_USE}
|
||||
* to appear in this position.
|
||||
*
|
||||
* @return annotations on the type parameter declaration
|
||||
* @since 1.8
|
||||
*/
|
||||
List<? extends AnnotationTree> getAnnotations();
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class AllClassesFrameWriter extends HtmlDocletWriter {
|
||||
configuration.standardmessage.
|
||||
error("doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,7 +304,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
|
||||
subDiv.addContent(div);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ public class ClassUseWriter extends SubWriterHolderWriter {
|
||||
configuration.standardmessage.
|
||||
error("doclet.exception_encountered",
|
||||
exc.toString(), path.getPath());
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -610,7 +610,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
|
||||
subDiv.addContent(div);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -127,7 +127,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class FrameOutputWriter extends HtmlDocletWriter {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class HelpWriter extends HtmlDocletWriter {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ public class HtmlDoclet extends AbstractDoclet {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -332,7 +332,7 @@ public class HtmlDoclet extends AbstractDoclet {
|
||||
configuration.message.error((SourcePosition) null,
|
||||
"doclet.perform_copy_exception_encountered",
|
||||
exc.toString());
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
|
||||
head.addContent(headComment);
|
||||
}
|
||||
if (configuration.charset.length() > 0) {
|
||||
Content meta = HtmlTree.META("Content-Type", "text/html",
|
||||
Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE,
|
||||
configuration.charset);
|
||||
head.addContent(meta);
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class PackageFrameWriter extends HtmlDocletWriter {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), DocPaths.PACKAGE_FRAME.getPath());
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ public class PackageTreeWriter extends AbstractTreeWriter {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), path.getPath());
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class ProfileIndexFrameWriter extends AbstractProfileIndexWriter {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ public class ProfilePackageFrameWriter extends HtmlDocletWriter {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), DocPaths.PACKAGE_FRAME.getPath());
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class ProfilePackageIndexFrameWriter extends AbstractProfileIndexWriter {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
@ -79,7 +79,7 @@ public class SingleIndexWriter extends AbstractIndexWriter {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
@ -102,7 +102,7 @@ public class SplitIndexWriter extends AbstractIndexWriter {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename.getPath());
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -93,7 +93,7 @@ public class TreeWriter extends AbstractTreeWriter {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
@ -63,7 +63,7 @@ public class Comment extends Content {
|
||||
* is not supported.
|
||||
*/
|
||||
public void addContent(Content content) {
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,7 +75,7 @@ public class Comment extends Content {
|
||||
* is not supported.
|
||||
*/
|
||||
public void addContent(String stringContent) {
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
@ -70,7 +70,7 @@ public class DocType extends Content {
|
||||
* is not supported.
|
||||
*/
|
||||
public void addContent(Content content) {
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,7 +82,7 @@ public class DocType extends Content {
|
||||
* is not supported.
|
||||
*/
|
||||
public void addContent(String stringContent) {
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,7 +40,6 @@ public enum HtmlAttr {
|
||||
BORDER,
|
||||
CELLPADDING,
|
||||
CELLSPACING,
|
||||
CHARSET,
|
||||
CLASS,
|
||||
CLEAR,
|
||||
COLS,
|
||||
|
@ -53,6 +53,8 @@ import com.sun.tools.doclets.internal.toolkit.util.DocPath;
|
||||
*/
|
||||
public abstract class HtmlDocWriter extends HtmlWriter {
|
||||
|
||||
public static final String CONTENT_TYPE = "text/html";
|
||||
|
||||
/**
|
||||
* Constructor. Initializes the destination file name through the super
|
||||
* class HtmlWriter.
|
||||
@ -194,7 +196,7 @@ public abstract class HtmlDocWriter extends HtmlWriter {
|
||||
head.addContent(headComment);
|
||||
}
|
||||
if (configuration.charset.length() > 0) {
|
||||
Content meta = HtmlTree.META("Content-Type", "text/html",
|
||||
Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE,
|
||||
configuration.charset);
|
||||
head.addContent(meta);
|
||||
}
|
||||
|
@ -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
|
||||
@ -91,7 +91,7 @@ public class HtmlDocument extends Content {
|
||||
* is not supported.
|
||||
*/
|
||||
public void addContent(String stringContent) {
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -456,9 +456,9 @@ public class HtmlTree extends Content {
|
||||
*/
|
||||
public static HtmlTree META(String httpEquiv, String content, String charSet) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.META);
|
||||
String contentCharset = content + "; charset=" + charSet;
|
||||
htmltree.addAttr(HtmlAttr.HTTP_EQUIV, nullCheck(httpEquiv));
|
||||
htmltree.addAttr(HtmlAttr.CONTENT, nullCheck(content));
|
||||
htmltree.addAttr(HtmlAttr.CHARSET, nullCheck(charSet));
|
||||
htmltree.addAttr(HtmlAttr.CONTENT, contentCharset);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class RawHtml extends Content {
|
||||
* is not supported.
|
||||
*/
|
||||
public void addContent(Content content) {
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,7 +77,7 @@ public class RawHtml extends Content {
|
||||
* is not supported.
|
||||
*/
|
||||
public void addContent(String stringContent) {
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,7 +72,7 @@ public class StringContent extends Content {
|
||||
*/
|
||||
@Override
|
||||
public void addContent(Content content) {
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -539,7 +539,7 @@ public abstract class Configuration {
|
||||
initProfiles();
|
||||
initProfilePackages();
|
||||
} catch (Exception e) {
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
}
|
||||
setSpecificDocletOptions(root.options());
|
||||
|
@ -55,7 +55,7 @@ public abstract class Content {
|
||||
write(out, true);
|
||||
} catch (IOException e) {
|
||||
// cannot happen from StringWriter
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
@ -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
|
||||
@ -138,7 +138,7 @@ public abstract class AbstractBuilder {
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
configuration.root.printError("Unknown element: " + component);
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
e.getCause().printStackTrace();
|
||||
} catch (Exception e) {
|
||||
@ -146,7 +146,7 @@ public abstract class AbstractBuilder {
|
||||
configuration.root.printError("Exception " +
|
||||
e.getClass().getName() +
|
||||
" thrown while processing element: " + component);
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
@ -62,7 +62,7 @@ public abstract class AbstractMemberBuilder extends AbstractBuilder {
|
||||
*/
|
||||
public void build() throws DocletAbortException {
|
||||
//You may not call the build method in a subbuilder.
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 @@ public class LayoutParser extends DefaultHandler {
|
||||
return xmlElementsMap.get(root);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
@ -125,7 +125,7 @@ public class SerializedFormBuilder extends AbstractBuilder {
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
build(layoutParser.parseXML(NAME), contentTree);
|
||||
writer.close();
|
||||
|
@ -126,7 +126,7 @@ public class ValueTaglet extends BaseInlineTaglet {
|
||||
return (FieldDoc) tag.holder();
|
||||
} else {
|
||||
//This should never ever happen.
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException("should not happen");
|
||||
}
|
||||
}
|
||||
StringTokenizer st = new StringTokenizer(name, "#");
|
||||
|
@ -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
|
||||
@ -452,7 +452,7 @@ public class ClassUseMapper {
|
||||
} else if (doc instanceof Parameter) {
|
||||
annotations = ((Parameter) doc).annotations();
|
||||
} else {
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException("should not happen");
|
||||
}
|
||||
for (int i = 0; i < annotations.length; i++) {
|
||||
AnnotationTypeDoc annotationDoc = annotations[i].annotationType();
|
||||
|
@ -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
|
||||
@ -197,7 +197,7 @@ public abstract class DocFile {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(System.err);
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -34,6 +34,11 @@ package com.sun.tools.doclets.internal.toolkit.util;
|
||||
public class DocletAbortException extends RuntimeException {
|
||||
private static final long serialVersionUID = -9131058909576418984L;
|
||||
|
||||
public DocletAbortException() {
|
||||
public DocletAbortException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public DocletAbortException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
@ -71,7 +71,7 @@ public class PackageListWriter extends PrintWriter {
|
||||
} catch (IOException exc) {
|
||||
configuration.message.error("doclet.exception_encountered",
|
||||
exc.toString(), DocPaths.PACKAGE_LIST);
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
@ -77,7 +77,7 @@ class PathDocFileFactory extends DocFileFactory {
|
||||
Path dir = fileManager.getDefaultFileSystem().getPath(dirName);
|
||||
fileManager.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir));
|
||||
} catch (IOException e) {
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
@ -269,7 +269,7 @@ class SimpleDocFileFactory extends DocFileFactory {
|
||||
|
||||
configuration.message.error(
|
||||
"doclet.Unable_to_create_directory_0", dir.getPath());
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException("can't create directory");
|
||||
}
|
||||
|
||||
/** Return a string to identify the contents of this object,
|
||||
|
@ -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
|
||||
@ -79,7 +79,7 @@ class StandardDocFileFactory extends DocFileFactory {
|
||||
File dir = new File(dirName);
|
||||
fileManager.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir));
|
||||
} catch (IOException e) {
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,9 +241,9 @@ public class Util {
|
||||
first = false;
|
||||
}
|
||||
} catch (SecurityException exc) {
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
} catch (IOException exc) {
|
||||
throw new DocletAbortException();
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,12 +42,14 @@ import static com.sun.tools.doclint.HtmlTag.Attr.*;
|
||||
*
|
||||
* The intent of this class is to embody the semantics of W3C HTML 4.01
|
||||
* to the extent supported/used by javadoc.
|
||||
* In time, we may wish to transition javadoc and doclint to using HTML 5.
|
||||
*
|
||||
* This is derivative of com.sun.tools.doclets.formats.html.markup.HtmlTag.
|
||||
* Eventually, these two should be merged back together, and possibly made
|
||||
* public.
|
||||
*
|
||||
* @see <a href="http://www.w3.org/TR/REC-html40/">HTML 4.01 Specification</a>
|
||||
* @see <a href="http://www.w3.org/TR/html5/">HTML 5 Specification</a>
|
||||
* @author Bhavesh Patel
|
||||
* @author Jonathan Gibbons (revised)
|
||||
*/
|
||||
@ -119,7 +121,8 @@ public enum HtmlTag {
|
||||
|
||||
HEAD(BlockType.OTHER, EndKind.REQUIRED),
|
||||
|
||||
HR(BlockType.BLOCK, EndKind.NONE),
|
||||
HR(BlockType.BLOCK, EndKind.NONE,
|
||||
attrs(AttrKind.OK, WIDTH)), // OK in 4.01; not allowed in 5
|
||||
|
||||
HTML(BlockType.OTHER, EndKind.REQUIRED),
|
||||
|
||||
@ -152,7 +155,7 @@ public enum HtmlTag {
|
||||
|
||||
OL(BlockType.BLOCK, EndKind.REQUIRED,
|
||||
EnumSet.of(Flag.EXPECT_CONTENT),
|
||||
attrs(AttrKind.USE_CSS, START, TYPE)){
|
||||
attrs(AttrKind.OK, START, TYPE)) {
|
||||
@Override
|
||||
public boolean accepts(HtmlTag t) {
|
||||
return (t == LI);
|
||||
@ -196,8 +199,8 @@ public enum HtmlTag {
|
||||
TABLE(BlockType.BLOCK, EndKind.REQUIRED,
|
||||
EnumSet.of(Flag.EXPECT_CONTENT),
|
||||
attrs(AttrKind.OK, SUMMARY, Attr.FRAME, RULES, BORDER,
|
||||
CELLPADDING, CELLSPACING),
|
||||
attrs(AttrKind.USE_CSS, ALIGN, WIDTH, BGCOLOR)) {
|
||||
CELLPADDING, CELLSPACING, WIDTH), // width OK in 4.01; not allowed in 5
|
||||
attrs(AttrKind.USE_CSS, ALIGN, BGCOLOR)) {
|
||||
@Override
|
||||
public boolean accepts(HtmlTag t) {
|
||||
switch (t) {
|
||||
@ -267,7 +270,7 @@ public enum HtmlTag {
|
||||
|
||||
UL(BlockType.BLOCK, EndKind.REQUIRED,
|
||||
EnumSet.of(Flag.EXPECT_CONTENT),
|
||||
attrs(AttrKind.USE_CSS, COMPACT, TYPE)){
|
||||
attrs(AttrKind.OK, COMPACT, TYPE)) { // OK in 4.01; not allowed in 5
|
||||
@Override
|
||||
public boolean accepts(HtmlTag t) {
|
||||
return (t == LI);
|
||||
|
@ -27,8 +27,6 @@ package com.sun.tools.javac.code;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.lang.model.type.TypeKind;
|
||||
|
||||
import com.sun.tools.javac.api.Messages;
|
||||
import com.sun.tools.javac.code.Type.AnnotatedType;
|
||||
import com.sun.tools.javac.code.Type.ArrayType;
|
||||
@ -191,7 +189,7 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
|
||||
|
||||
void printBaseElementType(Type t, StringBuilder sb, Locale locale) {
|
||||
Type arrel = t;
|
||||
while (arrel.getKind() == TypeKind.ARRAY) {
|
||||
while (arrel.hasTag(TypeTag.ARRAY)) {
|
||||
arrel = arrel.unannotatedType();
|
||||
arrel = ((ArrayType) arrel).elemtype;
|
||||
}
|
||||
@ -200,7 +198,7 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
|
||||
|
||||
void printBrackets(Type t, StringBuilder sb, Locale locale) {
|
||||
Type arrel = t;
|
||||
while (arrel.getKind() == TypeKind.ARRAY) {
|
||||
while (arrel.hasTag(TypeTag.ARRAY)) {
|
||||
if (arrel.isAnnotated()) {
|
||||
sb.append(' ');
|
||||
sb.append(arrel.getAnnotationMirrors());
|
||||
@ -264,12 +262,12 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
|
||||
public String visitAnnotatedType(AnnotatedType t, Locale locale) {
|
||||
if (t.typeAnnotations != null &&
|
||||
t.typeAnnotations.nonEmpty()) {
|
||||
if (t.underlyingType.getKind() == TypeKind.ARRAY) {
|
||||
if (t.underlyingType.hasTag(TypeTag.ARRAY)) {
|
||||
StringBuilder res = new StringBuilder();
|
||||
printBaseElementType(t, res, locale);
|
||||
printBrackets(t, res, locale);
|
||||
return res.toString();
|
||||
} else if (t.underlyingType.getKind() == TypeKind.DECLARED &&
|
||||
} else if (t.underlyingType.hasTag(TypeTag.CLASS) &&
|
||||
t.underlyingType.getEnclosingType() != Type.noType) {
|
||||
return visit(t.underlyingType.getEnclosingType(), locale) +
|
||||
". " +
|
||||
@ -348,7 +346,7 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
|
||||
args = args.tail;
|
||||
buf.append(',');
|
||||
}
|
||||
if (args.head.unannotatedType().getKind() == TypeKind.ARRAY) {
|
||||
if (args.head.unannotatedType().hasTag(TypeTag.ARRAY)) {
|
||||
buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale));
|
||||
if (args.head.getAnnotationMirrors().nonEmpty()) {
|
||||
buf.append(' ');
|
||||
|
@ -1179,7 +1179,7 @@ public abstract class Symbol implements Element {
|
||||
/**
|
||||
* The variable's constant value, if this is a constant.
|
||||
* Before the constant value is evaluated, it points to an
|
||||
* initalizer environment. If this is not a constant, it can
|
||||
* initializer environment. If this is not a constant, it can
|
||||
* be used for other stuff.
|
||||
*/
|
||||
private Object data;
|
||||
@ -1231,6 +1231,9 @@ public abstract class Symbol implements Element {
|
||||
/** The extra (synthetic/mandated) parameters of the method. */
|
||||
public List<VarSymbol> extraParams = List.nil();
|
||||
|
||||
/** The captured local variables in an anonymous class */
|
||||
public List<VarSymbol> capturedLocals = List.nil();
|
||||
|
||||
/** The parameters of the method. */
|
||||
public List<VarSymbol> params = null;
|
||||
|
||||
|
@ -29,6 +29,8 @@ import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ElementKind;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
import com.sun.tools.javac.code.Attribute;
|
||||
import com.sun.tools.javac.code.Attribute.TypeCompound;
|
||||
import com.sun.tools.javac.code.Flags;
|
||||
@ -52,12 +54,16 @@ import com.sun.tools.javac.code.Symbol.VarSymbol;
|
||||
import com.sun.tools.javac.code.Symbol.MethodSymbol;
|
||||
import com.sun.tools.javac.comp.Annotate;
|
||||
import com.sun.tools.javac.comp.Annotate.Annotator;
|
||||
import com.sun.tools.javac.comp.AttrContext;
|
||||
import com.sun.tools.javac.comp.Env;
|
||||
import com.sun.tools.javac.tree.JCTree;
|
||||
import com.sun.tools.javac.tree.TreeInfo;
|
||||
import com.sun.tools.javac.tree.JCTree.JCBlock;
|
||||
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
|
||||
import com.sun.tools.javac.tree.JCTree.JCExpression;
|
||||
import com.sun.tools.javac.tree.JCTree.JCLambda;
|
||||
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
|
||||
import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
|
||||
import com.sun.tools.javac.tree.JCTree.JCNewClass;
|
||||
import com.sun.tools.javac.tree.JCTree.JCTypeApply;
|
||||
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
|
||||
@ -90,11 +96,17 @@ public class TypeAnnotations {
|
||||
* later processing.
|
||||
*/
|
||||
public static void organizeTypeAnnotationsSignatures(final Symtab syms, final Names names,
|
||||
final Log log, final JCClassDecl tree, Annotate annotate) {
|
||||
final Log log, final Env<AttrContext> env, final JCClassDecl tree, final Annotate annotate) {
|
||||
annotate.afterRepeated( new Annotator() {
|
||||
@Override
|
||||
public void enterAnnotation() {
|
||||
new TypeAnnotationPositions(syms, names, log, true).scan(tree);
|
||||
JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);
|
||||
|
||||
try {
|
||||
new TypeAnnotationPositions(syms, names, log, true).scan(tree);
|
||||
} finally {
|
||||
log.useSource(oldSource);
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
@ -906,7 +918,14 @@ public class TypeAnnotations {
|
||||
if (!invocation.typeargs.contains(tree)) {
|
||||
Assert.error("{" + tree + "} is not an argument in the invocation: " + invocation);
|
||||
}
|
||||
p.type = TargetType.METHOD_INVOCATION_TYPE_ARGUMENT;
|
||||
MethodSymbol exsym = (MethodSymbol) TreeInfo.symbol(invocation.getMethodSelect());
|
||||
if (exsym == null) {
|
||||
Assert.error("could not determine symbol for {" + invocation + "}");
|
||||
} else if (exsym.isConstructor()) {
|
||||
p.type = TargetType.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT;
|
||||
} else {
|
||||
p.type = TargetType.METHOD_INVOCATION_TYPE_ARGUMENT;
|
||||
}
|
||||
p.pos = invocation.pos;
|
||||
p.type_index = invocation.typeargs.indexOf(tree);
|
||||
return;
|
||||
|
@ -505,12 +505,27 @@ public class Types {
|
||||
|
||||
//merge thrown types - form the intersection of all the thrown types in
|
||||
//all the signatures in the list
|
||||
boolean toErase = !bestSoFar.type.hasTag(FORALL);
|
||||
List<Type> thrown = null;
|
||||
for (Symbol msym1 : methodSyms) {
|
||||
Type mt1 = memberType(origin.type, msym1);
|
||||
Type mt1 = memberType(origin.type, bestSoFar);
|
||||
for (Symbol msym2 : methodSyms) {
|
||||
Type mt2 = memberType(origin.type, msym2);
|
||||
List<Type> thrown_mt2 = mt2.getThrownTypes();
|
||||
if (toErase) {
|
||||
thrown_mt2 = erasure(thrown_mt2);
|
||||
} else {
|
||||
/* If bestSoFar is generic then all the methods are generic.
|
||||
* The opposite is not true: a non generic method can override
|
||||
* a generic method (raw override) so it's safe to cast mt1 and
|
||||
* mt2 to ForAll.
|
||||
*/
|
||||
ForAll fa1 = (ForAll)mt1;
|
||||
ForAll fa2 = (ForAll)mt2;
|
||||
thrown_mt2 = subst(thrown_mt2, fa2.tvars, fa1.tvars);
|
||||
}
|
||||
thrown = (thrown == null) ?
|
||||
mt1.getThrownTypes() :
|
||||
chk.intersect(mt1.getThrownTypes(), thrown);
|
||||
thrown_mt2 :
|
||||
chk.intersect(thrown_mt2, thrown);
|
||||
}
|
||||
|
||||
final List<Type> thrown1 = thrown;
|
||||
|
@ -1063,9 +1063,7 @@ public class Attr extends JCTree.Visitor {
|
||||
|
||||
if (tree.init != null) {
|
||||
if ((v.flags_field & FINAL) != 0 &&
|
||||
!tree.init.hasTag(NEWCLASS) &&
|
||||
!tree.init.hasTag(LAMBDA) &&
|
||||
!tree.init.hasTag(REFERENCE)) {
|
||||
memberEnter.needsLazyConstValue(tree.init)) {
|
||||
// In this case, `v' is final. Ensure that it's initializer is
|
||||
// evaluated.
|
||||
v.getConstValue(); // ensure initializer is evaluated
|
||||
|
@ -2216,11 +2216,11 @@ public class Check {
|
||||
if (t.hasTag(TYPEVAR) && (t.tsym.flags() & UNATTRIBUTED) != 0)
|
||||
return;
|
||||
if (seen.contains(t)) {
|
||||
tv = (TypeVar)t;
|
||||
tv = (TypeVar)t.unannotatedType();
|
||||
tv.bound = types.createErrorType(t);
|
||||
log.error(pos, "cyclic.inheritance", t);
|
||||
} else if (t.hasTag(TYPEVAR)) {
|
||||
tv = (TypeVar)t;
|
||||
tv = (TypeVar)t.unannotatedType();
|
||||
seen = seen.prepend(tv);
|
||||
for (Type b : types.getBounds(tv))
|
||||
checkNonCyclic1(pos, b, seen);
|
||||
|
@ -249,7 +249,7 @@ public class LambdaToMethod extends TreeTranslator {
|
||||
MethodType lambdaType = (MethodType) sym.type;
|
||||
|
||||
{
|
||||
MethodSymbol owner = (MethodSymbol) localContext.owner;
|
||||
Symbol owner = localContext.owner;
|
||||
ListBuffer<Attribute.TypeCompound> ownerTypeAnnos = new ListBuffer<Attribute.TypeCompound>();
|
||||
ListBuffer<Attribute.TypeCompound> lambdaTypeAnnos = new ListBuffer<Attribute.TypeCompound>();
|
||||
|
||||
|
@ -2735,9 +2735,9 @@ public class Lower extends TreeTranslator {
|
||||
for (List<VarSymbol> l = fvs; l.nonEmpty(); l = l.tail) {
|
||||
if (TreeInfo.isInitialConstructor(tree)) {
|
||||
final Name pName = proxyName(l.head.name);
|
||||
m.extraParams =
|
||||
m.extraParams.append((VarSymbol)
|
||||
(proxies.lookup(pName).sym));
|
||||
m.capturedLocals =
|
||||
m.capturedLocals.append((VarSymbol)
|
||||
(proxies.lookup(pName).sym));
|
||||
added = added.prepend(
|
||||
initField(tree.body.pos, pName));
|
||||
}
|
||||
|
@ -677,8 +677,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
if (tree.init != null) {
|
||||
v.flags_field |= HASINIT;
|
||||
if ((v.flags_field & FINAL) != 0 &&
|
||||
!tree.init.hasTag(NEWCLASS) &&
|
||||
!tree.init.hasTag(LAMBDA)) {
|
||||
needsLazyConstValue(tree.init)) {
|
||||
Env<AttrContext> initEnv = getInitEnv(tree, env);
|
||||
initEnv.info.enclVar = v;
|
||||
v.setLazyConstValue(initEnv(tree, initEnv), attr, tree.init);
|
||||
@ -700,6 +699,59 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean needsLazyConstValue(JCTree tree) {
|
||||
InitTreeVisitor initTreeVisitor = new InitTreeVisitor();
|
||||
tree.accept(initTreeVisitor);
|
||||
return initTreeVisitor.result;
|
||||
}
|
||||
|
||||
/** Visitor class for expressions which might be constant expressions.
|
||||
*/
|
||||
static class InitTreeVisitor extends JCTree.Visitor {
|
||||
|
||||
private boolean result = true;
|
||||
|
||||
@Override
|
||||
public void visitTree(JCTree tree) {}
|
||||
|
||||
@Override
|
||||
public void visitNewClass(JCNewClass that) {
|
||||
result = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLambda(JCLambda that) {
|
||||
result = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReference(JCMemberReference that) {
|
||||
result = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSelect(JCFieldAccess tree) {
|
||||
tree.selected.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitConditional(JCConditional tree) {
|
||||
tree.cond.accept(this);
|
||||
tree.truepart.accept(this);
|
||||
tree.falsepart.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitParens(JCParens tree) {
|
||||
tree.expr.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTypeCast(JCTypeCast tree) {
|
||||
tree.expr.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
/** Create a fresh environment for a variable's initializer.
|
||||
* If the variable is a field, the owner of the environment's scope
|
||||
* is be the variable itself, otherwise the owner is the method
|
||||
@ -1089,7 +1141,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
|
||||
}
|
||||
}
|
||||
if (allowTypeAnnos) {
|
||||
TypeAnnotations.organizeTypeAnnotationsSignatures(syms, names, log, tree, annotate);
|
||||
TypeAnnotations.organizeTypeAnnotationsSignatures(syms, names, log, env, tree, annotate);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1859,7 +1859,10 @@ public class Resolve {
|
||||
}
|
||||
}
|
||||
|
||||
/** Find qualified member type.
|
||||
|
||||
/**
|
||||
* Find a type declared in a scope (not inherited). Return null
|
||||
* if none is found.
|
||||
* @param env The current environment.
|
||||
* @param site The original type from where the selection takes
|
||||
* place.
|
||||
@ -1868,12 +1871,10 @@ public class Resolve {
|
||||
* always a superclass or implemented interface of
|
||||
* site's class.
|
||||
*/
|
||||
Symbol findMemberType(Env<AttrContext> env,
|
||||
Type site,
|
||||
Name name,
|
||||
TypeSymbol c) {
|
||||
Symbol bestSoFar = typeNotFound;
|
||||
Symbol sym;
|
||||
Symbol findImmediateMemberType(Env<AttrContext> env,
|
||||
Type site,
|
||||
Name name,
|
||||
TypeSymbol c) {
|
||||
Scope.Entry e = c.members().lookup(name);
|
||||
while (e.scope != null) {
|
||||
if (e.sym.kind == TYP) {
|
||||
@ -1883,6 +1884,24 @@ public class Resolve {
|
||||
}
|
||||
e = e.next();
|
||||
}
|
||||
return typeNotFound;
|
||||
}
|
||||
|
||||
/** Find a member type inherited from a superclass or interface.
|
||||
* @param env The current environment.
|
||||
* @param site The original type from where the selection takes
|
||||
* place.
|
||||
* @param name The type's name.
|
||||
* @param c The class to search for the member type. This is
|
||||
* always a superclass or implemented interface of
|
||||
* site's class.
|
||||
*/
|
||||
Symbol findInheritedMemberType(Env<AttrContext> env,
|
||||
Type site,
|
||||
Name name,
|
||||
TypeSymbol c) {
|
||||
Symbol bestSoFar = typeNotFound;
|
||||
Symbol sym;
|
||||
Type st = types.supertype(c.type);
|
||||
if (st != null && st.hasTag(CLASS)) {
|
||||
sym = findMemberType(env, site, name, st.tsym);
|
||||
@ -1901,6 +1920,28 @@ public class Resolve {
|
||||
return bestSoFar;
|
||||
}
|
||||
|
||||
/** Find qualified member type.
|
||||
* @param env The current environment.
|
||||
* @param site The original type from where the selection takes
|
||||
* place.
|
||||
* @param name The type's name.
|
||||
* @param c The class to search for the member type. This is
|
||||
* always a superclass or implemented interface of
|
||||
* site's class.
|
||||
*/
|
||||
Symbol findMemberType(Env<AttrContext> env,
|
||||
Type site,
|
||||
Name name,
|
||||
TypeSymbol c) {
|
||||
Symbol sym = findImmediateMemberType(env, site, name, c);
|
||||
|
||||
if (sym != typeNotFound)
|
||||
return sym;
|
||||
|
||||
return findInheritedMemberType(env, site, name, c);
|
||||
|
||||
}
|
||||
|
||||
/** Find a global type in given scope and load corresponding class.
|
||||
* @param env The current environment.
|
||||
* @param scope The scope in which to look for the type.
|
||||
@ -1919,6 +1960,21 @@ public class Resolve {
|
||||
return bestSoFar;
|
||||
}
|
||||
|
||||
Symbol findTypeVar(Env<AttrContext> env, Name name, boolean staticOnly) {
|
||||
for (Scope.Entry e = env.info.scope.lookup(name);
|
||||
e.scope != null;
|
||||
e = e.next()) {
|
||||
if (e.sym.kind == TYP) {
|
||||
if (staticOnly &&
|
||||
e.sym.type.hasTag(TYPEVAR) &&
|
||||
e.sym.owner.kind == TYP)
|
||||
return new StaticError(e.sym);
|
||||
return e.sym;
|
||||
}
|
||||
}
|
||||
return typeNotFound;
|
||||
}
|
||||
|
||||
/** Find an unqualified type symbol.
|
||||
* @param env The current environment.
|
||||
* @param name The type's name.
|
||||
@ -1929,19 +1985,26 @@ public class Resolve {
|
||||
boolean staticOnly = false;
|
||||
for (Env<AttrContext> env1 = env; env1.outer != null; env1 = env1.outer) {
|
||||
if (isStatic(env1)) staticOnly = true;
|
||||
for (Scope.Entry e = env1.info.scope.lookup(name);
|
||||
e.scope != null;
|
||||
e = e.next()) {
|
||||
if (e.sym.kind == TYP) {
|
||||
if (staticOnly &&
|
||||
e.sym.type.hasTag(TYPEVAR) &&
|
||||
e.sym.owner.kind == TYP) return new StaticError(e.sym);
|
||||
return e.sym;
|
||||
}
|
||||
// First, look for a type variable and the first member type
|
||||
final Symbol tyvar = findTypeVar(env1, name, staticOnly);
|
||||
sym = findImmediateMemberType(env1, env1.enclClass.sym.type,
|
||||
name, env1.enclClass.sym);
|
||||
|
||||
// Return the type variable if we have it, and have no
|
||||
// immediate member, OR the type variable is for a method.
|
||||
if (tyvar != typeNotFound) {
|
||||
if (sym == typeNotFound ||
|
||||
(tyvar.kind == TYP && tyvar.exists() &&
|
||||
tyvar.owner.kind == MTH))
|
||||
return tyvar;
|
||||
}
|
||||
|
||||
sym = findMemberType(env1, env1.enclClass.sym.type, name,
|
||||
env1.enclClass.sym);
|
||||
// If the environment is a class def, finish up,
|
||||
// otherwise, do the entire findMemberType
|
||||
if (sym == typeNotFound)
|
||||
sym = findInheritedMemberType(env1, env1.enclClass.sym.type,
|
||||
name, env1.enclClass.sym);
|
||||
|
||||
if (staticOnly && sym.kind == TYP &&
|
||||
sym.type.hasTag(CLASS) &&
|
||||
sym.type.getEnclosingType().hasTag(CLASS) &&
|
||||
|
@ -657,6 +657,14 @@ public class ClassWriter extends ClassFile {
|
||||
databuf.appendChar(pool.put(s.name));
|
||||
databuf.appendChar(flags);
|
||||
}
|
||||
// Now write the captured locals
|
||||
for (VarSymbol s : m.capturedLocals) {
|
||||
final int flags =
|
||||
((int) s.flags() & (FINAL | SYNTHETIC | MANDATED)) |
|
||||
((int) m.flags() & SYNTHETIC);
|
||||
databuf.appendChar(pool.put(s.name));
|
||||
databuf.appendChar(flags);
|
||||
}
|
||||
endAttr(attrIndex);
|
||||
return 1;
|
||||
} else
|
||||
|
@ -446,7 +446,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
||||
}
|
||||
|
||||
if (target.compareTo(Target.JDK1_5) <= 0) {
|
||||
log.warning(LintCategory.OPTIONS, "option.obsolete.target", source.name);
|
||||
log.warning(LintCategory.OPTIONS, "option.obsolete.target", target.name);
|
||||
obsoleteOptionFound = true;
|
||||
}
|
||||
|
||||
|
@ -389,6 +389,7 @@ public enum Option {
|
||||
|
||||
XPREFER("-Xprefer:", "opt.prefer", EXTENDED, BASIC, ONEOF, "source", "newer"),
|
||||
|
||||
// see enum PkgInfo
|
||||
XPKGINFO("-Xpkginfo:", "opt.pkginfo", EXTENDED, BASIC, ONEOF, "always", "legacy", "nonempty"),
|
||||
|
||||
/* -O is a no-op, accepted for backward compatibility. */
|
||||
@ -686,7 +687,28 @@ public enum Option {
|
||||
|
||||
// For -XpkgInfo:value
|
||||
public enum PkgInfo {
|
||||
ALWAYS, LEGACY, NONEMPTY;
|
||||
/**
|
||||
* Always generate package-info.class for every package-info.java file.
|
||||
* The file may be empty if there annotations with a RetentionPolicy
|
||||
* of CLASS or RUNTIME. This option may be useful in conjunction with
|
||||
* build systems (such as Ant) that expect javac to generate at least
|
||||
* one .class file for every .java file.
|
||||
*/
|
||||
ALWAYS,
|
||||
/**
|
||||
* Generate a package-info.class file if package-info.java contains
|
||||
* annotations. The file may be empty if all the annotations have
|
||||
* a RetentionPolicy of SOURCE.
|
||||
* This value is just for backwards compatibility with earlier behavior.
|
||||
* Either of the other two values are to be preferred to using this one.
|
||||
*/
|
||||
LEGACY,
|
||||
/**
|
||||
* Generate a package-info.class file if and only if there are annotations
|
||||
* in package-info.java to be written into it.
|
||||
*/
|
||||
NONEMPTY;
|
||||
|
||||
public static PkgInfo get(Options options) {
|
||||
String v = options.get(XPKGINFO);
|
||||
return (v == null
|
||||
|
@ -89,7 +89,7 @@ import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*;
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public class JavacProcessingEnvironment implements ProcessingEnvironment, Closeable {
|
||||
Options options;
|
||||
private final Options options;
|
||||
|
||||
private final boolean printProcessorInfo;
|
||||
private final boolean printRounds;
|
||||
|
@ -2248,7 +2248,7 @@ compiler.err.cant.annotate.static.class=\
|
||||
# TODO 308: make a better error message
|
||||
# 0: unused
|
||||
compiler.err.cant.annotate.nested.type=\
|
||||
nested type cannot be annotated
|
||||
scoping construct for static nested type cannot be annotated
|
||||
|
||||
# 0: type, 1: type
|
||||
compiler.err.incorrect.receiver.name=\
|
||||
|
@ -148,7 +148,7 @@ public abstract class Profiles {
|
||||
}
|
||||
}
|
||||
|
||||
final static Map<String, Package> packages = new TreeMap<String, Package>();
|
||||
final Map<String, Package> packages = new TreeMap<String, Package>();
|
||||
|
||||
final int maxProfile = 4; // Three compact profiles plus full JRE
|
||||
|
||||
|
@ -944,10 +944,17 @@ public class Pretty extends JCTree.Visitor {
|
||||
try {
|
||||
if (tree.elemtype != null) {
|
||||
print("new ");
|
||||
printTypeAnnotations(tree.annotations);
|
||||
JCTree elem = tree.elemtype;
|
||||
printBaseElementType(elem);
|
||||
boolean isElemAnnoType = elem instanceof JCAnnotatedType;
|
||||
|
||||
if (!tree.annotations.isEmpty()) {
|
||||
print(' ');
|
||||
printTypeAnnotations(tree.annotations);
|
||||
}
|
||||
if (tree.elems != null) {
|
||||
print("[]");
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
List<List<JCAnnotation>> da = tree.dimAnnotations;
|
||||
for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
|
||||
@ -960,17 +967,7 @@ public class Pretty extends JCTree.Visitor {
|
||||
printExpr(l.head);
|
||||
print("]");
|
||||
}
|
||||
if (tree.elems != null) {
|
||||
if (isElemAnnoType) {
|
||||
print(' ');
|
||||
printTypeAnnotations(((JCAnnotatedType)tree.elemtype).annotations);
|
||||
}
|
||||
print("[]");
|
||||
}
|
||||
if (isElemAnnoType)
|
||||
elem = ((JCAnnotatedType)elem).underlyingType;
|
||||
if (elem instanceof JCArrayTypeTree)
|
||||
printBrackets((JCArrayTypeTree) elem);
|
||||
printBrackets(elem);
|
||||
}
|
||||
if (tree.elems != null) {
|
||||
print("{");
|
||||
@ -1260,20 +1257,24 @@ public class Pretty extends JCTree.Visitor {
|
||||
}
|
||||
|
||||
// prints the brackets of a nested array in reverse order
|
||||
private void printBrackets(JCArrayTypeTree tree) throws IOException {
|
||||
JCTree elem;
|
||||
// tree is either JCArrayTypeTree or JCAnnotatedTypeTree
|
||||
private void printBrackets(JCTree tree) throws IOException {
|
||||
JCTree elem = tree;
|
||||
while (true) {
|
||||
elem = tree.elemtype;
|
||||
if (elem.hasTag(ANNOTATED_TYPE)) {
|
||||
JCAnnotatedType atype = (JCAnnotatedType) elem;
|
||||
elem = atype.underlyingType;
|
||||
if (!elem.hasTag(TYPEARRAY)) break;
|
||||
print(' ');
|
||||
printTypeAnnotations(atype.annotations);
|
||||
if (elem.hasTag(TYPEARRAY)) {
|
||||
print(' ');
|
||||
printTypeAnnotations(atype.annotations);
|
||||
}
|
||||
}
|
||||
if (elem.hasTag(TYPEARRAY)) {
|
||||
print("[]");
|
||||
elem = ((JCArrayTypeTree)elem).elemtype;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
print("[]");
|
||||
if (!elem.hasTag(TYPEARRAY)) break;
|
||||
tree = (JCArrayTypeTree) elem;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1378,22 +1379,15 @@ public class Pretty extends JCTree.Visitor {
|
||||
|
||||
public void visitAnnotatedType(JCAnnotatedType tree) {
|
||||
try {
|
||||
if (tree.underlyingType.getKind() == JCTree.Kind.MEMBER_SELECT) {
|
||||
if (tree.underlyingType.hasTag(SELECT)) {
|
||||
JCFieldAccess access = (JCFieldAccess) tree.underlyingType;
|
||||
printExpr(access.selected, TreeInfo.postfixPrec);
|
||||
print(".");
|
||||
printTypeAnnotations(tree.annotations);
|
||||
print(access.name);
|
||||
} else if (tree.underlyingType.getKind() == JCTree.Kind.ARRAY_TYPE) {
|
||||
JCArrayTypeTree array = (JCArrayTypeTree) tree.underlyingType;
|
||||
} else if (tree.underlyingType.hasTag(TYPEARRAY)) {
|
||||
printBaseElementType(tree);
|
||||
print(' ');
|
||||
printTypeAnnotations(tree.annotations);
|
||||
print("[]");
|
||||
JCExpression elem = array.elemtype;
|
||||
if (elem.hasTag(TYPEARRAY)) {
|
||||
printBrackets((JCArrayTypeTree) elem);
|
||||
}
|
||||
printBrackets(tree);
|
||||
} else {
|
||||
printTypeAnnotations(tree.annotations);
|
||||
printExpr(tree.underlyingType);
|
||||
|
@ -128,7 +128,14 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
|
||||
try {
|
||||
return clazz.flags();
|
||||
} catch (CompletionFailure ex) {
|
||||
// quietly ignore completion failures
|
||||
/* Quietly ignore completion failures.
|
||||
* Note that a CompletionFailure can only
|
||||
* occur as a result of calling complete(),
|
||||
* which will always remove the current
|
||||
* completer, leaving it to be null or
|
||||
* follow-up completer. Thus the loop
|
||||
* is guaranteed to eventually terminate.
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,12 @@ import com.sun.tools.javac.code.Flags;
|
||||
import com.sun.tools.javac.code.Kinds;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
import com.sun.tools.javac.comp.MemberEnter;
|
||||
import com.sun.tools.javac.tree.JCTree;
|
||||
import com.sun.tools.javac.tree.JCTree.*;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
|
||||
import static com.sun.tools.javac.code.Flags.*;
|
||||
|
||||
/**
|
||||
* Javadoc's own memberEnter phase does a few things above and beyond that
|
||||
* done by javac.
|
||||
@ -86,6 +89,17 @@ public class JavadocMemberEnter extends MemberEnter {
|
||||
|
||||
@Override
|
||||
public void visitVarDef(JCVariableDecl tree) {
|
||||
if (tree.init != null) {
|
||||
boolean isFinal = (tree.mods.flags & FINAL) != 0
|
||||
|| (env.enclClass.mods.flags & INTERFACE) != 0;
|
||||
if (!isFinal || containsNonConstantExpression(tree.init)) {
|
||||
// Avoid unnecessary analysis and release resources.
|
||||
// In particular, remove non-constant expressions
|
||||
// which may trigger Attr.attribClass, since
|
||||
// method bodies are also removed, in visitMethodDef.
|
||||
tree.init = null;
|
||||
}
|
||||
}
|
||||
super.visitVarDef(tree);
|
||||
if (tree.sym != null &&
|
||||
tree.sym.kind == Kinds.VAR &&
|
||||
@ -101,4 +115,95 @@ public class JavadocMemberEnter extends MemberEnter {
|
||||
private static boolean isParameter(VarSymbol var) {
|
||||
return (var.flags() & Flags.PARAMETER) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple analysis of an expression tree to see if it contains tree nodes
|
||||
* for any non-constant expression. This does not include checking references
|
||||
* to other fields which may or may not be constant.
|
||||
*/
|
||||
private static boolean containsNonConstantExpression(JCExpression tree) {
|
||||
return new MaybeConstantExpressionScanner().containsNonConstantExpression(tree);
|
||||
}
|
||||
|
||||
/**
|
||||
* See JLS 15.18, Constant Expression
|
||||
*/
|
||||
private static class MaybeConstantExpressionScanner extends JCTree.Visitor {
|
||||
boolean maybeConstantExpr = true;
|
||||
|
||||
public boolean containsNonConstantExpression(JCExpression tree) {
|
||||
scan(tree);
|
||||
return !maybeConstantExpr;
|
||||
}
|
||||
|
||||
public void scan(JCTree tree) {
|
||||
// short circuit scan when end result is definitely false
|
||||
if (maybeConstantExpr && tree != null)
|
||||
tree.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
/** default for any non-overridden visit method. */
|
||||
public void visitTree(JCTree tree) {
|
||||
maybeConstantExpr = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitBinary(JCBinary tree) {
|
||||
switch (tree.getTag()) {
|
||||
case MUL: case DIV: case MOD:
|
||||
case PLUS: case MINUS:
|
||||
case SL: case SR: case USR:
|
||||
case LT: case LE: case GT: case GE:
|
||||
case EQ: case NE:
|
||||
case BITAND: case BITXOR: case BITOR:
|
||||
case AND: case OR:
|
||||
break;
|
||||
default:
|
||||
maybeConstantExpr = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitConditional(JCConditional tree) {
|
||||
scan(tree.cond);
|
||||
scan(tree.truepart);
|
||||
scan(tree.falsepart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitIdent(JCIdent tree) { }
|
||||
|
||||
@Override
|
||||
public void visitLiteral(JCLiteral tree) { }
|
||||
|
||||
@Override
|
||||
public void visitParens(JCParens tree) {
|
||||
scan(tree.expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSelect(JCTree.JCFieldAccess tree) {
|
||||
scan(tree.selected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTypeCast(JCTypeCast tree) {
|
||||
scan(tree.clazz);
|
||||
scan(tree.expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTypeIdent(JCPrimitiveTypeTree tree) { }
|
||||
|
||||
@Override
|
||||
public void visitUnary(JCUnary tree) {
|
||||
switch (tree.getTag()) {
|
||||
case POS: case NEG: case COMPL: case NOT:
|
||||
break;
|
||||
default:
|
||||
maybeConstantExpr = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
82
langtools/test/com/sun/javadoc/testCharset/TestCharset.java
Normal file
82
langtools/test/com/sun/javadoc/testCharset/TestCharset.java
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* 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 7052170
|
||||
* @summary Run a test on -charset to make sure the charset gets generated as a
|
||||
* part of the meta tag.
|
||||
* @author Bhavesh Patel
|
||||
* @library ../lib/
|
||||
* @build JavadocTester TestCharset
|
||||
* @run main TestCharset
|
||||
*/
|
||||
|
||||
public class TestCharset extends JavadocTester {
|
||||
|
||||
//Test information.
|
||||
private static final String BUG_ID = "7052170";
|
||||
|
||||
//Javadoc arguments.
|
||||
private static final String[] ARGS = new String[] {
|
||||
"-d", BUG_ID, "-charset", "UTF-8", "-sourcepath", SRC_DIR, "pkg"
|
||||
};
|
||||
|
||||
private static final String[][] TEST = {
|
||||
{BUG_ID + FS + "index.html",
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"},
|
||||
{BUG_ID + FS + "pkg" + FS + "Foo.html",
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"}
|
||||
};
|
||||
|
||||
private static final String[][] NEGATED_TEST = {
|
||||
{BUG_ID + FS + "index.html",
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"UTF-8\">"},
|
||||
{BUG_ID + FS + "pkg" + FS + "Foo.html",
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"UTF-8\">"}
|
||||
};
|
||||
|
||||
/**
|
||||
* The entry point of the test.
|
||||
* @param args the array of command line arguments.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
TestCharset tester = new TestCharset();
|
||||
run(tester, ARGS, TEST, NEGATED_TEST);
|
||||
tester.printSummary();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getBugId() {
|
||||
return BUG_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getBugName() {
|
||||
return getClass().getName();
|
||||
}
|
||||
}
|
26
langtools/test/com/sun/javadoc/testCharset/pkg/Foo.java
Normal file
26
langtools/test/com/sun/javadoc/testCharset/pkg/Foo.java
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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 pkg;
|
||||
|
||||
public class Foo {}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2011, 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
|
||||
@ -29,11 +29,11 @@
|
||||
* @author jamieh
|
||||
* @library ../lib/
|
||||
* @build JavadocTester
|
||||
* @build TestNavagation
|
||||
* @run main TestNavagation
|
||||
* @build TestNavigation
|
||||
* @run main TestNavigation
|
||||
*/
|
||||
|
||||
public class TestNavagation extends JavadocTester {
|
||||
public class TestNavigation extends JavadocTester {
|
||||
|
||||
//Test information.
|
||||
private static final String BUG_ID = "4131628-4664607";
|
||||
@ -71,7 +71,7 @@ public class TestNavagation extends JavadocTester {
|
||||
* @param args the array of command line arguments.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
TestNavagation tester = new TestNavagation();
|
||||
TestNavigation tester = new TestNavigation();
|
||||
run(tester, ARGS, TEST, NEGATED_TEST);
|
||||
tester.printSummary();
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8006251 8013405
|
||||
* @bug 8006251 8013405 8022173
|
||||
* @summary test list tags
|
||||
* @library ..
|
||||
* @build DocLintTester
|
||||
@ -15,6 +15,7 @@ public class ListTagsTest {
|
||||
* <ol> <li value="1"> abc </ol>
|
||||
* <ol> <li value> bad </ol>
|
||||
* <ol> <li value="a"> bad </ol>
|
||||
* <ol type="a"> <li> bad </ol>
|
||||
* <ul> <li> abc </ul>
|
||||
*/
|
||||
public void supportedTags() { }
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8006251
|
||||
* @bug 8006251 8022173
|
||||
* @summary test other tags
|
||||
* @library ..
|
||||
* @build DocLintTester
|
||||
@ -14,6 +14,7 @@ public class OtherTagsTest {
|
||||
* <frame>
|
||||
* <frameset> </frameset>
|
||||
* <head> </head>
|
||||
* <hr width="50%">
|
||||
* <link>
|
||||
* <meta>
|
||||
* <noframes> </noframes>
|
||||
|
@ -10,19 +10,19 @@ OtherTagsTest.java:15: error: element not allowed in documentation comments: <fr
|
||||
OtherTagsTest.java:16: error: element not allowed in documentation comments: <head>
|
||||
* <head> </head>
|
||||
^
|
||||
OtherTagsTest.java:17: error: element not allowed in documentation comments: <link>
|
||||
OtherTagsTest.java:18: error: element not allowed in documentation comments: <link>
|
||||
* <link>
|
||||
^
|
||||
OtherTagsTest.java:18: error: element not allowed in documentation comments: <meta>
|
||||
OtherTagsTest.java:19: error: element not allowed in documentation comments: <meta>
|
||||
* <meta>
|
||||
^
|
||||
OtherTagsTest.java:19: error: element not allowed in documentation comments: <noframes>
|
||||
OtherTagsTest.java:20: error: element not allowed in documentation comments: <noframes>
|
||||
* <noframes> </noframes>
|
||||
^
|
||||
OtherTagsTest.java:20: error: element not allowed in documentation comments: <script>
|
||||
OtherTagsTest.java:21: error: element not allowed in documentation comments: <script>
|
||||
* <script> </script>
|
||||
^
|
||||
OtherTagsTest.java:21: error: element not allowed in documentation comments: <title>
|
||||
OtherTagsTest.java:22: error: element not allowed in documentation comments: <title>
|
||||
* <title> </title>
|
||||
^
|
||||
9 errors
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8006251
|
||||
* @bug 8006251 8022173
|
||||
* @summary test table tags
|
||||
* @library ..
|
||||
* @build DocLintTester
|
||||
@ -39,6 +39,7 @@ public class TableTagsTest {
|
||||
* <table summary="abc"> <thead> <tr> </thead> <tr> <td> </table>
|
||||
* <table summary="abc"> <tbody> <tr> <td> </tbody> </table>
|
||||
* <table summary="abc"> <tr> <td> <tfoot> <tr> </tfoot></table>
|
||||
* <table summary="abc" width="50%"> <tr> <td> <tfoot> <tr> </tfoot></table>
|
||||
*/
|
||||
public void supportedTags() { }
|
||||
}
|
||||
|
287
langtools/test/tools/javac/7118412/ShadowingTest.java
Normal file
287
langtools/test/tools/javac/7118412/ShadowingTest.java
Normal file
@ -0,0 +1,287 @@
|
||||
/*
|
||||
* 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 7118412
|
||||
* @summary Shadowing of type-variables vs. member types
|
||||
*/
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
public class ShadowingTest {
|
||||
|
||||
// We generate a method "test" that tries to call T.<something,
|
||||
// depending on the value of MethodCall>. This controls whether
|
||||
// "test" is static or not.
|
||||
private enum MethodContext {
|
||||
STATIC("static "),
|
||||
INSTANCE("");
|
||||
|
||||
public final String methodcontext;
|
||||
|
||||
MethodContext(final String methodcontext) {
|
||||
this.methodcontext = methodcontext;
|
||||
}
|
||||
}
|
||||
|
||||
// These control whether or not a type parameter, method type
|
||||
// parameter, or inner class get declared (and in the case of
|
||||
// inner classes, whether it's static or not.
|
||||
|
||||
private enum MethodTypeParameterDecl {
|
||||
NO(""),
|
||||
YES("<T extends Number> ");
|
||||
|
||||
public final String tyvar;
|
||||
|
||||
MethodTypeParameterDecl(final String tyvar) {
|
||||
this.tyvar = tyvar;
|
||||
}
|
||||
}
|
||||
|
||||
private enum InsideDef {
|
||||
NONE(""),
|
||||
STATIC("static class T { public void inner() {} }\n"),
|
||||
INSTANCE("class T { public void inner() {} }\n");
|
||||
|
||||
public final String instancedef;
|
||||
|
||||
InsideDef(final String instancedef) {
|
||||
this.instancedef = instancedef;
|
||||
}
|
||||
}
|
||||
|
||||
private enum TypeParameterDecl {
|
||||
NO(""),
|
||||
YES("<T extends Collection>");
|
||||
|
||||
public final String tyvar;
|
||||
|
||||
TypeParameterDecl(final String tyvar) {
|
||||
this.tyvar = tyvar;
|
||||
}
|
||||
}
|
||||
|
||||
// Represents what method we try to call. This is a way of
|
||||
// checking which T we're seeing.
|
||||
private enum MethodCall {
|
||||
// Method type variables extend Number, so we have intValue
|
||||
METHOD_TYPEVAR("intValue"),
|
||||
// The inner class declaration has a method called "inner"
|
||||
INNER_CLASS("inner"),
|
||||
// The class type variables extend Collection, so we call iterator
|
||||
TYPEVAR("iterator"),
|
||||
// The outer class declaration has a method called "outer"
|
||||
OUTER_CLASS("outer");
|
||||
|
||||
public final String methodcall;
|
||||
|
||||
MethodCall(final String methodcall) {
|
||||
this.methodcall = methodcall;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean succeeds(final MethodCall call,
|
||||
final MethodTypeParameterDecl mtyvar,
|
||||
final MethodContext ctx,
|
||||
final InsideDef inside,
|
||||
final TypeParameterDecl tyvar) {
|
||||
switch(call) {
|
||||
// We want to resolve to the method type variable
|
||||
case METHOD_TYPEVAR: switch(mtyvar) {
|
||||
// If the method type variable exists, then T will
|
||||
// resolve to it, and we'll have intValue.
|
||||
case YES: return true;
|
||||
// Otherwise, this cannot succeed.
|
||||
default: return false;
|
||||
}
|
||||
// We want to resolve to the inner class
|
||||
case INNER_CLASS: switch(mtyvar) {
|
||||
// The method type parameter will shadow the inner
|
||||
// class, so there can't be one.
|
||||
case NO: switch(ctx) {
|
||||
// If we're not static, then either one should succeed.
|
||||
case INSTANCE: switch(inside) {
|
||||
case INSTANCE:
|
||||
case STATIC:
|
||||
return true;
|
||||
default: return false;
|
||||
}
|
||||
case STATIC: switch(inside) {
|
||||
// If we are static, and the inner class is
|
||||
// static, then we also succeed, because we
|
||||
// can't see the type variable.
|
||||
case STATIC: return true;
|
||||
case INSTANCE: switch(tyvar) {
|
||||
// If we're calling from a non-static
|
||||
// context, there can't be a class type
|
||||
// variable, because that will shadow the
|
||||
// static inner class definition.
|
||||
case NO: return true;
|
||||
default: return false;
|
||||
}
|
||||
// If the inner class isn't declared, we can't
|
||||
// see it.
|
||||
default: return false;
|
||||
}
|
||||
// Can't get here.
|
||||
default: return false;
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
// We want to resolve to the class type parameter
|
||||
case TYPEVAR: switch(mtyvar) {
|
||||
// We can't have a method type parameter, as that would
|
||||
// shadow the class type parameter
|
||||
case NO: switch(ctx) {
|
||||
case INSTANCE: switch(inside) {
|
||||
// We have to be in an instance context. If
|
||||
// we're static, we can't see the type
|
||||
// variable.
|
||||
case NONE: switch(tyvar) {
|
||||
// Obviously, the type parameter has to be declared.
|
||||
case YES: return true;
|
||||
default: return false;
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
// We want to resolve to the outer class
|
||||
case OUTER_CLASS: switch(mtyvar) {
|
||||
case NO: switch(inside) {
|
||||
case NONE: switch(tyvar) {
|
||||
// Basically, nothing else can be declared, or
|
||||
// else we can't see it. Even if our context
|
||||
// is static, the compiler will complain if
|
||||
// non-static T's exist, because they will
|
||||
// shadow the outer class.
|
||||
case NO: return true;
|
||||
default: return false;
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final File classesdir = new File("7118412");
|
||||
|
||||
private int errors = 0;
|
||||
|
||||
private int dirnum = 0;
|
||||
|
||||
private void doTest(final MethodTypeParameterDecl mtyvar,
|
||||
final TypeParameterDecl tyvar,
|
||||
final InsideDef insidedef, final MethodContext ctx,
|
||||
final MethodCall call)
|
||||
throws IOException {
|
||||
final String content = "import java.util.Collection;\n" +
|
||||
"class Test" + tyvar.tyvar + " {\n" +
|
||||
" " + insidedef.instancedef +
|
||||
" " + ctx.methodcontext + mtyvar.tyvar + "void test(T t) { t." +
|
||||
call.methodcall + "(); }\n" +
|
||||
"}\n" +
|
||||
"class T { void outer() {} }\n";
|
||||
final File dir = new File(classesdir, "" + dirnum);
|
||||
final File Test_java = writeFile(dir, "Test.java", content);
|
||||
dirnum++;
|
||||
if(succeeds(call, mtyvar, ctx, insidedef, tyvar)) {
|
||||
if(!assert_compile_succeed(Test_java))
|
||||
System.err.println("Failed file:\n" + content);
|
||||
}
|
||||
else {
|
||||
if(!assert_compile_fail(Test_java))
|
||||
System.err.println("Failed file:\n" + content);
|
||||
}
|
||||
}
|
||||
|
||||
private void run() throws Exception {
|
||||
classesdir.mkdir();
|
||||
for(MethodTypeParameterDecl mtyvar : MethodTypeParameterDecl.values())
|
||||
for(TypeParameterDecl tyvar : TypeParameterDecl.values())
|
||||
for(InsideDef insidedef : InsideDef.values())
|
||||
for(MethodContext ctx : MethodContext.values())
|
||||
for(MethodCall methodcall : MethodCall.values())
|
||||
doTest(mtyvar, tyvar, insidedef, ctx, methodcall);
|
||||
if (errors != 0)
|
||||
throw new Exception("ShadowingTest test failed with " +
|
||||
errors + " errors.");
|
||||
}
|
||||
|
||||
private boolean assert_compile_fail(final File file) {
|
||||
final String filename = file.getPath();
|
||||
final String[] args = { filename };
|
||||
final StringWriter sw = new StringWriter();
|
||||
final PrintWriter pw = new PrintWriter(sw);
|
||||
final int rc = com.sun.tools.javac.Main.compile(args, pw);
|
||||
pw.close();
|
||||
if (rc == 0) {
|
||||
System.err.println("Compilation of " + file.getName() +
|
||||
" didn't fail as expected.");
|
||||
errors++;
|
||||
return false;
|
||||
} else return true;
|
||||
}
|
||||
|
||||
private boolean assert_compile_succeed(final File file) {
|
||||
final String filename = file.getPath();
|
||||
final String[] args = { filename };
|
||||
final StringWriter sw = new StringWriter();
|
||||
final PrintWriter pw = new PrintWriter(sw);
|
||||
final int rc = com.sun.tools.javac.Main.compile(args, pw);
|
||||
pw.close();
|
||||
if (rc != 0) {
|
||||
System.err.println("Compilation of " + file.getName() +
|
||||
" didn't succeed as expected. Output:");
|
||||
System.err.println(sw.toString());
|
||||
errors++;
|
||||
return false;
|
||||
} else return true;
|
||||
}
|
||||
|
||||
private File writeFile(final File dir,
|
||||
final String path,
|
||||
final String body) throws IOException {
|
||||
final File f = new File(dir, path);
|
||||
f.getParentFile().mkdirs();
|
||||
final FileWriter out = new FileWriter(f);
|
||||
out.write(body);
|
||||
out.close();
|
||||
return f;
|
||||
}
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
new ShadowingTest().run();
|
||||
}
|
||||
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* 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 8015701
|
||||
* @summary javac should generate method parameters correctly.
|
||||
* @compile -parameters AnonymousParameters.java
|
||||
* @run main AnonymousParameters
|
||||
*/
|
||||
import java.lang.Class;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class AnonymousParameters {
|
||||
|
||||
String[] names = {
|
||||
"this$0",
|
||||
"val$message"
|
||||
};
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
new AnonymousParameters().run();
|
||||
}
|
||||
|
||||
void run() throws Exception {
|
||||
Class<?> cls = new ParameterNames().makeInner("hello").getClass();
|
||||
Constructor<?> ctor = cls.getDeclaredConstructors()[0];
|
||||
Parameter[] params = ctor.getParameters();
|
||||
|
||||
if(params.length == 2) {
|
||||
for(int i = 0; i < 2; i++) {
|
||||
System.err.println("Testing parameter " + params[i].getName());
|
||||
if(!params[i].getName().equals(names[i]))
|
||||
error("Expected parameter name " + names[i] +
|
||||
" got " + params[i].getName());
|
||||
}
|
||||
} else
|
||||
error("Expected 2 parameters");
|
||||
|
||||
if(0 != errors)
|
||||
throw new Exception("MethodParameters test failed with " +
|
||||
errors + " errors");
|
||||
}
|
||||
|
||||
void error(String msg) {
|
||||
System.err.println("Error: " + msg);
|
||||
errors++;
|
||||
}
|
||||
|
||||
int errors;
|
||||
}
|
||||
|
||||
class ParameterNames {
|
||||
|
||||
public Callable<String> makeInner(final String message) {
|
||||
return new Callable<String>() {
|
||||
public String call() throws Exception {
|
||||
return message;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
ParameterNames test = new ParameterNames();
|
||||
System.out.println(test.makeInner("Hello").call());
|
||||
}
|
||||
}
|
289
langtools/test/tools/javac/MethodParameters/CaptureTest.java
Normal file
289
langtools/test/tools/javac/MethodParameters/CaptureTest.java
Normal file
@ -0,0 +1,289 @@
|
||||
/*
|
||||
* 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 8015701
|
||||
* @summary Test method parameter attribute generation with captured locals.
|
||||
* @compile -parameters CaptureTest.java
|
||||
* @run main CaptureTest
|
||||
*/
|
||||
import java.lang.Class;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CaptureTest {
|
||||
|
||||
private static final int SYNTHETIC = 0x1000;
|
||||
private static final int MANDATED = 0x8000;
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
new CaptureTest().run();
|
||||
}
|
||||
|
||||
|
||||
private void run() throws Exception {
|
||||
final Encloser pn = new Encloser();
|
||||
|
||||
/* Cases covered here:
|
||||
*
|
||||
* - Local class
|
||||
* - Inner class
|
||||
* - Anonymous class
|
||||
* - Anonymous class extending a local
|
||||
* - Anonymous class extending an inner
|
||||
*/
|
||||
pn.makeLocal("hello").check();
|
||||
pn.makeInner("hello").check();
|
||||
pn.makeAnon("hello").check();
|
||||
pn.makeAnonExtendsLocal("hello").check();
|
||||
pn.makeAnonExtendsInner("hello").check();
|
||||
|
||||
if (0 != errors)
|
||||
throw new Exception("MethodParameters test failed with " +
|
||||
errors + " errors");
|
||||
}
|
||||
|
||||
private void error(final String msg) {
|
||||
System.err.println("Error: " + msg);
|
||||
errors++;
|
||||
}
|
||||
|
||||
int errors;
|
||||
|
||||
abstract class Tester {
|
||||
|
||||
public Tester(final int param) {}
|
||||
|
||||
protected abstract String[] names();
|
||||
protected abstract int[] modifiers();
|
||||
protected abstract Class[] types();
|
||||
|
||||
public void check() {
|
||||
final Class<?> cls = this.getClass();
|
||||
final Constructor<?> ctor = cls.getDeclaredConstructors()[0];
|
||||
final Parameter[] params = ctor.getParameters();
|
||||
final String[] names = names();
|
||||
final int[] modifiers = modifiers();
|
||||
final Class[] types = types();
|
||||
|
||||
System.err.println("Testing class " + cls);
|
||||
|
||||
if (params.length == names.length) {
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
System.err.println("Testing parameter " + params[i].getName());
|
||||
if (!params[i].getName().equals(names[i]))
|
||||
error("Expected parameter name " + names[i] +
|
||||
" got " + params[i].getName());
|
||||
if (params[i].getModifiers() != modifiers[i])
|
||||
error("Expected parameter modifiers " +
|
||||
modifiers[i] + " got " +
|
||||
params[i].getModifiers());
|
||||
if (!params[i].getType().equals(types[i]))
|
||||
error("Expected parameter type " + types[i] +
|
||||
" got " + params[i].getType());
|
||||
}
|
||||
} else
|
||||
error("Expected " + names.length + " parameters");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Encloser {
|
||||
private class InnerTester extends Tester {
|
||||
public InnerTester(final int innerparam) {
|
||||
super(innerparam);
|
||||
}
|
||||
|
||||
protected String[] names() {
|
||||
return new String[] {
|
||||
"this$1",
|
||||
"innerparam"
|
||||
};
|
||||
}
|
||||
|
||||
protected int[] modifiers() {
|
||||
return new int[] {
|
||||
Modifier.FINAL | SYNTHETIC,
|
||||
Modifier.FINAL
|
||||
};
|
||||
}
|
||||
|
||||
protected Class[] types() {
|
||||
return new Class[] {
|
||||
Encloser.class,
|
||||
int.class
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public Tester makeInner(final String message) {
|
||||
return new InnerTester(2);
|
||||
}
|
||||
|
||||
public Tester makeLocal(final String message) {
|
||||
class LocalTester extends Tester {
|
||||
public LocalTester(final int localparam) {
|
||||
super(localparam);
|
||||
}
|
||||
|
||||
protected String[] names() {
|
||||
return new String[] {
|
||||
"this$1",
|
||||
"localparam",
|
||||
"val$message"
|
||||
};
|
||||
}
|
||||
|
||||
protected int[] modifiers() {
|
||||
return new int[] {
|
||||
Modifier.FINAL | MANDATED,
|
||||
Modifier.FINAL,
|
||||
Modifier.FINAL | SYNTHETIC
|
||||
};
|
||||
}
|
||||
|
||||
protected Class[] types() {
|
||||
return new Class[] {
|
||||
Encloser.class,
|
||||
int.class,
|
||||
String.class
|
||||
};
|
||||
}
|
||||
|
||||
public String message() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
return new LocalTester(2);
|
||||
}
|
||||
|
||||
public Tester makeAnonExtendsLocal(final String message) {
|
||||
abstract class LocalTester extends Tester {
|
||||
public LocalTester(final int localparam) {
|
||||
super(localparam);
|
||||
}
|
||||
|
||||
protected String[] names() {
|
||||
return new String[] {
|
||||
"this$1",
|
||||
"localparam",
|
||||
"val$message"
|
||||
};
|
||||
}
|
||||
|
||||
protected int[] modifiers() {
|
||||
return new int[] {
|
||||
Modifier.FINAL | MANDATED,
|
||||
Modifier.FINAL,
|
||||
Modifier.FINAL | SYNTHETIC
|
||||
};
|
||||
}
|
||||
|
||||
protected Class[] types() {
|
||||
return new Class[] {
|
||||
Encloser.class,
|
||||
int.class,
|
||||
String.class
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new LocalTester(2) {
|
||||
public String message() {
|
||||
return message;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Tester makeAnonExtendsInner(final String message) {
|
||||
return new InnerTester(2) {
|
||||
protected String[] names() {
|
||||
return new String[] {
|
||||
"this$1",
|
||||
"innerparam",
|
||||
"val$message"
|
||||
};
|
||||
}
|
||||
|
||||
protected int[] modifiers() {
|
||||
return new int[] {
|
||||
Modifier.FINAL | MANDATED,
|
||||
Modifier.FINAL,
|
||||
Modifier.FINAL | SYNTHETIC
|
||||
};
|
||||
}
|
||||
|
||||
protected Class[] types() {
|
||||
return new Class[] {
|
||||
Encloser.class,
|
||||
int.class,
|
||||
String.class
|
||||
};
|
||||
}
|
||||
|
||||
public String message() {
|
||||
return message;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Tester makeAnon(final String message) {
|
||||
return new Tester(2) {
|
||||
protected String[] names() {
|
||||
return new String[] {
|
||||
"this$1",
|
||||
"param",
|
||||
"val$message"
|
||||
};
|
||||
}
|
||||
|
||||
protected int[] modifiers() {
|
||||
return new int[] {
|
||||
Modifier.FINAL | MANDATED,
|
||||
Modifier.FINAL,
|
||||
Modifier.FINAL | SYNTHETIC
|
||||
};
|
||||
}
|
||||
|
||||
protected Class[] types() {
|
||||
return new Class[] {
|
||||
Encloser.class,
|
||||
int.class,
|
||||
String.class
|
||||
};
|
||||
}
|
||||
|
||||
public String message() {
|
||||
return message;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8022316
|
||||
* @summary Generic throws, overriding and method reference
|
||||
* @compile/fail/ref=CompilerErrorGenericThrowPlusMethodRefTest.out -XDrawDiagnostics CompilerErrorGenericThrowPlusMethodRefTest.java
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class CompilerErrorGenericThrowPlusMethodRefTest {
|
||||
interface SAM11 {
|
||||
public <E extends Throwable> void foo() throws E ;
|
||||
}
|
||||
|
||||
interface SAM12 extends SAM11{
|
||||
@Override
|
||||
public void foo() throws Throwable;
|
||||
}
|
||||
|
||||
public void boo() throws RuntimeException {}
|
||||
|
||||
static void test1() {
|
||||
try {
|
||||
SAM12 s2 = new CompilerErrorGenericThrowPlusMethodRefTest()::boo;
|
||||
s2.foo();
|
||||
} catch(Throwable ex) {}
|
||||
}
|
||||
|
||||
static void test2() {
|
||||
SAM11 s1 = null;
|
||||
s1.<Exception>foo();
|
||||
s1.<RuntimeException>foo();
|
||||
}
|
||||
|
||||
interface SAM21 {
|
||||
<E extends Exception> void m(E arg) throws E;
|
||||
}
|
||||
|
||||
interface SAM22 {
|
||||
<F extends Exception> void m(F arg) throws F;
|
||||
}
|
||||
|
||||
interface SAM23 extends SAM21, SAM22 {}
|
||||
|
||||
public <E extends Exception> void bar(E e) throws E {}
|
||||
|
||||
static <E extends Exception> void test3(E e) {
|
||||
try {
|
||||
SAM23 s2 = new CompilerErrorGenericThrowPlusMethodRefTest()::bar;
|
||||
s2.m(e);
|
||||
} catch(Exception ex) {}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
CompilerErrorGenericThrowPlusMethodRefTest.java:55:26: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
|
||||
1 error
|
@ -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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8023112
|
||||
* @summary Mixing up the method type argument with the class type for method
|
||||
* reference ClassType<Q>::<T>new
|
||||
* @compile SkipLazyConstantCreationForMethodRefTest.java
|
||||
*/
|
||||
|
||||
public class SkipLazyConstantCreationForMethodRefTest<T> {
|
||||
SkipLazyConstantCreationForMethodRefTest(int a, boolean b) {}
|
||||
SkipLazyConstantCreationForMethodRefTest() {}
|
||||
}
|
||||
|
||||
class SubClass<T> extends SkipLazyConstantCreationForMethodRefTest {
|
||||
SubClass(int a, boolean b) {}
|
||||
}
|
||||
|
||||
interface SAM {
|
||||
SubClass<SkipLazyConstantCreationForMethodRefTest> m(int a, boolean b);
|
||||
}
|
||||
|
||||
interface Tester1 {
|
||||
SAM s11 = SubClass<SkipLazyConstantCreationForMethodRefTest>::<Object>new;
|
||||
SAM s12 = (SubClass<SkipLazyConstantCreationForMethodRefTest>::<Object>new);
|
||||
SAM s13 = (SAM)SubClass<SkipLazyConstantCreationForMethodRefTest>::<Object>new;
|
||||
SAM s14 = true ? s11 : s12;
|
||||
SAM s15 = true ? s11 : (SAM)SubClass<SkipLazyConstantCreationForMethodRefTest>::<Object>new;
|
||||
SAM s16 = true ? (SAM)SubClass<SkipLazyConstantCreationForMethodRefTest>::<Object>new : s12;
|
||||
}
|
||||
|
||||
interface Tester2 {
|
||||
SAM s21 = Tester1.s11;
|
||||
}
|
@ -35,13 +35,16 @@ public class CombinationsTargetTest2 extends ClassfileTestHelper {
|
||||
// Test count helps identify test case in event of failure.
|
||||
int testcount = 0;
|
||||
|
||||
// Base test case template descriptions
|
||||
// Base test case template descriptions;true==annotations in code attribute.
|
||||
enum srce {
|
||||
src1("(repeating) type annotations on on field in method body",true),
|
||||
src2("(repeating) type annotations on type parameters, bounds and type arguments", true),
|
||||
src3("(repeating) type annotations on type parameters of class, method return value in method", true),
|
||||
src4("(repeating) type annotations on field in anonymous class", false),
|
||||
src5("(repeating) type annotations on field in anonymous class", false);
|
||||
src5("(repeating) type annotations on field in anonymous class", false),
|
||||
src6("(repeating) type annotations on void method declaration", false),
|
||||
src7("(repeating) type annotations in use of instanceof", true),
|
||||
src8("(repeating) type annotations in use of instanceof in method", true);
|
||||
|
||||
String description;
|
||||
Boolean local;
|
||||
@ -84,6 +87,12 @@ public class CombinationsTargetTest2 extends ClassfileTestHelper {
|
||||
test( 0, 8, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src1);
|
||||
test( 2, 0, 2, 0, As, BDs, ABMix, "CLASS", et, ++testrun, srce.src5);
|
||||
test( 0, 2, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src5);
|
||||
test( 0, 0, 2, 0, As, BDs, ABMix, "CLASS", et, ++testrun, srce.src6);
|
||||
test( 0, 0, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src6);
|
||||
test( 2, 0, 0, 0, As, BDs, ABMix, "CLASS", et, ++testrun, srce.src7);
|
||||
test( 0, 2, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src7);
|
||||
test( 4, 0, 0, 0, As, BDs, ABMix, "CLASS", et, ++testrun, srce.src8);
|
||||
test( 0, 4, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src8);
|
||||
break;
|
||||
case "FIELD":
|
||||
test( 8, 0, 0, 0, As, BDs, ABMix, "CLASS", et, ++testrun, srce.src1);
|
||||
@ -121,18 +130,6 @@ public class CombinationsTargetTest2 extends ClassfileTestHelper {
|
||||
", ABmix=" + ABmix + ", retention: " + rtn + ", anno2: " +
|
||||
et2 + ", src=" + source + "\n " + source.description;
|
||||
|
||||
if(
|
||||
// 8005681 - src1,2,3 - skip cases with repeated annotations on new, array, cast.
|
||||
(( source.equals(srce.src1) || source.equals(srce.src2) ||
|
||||
source.equals(srce.src3)) && (ABmix || (Arepeats && BDrepeats)))
|
||||
// 8008928 - src4,5 - this change cause crash with t-a on anon class)
|
||||
|| (source.equals(srce.src4) || source.equals(srce.src5))
|
||||
) {
|
||||
System.out.println(testDef +
|
||||
"\n 8005681-skip repeated annotations on new,array,cast");
|
||||
return;
|
||||
}
|
||||
|
||||
println(testDef);
|
||||
// Create test source and File.
|
||||
String sourceString = sourceString(tname, rtn, et2, Arepeats,
|
||||
@ -178,9 +175,7 @@ public class CombinationsTargetTest2 extends ClassfileTestHelper {
|
||||
println("Pass");
|
||||
}
|
||||
|
||||
//
|
||||
// Source for test cases
|
||||
//
|
||||
String sourceString(String testname, String retentn, String annot2,
|
||||
Boolean Arepeats, Boolean BDrepeats, Boolean ABmix,
|
||||
srce src) {
|
||||
@ -359,6 +354,63 @@ public class CombinationsTargetTest2 extends ClassfileTestHelper {
|
||||
hasInnerClass=true;
|
||||
innerClassname="$1";
|
||||
break;
|
||||
case src6: // (repeating)annotations on void method declaration
|
||||
/*
|
||||
* class Test95{
|
||||
* @A @A @B @B public void test() { };
|
||||
* }
|
||||
*/
|
||||
source = new String( source +
|
||||
"// " + src.description + "\n" +
|
||||
"class "+ testname + "{\n" +
|
||||
" _As_ _Bs_ public void test() { }\n" +
|
||||
"}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
|
||||
"\n\n";
|
||||
hasInnerClass=false;
|
||||
break;
|
||||
case src7: // (repeating) type annotations in use of instanceof
|
||||
/*
|
||||
* class Test10{
|
||||
* String data = "test";
|
||||
* boolean dataIsString = ( data instanceof @A @B @A @B String);
|
||||
* }
|
||||
*/
|
||||
source = new String( source +
|
||||
"// " + src.description + "\n" +
|
||||
"class "+ testname + "{\n" +
|
||||
" String data = \"test\";\n" +
|
||||
" boolean dataIsString = ( data instanceof _As_ _Bs_ String);\n" +
|
||||
"}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
|
||||
"\n\n";
|
||||
hasInnerClass=false;
|
||||
break;
|
||||
case src8: // (repeating) type annotations in use of instanceof
|
||||
/*
|
||||
* class Test20{
|
||||
* String data = "test";
|
||||
* Boolean isString() {
|
||||
* if( data instanceof @A @B @A @B String )
|
||||
* return true;
|
||||
* else
|
||||
* return( data instanceof @A @B @A @B String );
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
source = new String( source +
|
||||
"// " + src.description + "\n" +
|
||||
"class "+ testname + "{\n" +
|
||||
" String data = \"test\";\n" +
|
||||
" Boolean isString() { \n" +
|
||||
" if( data instanceof _As_ _Bs_ String )\n" +
|
||||
" return true;\n" +
|
||||
" else\n" +
|
||||
" return( data instanceof _As_ _Bs_ String );\n" +
|
||||
" }\n" +
|
||||
"}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
|
||||
"\n\n";
|
||||
hasInnerClass=false;
|
||||
break;
|
||||
|
||||
}
|
||||
return imports + source;
|
||||
}
|
||||
|
@ -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.
|
||||
*/
|
||||
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/* A simple annotation processor. */
|
||||
@SupportedAnnotationTypes("*")
|
||||
public class DummyProcessor extends AbstractProcessor {
|
||||
@Override
|
||||
public SourceVersion getSupportedSourceVersion() {
|
||||
return SourceVersion.latest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean process(Set<? extends TypeElement> annotations,
|
||||
RoundEnvironment roundEnv) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -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
|
||||
* @summary Regression: compiling program with lambda crashed compiler
|
||||
* @bug 8020715
|
||||
* @compile T8020715.java
|
||||
*/
|
||||
class T8020715 {
|
||||
// This crashed.
|
||||
private static void makeTask1() {
|
||||
class LocalClass {
|
||||
private Runnable r = () -> {};
|
||||
}
|
||||
}
|
||||
|
||||
// This crashed, too.
|
||||
private void makeTask2() {
|
||||
class LocalClass {
|
||||
private Runnable r = () -> {};
|
||||
}
|
||||
}
|
||||
|
||||
// This is fine.
|
||||
private class InnerClass {
|
||||
private Runnable r = () -> {};
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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 8023768
|
||||
* @summary Type annotations on a type variable, where the bound of
|
||||
* the type variable is an annotated type variable,
|
||||
* need to be processed correctly.
|
||||
* @author Werner Dietl
|
||||
* @compile TypeVariableCycleTest.java
|
||||
*/
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
class TypeVariableCycleTest<CTV> {
|
||||
<MTV extends @TA CTV> MTV cast(CTV p) {
|
||||
return (@TA MTV) p;
|
||||
}
|
||||
}
|
||||
|
||||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
|
||||
@interface TA {}
|
||||
|
@ -85,4 +85,24 @@ public class Constructors {
|
||||
" } } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 4),
|
||||
@TADescription(annotation = "TB", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 0)
|
||||
})
|
||||
public String generic1() {
|
||||
return "class Test { <T> Test(int i) { new <@TA T>Test(); }" +
|
||||
" <T> Test() { <@TB String>this(0); } }";
|
||||
}
|
||||
|
||||
@TADescriptions({
|
||||
@TADescription(annotation = "TA", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
|
||||
typeIndex = 0, offset = 0)
|
||||
})
|
||||
public String generic2() {
|
||||
return "class Super { <T> Super(int i) { } } " +
|
||||
"class Test extends Super { <T> Test() { <@TA String>super(0); } }";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 8009299
|
||||
* @ignore 8013875: Incorrect vtable index being set during methodHandle creation for static
|
||||
* @summary Javac crashes when compiling method reference to static interface method
|
||||
* @run main/othervm -Xverify:none MethodReference66
|
||||
*/
|
||||
|
@ -26,7 +26,6 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 8003639
|
||||
* @ignore 8013875: Incorrect vtable index being set during methodHandle creation for static
|
||||
* @summary convert lambda testng tests to jtreg and add them
|
||||
* @run testng InInterface
|
||||
*/
|
||||
|
114
langtools/test/tools/javac/profiles/ProfileTest.java
Normal file
114
langtools/test/tools/javac/profiles/ProfileTest.java
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* 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 8022287
|
||||
* @summary javac.sym.Profiles uses a static Map when it should not
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import com.sun.tools.javac.sym.Profiles;
|
||||
|
||||
public class ProfileTest {
|
||||
public static void main(String... args) throws Exception {
|
||||
new ProfileTest().run();
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
test("A");
|
||||
test("B");
|
||||
|
||||
if (errors > 0)
|
||||
throw new Exception(errors + " occurred");
|
||||
}
|
||||
|
||||
void test(String base) throws IOException {
|
||||
System.err.println("test " + base);
|
||||
File profileDesc = createFiles(base);
|
||||
checkProfile(profileDesc, base);
|
||||
}
|
||||
|
||||
void checkProfile(File profileDesc, String base) throws IOException {
|
||||
Profiles p = Profiles.read(profileDesc);
|
||||
for (int i = 0; i < p.getProfileCount(); i++) {
|
||||
System.err.println(p.getPackages(i));
|
||||
for (String pkg: p.getPackages(i)) {
|
||||
if (!pkg.endsWith(base))
|
||||
error("unexpected package " + pkg + " for profile " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File createFiles(String base) throws IOException {
|
||||
File baseDir = new File(base);
|
||||
baseDir.mkdirs();
|
||||
for (int p = 1; p <= 4; p++) {
|
||||
String pkg = "pkg" + p + base;
|
||||
File pkgDir = new File(baseDir, pkg);
|
||||
pkgDir.mkdirs();
|
||||
File clssFile = new File(pkgDir, pkg + "Class.java");
|
||||
try (PrintWriter out = new PrintWriter(new FileWriter(clssFile))) {
|
||||
out.println("package " + pkgDir.getName() + ";");
|
||||
out.println("class " + clssFile.getName().replace(".java", ""));
|
||||
}
|
||||
}
|
||||
|
||||
File profileDesc = new File(baseDir, "profiles" + base + ".txt");
|
||||
try (PrintWriter out = new PrintWriter(new FileWriter(profileDesc))) {
|
||||
for (int p = 1; p <= 4; p++) {
|
||||
String pkg = "pkg" + p + base;
|
||||
createPackage(baseDir, pkg, "Pkg" + p + base + "Class");
|
||||
out.println("PROFILE_" + p + "_RTJAR_INCLUDE_PACKAGES := " + pkg);
|
||||
out.println("PROFILE_" + p + "_RTJAR_INCLUDE_TYPES :=");
|
||||
out.println("PROFILE_" + p + "_RTJAR_EXCLUDE_TYPES :=");
|
||||
out.println("PROFILE_" + p + "_INCLUDE_METAINF_SERVICES := ");
|
||||
}
|
||||
}
|
||||
|
||||
return profileDesc;
|
||||
}
|
||||
|
||||
void createPackage(File baseDir, String pkg, String... classNames) throws IOException {
|
||||
File pkgDir = new File(baseDir, pkg);
|
||||
pkgDir.mkdirs();
|
||||
for (String className: classNames) {
|
||||
File clssFile = new File(pkgDir, className + ".java");
|
||||
try (PrintWriter out = new PrintWriter(new FileWriter(clssFile))) {
|
||||
out.println("package " + pkg + ";");
|
||||
out.println("public class " + className + " { }");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void error(String msg) {
|
||||
System.err.println("Error: " + msg);
|
||||
errors++;
|
||||
}
|
||||
|
||||
int errors;
|
||||
}
|
169
langtools/test/tools/javac/tree/TypeAnnotationsPretty.java
Normal file
169
langtools/test/tools/javac/tree/TypeAnnotationsPretty.java
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* 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 8023522
|
||||
* @summary test Pretty print of type annotations
|
||||
* @author wmdietl
|
||||
*/
|
||||
|
||||
import com.sun.source.tree.ClassTree;
|
||||
import com.sun.source.tree.CompilationUnitTree;
|
||||
import com.sun.tools.javac.api.JavacTaskImpl;
|
||||
import com.sun.tools.javac.tree.JCTree;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.SimpleJavaFileObject;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
public class TypeAnnotationsPretty {
|
||||
private final JavaCompiler tool;
|
||||
|
||||
TypeAnnotationsPretty() {
|
||||
tool = ToolProvider.getSystemJavaCompiler();
|
||||
}
|
||||
|
||||
private List<String> matches = new LinkedList<String>();
|
||||
private List<String> mismatches = new LinkedList<String>();
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
TypeAnnotationsPretty tap = new TypeAnnotationsPretty();
|
||||
|
||||
tap.runField("@TA()\nObject cls = null");
|
||||
tap.runField("@TA()\nObject cls = new @TA() Object()");
|
||||
|
||||
tap.runField("@TA()\nList<@TB() Object> cls = null");
|
||||
tap.runField("@TA()\nList<@TB() Object> cls = new @TA() LinkedList<@TB() Object>()");
|
||||
|
||||
tap.runField("Class[] cls = null");
|
||||
tap.runField("@TA()\nClass[] cls = null");
|
||||
tap.runField("Class @TA() [] cls = null");
|
||||
tap.runField("@TA()\nClass @TB() [] cls = null");
|
||||
|
||||
tap.runField("Class[] cls = new Class[]{Object.class}");
|
||||
tap.runField("@TA()\nClass[] cls = new @TA() Class[]{Object.class}");
|
||||
tap.runField("Class @TB() [] cls = new Class @TB() []{Object.class}");
|
||||
tap.runField("@TA()\nClass @TB() [] cls = new @TA() Class @TB() []{Object.class}");
|
||||
tap.runField("@TA()\nClass @TB() [] @TC() [] cls = new @TA() Class @TB() [10] @TC() []");
|
||||
tap.runField("Class @TB() [] @TC() [] cls = new Class @TB() [10] @TC() []");
|
||||
tap.runField("@TA()\nClass @TB() [] @TC() [] @TD() [] cls = new @TA() Class @TB() [10] @TC() [] @TD() []");
|
||||
|
||||
tap.runMethod("\n@TA()\nObject test(@TB()\nList<@TC() String> p) {\n" +
|
||||
" return null;\n" +
|
||||
"}");
|
||||
|
||||
|
||||
if (!tap.matches.isEmpty()) {
|
||||
for (String m : tap.matches)
|
||||
System.out.println(m);
|
||||
}
|
||||
if (!tap.mismatches.isEmpty()) {
|
||||
for (String mm : tap.mismatches)
|
||||
System.err.println(mm + NL);
|
||||
throw new RuntimeException("Tests failed!");
|
||||
}
|
||||
}
|
||||
|
||||
private static final String prefix =
|
||||
"import java.lang.annotation.*;" +
|
||||
"import java.util.*;" +
|
||||
"public class Test {";
|
||||
|
||||
private static final String postfix =
|
||||
"@Target(ElementType.TYPE_USE)" +
|
||||
"@interface TA {}" +
|
||||
"@Target(ElementType.TYPE_USE)" +
|
||||
"@interface TB {}" +
|
||||
"@Target(ElementType.TYPE_USE)" +
|
||||
"@interface TC {}" +
|
||||
"@Target(ElementType.TYPE_USE)" +
|
||||
"@interface TD {}";
|
||||
|
||||
private static final String NL = System.getProperty("line.separator");
|
||||
|
||||
private void runField(String code) throws IOException {
|
||||
String src = prefix +
|
||||
code + "; }" +
|
||||
postfix;
|
||||
|
||||
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
|
||||
null, Arrays.asList(new MyFileObject(src)));
|
||||
|
||||
for (CompilationUnitTree cut : ct.parse()) {
|
||||
JCTree.JCVariableDecl var =
|
||||
(JCTree.JCVariableDecl) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0);
|
||||
checkMatch(code, var);
|
||||
}
|
||||
}
|
||||
|
||||
private void runMethod(String code) throws IOException {
|
||||
String src = prefix +
|
||||
code + "}" +
|
||||
postfix;
|
||||
|
||||
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
|
||||
null, Arrays.asList(new MyFileObject(src)));
|
||||
|
||||
|
||||
for (CompilationUnitTree cut : ct.parse()) {
|
||||
JCTree.JCMethodDecl meth =
|
||||
(JCTree.JCMethodDecl) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0);
|
||||
checkMatch(code, meth);
|
||||
}
|
||||
}
|
||||
|
||||
void checkMatch(String code, JCTree tree) {
|
||||
String expect = code.replace("\n", NL);
|
||||
String found = tree.toString();
|
||||
if (!expect.equals(found)) {
|
||||
mismatches.add("Expected: " + expect + NL +
|
||||
"Obtained: " + found);
|
||||
} else {
|
||||
matches.add("Passed: " + expect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MyFileObject extends SimpleJavaFileObject {
|
||||
|
||||
private String text;
|
||||
|
||||
public MyFileObject(String text) {
|
||||
super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
|
||||
return text;
|
||||
}
|
||||
}
|
62
langtools/test/tools/javadoc/nonConstExprs/Test.java
Normal file
62
langtools/test/tools/javadoc/nonConstExprs/Test.java
Normal file
@ -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 8010310
|
||||
* @summary Error processing sources with -private
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Test {
|
||||
public static void main(String... args) throws Exception {
|
||||
File testSrc = new File(System.getProperty("test.src"));
|
||||
String[] jdoc_args = {
|
||||
"-d", "out",
|
||||
new File(testSrc, Test.class.getSimpleName() + ".java").getPath()
|
||||
};
|
||||
int rc = com.sun.tools.javadoc.Main.execute(jdoc_args);
|
||||
if (rc != 0)
|
||||
throw new Exception("unexpected return code from javadoc: " + rc);
|
||||
}
|
||||
|
||||
static int array[] = { 1, 2, 3};
|
||||
static int method(int p) { return p; }
|
||||
static int value = 0;
|
||||
|
||||
public int not_static_not_final = 1;
|
||||
public static int static_not_final = 2;
|
||||
public final int not_static_final = 3;
|
||||
public static final int static_final = 4;
|
||||
|
||||
public static final int array_index = array[0];
|
||||
public static final int method_call = method(0);
|
||||
public static final int inner_class = new Test() { }.method(0);
|
||||
public static final int new_class = new Test().method(0);
|
||||
public static final int pre_inc = ++value;
|
||||
public static final int pre_dec = --value;
|
||||
public static final int post_inc = value++;
|
||||
public static final int post_dec = value--;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user