Candidate.java revision 3170:dc017a37aac5
1/* 2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24import java.lang.annotation.ElementType; 25import java.lang.annotation.Target; 26 27@Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) 28@interface Candidate { 29 /** 30 * the candidate position (line/col of the method call for which this candidate 31 * is a potential overload candidate) 32 */ 33 Pos pos() default @Pos(userDefined=false); 34 /** 35 * resolution phases for which this candidate is applicable 36 */ 37 Phase[] applicable() default { }; 38 /** 39 * is this candidate the most specific (in the resolution phases for which it 40 * is also applicable) 41 */ 42 boolean mostSpecific() default false; 43 /** 44 * this candidate inferred signature (in the resolution phases for which it 45 * is also applicable, in case it corresponds to a generic method) 46 */ 47 String sig() default ""; 48} 49 50enum Phase { 51 BASIC("BASIC"), 52 BOX("BOX"), 53 VARARGS("VARARITY"); 54 55 final String javacString; 56 57 private Phase(String javacString) { 58 this.javacString = javacString; 59 } 60 61 static Phase fromString(String s) { 62 for (Phase phase : Phase.values()) { 63 if (phase.javacString.equals(s)) { 64 return phase; 65 } 66 } 67 throw new AssertionError("Invalid resolution phase string " + s); 68 } 69} 70