This commit is contained in:
Lana Steuck 2013-05-29 16:59:36 -07:00
commit 9c5e38248f
35 changed files with 609 additions and 345 deletions

View File

@ -230,9 +230,9 @@ public class GenStubs {
tree.typarams = translateTypeParams(tree.typarams);
tree.params = translateVarDefs(tree.params);
tree.thrown = translate(tree.thrown);
if (tree.restype != null && tree.body != null) {
if (tree.body != null) {
if ((currClassMods & Flags.INTERFACE) != 0) {
tree.mods.flags &= ~Flags.DEFAULT;
tree.mods.flags &= ~(Flags.DEFAULT | Flags.STATIC);
} else {
tree.mods.flags |= Flags.NATIVE;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,6 +29,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import static com.sun.tools.classfile.AccessFlags.*;
@ -46,6 +47,11 @@ public class ClassFile {
return read(file, new Attribute.Factory());
}
public static ClassFile read(Path path)
throws IOException, ConstantPoolException {
return read(path.toFile(), new Attribute.Factory());
}
public static ClassFile read(File file, Attribute.Factory attributeFactory)
throws IOException, ConstantPoolException {
FileInputStream in = new FileInputStream(file);

View File

@ -3732,7 +3732,7 @@ public class Attr extends JCTree.Visitor {
noteWarner);
return chk.checkMethod(owntype, sym, env, argtrees, argtypes, env.info.lastResolveVarargs(),
noteWarner.hasNonSilentLint(LintCategory.UNCHECKED));
noteWarner.hasNonSilentLint(LintCategory.UNCHECKED), resultInfo.checkContext.inferenceContext());
} catch (Infer.InferenceException ex) {
//invalid target type - propagate exception outwards or report error
//depending on the current check context

View File

@ -853,7 +853,8 @@ public class Check {
final List<JCExpression> argtrees,
List<Type> argtypes,
boolean useVarargs,
boolean unchecked) {
boolean unchecked,
InferenceContext inferenceContext) {
// System.out.println("call : " + env.tree);
// System.out.println("method : " + owntype);
// System.out.println("actuals: " + argtypes);
@ -917,7 +918,7 @@ public class Check {
argtype);
}
if (!((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types)) {
TreeInfo.setVarargsElement(env.tree, types.elemtype(argtype));
setVarargsElement(env, types.elemtype(argtype), inferenceContext);
}
}
PolyKind pkind = (sym.type.hasTag(FORALL) &&
@ -927,6 +928,17 @@ public class Check {
return owntype;
}
//where
private void setVarargsElement(final Env<AttrContext> env, final Type elemtype, InferenceContext inferenceContext) {
if (inferenceContext.free(elemtype)) {
inferenceContext.addFreeTypeListener(List.of(elemtype), new FreeTypeListener() {
public void typesInferred(InferenceContext inferenceContext) {
setVarargsElement(env, inferenceContext.asInstType(elemtype), inferenceContext);
}
});
}
TreeInfo.setVarargsElement(env.tree, elemtype);
}
private void assertConvertible(JCTree tree, Type actual, Type formal, Warner warn) {
if (types.isConvertible(actual, formal, warn))
return;

View File

@ -2002,7 +2002,7 @@ public class Lower extends TreeTranslator {
JCStatement rethrow;
if (target.hasInitCause()) {
// rethrow = "throw new NoClassDefFoundError().initCause(e);
JCTree throwExpr =
JCExpression throwExpr =
makeCall(makeNewClass(syms.noClassDefFoundErrorType,
List.<JCExpression>nil()),
names.initCause,
@ -2931,7 +2931,7 @@ public class Lower extends TreeTranslator {
}
result =
make.If(cond,
make_at(detailPos).
make_at(tree).
Throw(makeNewClass(syms.assertionErrorType, exnArgs)),
null);
} else {

View File

@ -1343,7 +1343,7 @@ public class Resolve {
try {
Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes,
allowBoxing, useVarargs, types.noWarnings);
if (!operator)
if (!operator || verboseResolutionMode.contains(VerboseResolutionMode.PREDEF))
currentResolutionContext.addApplicableCandidate(sym, mt);
} catch (InapplicableMethodException ex) {
if (!operator)
@ -2500,17 +2500,21 @@ public class Resolve {
try {
currentResolutionContext = new MethodResolutionContext();
Name name = treeinfo.operatorName(optag);
env.info.pendingResolutionPhase = currentResolutionContext.step = BASIC;
Symbol sym = findMethod(env, syms.predefClass.type, name, argtypes,
null, false, false, true);
if (boxingEnabled && sym.kind >= WRONG_MTHS)
env.info.pendingResolutionPhase = currentResolutionContext.step = BOX;
sym = findMethod(env, syms.predefClass.type, name, argtypes,
null, true, false, true);
return accessMethod(sym, pos, env.enclClass.sym.type, name,
return lookupMethod(env, pos, syms.predefClass, currentResolutionContext,
new BasicLookupHelper(name, syms.predefClass.type, argtypes, null, BOX) {
@Override
Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
return findMethod(env, site, name, argtypes, typeargtypes,
phase.isBoxingRequired(),
phase.isVarargsRequired(), true);
}
@Override
Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
return accessMethod(sym, pos, env.enclClass.sym.type, name,
false, argtypes, null);
}
finally {
}
});
} finally {
currentResolutionContext = prevResolutionContext;
}
}
@ -2673,7 +2677,11 @@ public class Resolve {
abstract class BasicLookupHelper extends LookupHelper {
BasicLookupHelper(Name name, Type site, List<Type> argtypes, List<Type> typeargtypes) {
super(name, site, argtypes, typeargtypes, MethodResolutionPhase.VARARITY);
this(name, site, argtypes, typeargtypes, MethodResolutionPhase.VARARITY);
}
BasicLookupHelper(Name name, Type site, List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
super(name, site, argtypes, typeargtypes, maxPhase);
}
@Override

View File

@ -172,10 +172,13 @@ public class TransTypes extends TreeTranslator {
JCExpression retype(JCExpression tree, Type erasedType, Type target) {
// System.err.println("retype " + tree + " to " + erasedType);//DEBUG
if (!erasedType.isPrimitive()) {
if (target != null && target.isPrimitive())
if (target != null && target.isPrimitive()) {
target = erasure(tree.type);
}
tree.type = erasedType;
if (target != null) return coerce(tree, target);
if (target != null) {
return coerce(tree, target);
}
}
return tree;
}
@ -686,8 +689,8 @@ public class TransTypes extends TreeTranslator {
public void visitAssign(JCAssign tree) {
tree.lhs = translate(tree.lhs, null);
tree.rhs = translate(tree.rhs, erasure(tree.lhs.type));
tree.type = erasure(tree.type);
result = tree;
tree.type = erasure(tree.lhs.type);
result = retype(tree, tree.type, pt);
}
public void visitAssignop(JCAssignOp tree) {

View File

@ -1535,11 +1535,18 @@ public class JavacParser implements Parser {
outer: for (int lookahead = 0 ; ; lookahead++) {
TokenKind tk = S.token(lookahead).kind;
switch (tk) {
case EXTENDS: case SUPER: case COMMA:
case COMMA:
type = true;
case QUES: case DOT: case AMP:
case EXTENDS: case SUPER: case DOT: case AMP:
//skip
break;
case QUES:
if (peekToken(lookahead, EXTENDS) ||
peekToken(lookahead, SUPER)) {
//wildcards
type = true;
}
break;
case BYTE: case SHORT: case INT: case LONG: case FLOAT:
case DOUBLE: case BOOLEAN: case CHAR:
if (peekToken(lookahead, RPAREN)) {

View File

@ -700,7 +700,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
public List<JCTypeParameter> getTypeParameters() {
return typarams;
}
public JCTree getExtendsClause() { return extending; }
public JCExpression getExtendsClause() { return extending; }
public List<JCExpression> getImplementsClause() {
return implementing;
}
@ -1175,7 +1175,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
return v.visitTry(this, d);
}
@Override
public List<? extends JCTree> getResources() {
public List<JCTree> getResources() {
return resources;
}
@Override
@ -1392,8 +1392,8 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
*/
public static class JCThrow extends JCStatement implements ThrowTree {
public JCExpression expr;
protected JCThrow(JCTree expr) {
this.expr = (JCExpression)expr;
protected JCThrow(JCExpression expr) {
this.expr = expr;
}
@Override
public void accept(Visitor v) { v.visitThrow(this); }
@ -2466,7 +2466,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
JCBreak Break(Name label);
JCContinue Continue(Name label);
JCReturn Return(JCExpression expr);
JCThrow Throw(JCTree expr);
JCThrow Throw(JCExpression expr);
JCAssert Assert(JCExpression cond, JCExpression detail);
JCMethodInvocation Apply(List<JCExpression> typeargs,
JCExpression fn,

View File

@ -340,7 +340,7 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
public JCTree visitThrow(ThrowTree node, P p) {
JCThrow t = (JCThrow) node;
JCTree expr = copy(t.expr, p);
JCExpression expr = copy(t.expr, p);
return M.at(t.pos).Throw(expr);
}

View File

@ -332,7 +332,7 @@ public class TreeMaker implements JCTree.Factory {
return tree;
}
public JCThrow Throw(JCTree expr) {
public JCThrow Throw(JCExpression expr) {
JCThrow tree = new JCThrow(expr);
tree.pos = pos;
return tree;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -28,6 +28,24 @@ package com.sun.tools.javac.util;
/** Utility class for static conversion methods between numbers
* and strings in various formats.
*
* <p>Note regarding UTF-8.
* The JVMS defines its own version of the UTF-8 format so that it
* contains no zero bytes (modified UTF-8). This is not actually the same
* as Charset.forName("UTF-8").
*
* <p>
* See also:
* <ul>
* <li><a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4.7">
* JVMS 4.4.7 </a></li>
* <li><a href="http://docs.oracle.com/javase/7/docs/api/java/io/DataInput.html#modified-utf-8">
java.io.DataInput: Modified UTF-8 </a></li>
<li><a href="https://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8">
Modified UTF-8 (wikipedia) </a></li>
* </ul>
*
* The methods here support modified UTF-8.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -125,8 +125,6 @@ public class UnsharedNameTable extends Name.Table {
System.arraycopy(cs, start, bytes, 0, len);
n = new NameImpl(this, bytes, index++);
System.arraycopy(cs, start, n.bytes, 0, len);
HashEntry newEntry = new HashEntry(n);
if (previousNonNullTableEntry == null) { // We are not the first name with that hashCode.

View File

@ -39,35 +39,76 @@ import javax.lang.model.type.*;
* are on a <em>declaration</em>, whereas annotations on a type are on
* a specific <em>use</em> of a type name.
*
* The terms <em>directly present</em> and <em>present</em> are used
* The terms <em>directly present</em>, <em>present</em>,
* <em>indirectly present</em>, and <em>associated </em> are used
* throughout this interface to describe precisely which annotations
* are returned by methods:
* are returned by the methods defined herein.
*
* <p>An annotation <i>A</i> is <em>directly present</em> on a
* construct <i>E</i> if <i>E</i> is annotated, and:
* <p>In the definitions below, an annotation <i>A</i> has an
* annotation type <i>AT</i>. If <i>AT</i> is a repeatable annotation
* type, the type of the containing annotation is <i>ATC</i>.
*
* <p>Annotation <i>A</i> is <em>directly present</em> on a construct
* <i>C</i> if either:
*
* <ul>
*
* <li> for an invocation of {@code getAnnotation(Class<T>)} or
* {@code getAnnotationMirrors()}, <i>E</i>'s annotations contain <i>A</i>.
* <li><i>A</i> is explicitly or implicitly declared as applying to
* the source code representation of <i>C</i>.
*
* <li> for an invocation of {@code getAnnotationsByType(Class<T>)},
* <i>E</i>'s annotations either contain <i>A</i> or, if the type of
* <i>A</i> is repeatable, contain exactly one annotation whose value
* element contains <i>A</i> and whose type is the containing
* annotation type of <i>A</i>'s type.
* <p>Typically, if exactly one annotation of type <i>AT</i> appears in
* the source code of representation of <i>C</i>, then <i>A</i> is
* explicitly declared as applying to <i>C</i>.
*
* If there are multiple annotations of type <i>AT</i> present on
* <i>C</i>, then if <i>AT</i> is repeatable annotation type, an
* annotation of type <i>ATC</i> is implicitly declared on <i>C</i>.
*
* <li> A representation of <i>A</i> appears in the executable output
* for <i>C</i>, such as the {@code RuntimeVisibleAnnotations} or
* {@code RuntimeVisibleParameterAnnotations} attributes of a class
* file.
*
* </ul>
*
* <p>An annotation A is <em>present</em> on a construct E if either:
* <p>An annotation <i>A</i> is <em>present</em> on a
* construct <i>C</i> if either:
* <ul>
*
* <li><i>A</i> is directly present on <i>C</i>.
*
* <li>No annotation of type <i>AT</i> is directly present on
* <i>C</i>, and <i>C</i> is a class and <i>AT</i> is inheritable
* and <i>A</i> is present on the superclass of <i>C</i>.
*
* </ul>
*
* An annotation <i>A</i> is <em>indirectly present</em> on a construct
* <i>C</i> if both:
*
* <ul>
* <li> <i>A</i> is <em>directly present</em> on <i>E</i>; or
*
* <li> <i>A</i> is not <em>directly present</em> on <i>E</i>, and
* <i>E</i> is an element representing a class, and <i>A</i>'s type
* is inheritable, and <i>A</i> is <em>present</em> on the element
* representing the superclass of <i>E</i>.
* <li><i>AT</i> is a repeatable annotation type with a containing
* annotation type <i>ATC</i>.
*
* <li>An annotation of type <i>ATC</i> is directly present on
* <i>C</i> and <i>A</i> is an annotation included in the result of
* calling the {@code value} method of the directly present annotation
* of type <i>ATC</i>.
*
* </ul>
*
* An annotation <i>A</i> is <em>associated</em> with a construct
* <i>C</i> if either:
*
* <ul>
*
* <li> <i>A</i> is directly or indirectly present on <i>C</i>.
*
* <li> No annotation of type <i>AT</i> is directly or indirectly
* present on <i>C</i>, and <i>C</i> is a class, and <i>AT</i> is
* inheritable, and <i>A</i> is associated with the superclass of
* <i>C</i>.
*
* </ul>
*
@ -86,9 +127,8 @@ public interface AnnotatedConstruct {
List<? extends AnnotationMirror> getAnnotationMirrors();
/**
* Returns this construct's annotation of the
* specified type if such an annotation is <em>present</em>, else {@code
* null}.
* Returns this construct's annotation of the specified type if
* such an annotation is <em>present</em>, else {@code null}.
*
* <p> The annotation returned by this method could contain an element
* whose value is of type {@code Class}.
@ -118,9 +158,8 @@ public interface AnnotatedConstruct {
* @param <A> the annotation type
* @param annotationType the {@code Class} object corresponding to
* the annotation type
* @return this element's or type use's annotation for the
* specified annotation type if present on this element, else
* {@code null}
* @return this construct's annotation for the specified
* annotation type if present, else {@code null}
*
* @see #getAnnotationMirrors()
* @see java.lang.reflect.AnnotatedElement#getAnnotation
@ -134,10 +173,16 @@ public interface AnnotatedConstruct {
<A extends Annotation> A getAnnotation(Class<A> annotationType);
/**
* Returns annotations that are <em>present</em> on this construct.
* Returns annotations that are <em>associated</em> with this construct.
*
* If there are no annotations <em>present</em> on this construct,
* the return value is an array of length 0.
* If there are no annotations associated with this construct, the
* return value is an array of length 0.
*
* The order of annotations which are directly or indirectly
* present on a construct <i>C</i> is computed as if indirectly present
* annotations on <i>C</i> are directly present on <i>C</i> in place of their
* container annotation, in the order in which they appear in the
* value element of the container annotation.
*
* The difference between this method and {@link #getAnnotation(Class)}
* is that this method detects if its argument is a <em>repeatable
@ -172,8 +217,8 @@ public interface AnnotatedConstruct {
* @param <A> the annotation type
* @param annotationType the {@code Class} object corresponding to
* the annotation type
* @return this element's annotations for the specified annotation
* type if present on this element, else an empty array
* @return this construct's annotations for the specified annotation
* type if present on this construct, else an empty array
*
* @see #getAnnotationMirrors()
* @see #getAnnotation(java.lang.Class)

View File

@ -143,12 +143,13 @@ public interface Elements {
List<? extends Element> getAllMembers(TypeElement type);
/**
* Returns all annotations of an element, whether
* inherited or directly present.
* Returns all annotations <i>present</i> on an element, whether
* directly present or present via inheritance.
*
* @param e the element being examined
* @return all annotations of the element
* @see Element#getAnnotationMirrors
* @see javax.lang.model.AnnotatedConstruct
*/
List<? extends AnnotationMirror> getAllAnnotationMirrors(Element e);

View File

@ -439,15 +439,11 @@ public class CoreReflectionFactory {
ReflectionElement getGenericElement();
// Functionality specific to the specialization
// Conceptually should have an override for getSource
// returning GenericDeclaration, but GenericDeclaration
// doesn't currently implement AnnotatedElement.
// /**
// * {@inheritDoc}
// */
// @Override
// java.lang.reflect.GenericDeclaration getSource();
/**
* {@inheritDoc}
*/
@Override
java.lang.reflect.TypeVariable<?> getSource();
}
/**
@ -1296,8 +1292,8 @@ public class CoreReflectionFactory {
}
@Override
public AnnotatedElement getSource() {
return (AnnotatedElement)source;
public java.lang.reflect.TypeVariable<?> getSource() {
return sourceTypeVar;
}
protected java.lang.reflect.TypeVariable<?> getSourceTypeVar() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -22,20 +22,13 @@
*/
/* @test
* @bug 8004832
* @bug 8004832 8000103
* @summary Add new doclint package
* @bug 8000103
* @summary Create doclint utility
*/
import com.sun.tools.doclint.DocLint;
import com.sun.tools.doclint.DocLint.BadArgs;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.annotation.Annotation;
@ -44,6 +37,9 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import com.sun.tools.doclint.DocLint;
import com.sun.tools.doclint.DocLint.BadArgs;
/** javadoc error on toplevel: a & b. */
public class RunTest {
/** javadoc error on member: a < b */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -21,12 +21,6 @@
* questions.
*/
/**
* @test
* @bug 5045412 6627366
* @compile -Xlint:serial -XDfailcomplete=java.io.Serializable Bar.java
*/
/**
* @test
* @bug 5045412 6627366

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,11 +25,6 @@
* @test
* @bug 5045412 6627366
* @compile -Xlint:serial -XDfailcomplete=java.io.Serializable Foo.java
*/
/**
* @test
* @bug 5045412 6627366
* @compile -Xlint:serial -XDfailcomplete=java.io.Serializable Foo.java Bar.java
*/

View File

@ -8,5 +8,5 @@
* the method has the same name, it does not override.
* @author turnidge
*
* @compile/fail -nowrite one/Parent.java two/Child.java
* @compile/fail one/Parent.java two/Child.java
*/

View File

@ -5,6 +5,6 @@
* compiler as ambigous.
* @author turnidge
*
* @compile -nowrite one/Parent.java two/Child.java
* @compile -nowrite one/Parent2.java two/Child2.java
* @compile one/Parent.java two/Child.java
* @compile/fail one/Parent2.java two/Child2.java
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 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
@ -28,9 +28,7 @@ interface I {
}
public class Child2 extends one.Parent2 implements I {
class inner {
void method() {
System.out.println(i);
}
void method() {
System.out.println(i);
}
}

View File

@ -0,0 +1,112 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6970173
* @summary Debug pointer at bad position
* @library /tools/javac/lib
* @build ToolBox
* @run main DebugPointerAtBadPositionTest
*/
import java.io.File;
import java.nio.file.Paths;
import com.sun.tools.classfile.ClassFile;
import com.sun.tools.classfile.Code_attribute;
import com.sun.tools.classfile.LineNumberTable_attribute;
import com.sun.tools.classfile.Method;
import com.sun.tools.javac.util.Assert;
public class DebugPointerAtBadPositionTest {
static final String testSource =
"public class AssertionTest {\n" +
" void lookForThisMethod() {\n" +
" int i;\n" +
" i = 33;\n" +
" assert // line 5\n" +
" i < 89:\n" +
" i < 100; // line 7\n" +
" }\n" +
"}";
static final int[][] expectedLNT = {
{4, 0},
{5, 3},
{8, 34}
};
static final String methodToLookFor = "lookForThisMethod";
static final String seekMethodNotFoundMsg =
"The seek method was not found";
static final String foundLNTLengthDifferentThanExpMsg =
"The LineNumberTable found has a length different to the expected one";
public static void main(String[] args) throws Exception {
new DebugPointerAtBadPositionTest().run();
}
void run() throws Exception {
compileTestClass();
checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
"AssertionTest.class").toUri()), methodToLookFor);
}
void compileTestClass() throws Exception {
ToolBox.JavaToolArgs javacSuccessArgs =
new ToolBox.JavaToolArgs().setSources(testSource);
ToolBox.javac(javacSuccessArgs);
}
void checkClassFile(final File cfile, String methodToFind) throws Exception {
ClassFile classFile = ClassFile.read(cfile);
boolean methodFound = false;
for (Method method : classFile.methods) {
if (method.getName(classFile.constant_pool).equals(methodToFind)) {
methodFound = true;
Code_attribute code = (Code_attribute) method.attributes.get("Code");
LineNumberTable_attribute lnt =
(LineNumberTable_attribute) code.attributes.get("LineNumberTable");
Assert.check(lnt.line_number_table_length == expectedLNT.length,
foundLNTLengthDifferentThanExpMsg);
int i = 0;
for (LineNumberTable_attribute.Entry entry: lnt.line_number_table) {
Assert.check(entry.line_number == expectedLNT[i][0] &&
entry.start_pc == expectedLNT[i][1],
"LNT entry at pos " + i + " differ from expected." +
"Found " + entry.line_number + ":" + entry.start_pc +
". Expected " + expectedLNT[i][0] + ":" + expectedLNT[i][1]);
i++;
}
}
}
Assert.check(methodFound, seekMethodNotFoundMsg);
}
void error(String msg) {
throw new AssertionError(msg);
}
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7053059
* @summary VerifyError with double Assignment using a Generic Member of a Superclass
* @run main VerifyErrorWithDoubleAssignmentTest
*/
public class VerifyErrorWithDoubleAssignmentTest {
static class A<D> {
D d;
D getD() {
return null;
}
}
static class B extends A<Integer> {
Integer y;
B() {
y = d = getD();
}
}
public static void main(String[] args) {
new B();
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
/*
* @test
* @bug 8013180
* @summary Qualified type annotation name used to crash javac
* @compile QualifiedName.java
*/
public class QualifiedName {
@Target(ElementType.TYPE_USE) @interface TA { }
class E extends Exception { }
void m() throws @TA QualifiedName.@TA E { }
}

View File

@ -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
@ -296,7 +296,10 @@ class Example implements Comparable<Example> {
private Set<String> actualKeys;
private Set<String> declaredKeys;
static File tempDir = new File(System.getProperty("java.io.tmpdir"));
static File tempDir = (System.getProperty("test.src") != null) ?
new File(System.getProperty("user.dir")):
new File(System.getProperty("java.io.tmpdir"));
static void setTempDir(File tempDir) {
Example.tempDir = tempDir;
}

View File

@ -23,8 +23,7 @@
/*
* @test
* @bug 7115052
* @bug 8003280 8006694
* @bug 7115052 8003280 8006694
* @summary Add lambda tests
* Add parser support for method references
* temporarily workaround combo tests are causing time out in several platforms

View File

@ -0,0 +1,47 @@
/*
* 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 8014494
* @summary javac crashes when varargs element of a method reference is inferred from the context
* @compile TargetType73.java
*/
import java.util.List;
class TargetType73 {
interface Function<X,Y> {
Y m(X x);
}
static void test() {
m(TargetType73::g);
}
public static <T> List<T> g(T... a) {
return null;
}
public static <C> void m(Function<String, C> zipper) { }
}

View File

@ -23,8 +23,7 @@
/*
* @test
* @bug 7194586
* @bug 8003280 8006694 8010404
* @bug 7194586 8003280 8006694 8010404
* @summary Add lambda tests
* Add back-end support for invokedynamic
* temporarily workaround combo tests are causing time out in several platforms
@ -36,6 +35,16 @@
// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
// see JDK-8006746
import java.io.File;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Locale;
import javax.tools.Diagnostic;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import com.sun.source.tree.MethodInvocationTree;
import com.sun.source.tree.MethodTree;
import com.sun.source.util.TaskEvent;
@ -63,16 +72,6 @@ import com.sun.tools.javac.tree.JCTree.JCIdent;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Names;
import java.io.File;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Locale;
import javax.tools.Diagnostic;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import static com.sun.tools.javac.jvm.ClassFile.*;
public class TestInvokeDynamic

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,109 +29,19 @@
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test1.out -XDrawDiagnostics A.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test1.out -XDrawDiagnostics -nowarn A.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test1.out -XDrawDiagnostics -Xmaxwarns 1 A.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test2.out -XDrawDiagnostics A.java B.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test2.out -XDrawDiagnostics -nowarn A.java B.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test2.out -XDrawDiagnostics -Xmaxwarns 1 A.java B.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test3.out -XDrawDiagnostics -Xlint:deprecation A.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test3.out -XDrawDiagnostics -nowarn -Xlint:deprecation A.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test3b.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 1 A.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test4.out -XDrawDiagnostics -Xlint:deprecation A.java B.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test4.out -XDrawDiagnostics -nowarn -Xlint:deprecation A.java B.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test4b.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 1 A.java B.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test4c.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 2 A.java B.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test4d.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 3 A.java B.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test5.out -XDrawDiagnostics -Xlint:deprecation P.java Q.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test5b.out -XDrawDiagnostics -Xlint:deprecation -Xmaxwarns 2 P.java Q.java
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,95 +29,17 @@
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test1.out -XDrawDiagnostics A.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test1.out -XDrawDiagnostics -nowarn A.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test1.out -XDrawDiagnostics -Xmaxwarns 1 A.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test2.out -XDrawDiagnostics A.java B.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test2.out -XDrawDiagnostics -nowarn A.java B.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test2.out -XDrawDiagnostics -Xmaxwarns 1 A.java B.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test3.out -XDrawDiagnostics -Xlint:unchecked A.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test3.out -XDrawDiagnostics -nowarn -Xlint:unchecked A.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test3b.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 1 A.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test4.out -XDrawDiagnostics -Xlint:unchecked A.java B.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test4.out -XDrawDiagnostics -nowarn -Xlint:unchecked A.java B.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test4b.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 1 A.java B.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test4c.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 2 A.java B.java
*/
/*
* @test
* @bug 5047307
* @summary javac -nowarn improperly suppresses JLS-mandated warnings
* @compile/ref=Test4d.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 3 A.java B.java
*/

View File

@ -0,0 +1,41 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8014643
* @summary Parser regression in JDK 8 when compiling super.x
* @compile T8014643.java
*/
class T8014643 {
static class A {
int b = 1;
}
static class B extends A {
int b = 12;
int m() { return (super.b); }
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 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
@ -123,47 +123,3 @@ public class Test {
int errors;
}
// These tests test the ability of the compiler to continue in the face of
// errors, accordining to the shouldStopPolicy
/* @ test /nodynamiccopyright/
* @bug 6813059
* @summary
* @compile/fail/ref=flow.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=FLOW Test.java
* @compile/fail/ref=default.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy Test.java
* @compile/fail/ref=enter.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=ENTER Test.java
* @compile/fail/ref=attr.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=ATTR Test.java
* @compile/fail/ref=transtypes.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=TRANSTYPES Test.java
* @compile/fail/ref=lower.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=LOWER Test.java
* @compile/fail/ref=generate.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=GENERATE Test.java
*/
/*
class Test {
void m1() {
System.err.println("hello");
0 // syntax error
System.err.println("world");
}
void m2() {
}
}
class Test2 {
}
*/

View File

@ -43,6 +43,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.annotation.processing.AbstractProcessor;
@ -85,6 +86,7 @@ public class ResolveHarness implements javax.tools.DiagnosticListener<JavaFileOb
Set<String> declaredKeys = new HashSet<>();
List<Diagnostic<? extends JavaFileObject>> diags = new ArrayList<>();
List<ElementKey> seenCandidates = new ArrayList<>();
Map<String, String> predefTranslationMap = new HashMap<>();
protected ResolveHarness(JavaFileObject jfo) {
this.jfo = jfo;
@ -93,12 +95,36 @@ public class ResolveHarness implements javax.tools.DiagnosticListener<JavaFileOb
new VerboseDeferredInferenceNoteProcessor(),
new ErrorProcessor()
};
predefTranslationMap.put("+", "_plus");
predefTranslationMap.put("-", "_minus");
predefTranslationMap.put("~", "_not");
predefTranslationMap.put("++", "_plusplus");
predefTranslationMap.put("--", "_minusminus");
predefTranslationMap.put("!", "_bang");
predefTranslationMap.put("*", "_mul");
predefTranslationMap.put("/", "_div");
predefTranslationMap.put("%", "_mod");
predefTranslationMap.put("&", "_and");
predefTranslationMap.put("|", "_or");
predefTranslationMap.put("^", "_xor");
predefTranslationMap.put("<<", "_lshift");
predefTranslationMap.put(">>", "_rshift");
predefTranslationMap.put("<<<", "_lshiftshift");
predefTranslationMap.put(">>>", "_rshiftshift");
predefTranslationMap.put("<", "_lt");
predefTranslationMap.put(">", "_gt");
predefTranslationMap.put("<=", "_lteq");
predefTranslationMap.put(">=", "_gteq");
predefTranslationMap.put("==", "_eq");
predefTranslationMap.put("!=", "_neq");
predefTranslationMap.put("&&", "_andand");
predefTranslationMap.put("||", "_oror");
}
protected void check() throws Exception {
String[] options = {
"-XDshouldStopPolicy=ATTR",
"-XDverboseResolution=success,failure,applicable,inapplicable,deferred-inference"
"-XDverboseResolution=success,failure,applicable,inapplicable,deferred-inference,predef"
};
AbstractProcessor[] processors = { new ResolveCandidateFinder(), null };
@ -223,7 +249,8 @@ public class ResolveHarness implements javax.tools.DiagnosticListener<JavaFileOb
@Override
void process(Diagnostic<? extends JavaFileObject> diagnostic) {
Element siteSym = getSiteSym(diagnostic);
if (siteSym.getAnnotation(TraceResolve.class) == null) {
if (siteSym.getSimpleName().length() != 0 &&
siteSym.getAnnotation(TraceResolve.class) == null) {
return;
}
int candidateIdx = 0;
@ -307,7 +334,7 @@ public class ResolveHarness implements javax.tools.DiagnosticListener<JavaFileOb
if (Arrays.asList(c.applicable()).contains(phase)) { //applicable
if (c.mostSpecific() != mostSpecific) {
error("Invalid most specific value for method " + methodSym);
error("Invalid most specific value for method " + methodSym + " " + new ElementKey(methodSym).key);
}
MethodType mtype = getSig(diagnostic);
if (mtype != null) {
@ -444,11 +471,21 @@ public class ResolveHarness implements javax.tools.DiagnosticListener<JavaFileOb
String computeKey(Element e) {
StringBuilder buf = new StringBuilder();
while (e != null) {
if (predefTranslationMap.containsKey(e.getSimpleName().toString())) {
//predef element
buf.append("<predef>.");
String replacedName = predefTranslationMap.get(e.getSimpleName().toString());
buf.append(e.toString().replace(e.getSimpleName().toString(), replacedName));
} else if (e.getSimpleName().toString().startsWith("_")) {
buf.append("<predef>.");
buf.append(e.toString());
e = e.getEnclosingElement();
} else {
while (e != null) {
buf.append(e.toString());
e = e.getEnclosingElement();
}
buf.append(jfo.getName());
}
buf.append(jfo.getName());
return buf.toString();
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
@TraceResolve
class PrimitiveBinopOverload {
@Candidate(applicable=Phase.BASIC, mostSpecific=true)
int _plus(int x, int y) { return -1; }
@Candidate(applicable=Phase.BASIC)
long _plus(long x, long y) { return -1; }
@Candidate(applicable=Phase.BASIC)
float _plus(float x, float y) { return -1; }
@Candidate(applicable=Phase.BASIC)
double _plus(double x, double y) { return -1; }
//not a candidate
Object _plus(Object x, Object y) { return -1; }
@Candidate(applicable= { Phase.BASIC, Phase.BOX }, mostSpecific=true)
int _minus(int x, int y) { return -1; }
@Candidate(applicable= { Phase.BASIC, Phase.BOX })
long _minus(long x, long y) { return -1; }
@Candidate(applicable= { Phase.BASIC, Phase.BOX })
float _minus(float x, float y) { return -1; }
@Candidate(applicable= { Phase.BASIC, Phase.BOX })
double _minus(double x, double y) { return -1; }
@Candidate(applicable= { Phase.BASIC, Phase.BOX }, mostSpecific=true)
int _mul(int x, int y) { return -1; }
@Candidate(applicable= { Phase.BASIC, Phase.BOX })
long _mul(long x, long y) { return -1; }
@Candidate(applicable= { Phase.BASIC, Phase.BOX })
float _mul(float x, float y) { return -1; }
@Candidate(applicable= { Phase.BASIC, Phase.BOX })
double _mul(double x, double y) { return -1; }
@Candidate(applicable= { Phase.BASIC, Phase.BOX }, mostSpecific=true)
int _div(int x, int y) { return -1; }
@Candidate(applicable= { Phase.BASIC, Phase.BOX })
long _div(long x, long y) { return -1; }
@Candidate(applicable= { Phase.BASIC, Phase.BOX })
float _div(float x, float y) { return -1; }
@Candidate(applicable= { Phase.BASIC, Phase.BOX })
double _div(double x, double y) { return -1; }
{
int i1 = 1 + 1;
int i2 = 5 - new Integer(3);
int i3 = new Integer(5) * 3;
int i4 = new Integer(6) / new Integer(2);
}
}