|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.tasklist.compiler; import java.util.ArrayList; import java.util.regex.*; import org.openide.compiler.ErrorEvent; /** * javac message * * @author Tim Lebedkov */ public class JavacError extends CompileError { /** * Javac message description. */ private static class MessageInfo { private Pattern re; private int[] pos; private String regexp; private int code; /** * Constructor. All regular subexpressions will be used. * * @param code error code * @param regexp regular expression for an error message */ public MessageInfo(int code, String regexp) { this(code, regexp, null); } /** * Constructor * * @param code error code * @param regexp regular expression for an error message * @param pos indices of subexpressions for message parameters or null * if all subexpressions should be used */ public MessageInfo(int code, String regexp, int[] pos) { this.code = code; this.regexp = regexp; this.pos = pos; re = Pattern.compile(regexp); } /** * Parses an error message * * @param msg a Javac message to be parsed * @return parameters of the message */ public String[] split(String msg) { Matcher m = re.matcher(msg); if (!m.matches()) return null; ArrayList ret = new ArrayList(); if (pos != null) { for (int i = 0; i < pos.length; i++) { int start = m.start(pos[i]); int end = m.end(pos[i]); if (start != -1 && end != -1) ret.add(msg.substring(start, end)); else ret.add(null); } } else { for (int i = 1; i < m.groupCount(); i++) { int start = m.start(i); int end = m.end(i); if (start != -1 && end != -1) ret.add(msg.substring(start, end)); else ret.add(null); } } return (String[]) ret.toArray(new String[ret.size()]); } /** * Getter for property code. * * @return Value of property code. */ public int getCode() { return code; } } /** * All errors which do not refer to a particular line in the source code are * preceded by this string. */ private static String ERROR_PREFIX = "error: "; /** * The following string will appear before all messages keyed as: * "compiler.note". */ private static String NOTE_KEY = "Note: "; /** All warning messages are preceded by the following string. */ private static String WARNING_KEY = "warning: "; /** * The following string will always appear after one of the above deprecation * messages. */ private static String DEPRECATION_MSG = "Recompile with -deprecation for details."; /** * The following string will always appear after one of the above deprecation * messages. */ private static String UNCHECKED_MSG = "Recompile with -warnunchecked for details."; private static MessageInfo[] MESSAGES = { new MessageInfo(1, "(\\S*) is abstract; cannot be instantiated"), new MessageInfo(2, "abstract methods cannot have a body"), new MessageInfo(3, "(\\S*) is already defined in a single-type import"), new MessageInfo(4, "(\\S*) is already defined in this compilation unit"), new MessageInfo(5, "(\\S*) is already defined in (\\S*)"), new MessageInfo(6, "anonymous class implements interface; cannot have arguments"), new MessageInfo(7, "anonymous class implements interface; cannot have qualifier for new"), new MessageInfo(8, "array required, but (\\S*) found"), new MessageInfo(9, "break outside switch or loop"), new MessageInfo(10, "call to (\\S*) must be first statement in constructor"), new MessageInfo(11, "cannot access (\\S*); (\\S*)"), new MessageInfo(12, "(\\S*) in (\\S*) cannot be applied to \\x28(\\S*)\\x29"), new MessageInfo(13, "cannot assign a value to final variable (\\S*)"), new MessageInfo(14, "(\\S*) cannot be dereferenced"), new MessageInfo(15, "cannot inherit from final (\\S*)"), new MessageInfo(16, "cannot reference (\\S*) before supertype constructor has been called"), new MessageInfo(17, "cannot return a value from method whose result type is void"), new MessageInfo(18, "cannot select a static class from a parameterized type"), new MessageInfo(19, "(\\S*) cannot be inherited with different arguments: <(\\S*)> and <(\\S*)>"), new MessageInfo(20, "'catch' without 'try'"), new MessageInfo(21, "(\\S*) clashes with package of same name"), new MessageInfo(22, "code too large for try statement"), new MessageInfo(23, "constant expression required"), new MessageInfo(24, "continue outside of loop"), new MessageInfo(25, "cyclic inheritance involving (\\S*)"), new MessageInfo(26, "package (\\S*) does not exist"), new MessageInfo(27, "duplicate class: (\\S*)"), new MessageInfo(28, "duplicate case label"), new MessageInfo(29, "duplicate default label"), new MessageInfo(30, "'else' without 'if'"), new MessageInfo(31, "empty character literal"), new MessageInfo(32, "error reading (\\S*); (\\S*)"), new MessageInfo(33, "exception (\\S*) has already been caught"), new MessageInfo(34, "exception (\\S*) is never thrown in body of corresponding try statement"), new MessageInfo(35, "'finally' without 'try'"), new MessageInfo(36, "floating point number too large"), new MessageInfo(37, "floating point number too small"), new MessageInfo(38, "inner classes cannot have static declarations"), new MessageInfo(39, "illegal character: \\\\(\\S*)"), new MessageInfo(40, "illegal combination of modifiers: (\\S*) and (\\S*)"), new MessageInfo(41, "illegal escape character"), new MessageInfo(42, "illegal forward reference"), new MessageInfo(43, "illegal initializer for (\\S*)"), new MessageInfo(44, "illegal line end in character literal"), new MessageInfo(45, "illegal qualifier; (\\S*) is not an inner class"), new MessageInfo(46, "illegal start of expression"), new MessageInfo(47, "illegal start of type"), new MessageInfo(48, "illegal unicode escape"), new MessageInfo(49, "improperly formed type, some parameters are missing"), new MessageInfo(50, "incomparable types: (\\S*) and (\\S*)"), new MessageInfo(51, "integer number too large: (\\S*)"), new MessageInfo(52, "internal error; cannot instantiate (\\S*) at (\\S*) to \\x28(\\S*)\\x29"), new MessageInfo(53, "interfaces (\\S*) and (\\S*) are incompatible; both define (\\S*), but with different return type"), new MessageInfo(54, "interface expected here"), new MessageInfo(55, "interface methods cannot have body"), new MessageInfo(56, "hexadecimal numbers must contain at least one hexadecimal digit"), new MessageInfo(57, "invalid method declaration; return type required"), new MessageInfo(58, "label (\\S*) already in use"), new MessageInfo(59, "local variable (\\S*) is accessed from within inner class; needs to be declared final"), new MessageInfo(60, "malformed floating point literal"), new MessageInfo(61, "missing method body, or declare abstract"), new MessageInfo(62, "missing return statement"), new MessageInfo(63, "missing return value"), new MessageInfo(64, "modifier (\\S*) not allowed here"), new MessageInfo(65, "name clash: (\\S*) and (\\S*) have the same erasure"), new MessageInfo(66, "name clash: (\\S*) in (\\S*) and (\\S*) in (\\S*) have the same erasure, yet none overrides the other"), new MessageInfo(67, "(\\S*) is reserved for internal use"), new MessageInfo(68, "native methods cannot have a body"), new MessageInfo(69, "no enclosing instance of type (\\S*) is in scope"), new MessageInfo(70, "no interface expected here"), new MessageInfo(71, "(\\S*) has no match in entry in (\\S*); required (\\S*)"), new MessageInfo(72, "(\\S*) in (\\S*) is not defined in a public class or interface; cannot be accessed from outside package"), new MessageInfo(73, "(\\S*) is not public in (\\S*); cannot be accessed from outside package"), new MessageInfo(74, "not a loop label: (\\S*)"), new MessageInfo(75, "not a statement"), new MessageInfo(76, "not an enclosing class: (\\S*)"), new MessageInfo(77, "operator (\\S*) cannot be applied to (\\S*)"), new MessageInfo(78, "package (\\S*) clashes with class of same name"), new MessageInfo(79, "qualified new of static class"), new MessageInfo(80, "recursive constructor invocation"), new MessageInfo(81, "reference to (\\S*) is ambiguous, both (\\S*) (\\S*) in (\\S*) and (\\S*) (\\S*) in (\\S*) match"), new MessageInfo(82, "repeated interface"), new MessageInfo(83, "repeated modifier"), new MessageInfo(84, "(\\S*) has (\\S*) access in (\\S*)"), new MessageInfo(85, "return outside method"), new MessageInfo(86, "signature does not match (\\S*); incompatible supertype"), new MessageInfo(87, "signature does not match (\\S*); incompatible interfaces"), new MessageInfo(88, "(\\S*) should be declared abstract; it does not define (\\S*) in (\\S*)"), new MessageInfo(89, "error writing source; cannot overwrite input file (\\S*)"), new MessageInfo(90, "the symbol (\\S*) conflicts with a compiler-synthesized symbol in (\\S*)"), new MessageInfo(91, "'try' without 'catch' or 'finally'"), new MessageInfo(92, "type (\\S*) does not take parameters"), new MessageInfo(93, "type variables cannot be dereferenced"), new MessageInfo(94, "type variable (\\S*) occurs more than once in result type of (\\S*); cannot be left uninstantiated"), new MessageInfo(95, "type variable (\\S*) occurs more than once in type of (\\S*); cannot be left uninstantiated"), new MessageInfo(96, "unclosed character literal"), new MessageInfo(97, "unclosed comment"), new MessageInfo(98, "unclosed string literal"), new MessageInfo(99, "unsupported encoding: (\\S*)"), new MessageInfo(100, "error reading source file: (\\S*)"), new MessageInfo(101, "undefined label: (\\S*)"), new MessageInfo(102, "unreachable statement"), new MessageInfo(103, "initializer must be able to complete normally"), new MessageInfo(104, "unreported exception (\\S*); must be caught or declared to be thrown"), new MessageInfo(105, "'void' type not allowed here"), new MessageInfo(106, "wrong number of type arguments; required (\\S*)"), new MessageInfo(107, "variable (\\S*) might already have been assigned to"), new MessageInfo(108, "variable (\\S*) might not have been initialized"), new MessageInfo(109, "variable (\\S*) might be assigned in loop"), new MessageInfo(110, "as of release 1\\x2E4, 'assert' is a keyword, and may not be used as an identifier"), // In the following string, {1} will always be the detail message from // java.io.IOException. new MessageInfo(111, "error while writing (\\S*): (\\S*)"), // In the following string, {0} is the name of the class in the Java source. // It really should be used two times.. new MessageInfo(112, "class (\\S*) is public, should be declared in a file named (\\S*)\\x2Ejava"), // The following error messages do not refer to a line in the source code. new MessageInfo(113, "cannot read: (\\S*)"), // Fatal Errors new MessageInfo(114, "Fatal Error: Unable to locate package java\\x2Elang in classpath or bootclasspath"), new MessageInfo(115, "Fatal Error: Unable to locate method (\\S*)"), new MessageInfo(116, "(\\S*) uses or overrides a deprecated API\\x2E"), new MessageInfo(117, "Some input files use or override a deprecated API\\x2E"), new MessageInfo(118, "(\\S*) uses unchecked operations\\x2E"), new MessageInfo(119, "Some input files use unchecked operations\\x2E"), // extra output when using -checkclassfile (code/ClassReader) new MessageInfo(120, "class file has later version than expected: (\\S*)"), new MessageInfo(121, "unrecognized attribute: (\\S*)"), // warnings new MessageInfo(122, "(\\S*) in (\\S*) has been deprecated"), new MessageInfo(123, "unchecked assignment: (\\S*) to (\\S*)"), new MessageInfo(124, "unchecked assignment to variable (\\S*) of raw type class (\\S*)"), new MessageInfo(125, "unchecked call to (\\S*) as a member of the raw type (\\S*)"), new MessageInfo(126, "unchecked cast to type (\\S*)"), new MessageInfo(127, "unchecked generic array creation"), new MessageInfo(128, "unchecked method invocation: (\\S*) in (\\S*) is applied to ((\\S*))"), new MessageInfo(129, "as of release 1\\x2E4, 'assert' is a keyword, and may not be used as an identifier"), new MessageInfo(130, "possible fall-through into case"), // The following are tokens which are non-terminals in the language. They should // be named as JLS3 calls them when translated to the appropriate language. // " |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.