Merge
This commit is contained in:
commit
5c411f3cc6
File diff suppressed because it is too large
Load Diff
@ -91,32 +91,32 @@ classes:
|
||||
<pre>
|
||||
import com.sun.javadoc.*;
|
||||
|
||||
public class ListParams extends <font color=red title="Doclet API">Doclet</font> {
|
||||
public class ListParams extends <font style="color:red;">Doclet</font> {
|
||||
|
||||
public static boolean start(<font color=red title="Doclet API">RootDoc</font> root) {
|
||||
<font color=red title="Doclet API">ClassDoc</font>[] classes = root.<font color=red title="Doclet API">classes</font>();
|
||||
for (int i = 0; i < classes.length; ++i) {
|
||||
<font color=red title="Doclet API">ClassDoc</font> cd = classes[i];
|
||||
printMembers(cd.<font color=red title="Doclet API">constructors</font>());
|
||||
printMembers(cd.<font color=red title="Doclet API">methods</font>());
|
||||
public static boolean start(<font style="color:red;">RootDoc</font> root) {
|
||||
<font style="color:red;">ClassDoc</font>[] classes = root.<font style="color:red;">classes</font>();
|
||||
for (int i = 0; i < classes.length; ++i) {
|
||||
<font style="color:red;">ClassDoc</font> cd = classes[i];
|
||||
printMembers(cd.<font style="color:red;">constructors</font>());
|
||||
printMembers(cd.<font style="color:red;">methods</font>());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void printMembers(<font color=red title="Doclet API">ExecutableMemberDoc</font>[] mems) {
|
||||
for (int i = 0; i < mems.length; ++i) {
|
||||
<font color=red title="Doclet API">ParamTag</font>[] params = mems[i].<font color=red title="Doclet API">paramTags</font>();
|
||||
System.out.println(mems[i].<font color=red title="Doclet API">qualifiedName</font>());
|
||||
for (int j = 0; j < params.length; ++j) {
|
||||
System.out.println(" " + params[j].<font color=red title="Doclet API">parameterName</font>()
|
||||
+ " - " + params[j].<font color=red title="Doclet API">parameterComment</font>());
|
||||
static void printMembers(<font style="color:red;">ExecutableMemberDoc</font>[] mems) {
|
||||
for (int i = 0; i < mems.length; ++i) {
|
||||
<font style="color:red;">ParamTag</font>[] params = mems[i].<font style="color:red;">paramTags</font>();
|
||||
System.out.println(mems[i].<font style="color:red;">qualifiedName</font>());
|
||||
for (int j = 0; j < params.length; ++j) {
|
||||
System.out.println(" " + params[j].<font style="color:red;">parameterName</font>()
|
||||
+ " - " + params[j].<font style="color:red;">parameterComment</font>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
Interfaces and methods from the Javadoc API are marked in
|
||||
<font color=red title="Doclet API">red</font>.
|
||||
<font style="color:red;">red</font>.
|
||||
{@link com.sun.javadoc.Doclet Doclet} is an abstract class that specifies
|
||||
the invocation interface for doclets,
|
||||
{@link com.sun.javadoc.Doclet Doclet} holds class or interface information,
|
||||
|
@ -1713,9 +1713,13 @@ public class HtmlDocletWriter extends HtmlDocWriter {
|
||||
//might be missing '>' character because the href has an inline tag.
|
||||
break;
|
||||
}
|
||||
if (textBuff.substring(begin, end).contains("\"")){
|
||||
begin = textBuff.indexOf("\"", begin) + 1;
|
||||
end = textBuff.indexOf("\"", begin +1);
|
||||
|
||||
String quote = textBuff.substring(begin, end);
|
||||
quote = quote.contains("\"") ? "\"" :
|
||||
quote.contains("\'") ? "\'" : null;
|
||||
if (quote != null) {
|
||||
begin = textBuff.indexOf(quote, begin) + 1;
|
||||
end = textBuff.indexOf(quote, begin +1);
|
||||
if (begin == 0 || end == -1){
|
||||
//Link is missing a quote.
|
||||
break;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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,20 +269,7 @@ public class JavacTrees extends DocTrees {
|
||||
}
|
||||
|
||||
public JCTree getTree(Element element) {
|
||||
Symbol symbol = (Symbol) element;
|
||||
TypeSymbol enclosing = symbol.enclClass();
|
||||
Env<AttrContext> env = enter.getEnv(enclosing);
|
||||
if (env == null)
|
||||
return null;
|
||||
JCClassDecl classNode = env.enclClass;
|
||||
if (classNode != null) {
|
||||
if (TreeInfo.symbolFor(classNode) == element)
|
||||
return classNode;
|
||||
for (JCTree node : classNode.getMembers())
|
||||
if (TreeInfo.symbolFor(node) == element)
|
||||
return node;
|
||||
}
|
||||
return null;
|
||||
return getTree(element, null);
|
||||
}
|
||||
|
||||
public JCTree getTree(Element e, AnnotationMirror a) {
|
||||
|
@ -207,9 +207,6 @@ public enum Source {
|
||||
public boolean allowDefaultMethods() {
|
||||
return compareTo(JDK1_8) >= 0;
|
||||
}
|
||||
public boolean allowDefaultMethodsResolution() {
|
||||
return compareTo(JDK1_7) >= 0;
|
||||
}
|
||||
public boolean allowStaticInterfaceMethods() {
|
||||
return compareTo(JDK1_8) >= 0;
|
||||
}
|
||||
|
@ -1705,7 +1705,12 @@ public class Check {
|
||||
|
||||
// Warn if a deprecated method overridden by a non-deprecated one.
|
||||
if (!isDeprecatedOverrideIgnorable(other, origin)) {
|
||||
checkDeprecated(TreeInfo.diagnosticPositionFor(m, tree), m, other);
|
||||
Lint prevLint = setLint(lint.augment(m));
|
||||
try {
|
||||
checkDeprecated(TreeInfo.diagnosticPositionFor(m, tree), m, other);
|
||||
} finally {
|
||||
setLint(prevLint);
|
||||
}
|
||||
}
|
||||
}
|
||||
// where
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -583,11 +583,17 @@ public class Infer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean accepts(UndetVar uv, InferenceContext inferenceContext) {
|
||||
return !uv.isCaptured() && uv.getBounds(InferenceBound.EQ).nonEmpty();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Check consistency of equality constraints.
|
||||
*/
|
||||
EQ_CHECK() {
|
||||
@Override
|
||||
public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) {
|
||||
Infer infer = inferenceContext.infer();
|
||||
for (Type e : uv.getBounds(InferenceBound.EQ)) {
|
||||
@ -604,6 +610,11 @@ public class Infer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean accepts(UndetVar uv, InferenceContext inferenceContext) {
|
||||
return !uv.isCaptured() && uv.getBounds(InferenceBound.EQ).nonEmpty();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Given a bound set containing {@code alpha <: T} and {@code alpha :> S}
|
||||
@ -618,6 +629,13 @@ public class Infer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean accepts(UndetVar uv, InferenceContext inferenceContext) {
|
||||
return !uv.isCaptured() &&
|
||||
uv.getBounds(InferenceBound.UPPER).nonEmpty() &&
|
||||
uv.getBounds(InferenceBound.LOWER).nonEmpty();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Given a bound set containing {@code alpha <: T} and {@code alpha == S}
|
||||
@ -632,6 +650,13 @@ public class Infer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean accepts(UndetVar uv, InferenceContext inferenceContext) {
|
||||
return !uv.isCaptured() &&
|
||||
uv.getBounds(InferenceBound.EQ).nonEmpty() &&
|
||||
uv.getBounds(InferenceBound.UPPER).nonEmpty();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Given a bound set containing {@code alpha :> S} and {@code alpha == T}
|
||||
@ -646,6 +671,13 @@ public class Infer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean accepts(UndetVar uv, InferenceContext inferenceContext) {
|
||||
return !uv.isCaptured() &&
|
||||
uv.getBounds(InferenceBound.EQ).nonEmpty() &&
|
||||
uv.getBounds(InferenceBound.LOWER).nonEmpty();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Given a bound set containing {@code alpha == S} and {@code alpha == T}
|
||||
@ -662,6 +694,12 @@ public class Infer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean accepts(UndetVar uv, InferenceContext inferenceContext) {
|
||||
return !uv.isCaptured() &&
|
||||
uv.getBounds(InferenceBound.EQ).nonEmpty();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Given a bound set containing {@code alpha <: beta} propagate lower bounds
|
||||
@ -688,6 +726,12 @@ public class Infer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean accepts(UndetVar uv, InferenceContext inferenceContext) {
|
||||
return !uv.isCaptured() &&
|
||||
uv.getBounds(InferenceBound.UPPER).nonEmpty();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Given a bound set containing {@code alpha :> beta} propagate lower bounds
|
||||
@ -714,6 +758,12 @@ public class Infer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean accepts(UndetVar uv, InferenceContext inferenceContext) {
|
||||
return !uv.isCaptured() &&
|
||||
uv.getBounds(InferenceBound.LOWER).nonEmpty();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Given a bound set containing {@code alpha == beta} propagate lower/upper
|
||||
@ -748,6 +798,12 @@ public class Infer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean accepts(UndetVar uv, InferenceContext inferenceContext) {
|
||||
return !uv.isCaptured() &&
|
||||
uv.getBounds(InferenceBound.EQ).nonEmpty();
|
||||
}
|
||||
};
|
||||
|
||||
abstract void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn);
|
||||
|
@ -91,10 +91,9 @@ public class Resolve {
|
||||
TreeInfo treeinfo;
|
||||
Types types;
|
||||
JCDiagnostic.Factory diags;
|
||||
public final boolean boxingEnabled; // = source.allowBoxing();
|
||||
public final boolean varargsEnabled; // = source.allowVarargs();
|
||||
public final boolean boxingEnabled;
|
||||
public final boolean varargsEnabled;
|
||||
public final boolean allowMethodHandles;
|
||||
public final boolean allowDefaultMethodsResolution;
|
||||
public final boolean allowStructuralMostSpecific;
|
||||
private final boolean debugResolve;
|
||||
private final boolean compactMethodDiags;
|
||||
@ -136,7 +135,6 @@ public class Resolve {
|
||||
verboseResolutionMode = VerboseResolutionMode.getVerboseResolutionMode(options);
|
||||
Target target = Target.instance(context);
|
||||
allowMethodHandles = target.hasMethodHandles();
|
||||
allowDefaultMethodsResolution = source.allowDefaultMethodsResolution();
|
||||
allowStructuralMostSpecific = source.allowStructuralMostSpecific();
|
||||
polymorphicSignatureScope = new Scope(syms.noSymbol);
|
||||
|
||||
@ -1680,7 +1678,6 @@ public class Resolve {
|
||||
bestSoFar : methodNotFound;
|
||||
|
||||
for (InterfaceLookupPhase iphase2 : InterfaceLookupPhase.values()) {
|
||||
if (iphase2 == InterfaceLookupPhase.DEFAULT_OK && !allowDefaultMethodsResolution) break;
|
||||
//keep searching for abstract methods
|
||||
for (Type itype : itypes[iphase2.ordinal()]) {
|
||||
if (!itype.isInterface()) continue; //skip j.l.Object (included by Types.closure())
|
||||
@ -1713,10 +1710,8 @@ public class Resolve {
|
||||
//from superinterfaces)
|
||||
if ((s.flags() & (ABSTRACT | INTERFACE | ENUM)) != 0) {
|
||||
return this;
|
||||
} else if (rs.allowDefaultMethodsResolution) {
|
||||
return DEFAULT_OK;
|
||||
} else {
|
||||
return null;
|
||||
return DEFAULT_OK;
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -3340,9 +3335,9 @@ public class Resolve {
|
||||
if ((env1.enclClass.sym.flags() & STATIC) != 0) staticOnly = true;
|
||||
env1 = env1.outer;
|
||||
}
|
||||
if (allowDefaultMethodsResolution && c.isInterface() &&
|
||||
name == names._super && !isStatic(env) &&
|
||||
types.isDirectSuperInterface(c, env.enclClass.sym)) {
|
||||
if (c.isInterface() &&
|
||||
name == names._super && !isStatic(env) &&
|
||||
types.isDirectSuperInterface(c, env.enclClass.sym)) {
|
||||
//this might be a default super call if one of the superinterfaces is 'c'
|
||||
for (Type t : pruneInterfaces(env.enclClass.type)) {
|
||||
if (t.tsym == c) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,7 @@
|
||||
package com.sun.tools.javac.comp;
|
||||
|
||||
import java.util.AbstractQueue;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
@ -34,6 +34,8 @@ import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
import com.sun.tools.javac.util.Context;
|
||||
|
||||
/** A queue of all as yet unattributed classes.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
@ -82,6 +84,22 @@ public class Todo extends AbstractQueue<Env<AttrContext>> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all unattributed classes except those belonging to the given
|
||||
* collection of files.
|
||||
*
|
||||
* @param sourceFiles The source files of the classes to keep.
|
||||
*/
|
||||
public void retainFiles(Collection<? extends JavaFileObject> sourceFiles) {
|
||||
for (Iterator<Env<AttrContext>> it = contents.iterator(); it.hasNext(); ) {
|
||||
Env<AttrContext> env = it.next();
|
||||
if (!sourceFiles.contains(env.toplevel.sourcefile)) {
|
||||
if (contentsByFile != null) removeByFile(env);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Env<AttrContext> poll() {
|
||||
if (size() == 0)
|
||||
return null;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -856,6 +856,12 @@ public class JavaCompiler {
|
||||
enterTrees(stopIfError(CompileState.PARSE, parseFiles(sourceFileObjects))),
|
||||
classnames);
|
||||
|
||||
// If it's safe to do so, skip attr / flow / gen for implicit classes
|
||||
if (taskListener.isEmpty() &&
|
||||
implicitSourcePolicy == ImplicitSourcePolicy.NONE) {
|
||||
delegateCompiler.todo.retainFiles(delegateCompiler.inputFiles);
|
||||
}
|
||||
|
||||
delegateCompiler.compile2();
|
||||
delegateCompiler.close();
|
||||
elapsed_msec = delegateCompiler.elapsed_msec;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -38,6 +38,7 @@ import javax.lang.model.SourceVersion;
|
||||
|
||||
import com.sun.tools.doclint.DocLint;
|
||||
import com.sun.tools.javac.code.Lint;
|
||||
import com.sun.tools.javac.code.Lint.LintCategory;
|
||||
import com.sun.tools.javac.code.Source;
|
||||
import com.sun.tools.javac.code.Type;
|
||||
import com.sun.tools.javac.jvm.Profile;
|
||||
@ -80,8 +81,34 @@ public enum Option {
|
||||
|
||||
XLINT("-Xlint", "opt.Xlint", EXTENDED, BASIC),
|
||||
|
||||
XLINT_CUSTOM("-Xlint:", "opt.Xlint.suboptlist",
|
||||
EXTENDED, BASIC, ANYOF, getXLintChoices()),
|
||||
XLINT_CUSTOM("-Xlint:", EXTENDED, BASIC, ANYOF, getXLintChoices()) {
|
||||
private static final String LINT_KEY_FORMAT = " %-19s %s";
|
||||
void help(Log log, OptionKind kind) {
|
||||
if (this.kind != kind)
|
||||
return;
|
||||
|
||||
log.printRawLines(WriterKind.NOTICE,
|
||||
String.format(HELP_LINE_FORMAT,
|
||||
log.localize(PrefixKind.JAVAC, "opt.Xlint.subopts"),
|
||||
log.localize(PrefixKind.JAVAC, "opt.Xlint.suboptlist")));
|
||||
log.printRawLines(WriterKind.NOTICE,
|
||||
String.format(LINT_KEY_FORMAT,
|
||||
"all",
|
||||
log.localize(PrefixKind.JAVAC, "opt.Xlint.all")));
|
||||
for (LintCategory lc : LintCategory.values()) {
|
||||
if (lc.hidden) continue;
|
||||
log.printRawLines(WriterKind.NOTICE,
|
||||
String.format(LINT_KEY_FORMAT,
|
||||
lc.option,
|
||||
log.localize(PrefixKind.JAVAC,
|
||||
"opt.Xlint.desc." + lc.option)));
|
||||
}
|
||||
log.printRawLines(WriterKind.NOTICE,
|
||||
String.format(LINT_KEY_FORMAT,
|
||||
"none",
|
||||
log.localize(PrefixKind.JAVAC, "opt.Xlint.none")));
|
||||
}
|
||||
},
|
||||
|
||||
XDOCLINT("-Xdoclint", "opt.Xdoclint", EXTENDED, BASIC),
|
||||
|
||||
@ -550,10 +577,9 @@ public enum Option {
|
||||
this(text, argsNameKey, descrKey, kind, group, null, null, doHasSuffix);
|
||||
}
|
||||
|
||||
Option(String text, String descrKey,
|
||||
OptionKind kind, OptionGroup group,
|
||||
Option(String text, OptionKind kind, OptionGroup group,
|
||||
ChoiceKind choiceKind, Map<String,Boolean> choices) {
|
||||
this(text, null, descrKey, kind, group, choiceKind, choices, false);
|
||||
this(text, null, null, kind, group, choiceKind, choices, false);
|
||||
}
|
||||
|
||||
Option(String text, String descrKey,
|
||||
@ -650,12 +676,14 @@ public enum Option {
|
||||
return process(helper, option, option);
|
||||
}
|
||||
|
||||
private static final String HELP_LINE_FORMAT = " %-26s %s";
|
||||
|
||||
void help(Log log, OptionKind kind) {
|
||||
if (this.kind != kind)
|
||||
return;
|
||||
|
||||
log.printRawLines(WriterKind.NOTICE,
|
||||
String.format(" %-26s %s",
|
||||
String.format(HELP_LINE_FORMAT,
|
||||
helpSynopsis(log),
|
||||
log.localize(PrefixKind.JAVAC, descrKey)));
|
||||
|
||||
|
@ -193,13 +193,17 @@ public class JavacElements implements Elements {
|
||||
public void visitVarDef(JCVariableDecl tree) {
|
||||
result = tree.mods.annotations;
|
||||
}
|
||||
@Override
|
||||
public void visitTypeParameter(JCTypeParameter tree) {
|
||||
result = tree.annotations;
|
||||
}
|
||||
}
|
||||
Vis vis = new Vis();
|
||||
tree.accept(vis);
|
||||
if (vis.result == null)
|
||||
return null;
|
||||
|
||||
List<Attribute.Compound> annos = sym.getRawAttributes();
|
||||
List<Attribute.Compound> annos = sym.getAnnotationMirrors();
|
||||
return matchAnnoToTree(cast(Attribute.Compound.class, findme),
|
||||
annos,
|
||||
vis.result);
|
||||
|
@ -107,6 +107,10 @@ public class JavadocTokenizer extends JavaTokenizer {
|
||||
*/
|
||||
int pp = 0;
|
||||
|
||||
/** The buffer index of the last double backslash sequence
|
||||
*/
|
||||
private int doubleBackslashBp = -1;
|
||||
|
||||
DocReader(ScannerFactory fac, char[] input, int inputLength, int startPos) {
|
||||
super(fac, input, inputLength);
|
||||
this.startPos = startPos;
|
||||
@ -149,8 +153,8 @@ public class JavadocTokenizer extends JavaTokenizer {
|
||||
scanChar();
|
||||
if (ch == '\\') {
|
||||
if (peekChar() == '\\' && !isUnicode()) {
|
||||
putChar(ch, false);
|
||||
bp++; col++;
|
||||
doubleBackslashBp = bp;
|
||||
} else {
|
||||
convertUnicode();
|
||||
}
|
||||
@ -204,6 +208,13 @@ public class JavadocTokenizer extends JavaTokenizer {
|
||||
}
|
||||
super.putChar(ch, scan);
|
||||
}
|
||||
|
||||
/** Whether the ch represents a sequence of two backslashes. */
|
||||
boolean isDoubleBackslash() {
|
||||
return doubleBackslashBp == bp;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected static class JavadocComment extends JavaTokenizer.BasicComment<DocReader> {
|
||||
@ -375,6 +386,13 @@ public class JavadocTokenizer extends JavaTokenizer {
|
||||
// the buffer.
|
||||
comment_reader.putChar('*', false);
|
||||
break;
|
||||
case '\\':
|
||||
comment_reader.putChar('\\', false);
|
||||
// If a double backslash was found, write two
|
||||
if (comment_reader.isDoubleBackslash()) {
|
||||
comment_reader.putChar('\\', false);
|
||||
}
|
||||
comment_reader.scanCommentChar();
|
||||
case ' ':
|
||||
case '\t':
|
||||
comment_reader.putChar(comment_reader.ch, false);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -142,8 +142,80 @@ javac.opt.arg.file=\
|
||||
<filename>
|
||||
javac.opt.Xlint=\
|
||||
Enable recommended warnings
|
||||
javac.opt.Xlint.suboptlist=\
|
||||
Enable or disable specific warnings
|
||||
javac.opt.Xlint.all=\
|
||||
Enable all warnings
|
||||
javac.opt.Xlint.none=\
|
||||
Disable all warnings
|
||||
#L10N: do not localize: -Xlint
|
||||
javac.opt.Xlint.subopts=\
|
||||
-Xlint:key,...
|
||||
javac.opt.Xlint.suboptlist=\n\
|
||||
\ Warnings to enable or disable, separated by comma.\n\
|
||||
\ Precede a key by '-' to disable the specified warning.\n\
|
||||
\ Supported keys are:
|
||||
javac.opt.Xlint.desc.auxiliaryclass=\
|
||||
Warn about an auxiliary class that is hidden in a source file, and is used from other files.
|
||||
|
||||
javac.opt.Xlint.desc.cast=\
|
||||
Warn about use of unnecessary casts.
|
||||
|
||||
javac.opt.Xlint.desc.classfile=\
|
||||
Warn about issues related to classfile contents.
|
||||
|
||||
javac.opt.Xlint.desc.deprecation=\
|
||||
Warn about use of deprecated items.
|
||||
|
||||
javac.opt.Xlint.desc.dep-ann=\
|
||||
Warn about items marked as deprecated in JavaDoc but not using the @Deprecated annotation.
|
||||
|
||||
javac.opt.Xlint.desc.divzero=\
|
||||
Warn about division by constant integer 0.
|
||||
|
||||
javac.opt.Xlint.desc.empty=\
|
||||
Warn about empty statement after if.
|
||||
|
||||
javac.opt.Xlint.desc.fallthrough=\
|
||||
Warn about falling through from one case of a switch statement to the next.
|
||||
|
||||
javac.opt.Xlint.desc.finally=\
|
||||
Warn about finally clauses that do not terminate normally.
|
||||
|
||||
javac.opt.Xlint.desc.options=\
|
||||
Warn about issues relating to use of command line options.
|
||||
|
||||
javac.opt.Xlint.desc.overloads=\
|
||||
Warn about issues regarding method overloads.
|
||||
|
||||
javac.opt.Xlint.desc.overrides=\
|
||||
Warn about issues regarding method overrides.
|
||||
|
||||
javac.opt.Xlint.desc.path=\
|
||||
Warn about invalid path elements on the command line.
|
||||
|
||||
javac.opt.Xlint.desc.processing=\
|
||||
Warn about issues regarding annotation processing.
|
||||
|
||||
javac.opt.Xlint.desc.rawtypes=\
|
||||
Warn about use of raw types.
|
||||
|
||||
javac.opt.Xlint.desc.serial=\
|
||||
Warn about Serializable classes that do not provide a serial version ID.
|
||||
|
||||
javac.opt.Xlint.desc.static=\
|
||||
Warn about accessing a static member using an instance.
|
||||
|
||||
javac.opt.Xlint.desc.sunapi=\
|
||||
Warn about proprietary API that may be removed in a future release.
|
||||
|
||||
javac.opt.Xlint.desc.try=\
|
||||
Warn about issues relating to use of try blocks (i.e. try-with-resources).
|
||||
|
||||
javac.opt.Xlint.desc.unchecked=\
|
||||
Warn about unchecked operations.
|
||||
|
||||
javac.opt.Xlint.desc.varargs=\
|
||||
Warn about potentially unsafe vararg methods
|
||||
|
||||
javac.opt.Xdoclint=\
|
||||
Enable recommended checks for problems in javadoc comments
|
||||
# L10N: do not localize: all none
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -30,6 +30,7 @@ import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.tools.JavaFileManager.Location;
|
||||
@ -238,10 +239,13 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
files = lb.toList();
|
||||
}
|
||||
|
||||
Set<JavaFileObject> ufiles = new HashSet<>();
|
||||
for (JavaFileObject fo : files) {
|
||||
// messager.notice("main.Loading_source_file", fn);
|
||||
trees.append(parse(fo));
|
||||
hasFiles = true;
|
||||
if (ufiles.add(fo)) { // ignore duplicates
|
||||
// messager.notice("main.Loading_source_file", fn);
|
||||
trees.append(parse(fo));
|
||||
hasFiles = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasFiles) {
|
||||
|
@ -531,7 +531,6 @@ public class AttributeWriter extends BasicWriter
|
||||
for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
|
||||
w.write(entry);
|
||||
}
|
||||
println();
|
||||
indent(-1);
|
||||
return null;
|
||||
}
|
||||
@ -543,7 +542,6 @@ public class AttributeWriter extends BasicWriter
|
||||
for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
|
||||
w.write(entry);
|
||||
}
|
||||
println();
|
||||
indent(-1);
|
||||
return null;
|
||||
}
|
||||
@ -555,14 +553,12 @@ public class AttributeWriter extends BasicWriter
|
||||
}
|
||||
|
||||
public Void visit_same_frame(StackMapTable_attribute.same_frame frame, Void p) {
|
||||
printHeader(frame);
|
||||
println(" /* same */");
|
||||
printHeader(frame, "/* same */");
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void visit_same_locals_1_stack_item_frame(StackMapTable_attribute.same_locals_1_stack_item_frame frame, Void p) {
|
||||
printHeader(frame);
|
||||
println(" /* same_locals_1_stack_item */");
|
||||
printHeader(frame, "/* same_locals_1_stack_item */");
|
||||
indent(+1);
|
||||
printMap("stack", frame.stack);
|
||||
indent(-1);
|
||||
@ -570,8 +566,7 @@ public class AttributeWriter extends BasicWriter
|
||||
}
|
||||
|
||||
public Void visit_same_locals_1_stack_item_frame_extended(StackMapTable_attribute.same_locals_1_stack_item_frame_extended frame, Void p) {
|
||||
printHeader(frame);
|
||||
println(" /* same_locals_1_stack_item_frame_extended */");
|
||||
printHeader(frame, "/* same_locals_1_stack_item_frame_extended */");
|
||||
indent(+1);
|
||||
println("offset_delta = " + frame.offset_delta);
|
||||
printMap("stack", frame.stack);
|
||||
@ -580,8 +575,7 @@ public class AttributeWriter extends BasicWriter
|
||||
}
|
||||
|
||||
public Void visit_chop_frame(StackMapTable_attribute.chop_frame frame, Void p) {
|
||||
printHeader(frame);
|
||||
println(" /* chop */");
|
||||
printHeader(frame, "/* chop */");
|
||||
indent(+1);
|
||||
println("offset_delta = " + frame.offset_delta);
|
||||
indent(-1);
|
||||
@ -589,8 +583,7 @@ public class AttributeWriter extends BasicWriter
|
||||
}
|
||||
|
||||
public Void visit_same_frame_extended(StackMapTable_attribute.same_frame_extended frame, Void p) {
|
||||
printHeader(frame);
|
||||
println(" /* same_frame_extended */");
|
||||
printHeader(frame, "/* same_frame_extended */");
|
||||
indent(+1);
|
||||
println("offset_delta = " + frame.offset_delta);
|
||||
indent(-1);
|
||||
@ -598,21 +591,20 @@ public class AttributeWriter extends BasicWriter
|
||||
}
|
||||
|
||||
public Void visit_append_frame(StackMapTable_attribute.append_frame frame, Void p) {
|
||||
printHeader(frame);
|
||||
println(" /* append */");
|
||||
printHeader(frame, "/* append */");
|
||||
indent(+1);
|
||||
println("offset_delta = " + frame.offset_delta);
|
||||
printMap("locals", frame.locals);
|
||||
indent(-1);
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void visit_full_frame(StackMapTable_attribute.full_frame frame, Void p) {
|
||||
printHeader(frame);
|
||||
if (frame instanceof StackMap_attribute.stack_map_frame) {
|
||||
printHeader(frame, "offset = " + frame.offset_delta);
|
||||
indent(+1);
|
||||
println(" offset = " + frame.offset_delta);
|
||||
} else {
|
||||
println(" /* full_frame */");
|
||||
printHeader(frame, "/* full_frame */");
|
||||
indent(+1);
|
||||
println("offset_delta = " + frame.offset_delta);
|
||||
}
|
||||
@ -622,8 +614,9 @@ public class AttributeWriter extends BasicWriter
|
||||
return null;
|
||||
}
|
||||
|
||||
void printHeader(StackMapTable_attribute.stack_map_frame frame) {
|
||||
print(" frame_type = " + frame.frame_type);
|
||||
void printHeader(StackMapTable_attribute.stack_map_frame frame, String extra) {
|
||||
print("frame_type = " + frame.frame_type + " ");
|
||||
println(extra);
|
||||
}
|
||||
|
||||
void printMap(String name, StackMapTable_attribute.verification_type_info[] map) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -151,12 +151,22 @@ public class BasicWriter {
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
switch (c) {
|
||||
case ' ':
|
||||
pendingSpaces++;
|
||||
break;
|
||||
|
||||
case '\n':
|
||||
println();
|
||||
break;
|
||||
|
||||
default:
|
||||
if (buffer.length() == 0)
|
||||
indent();
|
||||
if (pendingSpaces > 0) {
|
||||
for (int sp = 0; sp < pendingSpaces; sp++)
|
||||
buffer.append(' ');
|
||||
pendingSpaces = 0;
|
||||
}
|
||||
buffer.append(c);
|
||||
}
|
||||
}
|
||||
@ -164,6 +174,8 @@ public class BasicWriter {
|
||||
}
|
||||
|
||||
protected void println() {
|
||||
// ignore/discard pending spaces
|
||||
pendingSpaces = 0;
|
||||
out.println(buffer);
|
||||
buffer.setLength(0);
|
||||
}
|
||||
@ -173,26 +185,21 @@ public class BasicWriter {
|
||||
}
|
||||
|
||||
protected void tab() {
|
||||
if (buffer.length() == 0)
|
||||
indent();
|
||||
space(indentCount * indentWidth + tabColumn - buffer.length());
|
||||
int col = indentCount * indentWidth + tabColumn;
|
||||
pendingSpaces += (col <= buffer.length() ? 1 : col - buffer.length());
|
||||
}
|
||||
|
||||
private void indent() {
|
||||
space(indentCount * indentWidth);
|
||||
pendingSpaces += (indentCount * indentWidth);
|
||||
}
|
||||
|
||||
private void space(int n) {
|
||||
for (int i = 0; i < n; i++)
|
||||
buffer.append(' ');
|
||||
}
|
||||
|
||||
private PrintWriter out;
|
||||
private StringBuilder buffer;
|
||||
private final PrintWriter out;
|
||||
private final StringBuilder buffer;
|
||||
private int indentCount;
|
||||
private int indentWidth;
|
||||
private int tabColumn;
|
||||
private final int indentWidth;
|
||||
private final int tabColumn;
|
||||
private boolean pendingNewline;
|
||||
private int pendingSpaces;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -64,7 +64,7 @@ public class ConstantWriter extends BasicWriter {
|
||||
public Integer visitClass(CONSTANT_Class_info info, Void p) {
|
||||
print("#" + info.name_index);
|
||||
tab();
|
||||
println("// " + stringValue(info));
|
||||
println("// " + stringValue(info));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ public class ConstantWriter extends BasicWriter {
|
||||
public Integer visitFieldref(CONSTANT_Fieldref_info info, Void p) {
|
||||
print("#" + info.class_index + ".#" + info.name_and_type_index);
|
||||
tab();
|
||||
println("// " + stringValue(info));
|
||||
println("// " + stringValue(info));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -93,14 +93,14 @@ public class ConstantWriter extends BasicWriter {
|
||||
public Integer visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, Void p) {
|
||||
print("#" + info.class_index + ".#" + info.name_and_type_index);
|
||||
tab();
|
||||
println("// " + stringValue(info));
|
||||
println("// " + stringValue(info));
|
||||
return 1;
|
||||
}
|
||||
|
||||
public Integer visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, Void p) {
|
||||
print("#" + info.bootstrap_method_attr_index + ":#" + info.name_and_type_index);
|
||||
tab();
|
||||
println("// " + stringValue(info));
|
||||
println("// " + stringValue(info));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -112,21 +112,21 @@ public class ConstantWriter extends BasicWriter {
|
||||
public Integer visitNameAndType(CONSTANT_NameAndType_info info, Void p) {
|
||||
print("#" + info.name_index + ":#" + info.type_index);
|
||||
tab();
|
||||
println("// " + stringValue(info));
|
||||
println("// " + stringValue(info));
|
||||
return 1;
|
||||
}
|
||||
|
||||
public Integer visitMethodref(CONSTANT_Methodref_info info, Void p) {
|
||||
print("#" + info.class_index + ".#" + info.name_and_type_index);
|
||||
tab();
|
||||
println("// " + stringValue(info));
|
||||
println("// " + stringValue(info));
|
||||
return 1;
|
||||
}
|
||||
|
||||
public Integer visitMethodHandle(CONSTANT_MethodHandle_info info, Void p) {
|
||||
print("#" + info.reference_kind.tag + ":#" + info.reference_index);
|
||||
tab();
|
||||
println("// " + stringValue(info));
|
||||
println("// " + stringValue(info));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ public class ConstantWriter extends BasicWriter {
|
||||
public Integer visitString(CONSTANT_String_info info, Void p) {
|
||||
print("#" + info.string_index);
|
||||
tab();
|
||||
println("// " + stringValue(info));
|
||||
println("// " + stringValue(info));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,9 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
void process(JavapTask task, String opt, String arg) throws BadArgs {
|
||||
int sep = opt.indexOf(":");
|
||||
try {
|
||||
task.options.indentWidth = Integer.valueOf(opt.substring(sep + 1));
|
||||
int i = Integer.valueOf(opt.substring(sep + 1));
|
||||
if (i > 0) // silently ignore invalid values
|
||||
task.options.indentWidth = i;
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
@ -289,7 +291,9 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
void process(JavapTask task, String opt, String arg) throws BadArgs {
|
||||
int sep = opt.indexOf(":");
|
||||
try {
|
||||
task.options.tabColumn = Integer.valueOf(opt.substring(sep + 1));
|
||||
int i = Integer.valueOf(opt.substring(sep + 1));
|
||||
if (i > 0) // silently ignore invalid values
|
||||
task.options.tabColumn = i;
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
@ -525,8 +529,12 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
}
|
||||
}
|
||||
|
||||
if (fileManager.handleOption(name, rest))
|
||||
return;
|
||||
try {
|
||||
if (fileManager.handleOption(name, rest))
|
||||
return;
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new BadArgs("err.invalid.use.of.option", name).showUsage(true);
|
||||
}
|
||||
|
||||
throw new BadArgs("err.unknown.option", name).showUsage(true);
|
||||
}
|
||||
|
@ -86,6 +86,6 @@ public class Options {
|
||||
public boolean showConstants;
|
||||
public boolean sysInfo;
|
||||
public boolean showInnerClasses;
|
||||
public int indentWidth = 2; // #spaces per indentWidth level
|
||||
public int tabColumn = 40; // column number for comments
|
||||
public int indentWidth = 2; // #spaces per indentWidth level; must be > 0
|
||||
public int tabColumn = 40; // column number for comments; must be > 0
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ err.ioerror=IO error reading {0}: {1}
|
||||
err.missing.arg=no value given for {0}
|
||||
err.no.classes.specified=no classes specified
|
||||
err.not.standard.file.manager=can only specify class files when using a standard file manager
|
||||
err.invalid.use.of.option=invalid use of option: {0}
|
||||
err.unknown.option=unknown option: {0}
|
||||
err.no.SourceFile.attribute=no SourceFile attribute
|
||||
err.source.file.not.found=source file not found
|
||||
@ -77,7 +78,7 @@ main.opt.bootclasspath=\
|
||||
\ -bootclasspath <path> Override location of bootstrap class files
|
||||
|
||||
main.opt.constants=\
|
||||
\ -constants Show static final constants
|
||||
\ -constants Show final constants
|
||||
|
||||
|
||||
main.opt.sysinfo=\
|
||||
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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 6457406
|
||||
* @summary Verify that a link in single quotes copied to the class-use page as is.
|
||||
* @author Yuri Nesterenko
|
||||
* @library ../lib/
|
||||
* @build JavadocTester TestSingleQuotedLink
|
||||
* @run main TestSingleQuotedLink
|
||||
*/
|
||||
public class TestSingleQuotedLink extends JavadocTester {
|
||||
|
||||
private static final String BUG_ID = "6457406";
|
||||
// We are testing the redirection algorithm with a known scenario when a writer is not forced to ignore it: "-use".
|
||||
private static final String[][] TEST = {
|
||||
{BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
|
||||
"<a href=\'http://download.oracle.com/javase/8/docs/technotes/guides/indexC2.html\'>"
|
||||
}
|
||||
};
|
||||
private static final String[][] NEGATED_TEST = {
|
||||
{BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
|
||||
"pkg1/\'http://download.oracle.com/javase/8/docs/technotes/guides/indexC2.html\'>"
|
||||
}
|
||||
};
|
||||
private static final String[] ARGS =
|
||||
new String[]{
|
||||
"-d", BUG_ID, "-sourcepath", SRC_DIR, "-use", "pkg1"
|
||||
};
|
||||
|
||||
/**
|
||||
* The entry point of the test.
|
||||
* @param args the array of command line arguments.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
TestSingleQuotedLink tester = new TestSingleQuotedLink();
|
||||
run(tester, ARGS, TEST, NEGATED_TEST);
|
||||
tester.printSummary();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getBugId() {
|
||||
return BUG_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getBugName() {
|
||||
return getClass().getName();
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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 pkg1;
|
||||
|
||||
/**
|
||||
* Class 1. This is a test.
|
||||
*/
|
||||
public class C1 {}
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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 pkg1;
|
||||
|
||||
/**
|
||||
* Class 2 refers to <a href='http://download.oracle.com/javase/8/docs/technotes/guides/indexC2.html'>Here</a>.
|
||||
* This is a single quoted link.
|
||||
*/
|
||||
public class C2 extends C1 {}
|
||||
|
@ -0,0 +1,14 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>javax.management package</title>
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
This is a test.
|
||||
<p id="spec">
|
||||
<a href='http://download.oracle.com/javase/8/docs/technotes/guides/indexdocument.html'>
|
||||
Another Test document 2.</a> Single quotes also but as of now, package-summary writer excluded from redirection algorithm.
|
||||
|
||||
@since 1.5
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6346249 6392177
|
||||
* @bug 6346249 6392177 6411385
|
||||
* @summary new Trees API
|
||||
*/
|
||||
|
||||
@ -51,6 +51,9 @@ public class TestTrees extends AbstractProcessor {
|
||||
@Anno
|
||||
int annoField;
|
||||
|
||||
@Anno
|
||||
public TestTrees() {
|
||||
}
|
||||
|
||||
static final String testSrcDir = System.getProperty("test.src");
|
||||
static final String testClassDir = System.getProperty("test.classes");
|
||||
@ -75,7 +78,7 @@ public class TestTrees extends AbstractProcessor {
|
||||
Iterable<? extends JavaFileObject> files =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
|
||||
|
||||
Iterable<String> opts = Arrays.asList("-d", ".");
|
||||
Iterable<String> opts = Arrays.asList("-d", ".", "-XDcompilePolicy=simple");
|
||||
|
||||
System.err.println("simple compilation, no processing");
|
||||
JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
|
||||
@ -83,7 +86,8 @@ public class TestTrees extends AbstractProcessor {
|
||||
if (!task.call())
|
||||
throw new AssertionError("compilation failed");
|
||||
|
||||
opts = Arrays.asList("-d", ".", "-processorpath", testClassDir, "-processor", self);
|
||||
opts = Arrays.asList("-d", ".", "-processorpath", testClassDir, "-processor", self,
|
||||
"-XDcompilePolicy=simple");
|
||||
|
||||
System.err.println();
|
||||
System.err.println("compilation with processing");
|
||||
@ -138,7 +142,7 @@ public class TestTrees extends AbstractProcessor {
|
||||
System.err.println("testAnnotation: " + e + " " + a);
|
||||
Tree tree = trees.getTree(e, a);
|
||||
|
||||
if (tree.getKind() != Tree.Kind.ANNOTATION)
|
||||
if (tree.getKind() != Tree.Kind.ANNOTATION && tree.getKind() != Tree.Kind.TYPE_ANNOTATION)
|
||||
error("bad result from getTree");
|
||||
|
||||
TreePath path = trees.getPath(e, a);
|
||||
@ -146,6 +150,36 @@ public class TestTrees extends AbstractProcessor {
|
||||
error("bad result from getPath");
|
||||
}
|
||||
|
||||
void testAllDeclarations(Trees trees, CompilationUnitTree cut) {
|
||||
new TreePathScanner<Void, Void>() {
|
||||
@Override public Void scan(Tree tree, Void p) {
|
||||
if (tree == null) return null;
|
||||
switch (tree.getKind()) {
|
||||
case METHOD: case CLASS: case VARIABLE: case TYPE_PARAMETER:
|
||||
TreePath path = new TreePath(getCurrentPath(), tree);
|
||||
Element el = trees.getElement(path);
|
||||
if (el == null) {
|
||||
error("null element");
|
||||
} else {
|
||||
TreePath inferred = trees.getPath(el);
|
||||
if (inferred == null) {
|
||||
error("null path");
|
||||
} else {
|
||||
if (inferred.getLeaf() != path.getLeaf())
|
||||
error("bad result from getPath");
|
||||
}
|
||||
if (trees.getTree(el) != path.getLeaf())
|
||||
error("bad result from getTree");
|
||||
for (AnnotationMirror m: el.getAnnotationMirrors()) {
|
||||
testAnnotation(trees, el, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.scan(tree, p);
|
||||
}
|
||||
}.scan(cut, null);
|
||||
}
|
||||
|
||||
void error(String msg) {
|
||||
if (messager != null)
|
||||
// annotation processing will happen in a separate instance/classloader
|
||||
@ -202,6 +236,7 @@ public class TestTrees extends AbstractProcessor {
|
||||
switch (e.getKind()) {
|
||||
case ANALYZE:
|
||||
testElement(Trees.instance(task), e.getTypeElement());
|
||||
testAllDeclarations(Trees.instance(task), e.getCompilationUnit());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -209,8 +244,19 @@ public class TestTrees extends AbstractProcessor {
|
||||
private final JavacTask task;
|
||||
}
|
||||
|
||||
public static class TestTypeParams<@Anno T extends CharSequence> {
|
||||
public <@Anno T extends Object> TestTypeParams(T param) { }
|
||||
public <@Anno T extends Number> void m(T param) {
|
||||
int local;
|
||||
try {
|
||||
new String();
|
||||
} catch (Exception exc) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE_PARAMETER,
|
||||
ElementType.FIELD, ElementType.LOCAL_VARIABLE})
|
||||
@interface Anno {
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,20 +23,21 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8029240
|
||||
* @bug 8029240 8030855
|
||||
* @summary Default methods not always visible under -source 7
|
||||
* Default methods should be visible under source previous to 8
|
||||
* @library /tools/javac/lib
|
||||
* @build ToolBox
|
||||
* @run main DefaultMethodsNotVisibileForSource7Test
|
||||
* @run main DefaultMethodsNotVisibleForSourceLessThan8Test
|
||||
*/
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class DefaultMethodsNotVisibileForSource7Test {
|
||||
public class DefaultMethodsNotVisibleForSourceLessThan8Test {
|
||||
// common definitions
|
||||
|
||||
// this one should be compiled with source 8, the rest with source 7
|
||||
// this one should be compiled with source 8, the rest with source < 8
|
||||
static final String ISrc =
|
||||
"interface I {\n" +
|
||||
" default void m() {}\n" +
|
||||
@ -54,22 +55,22 @@ public class DefaultMethodsNotVisibileForSource7Test {
|
||||
// test legacy implementations
|
||||
static final String C1Src =
|
||||
"class C1 implements I {\n" +
|
||||
" @Override public void m() {}\n" +
|
||||
" public void m() {}\n" +
|
||||
"}";
|
||||
|
||||
static final String C2Src =
|
||||
"class C2 implements J {\n" +
|
||||
" @Override public void m() {}\n" +
|
||||
" public void m() {}\n" +
|
||||
"}";
|
||||
|
||||
static final String C3Src =
|
||||
"class C3 extends A {\n" +
|
||||
" @Override public void m() {}\n" +
|
||||
" public void m() {}\n" +
|
||||
"}";
|
||||
|
||||
static final String C4Src =
|
||||
"class C4 extends B {\n" +
|
||||
" @Override public void m() {}\n" +
|
||||
" public void m() {}\n" +
|
||||
"}";
|
||||
|
||||
//test legacy invocations
|
||||
@ -99,10 +100,25 @@ public class DefaultMethodsNotVisibileForSource7Test {
|
||||
"}";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new DefaultMethodsNotVisibileForSource7Test().run();
|
||||
String[] sources = new String[] {
|
||||
"1.2",
|
||||
"1.3",
|
||||
"1.4",
|
||||
"1.5",
|
||||
"1.6",
|
||||
"1.7",
|
||||
};
|
||||
for (String source : sources) {
|
||||
new DefaultMethodsNotVisibleForSourceLessThan8Test().run(source);
|
||||
}
|
||||
}
|
||||
|
||||
void run() throws Exception {
|
||||
String outDir;
|
||||
String source;
|
||||
|
||||
void run(String source) throws Exception {
|
||||
this.source = source;
|
||||
outDir = "out" + source.replace('.', '_');
|
||||
testsPreparation();
|
||||
testLegacyImplementations();
|
||||
testLegacyInvocations();
|
||||
@ -110,27 +126,27 @@ public class DefaultMethodsNotVisibileForSource7Test {
|
||||
}
|
||||
|
||||
void testsPreparation() throws Exception {
|
||||
Files.createDirectory(Paths.get("out"));
|
||||
Files.createDirectory(Paths.get(outDir));
|
||||
|
||||
/* as an extra check let's make sure that interface 'I' can't be compiled
|
||||
* with source 7
|
||||
* with source < 8
|
||||
*/
|
||||
ToolBox.JavaToolArgs javacArgs =
|
||||
new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
|
||||
.setOptions("-d", "out", "-source", "7")
|
||||
.setOptions("-d", outDir, "-source", source)
|
||||
.setSources(ISrc);
|
||||
ToolBox.javac(javacArgs);
|
||||
|
||||
//but it should compile with source >= 8
|
||||
javacArgs =
|
||||
new ToolBox.JavaToolArgs()
|
||||
.setOptions("-d", "out")
|
||||
.setOptions("-d", outDir)
|
||||
.setSources(ISrc);
|
||||
ToolBox.javac(javacArgs);
|
||||
|
||||
javacArgs =
|
||||
new ToolBox.JavaToolArgs()
|
||||
.setOptions("-cp", "out", "-d", "out", "-source", "7")
|
||||
.setOptions("-cp", outDir, "-d", outDir, "-source", source)
|
||||
.setSources(JSrc, ASrc, BSrc);
|
||||
ToolBox.javac(javacArgs);
|
||||
}
|
||||
@ -139,7 +155,7 @@ public class DefaultMethodsNotVisibileForSource7Test {
|
||||
//compile C1-4
|
||||
ToolBox.JavaToolArgs javacArgs =
|
||||
new ToolBox.JavaToolArgs()
|
||||
.setOptions("-cp", "out", "-d", "out", "-source", "7")
|
||||
.setOptions("-cp", outDir, "-d", outDir, "-source", source)
|
||||
.setSources(C1Src, C2Src, C3Src, C4Src);
|
||||
ToolBox.javac(javacArgs);
|
||||
}
|
||||
@ -148,7 +164,7 @@ public class DefaultMethodsNotVisibileForSource7Test {
|
||||
//compile LegacyInvocation
|
||||
ToolBox.JavaToolArgs javacArgs =
|
||||
new ToolBox.JavaToolArgs()
|
||||
.setOptions("-cp", "out", "-d", "out", "-source", "7")
|
||||
.setOptions("-cp", outDir, "-d", outDir, "-source", source)
|
||||
.setSources(LegacyInvocationSrc);
|
||||
ToolBox.javac(javacArgs);
|
||||
}
|
||||
@ -157,7 +173,7 @@ public class DefaultMethodsNotVisibileForSource7Test {
|
||||
//compile SubA, SubB
|
||||
ToolBox.JavaToolArgs javacArgs =
|
||||
new ToolBox.JavaToolArgs()
|
||||
.setOptions("-cp", "out", "-d", "out", "-source", "7")
|
||||
.setOptions("-cp", outDir, "-d", outDir, "-source", source)
|
||||
.setSources(SubASrc, SubBSrc);
|
||||
ToolBox.javac(javacArgs);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,6 +31,7 @@ import java.io.*;
|
||||
import java.util.*;
|
||||
import javax.tools.*;
|
||||
import com.sun.tools.classfile.*;
|
||||
import com.sun.tools.javac.code.Lint.LintCategory;
|
||||
|
||||
/**
|
||||
* Compare string constants in javac classes against keys in javac resource bundles.
|
||||
@ -156,6 +157,20 @@ public class CheckResourceKeys {
|
||||
if (needToInvestigate.contains(rk))
|
||||
continue;
|
||||
|
||||
//check lint description keys:
|
||||
if (s.startsWith("opt.Xlint.desc.")) {
|
||||
String option = s.substring(15);
|
||||
boolean found = false;
|
||||
|
||||
for (LintCategory lc : LintCategory.values()) {
|
||||
if (option.equals(lc.option))
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (found)
|
||||
continue;
|
||||
}
|
||||
|
||||
error("Resource key not found in code: " + rk);
|
||||
}
|
||||
}
|
||||
@ -274,6 +289,7 @@ public class CheckResourceKeys {
|
||||
// prefix/embedded strings
|
||||
"compiler.",
|
||||
"compiler.misc.",
|
||||
"opt.Xlint.desc.",
|
||||
"count.",
|
||||
"illegal.",
|
||||
"javac.",
|
||||
|
24
langtools/test/tools/javac/implicitCompile/Implicit.java
Normal file
24
langtools/test/tools/javac/implicitCompile/Implicit.java
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
class Implicit {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8030714
|
||||
* @summary make sure attribute and flow is skipped for implicit classes
|
||||
* @compile/ref=SkipAttrFlowGenForImplicits.out -XDverboseCompilePolicy -implicit:none SkipAttrFlowGenForImplicits.java
|
||||
*/
|
||||
class Explicit {
|
||||
Implicit implicit;
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
[attribute Explicit]
|
||||
[flow Explicit]
|
||||
[desugar Explicit]
|
||||
[generate code Explicit]
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 7150368 8003412 8000407
|
||||
* @bug 7150368 8003412 8000407 8031545
|
||||
* @summary javac should include basic ability to generate native headers
|
||||
*/
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -129,50 +129,52 @@ public class TestClass1 {
|
||||
native List<String>[] gaamn();
|
||||
|
||||
// overloaded Java methods
|
||||
byte bm1() { return 0; }
|
||||
short sm1() { return 0; }
|
||||
int im1() { return 0; }
|
||||
long lm1() { return 0; }
|
||||
float fm1() { return 0; }
|
||||
double dm1() { return 0; }
|
||||
Object om1() { return null; }
|
||||
String tm1() { return ""; }
|
||||
List<String> gm1() { return null; }
|
||||
void vm1() { }
|
||||
byte bmo() { return 0; }
|
||||
short smo() { return 0; }
|
||||
int imo() { return 0; }
|
||||
long lmo() { return 0; }
|
||||
float fmo() { return 0; }
|
||||
double dmo() { return 0; }
|
||||
Object omo() { return null; }
|
||||
String tmo() { return ""; }
|
||||
List<String> gmo() { return null; }
|
||||
void vmo() { }
|
||||
|
||||
byte bm2(int i) { return 0; }
|
||||
short sm2(int i) { return 0; }
|
||||
int im2(int i) { return 0; }
|
||||
long lm2(int i) { return 0; }
|
||||
float fm2(int i) { return 0; }
|
||||
double dm2(int i) { return 0; }
|
||||
Object om2(int i) { return null; }
|
||||
String tm2(int i) { return ""; }
|
||||
List<String> gm2(int i) { return null; }
|
||||
void vm2(int i) { }
|
||||
byte bmo(int i) { return 0; }
|
||||
short smo(int i) { return 0; }
|
||||
int imo(int i) { return 0; }
|
||||
long lmo(int i) { return 0; }
|
||||
float fmo(int i) { return 0; }
|
||||
double dmo(int i) { return 0; }
|
||||
Object omo(int i) { return null; }
|
||||
String tmo(int i) { return ""; }
|
||||
List<String> gmo(int i) { return null; }
|
||||
void vmo(int i) { }
|
||||
|
||||
// overloaded native methods
|
||||
native byte bmn1();
|
||||
native short smn1();
|
||||
native int imn1();
|
||||
native long lmn1();
|
||||
native float fmn1();
|
||||
native double dmn1();
|
||||
native Object omn1();
|
||||
native String tmn1();
|
||||
native List<String> gmn1();
|
||||
native void vmn1();
|
||||
native byte bmno();
|
||||
native short smno();
|
||||
native int imno();
|
||||
native long lmno();
|
||||
native float fmno();
|
||||
native double dmno();
|
||||
native Object omno();
|
||||
native String tmno();
|
||||
native List<String> gmno();
|
||||
native void vmno();
|
||||
native Inner1 icmno();
|
||||
|
||||
native byte bmn2(int i);
|
||||
native short smn2(int i);
|
||||
native int imn2(int i);
|
||||
native long lmn2(int i);
|
||||
native float fmn2(int i);
|
||||
native double dmn2(int i);
|
||||
native Object omn2(int i);
|
||||
native String tmn2(int i);
|
||||
native List<String> gmn2(int i);
|
||||
native void vmn2(int i);
|
||||
native byte bmno(int i);
|
||||
native short smno(int i);
|
||||
native int imno(int i);
|
||||
native long lmno(int i);
|
||||
native float fmno(int i);
|
||||
native double dmno(int i);
|
||||
native Object omno(int i);
|
||||
native String tmno(int i);
|
||||
native List<String> gmno(int i);
|
||||
native void vmno(int i);
|
||||
native Inner1 icmno(Inner1 in1);
|
||||
|
||||
// arg types for Java methods
|
||||
void mb(byte b) { }
|
||||
@ -266,50 +268,50 @@ public class TestClass1 {
|
||||
native void vmn();
|
||||
|
||||
// overloaded Java methods
|
||||
byte bm1() { return 0; }
|
||||
short sm1() { return 0; }
|
||||
int im1() { return 0; }
|
||||
long lm1() { return 0; }
|
||||
float fm1() { return 0; }
|
||||
double dm1() { return 0; }
|
||||
Object om1() { return null; }
|
||||
String tm1() { return ""; }
|
||||
List<String> gm1() { return null; }
|
||||
void vm1() { }
|
||||
byte bmo() { return 0; }
|
||||
short smo() { return 0; }
|
||||
int imo() { return 0; }
|
||||
long lmo() { return 0; }
|
||||
float fmo() { return 0; }
|
||||
double dmo() { return 0; }
|
||||
Object omo() { return null; }
|
||||
String tmo() { return ""; }
|
||||
List<String> gmo() { return null; }
|
||||
void vmo() { }
|
||||
|
||||
byte bm2(int i) { return 0; }
|
||||
short sm2(int i) { return 0; }
|
||||
int im2(int i) { return 0; }
|
||||
long lm2(int i) { return 0; }
|
||||
float fm2(int i) { return 0; }
|
||||
double dm2(int i) { return 0; }
|
||||
Object om2(int i) { return null; }
|
||||
String tm2(int i) { return ""; }
|
||||
List<String> gm2(int i) { return null; }
|
||||
void vm2(int i) { }
|
||||
byte bmo(int i) { return 0; }
|
||||
short smo(int i) { return 0; }
|
||||
int imo(int i) { return 0; }
|
||||
long lmo(int i) { return 0; }
|
||||
float fmo(int i) { return 0; }
|
||||
double dmo(int i) { return 0; }
|
||||
Object omo(int i) { return null; }
|
||||
String tmo(int i) { return ""; }
|
||||
List<String> gmo(int i) { return null; }
|
||||
void vmo(int i) { }
|
||||
|
||||
// overloaded native methods
|
||||
native byte bmn1();
|
||||
native short smn1();
|
||||
native int imn1();
|
||||
native long lmn1();
|
||||
native float fmn1();
|
||||
native double dmn1();
|
||||
native Object omn1();
|
||||
native String tmn1();
|
||||
native List<String> gmn1();
|
||||
native void vmn1();
|
||||
native byte bmno();
|
||||
native short smno();
|
||||
native int imno();
|
||||
native long lmno();
|
||||
native float fmno();
|
||||
native double dmno();
|
||||
native Object omno();
|
||||
native String tmno();
|
||||
native List<String> gmno();
|
||||
native void vmno();
|
||||
|
||||
native byte bmn2(int i);
|
||||
native short smn2(int i);
|
||||
native int imn2(int i);
|
||||
native long lmn2(int i);
|
||||
native float fmn2(int i);
|
||||
native double dmn2(int i);
|
||||
native Object omn2(int i);
|
||||
native String tmn2(int i);
|
||||
native List<String> gmn2(int i);
|
||||
native void vmn2(int i);
|
||||
native byte bmno(int i);
|
||||
native short smno(int i);
|
||||
native int imno(int i);
|
||||
native long lmno(int i);
|
||||
native float fmno(int i);
|
||||
native double dmno(int i);
|
||||
native Object omno(int i);
|
||||
native String tmno(int i);
|
||||
native List<String> gmno(int i);
|
||||
native void vmno(int i);
|
||||
|
||||
// arg types for Java methods
|
||||
void mb(byte b) { }
|
||||
|
59
langtools/test/tools/javac/parser/T4910483.java
Normal file
59
langtools/test/tools/javac/parser/T4910483.java
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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 4910483
|
||||
* @summary javac shouldn't throw NPE while compiling invalid RuntimeInvisibleParameterAnnotations
|
||||
* @run main T4910483
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.sun.tools.javac.main.JavaCompiler;
|
||||
import com.sun.tools.javac.file.JavacFileManager;
|
||||
import com.sun.tools.javac.tree.JCTree;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
/**Test comment abc*\\def*/
|
||||
public class T4910483 {
|
||||
public static void main(String... args) {
|
||||
JavaCompiler compiler = JavaCompiler.instance(new Context());
|
||||
compiler.keepComments = true;
|
||||
|
||||
String testSrc = System.getProperty("test.src");
|
||||
JavacFileManager fm = new JavacFileManager(new Context(), false, null);
|
||||
JavaFileObject f = fm.getFileForInput(testSrc + File.separatorChar + "T4910483.java");
|
||||
|
||||
JCTree.JCCompilationUnit cu = compiler.parse(f);
|
||||
JCTree classDef = cu.getTypeDecls().head;
|
||||
String commentText = cu.docComments.getCommentText(classDef);
|
||||
|
||||
String expected = "Test comment abc*\\\\def"; // 4 '\' escapes to 2 in a string literal
|
||||
if (!expected.equals(commentText)) {
|
||||
throw new AssertionError("Incorrect comment text: [" + commentText + "], expected [" + expected + "]");
|
||||
}
|
||||
}
|
||||
}
|
@ -184,8 +184,7 @@ public class ProfileOptionTest {
|
||||
com.sun.security.auth.PolicyFile.class); // specifically included in 3
|
||||
|
||||
init(Profile.DEFAULT,
|
||||
java.beans.BeanInfo.class,
|
||||
javax.management.remote.rmi._RMIServer_Stub.class); // specifically excluded in 3
|
||||
java.beans.BeanInfo.class);
|
||||
}
|
||||
|
||||
void init(Profile p, Class<?>... classes) {
|
||||
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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 8033961
|
||||
* @summary Verify that all LintCategories have their descriptions filled.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import com.sun.tools.javac.code.Lint.LintCategory;
|
||||
import com.sun.tools.javac.util.Log.PrefixKind;
|
||||
|
||||
public class VerifyLintDescriptions {
|
||||
public static void main(String... args) {
|
||||
ResourceBundle b = ResourceBundle.getBundle("com.sun.tools.javac.resources.javac",
|
||||
Locale.US);
|
||||
|
||||
List<String> missing = new ArrayList<>();
|
||||
|
||||
for (LintCategory lc : LintCategory.values()) {
|
||||
try {
|
||||
b.getString(PrefixKind.JAVAC.key("opt.Xlint.desc." + lc.option));
|
||||
} catch (MissingResourceException ex) {
|
||||
missing.add(lc.option);
|
||||
}
|
||||
}
|
||||
|
||||
if (!missing.isEmpty()) {
|
||||
throw new UnsupportedOperationException("Lints that are missing description: " + missing);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
16
langtools/test/tools/javac/warnings/suppress/Overridden.java
Normal file
16
langtools/test/tools/javac/warnings/suppress/Overridden.java
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8033421
|
||||
* @summary Check that \\@SuppressWarnings works properly when overriding deprecated method.
|
||||
* @build VerifySuppressWarnings
|
||||
* @compile/ref=Overridden.out -XDrawDiagnostics -Xlint:deprecation Overridden.java
|
||||
* @run main VerifySuppressWarnings Overridden.java
|
||||
*/
|
||||
|
||||
public class Overridden implements Interface {
|
||||
public void test() { }
|
||||
}
|
||||
|
||||
interface Interface {
|
||||
@Deprecated void test();
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
Overridden.java:11:17: compiler.warn.has.been.deprecated: test(), Interface
|
||||
1 warning
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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 8033421
|
||||
* @summary Check that \\@SuppressWarnings works properly when overriding deprecated method.
|
||||
* @compile -Werror -Xlint:deprecation OverriddenSuppressed.java
|
||||
*/
|
||||
|
||||
public class OverriddenSuppressed implements Interface {
|
||||
@SuppressWarnings("deprecation")
|
||||
public void test() { }
|
||||
}
|
||||
|
||||
interface Interface {
|
||||
@Deprecated void test();
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,8 +23,8 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 7091528
|
||||
* @summary javadoc attempts to parse .class files
|
||||
* @bug 7091528 8029145
|
||||
* @summary ensures javadoc parses unique source files and ignores all class files
|
||||
* @compile p/C1.java p/q/C2.java
|
||||
* @run main T7091528
|
||||
*/
|
||||
@ -37,17 +37,22 @@ public class T7091528 {
|
||||
public static void main(String... args) {
|
||||
new T7091528().run();
|
||||
}
|
||||
|
||||
void run() {
|
||||
File testSrc = new File(System.getProperty("test.src"));
|
||||
File testClasses = new File(System.getProperty("test.classes"));
|
||||
String[] args = {
|
||||
"-d", ".",
|
||||
// 7091528, tests if class files are being ignored
|
||||
runTest("-d", ".",
|
||||
"-sourcepath", testClasses + File.pathSeparator + testSrc,
|
||||
"-subpackages",
|
||||
"p"
|
||||
};
|
||||
"p");
|
||||
// 8029145, tests if unique source files are parsed
|
||||
runTest("-d", ".",
|
||||
"-sourcepath", testSrc.getAbsolutePath(),
|
||||
"-subpackages",
|
||||
"p:p.q");
|
||||
|
||||
}
|
||||
void runTest(String... args) {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
String doclet = com.sun.tools.doclets.standard.Standard.class.getName();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -44,24 +44,24 @@ public class MethodParameters {
|
||||
static final String Init0_expected =
|
||||
(" Foo();\n" +
|
||||
" descriptor: ()V\n" +
|
||||
" flags: \n" +
|
||||
" flags:\n" +
|
||||
" Code:\n" +
|
||||
" stack=1, locals=1, args_size=1\n" +
|
||||
" 0: aload_0 \n" +
|
||||
" 0: aload_0\n" +
|
||||
" 1: invokespecial #1 // Method java/lang/Object.\"<init>\":()V\n" +
|
||||
" 4: return \n" +
|
||||
" 4: return\n" +
|
||||
" LineNumberTable:\n" +
|
||||
" line 2: 0").replaceAll(" +", " ");
|
||||
|
||||
static final String Init1_expected =
|
||||
(" Foo(int);\n" +
|
||||
" descriptor: (I)V\n" +
|
||||
" flags: \n" +
|
||||
" flags:\n" +
|
||||
" Code:\n" +
|
||||
" stack=1, locals=2, args_size=2\n" +
|
||||
" 0: aload_0 \n" +
|
||||
" 0: aload_0\n" +
|
||||
" 1: invokespecial #1 // Method java/lang/Object.\"<init>\":()V\n" +
|
||||
" 4: return \n" +
|
||||
" 4: return\n" +
|
||||
" LineNumberTable:\n" +
|
||||
" line 3: 0\n" +
|
||||
" MethodParameters:\n" +
|
||||
@ -71,25 +71,25 @@ public class MethodParameters {
|
||||
static final String foo0_expected =
|
||||
(" void foo0();\n" +
|
||||
" descriptor: ()V\n" +
|
||||
" flags: \n" +
|
||||
" flags:\n" +
|
||||
" Code:\n" +
|
||||
" stack=0, locals=1, args_size=1\n" +
|
||||
" 0: return \n" +
|
||||
" 0: return\n" +
|
||||
" LineNumberTable:\n" +
|
||||
" line 4: 0").replaceAll(" +", " ");
|
||||
|
||||
static final String foo2_expected =
|
||||
(" void foo2(int, int);\n" +
|
||||
" descriptor: (II)V\n" +
|
||||
" flags: \n" +
|
||||
" flags:\n" +
|
||||
" Code:\n" +
|
||||
" stack=0, locals=3, args_size=3\n" +
|
||||
" 0: return \n" +
|
||||
" 0: return\n" +
|
||||
" LineNumberTable:\n" +
|
||||
" line 5: 0\n" +
|
||||
" MethodParameters:\n" +
|
||||
" Name Flags\n" +
|
||||
" j \n" +
|
||||
" j\n" +
|
||||
" k").replaceAll(" +", " ");
|
||||
|
||||
static final File classesdir = new File("methodparameters");
|
||||
|
92
langtools/test/tools/javap/StackMapTableTest.java
Normal file
92
langtools/test/tools/javap/StackMapTableTest.java
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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 8033930 8033913
|
||||
* @summary bad formatting of StackMapTable entries
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class StackMapTableTest {
|
||||
public static void main(String... args) throws Exception {
|
||||
new StackMapTableTest().run();
|
||||
}
|
||||
|
||||
void run() throws Exception {
|
||||
String testClasses = System.getProperty("test.classes");
|
||||
String out = javap("-v", "-classpath", testClasses, A.class.getName());
|
||||
|
||||
String nl = System.getProperty("line.separator");
|
||||
out = out.replaceAll(nl, "\n");
|
||||
|
||||
if (out.contains("\n\n\n"))
|
||||
error("double blank line found");
|
||||
|
||||
String expect =
|
||||
" StackMapTable: number_of_entries = 2\n" +
|
||||
" frame_type = 252 /* append */\n" +
|
||||
" offset_delta = 2\n" +
|
||||
" locals = [ int ]\n" +
|
||||
" frame_type = 250 /* chop */\n" +
|
||||
" offset_delta = 18\n";
|
||||
if (!out.contains(expect))
|
||||
error("expected text not found");
|
||||
|
||||
if (errors > 0)
|
||||
throw new Exception(errors + " errors found");
|
||||
}
|
||||
|
||||
String javap(String... args) throws Exception {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter out = new PrintWriter(sw);
|
||||
int rc = com.sun.tools.javap.Main.run(args, out);
|
||||
out.close();
|
||||
System.out.println(sw.toString());
|
||||
if (rc < 0)
|
||||
throw new Exception("javap exited, rc=" + rc);
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
void error(String msg) {
|
||||
System.out.println("Error: " + msg);
|
||||
errors++;
|
||||
}
|
||||
|
||||
int errors;
|
||||
|
||||
/** Simple test class to run through javap. */
|
||||
public class A {
|
||||
public void a() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
public void b() {
|
||||
}
|
||||
public void c() {
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6868539 6868548
|
||||
* @bug 6868539 6868548 8035364
|
||||
* @summary javap should use current names for constant pool entries,
|
||||
* remove spurious ';' from constant pool entries
|
||||
*/
|
||||
@ -41,17 +41,17 @@ public class T6868539
|
||||
void run() {
|
||||
String output = javap("T6868539");
|
||||
verify(output, "Utf8 +java/lang/String"); // 1: Utf8
|
||||
// 2: currently unused
|
||||
// 2: currently unused
|
||||
verify(output, "Integer +123456"); // 3: Integer
|
||||
verify(output, "Float +123456.0f"); // 4: Float
|
||||
verify(output, "Long +123456l"); // 5: Long
|
||||
verify(output, "Double +123456.0d"); // 6: Double
|
||||
verify(output, "Class +#[0-9]+ +// + T6868539"); // 7: Class
|
||||
verify(output, "String +#[0-9]+ +// + not found"); // 8: String
|
||||
verify(output, "Class +#[0-9]+ +// +T6868539"); // 7: Class
|
||||
verify(output, "String +#[0-9]+ +// +not found"); // 8: String
|
||||
verify(output, "Fieldref +#[0-9]+\\.#[0-9]+ +// +T6868539.errors:I"); // 9: Fieldref
|
||||
verify(output, "Methodref +#[0-9]+\\.#[0-9]+ +// +T6868539.run:\\(\\)V"); // 10: Methodref
|
||||
verify(output, "InterfaceMethodref +#[0-9]+\\.#[0-9]+ +// +java/lang/Runnable\\.run:\\(\\)V");
|
||||
// 11: InterfaceMethodref
|
||||
// 11: InterfaceMethodref
|
||||
verify(output, "NameAndType +#[0-9]+:#[0-9]+ +// +run:\\(\\)V"); // 12: NameAndType
|
||||
if (errors > 0)
|
||||
throw new Error(errors + " found.");
|
||||
|
55
langtools/test/tools/javap/T8033711.java
Normal file
55
langtools/test/tools/javap/T8033711.java
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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 8033711
|
||||
* @summary An exception is thrown if using the "-classpath" option with no arguments
|
||||
*/
|
||||
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class T8033711 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
new T8033711().run();
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
String out = javap("-classpath");
|
||||
if (out.contains("IllegalArgumentException"))
|
||||
throw new Exception("exception found in javap output");
|
||||
if (!out.contains("Error: invalid use of option"))
|
||||
throw new Exception("expected error message not found in javap output");
|
||||
}
|
||||
|
||||
String javap(String... args) {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter out = new PrintWriter(sw);
|
||||
int rc = com.sun.tools.javap.Main.run(args, out);
|
||||
out.close();
|
||||
System.out.println(sw.toString());
|
||||
System.out.println("javap exited, rc=" + rc);
|
||||
return sw.toString();
|
||||
}
|
||||
}
|
93
langtools/test/tools/javap/WhitespaceTest.java
Normal file
93
langtools/test/tools/javap/WhitespaceTest.java
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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 8033581 8033798 8033726
|
||||
* @summary Check whitespace in generated output
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class WhitespaceTest {
|
||||
public static void main(String... args) throws Exception {
|
||||
new WhitespaceTest().run();
|
||||
}
|
||||
|
||||
void run() throws Exception {
|
||||
test("-v", "java.lang.String");
|
||||
test("-XDtab:1", "-v", "java.lang.String");
|
||||
|
||||
String testClasses = System.getProperty("test.classes");
|
||||
for (int i = 10; i < 40; i++)
|
||||
test("-XDtab:" + i, "-v", "-classpath", testClasses, "WhitespaceTest$HelloWorld");
|
||||
|
||||
if (errors > 0)
|
||||
throw new Exception(errors + " errors found");
|
||||
}
|
||||
|
||||
void test(String... args) throws Exception {
|
||||
// need to avoid "//" appearing as a constant in the constant pool
|
||||
String slash = "/";
|
||||
String doubleSlash = slash + slash;
|
||||
System.out.println("test: " + Arrays.asList(args));
|
||||
String out = javap(args);
|
||||
for (String line: out.split("[\r\n]+")) {
|
||||
if (line.endsWith(" "))
|
||||
error("line has trailing whitespace: " + line);
|
||||
int comment = line.indexOf(doubleSlash);
|
||||
if (comment > 0 && line.charAt(comment - 1) != ' ')
|
||||
error("no space before comment: " + line);
|
||||
if (line.matches(" +}"))
|
||||
error("bad indentation: " + line);
|
||||
}
|
||||
}
|
||||
|
||||
String javap(String... args) throws Exception {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter out = new PrintWriter(sw);
|
||||
int rc = com.sun.tools.javap.Main.run(args, out);
|
||||
out.close();
|
||||
System.out.println(sw.toString());
|
||||
if (rc < 0)
|
||||
throw new Exception("javap exited, rc=" + rc);
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
void error(String msg) {
|
||||
System.out.println("Error: " + msg);
|
||||
errors++;
|
||||
}
|
||||
|
||||
int errors;
|
||||
|
||||
// small class to test repeatedly with different tab values
|
||||
static class HelloWorld {
|
||||
public static void main(String... args) {
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user