Tightening up a bit on JDK 1.5 usage

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4769 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2006-10-31 07:04:25 +00:00
parent be5faa39b6
commit 17d8d3c2bb
2 changed files with 48 additions and 34 deletions

View File

@ -92,6 +92,12 @@ public class JavaParser {
}
}
private void checkForBadGenericsUsage() {
if (!isJDK15) {
throw new ParseException("Can't use generics unless running in JDK 1.5 mode!");
}
}
private void checkForBadVariableArgumentsUsage() {
if (!isJDK15) {
throw new ParseException("Can't use variable arguments (varargs) when running in JDK 1.4 mode!");
@ -1202,7 +1208,7 @@ void EnumConstant():
void TypeParameters():
{}
{
"<" TypeParameter() ( "," TypeParameter() )* ">"
"<" {checkForBadGenericsUsage();} TypeParameter() ( "," TypeParameter() )* ">"
}
void TypeParameter():
@ -1375,7 +1381,7 @@ void ClassOrInterfaceType():
void TypeArguments():
{}
{
"<" TypeArgument() ( "," TypeArgument() )* ">"
"<" {checkForBadGenericsUsage();} TypeArgument() ( "," TypeArgument() )* ">"
}
void TypeArgument():

View File

@ -27,6 +27,12 @@ public class JavaParser/*@bgen(jjtree)*/implements JavaParserTreeConstants, Java
}
}
private void checkForBadGenericsUsage() {
if (!isJDK15) {
throw new ParseException("Can't use generics unless running in JDK 1.5 mode!");
}
}
private void checkForBadVariableArgumentsUsage() {
if (!isJDK15) {
throw new ParseException("Can't use variable arguments (varargs) when running in JDK 1.4 mode!");
@ -816,6 +822,7 @@ jjtn000.setModifiers(modifiers);
jjtree.openNodeScope(jjtn000);
try {
jj_consume_token(LT);
checkForBadGenericsUsage();
TypeParameter();
label_11:
while (true) {
@ -1951,6 +1958,7 @@ Token t;
jjtree.openNodeScope(jjtn000);
try {
jj_consume_token(LT);
checkForBadGenericsUsage();
TypeArgument();
label_24:
while (true) {
@ -6217,26 +6225,6 @@ jjtn000.setModifiers(modifiers);
finally { jj_save(50, xla); }
}
final private boolean jj_3R_259() {
if (jj_scan_token(BIT_OR)) return true;
if (jj_3R_230()) return true;
return false;
}
final private boolean jj_3R_264() {
if (jj_scan_token(XOR)) return true;
if (jj_3R_251()) return true;
return false;
}
final private boolean jj_3R_260() {
if (jj_3R_265()) return true;
Token xsp;
xsp = jj_scanpos;
if (jj_3R_281()) jj_scanpos = xsp;
return false;
}
final private boolean jj_3R_256() {
if (jj_scan_token(SC_AND)) return true;
if (jj_3R_220()) return true;
@ -6466,6 +6454,12 @@ jjtn000.setModifiers(modifiers);
return false;
}
final private boolean jj_3R_254() {
if (jj_scan_token(COMMA)) return true;
if (jj_3R_119()) return true;
return false;
}
final private boolean jj_3R_94() {
if (jj_scan_token(IDENTIFIER)) return true;
Token xsp;
@ -6559,12 +6553,6 @@ jjtn000.setModifiers(modifiers);
return false;
}
final private boolean jj_3R_254() {
if (jj_scan_token(COMMA)) return true;
if (jj_3R_119()) return true;
return false;
}
final private boolean jj_3R_273() {
if (jj_scan_token(SUPER)) return true;
if (jj_3R_77()) return true;
@ -7161,6 +7149,12 @@ jjtn000.setModifiers(modifiers);
return false;
}
final private boolean jj_3R_164() {
if (jj_scan_token(COMMA)) return true;
if (jj_3R_163()) return true;
return false;
}
final private boolean jj_3R_156() {
if (jj_3R_137()) return true;
return false;
@ -7384,12 +7378,6 @@ jjtn000.setModifiers(modifiers);
return false;
}
final private boolean jj_3R_164() {
if (jj_scan_token(COMMA)) return true;
if (jj_3R_163()) return true;
return false;
}
final private boolean jj_3R_198() {
if (jj_scan_token(AT)) return true;
if (jj_3R_94()) return true;
@ -9297,6 +9285,26 @@ jjtn000.setModifiers(modifiers);
return false;
}
final private boolean jj_3R_259() {
if (jj_scan_token(BIT_OR)) return true;
if (jj_3R_230()) return true;
return false;
}
final private boolean jj_3R_264() {
if (jj_scan_token(XOR)) return true;
if (jj_3R_251()) return true;
return false;
}
final private boolean jj_3R_260() {
if (jj_3R_265()) return true;
Token xsp;
xsp = jj_scanpos;
if (jj_3R_281()) jj_scanpos = xsp;
return false;
}
public JavaParserTokenManager token_source;
public Token token, jj_nt;
private Token jj_scanpos, jj_lastpos;