Wed, 21 Sep 2011 21:56:53 -0700
7092965: javac should not close processorClassLoader before end of compilation
Reviewed-by: darcy
duke@1 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.tools.javac.parser; |
duke@1 | 27 | |
mcimadamore@136 | 28 | import java.util.Locale; |
mcimadamore@80 | 29 | |
mcimadamore@80 | 30 | import com.sun.tools.javac.api.Formattable; |
mcimadamore@136 | 31 | import com.sun.tools.javac.api.Messages; |
duke@1 | 32 | |
duke@1 | 33 | /** An interface that defines codes for Java source tokens |
duke@1 | 34 | * returned from lexical analysis. |
duke@1 | 35 | * |
jjg@581 | 36 | * <p><b>This is NOT part of any supported API. |
jjg@581 | 37 | * If you write code that depends on this, you do so at your own risk. |
duke@1 | 38 | * This code and its internal interfaces are subject to change or |
duke@1 | 39 | * deletion without notice.</b> |
duke@1 | 40 | */ |
mcimadamore@80 | 41 | public enum Token implements Formattable { |
duke@1 | 42 | EOF, |
duke@1 | 43 | ERROR, |
duke@1 | 44 | IDENTIFIER, |
duke@1 | 45 | ABSTRACT("abstract"), |
duke@1 | 46 | ASSERT("assert"), |
duke@1 | 47 | BOOLEAN("boolean"), |
duke@1 | 48 | BREAK("break"), |
duke@1 | 49 | BYTE("byte"), |
duke@1 | 50 | CASE("case"), |
duke@1 | 51 | CATCH("catch"), |
duke@1 | 52 | CHAR("char"), |
duke@1 | 53 | CLASS("class"), |
duke@1 | 54 | CONST("const"), |
duke@1 | 55 | CONTINUE("continue"), |
duke@1 | 56 | DEFAULT("default"), |
duke@1 | 57 | DO("do"), |
duke@1 | 58 | DOUBLE("double"), |
duke@1 | 59 | ELSE("else"), |
duke@1 | 60 | ENUM("enum"), |
duke@1 | 61 | EXTENDS("extends"), |
duke@1 | 62 | FINAL("final"), |
duke@1 | 63 | FINALLY("finally"), |
duke@1 | 64 | FLOAT("float"), |
duke@1 | 65 | FOR("for"), |
duke@1 | 66 | GOTO("goto"), |
duke@1 | 67 | IF("if"), |
duke@1 | 68 | IMPLEMENTS("implements"), |
duke@1 | 69 | IMPORT("import"), |
duke@1 | 70 | INSTANCEOF("instanceof"), |
duke@1 | 71 | INT("int"), |
duke@1 | 72 | INTERFACE("interface"), |
duke@1 | 73 | LONG("long"), |
duke@1 | 74 | NATIVE("native"), |
duke@1 | 75 | NEW("new"), |
duke@1 | 76 | PACKAGE("package"), |
duke@1 | 77 | PRIVATE("private"), |
duke@1 | 78 | PROTECTED("protected"), |
duke@1 | 79 | PUBLIC("public"), |
duke@1 | 80 | RETURN("return"), |
duke@1 | 81 | SHORT("short"), |
duke@1 | 82 | STATIC("static"), |
duke@1 | 83 | STRICTFP("strictfp"), |
duke@1 | 84 | SUPER("super"), |
duke@1 | 85 | SWITCH("switch"), |
duke@1 | 86 | SYNCHRONIZED("synchronized"), |
duke@1 | 87 | THIS("this"), |
duke@1 | 88 | THROW("throw"), |
duke@1 | 89 | THROWS("throws"), |
duke@1 | 90 | TRANSIENT("transient"), |
duke@1 | 91 | TRY("try"), |
duke@1 | 92 | VOID("void"), |
duke@1 | 93 | VOLATILE("volatile"), |
duke@1 | 94 | WHILE("while"), |
duke@1 | 95 | INTLITERAL, |
duke@1 | 96 | LONGLITERAL, |
duke@1 | 97 | FLOATLITERAL, |
duke@1 | 98 | DOUBLELITERAL, |
duke@1 | 99 | CHARLITERAL, |
duke@1 | 100 | STRINGLITERAL, |
duke@1 | 101 | TRUE("true"), |
duke@1 | 102 | FALSE("false"), |
duke@1 | 103 | NULL("null"), |
duke@1 | 104 | LPAREN("("), |
duke@1 | 105 | RPAREN(")"), |
duke@1 | 106 | LBRACE("{"), |
duke@1 | 107 | RBRACE("}"), |
duke@1 | 108 | LBRACKET("["), |
duke@1 | 109 | RBRACKET("]"), |
duke@1 | 110 | SEMI(";"), |
duke@1 | 111 | COMMA(","), |
duke@1 | 112 | DOT("."), |
duke@1 | 113 | ELLIPSIS("..."), |
duke@1 | 114 | EQ("="), |
duke@1 | 115 | GT(">"), |
duke@1 | 116 | LT("<"), |
duke@1 | 117 | BANG("!"), |
duke@1 | 118 | TILDE("~"), |
duke@1 | 119 | QUES("?"), |
duke@1 | 120 | COLON(":"), |
duke@1 | 121 | EQEQ("=="), |
duke@1 | 122 | LTEQ("<="), |
duke@1 | 123 | GTEQ(">="), |
duke@1 | 124 | BANGEQ("!="), |
duke@1 | 125 | AMPAMP("&&"), |
duke@1 | 126 | BARBAR("||"), |
duke@1 | 127 | PLUSPLUS("++"), |
duke@1 | 128 | SUBSUB("--"), |
duke@1 | 129 | PLUS("+"), |
duke@1 | 130 | SUB("-"), |
duke@1 | 131 | STAR("*"), |
duke@1 | 132 | SLASH("/"), |
duke@1 | 133 | AMP("&"), |
duke@1 | 134 | BAR("|"), |
duke@1 | 135 | CARET("^"), |
duke@1 | 136 | PERCENT("%"), |
duke@1 | 137 | LTLT("<<"), |
duke@1 | 138 | GTGT(">>"), |
duke@1 | 139 | GTGTGT(">>>"), |
duke@1 | 140 | PLUSEQ("+="), |
duke@1 | 141 | SUBEQ("-="), |
duke@1 | 142 | STAREQ("*="), |
duke@1 | 143 | SLASHEQ("/="), |
duke@1 | 144 | AMPEQ("&="), |
duke@1 | 145 | BAREQ("|="), |
duke@1 | 146 | CARETEQ("^="), |
duke@1 | 147 | PERCENTEQ("%="), |
duke@1 | 148 | LTLTEQ("<<="), |
duke@1 | 149 | GTGTEQ(">>="), |
duke@1 | 150 | GTGTGTEQ(">>>="), |
duke@1 | 151 | MONKEYS_AT("@"), |
duke@1 | 152 | CUSTOM; |
duke@1 | 153 | |
duke@1 | 154 | Token() { |
duke@1 | 155 | this(null); |
duke@1 | 156 | } |
duke@1 | 157 | Token(String name) { |
duke@1 | 158 | this.name = name; |
duke@1 | 159 | } |
duke@1 | 160 | |
duke@1 | 161 | public final String name; |
mcimadamore@80 | 162 | |
mcimadamore@80 | 163 | public String toString() { |
mcimadamore@80 | 164 | switch (this) { |
mcimadamore@80 | 165 | case IDENTIFIER: |
mcimadamore@80 | 166 | return "token.identifier"; |
mcimadamore@80 | 167 | case CHARLITERAL: |
mcimadamore@80 | 168 | return "token.character"; |
mcimadamore@80 | 169 | case STRINGLITERAL: |
mcimadamore@80 | 170 | return "token.string"; |
mcimadamore@80 | 171 | case INTLITERAL: |
mcimadamore@80 | 172 | return "token.integer"; |
mcimadamore@80 | 173 | case LONGLITERAL: |
mcimadamore@80 | 174 | return "token.long-integer"; |
mcimadamore@80 | 175 | case FLOATLITERAL: |
mcimadamore@80 | 176 | return "token.float"; |
mcimadamore@80 | 177 | case DOUBLELITERAL: |
mcimadamore@80 | 178 | return "token.double"; |
mcimadamore@80 | 179 | case ERROR: |
mcimadamore@80 | 180 | return "token.bad-symbol"; |
mcimadamore@80 | 181 | case EOF: |
mcimadamore@80 | 182 | return "token.end-of-input"; |
mcimadamore@80 | 183 | case DOT: case COMMA: case SEMI: case LPAREN: case RPAREN: |
mcimadamore@80 | 184 | case LBRACKET: case RBRACKET: case LBRACE: case RBRACE: |
mcimadamore@80 | 185 | return "'" + name + "'"; |
mcimadamore@80 | 186 | default: |
mcimadamore@80 | 187 | return name; |
mcimadamore@80 | 188 | } |
mcimadamore@80 | 189 | } |
mcimadamore@80 | 190 | |
mcimadamore@80 | 191 | public String getKind() { |
mcimadamore@80 | 192 | return "Token"; |
mcimadamore@80 | 193 | } |
mcimadamore@80 | 194 | |
mcimadamore@136 | 195 | public String toString(Locale locale, Messages messages) { |
mcimadamore@136 | 196 | return name != null ? toString() : messages.getLocalizedString(locale, "compiler.misc." + toString()); |
mcimadamore@80 | 197 | } |
duke@1 | 198 | } |