Lines 502-507
Link Here
|
502 |
"configure.incorrectExtDirsEntry", wrongPath)); //$NON-NLS-1$ |
502 |
"configure.incorrectExtDirsEntry", wrongPath)); //$NON-NLS-1$ |
503 |
} |
503 |
} |
504 |
|
504 |
|
|
|
505 |
public void logIncorrectVMVersionForAnnotationProcessing() { |
506 |
if ((this.tagBits & Logger.XML) != 0) { |
507 |
this.parameters.put(Logger.MESSAGE, this.main.bind("configure.incorrectVMVersionforAPT")); //$NON-NLS-1$ |
508 |
this.printTag(Logger.ERROR_TAG, this.parameters, true, true); |
509 |
} |
510 |
this.printlnErr(this.main.bind("configure.incorrectVMVersionforAPT")); //$NON-NLS-1$ |
511 |
} |
512 |
|
505 |
/** |
513 |
/** |
506 |
* |
514 |
* |
507 |
*/ |
515 |
*/ |
Lines 1515-1521
Link Here
|
1515 |
} |
1523 |
} |
1516 |
return MessageFormat.format(message, arguments); |
1524 |
return MessageFormat.format(message, arguments); |
1517 |
} |
1525 |
} |
1518 |
|
1526 |
/** |
|
|
1527 |
* Return true if and only if the running VM supports the given minimal version |
1528 |
* @param minimalSupportedVersion the given minimal version |
1529 |
* @return true if and only if the running VM supports the given minimal version, false otherwise |
1530 |
*/ |
1531 |
private boolean checkVMVersion(long minimalSupportedVersion) { |
1532 |
// the format of this property is supposed to be xx.x where x are digits. |
1533 |
String classFileVersion = System.getProperty("java.class.version"); //$NON-NLS-1$ |
1534 |
if (classFileVersion == null) { |
1535 |
// by default we don't support a class file version we cannot recognize |
1536 |
return false; |
1537 |
} |
1538 |
int index = classFileVersion.indexOf('.'); |
1539 |
if (index == -1) { |
1540 |
// by default we don't support a class file version we cannot recognize |
1541 |
return false; |
1542 |
} |
1543 |
int majorVersion; |
1544 |
try { |
1545 |
majorVersion = Integer.parseInt(classFileVersion.substring(0, index)); |
1546 |
} catch (NumberFormatException e) { |
1547 |
// by default we don't support a class file version we cannot recognize |
1548 |
return false; |
1549 |
} |
1550 |
switch(majorVersion) { |
1551 |
case 45 : // 1.0 and 1.1 |
1552 |
return ClassFileConstants.JDK1_1 >= minimalSupportedVersion; |
1553 |
case 46 : // 1.2 |
1554 |
return ClassFileConstants.JDK1_2 >= minimalSupportedVersion; |
1555 |
case 47 : // 1.3 |
1556 |
return ClassFileConstants.JDK1_3 >= minimalSupportedVersion; |
1557 |
case 48 : // 1.4 |
1558 |
return ClassFileConstants.JDK1_4 >= minimalSupportedVersion; |
1559 |
case 49 : // 1.5 |
1560 |
return ClassFileConstants.JDK1_5 >= minimalSupportedVersion; |
1561 |
case 50 : // 1.6 |
1562 |
return ClassFileConstants.JDK1_6 >= minimalSupportedVersion; |
1563 |
case 51 : // 1.7 |
1564 |
return ClassFileConstants.JDK1_7 >= minimalSupportedVersion; |
1565 |
} |
1566 |
// unknown version |
1567 |
return false; |
1568 |
} |
1519 |
/* |
1569 |
/* |
1520 |
* Low-level API performing the actual compilation |
1570 |
* Low-level API performing the actual compilation |
1521 |
*/ |
1571 |
*/ |
Lines 3329-3337
Link Here
|
3329 |
|
3379 |
|
3330 |
if (this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_6 |
3380 |
if (this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_6 |
3331 |
&& this.compilerOptions.processAnnotations) { |
3381 |
&& this.compilerOptions.processAnnotations) { |
3332 |
initializeAnnotationProcessorManager(); |
3382 |
if (checkVMVersion(ClassFileConstants.JDK1_6)) { |
3333 |
if (this.classNames != null) { |
3383 |
initializeAnnotationProcessorManager(); |
3334 |
this.batchCompiler.setBinaryTypes(processClassNames(this.batchCompiler.lookupEnvironment)); |
3384 |
if (this.classNames != null) { |
|
|
3385 |
this.batchCompiler.setBinaryTypes(processClassNames(this.batchCompiler.lookupEnvironment)); |
3386 |
} |
3387 |
} else { |
3388 |
// report a warning |
3389 |
this.logger.logIncorrectVMVersionForAnnotationProcessing(); |
3335 |
} |
3390 |
} |
3336 |
} |
3391 |
} |
3337 |
|
3392 |
|
Lines 3396-3401
Link Here
|
3396 |
} catch (IllegalAccessException e) { |
3451 |
} catch (IllegalAccessException e) { |
3397 |
// should not happen |
3452 |
// should not happen |
3398 |
throw new org.eclipse.jdt.internal.compiler.problem.AbortCompilation(); |
3453 |
throw new org.eclipse.jdt.internal.compiler.problem.AbortCompilation(); |
|
|
3454 |
} catch(UnsupportedClassVersionError e) { |
3455 |
// report a warning |
3456 |
this.logger.logIncorrectVMVersionForAnnotationProcessing(); |
3399 |
} |
3457 |
} |
3400 |
} |
3458 |
} |
3401 |
public void printUsage() { |
3459 |
public void printUsage() { |
Lines 3918-3928
Link Here
|
3918 |
&& CompilerOptions.versionToJdkLevel(targetVersion) < ClassFileConstants.JDK1_5){ |
3976 |
&& CompilerOptions.versionToJdkLevel(targetVersion) < ClassFileConstants.JDK1_5){ |
3919 |
throw new InvalidInputException(this.bind("configure.incompatibleTargetForSource", (String) targetVersion, CompilerOptions.VERSION_1_5)); //$NON-NLS-1$ |
3977 |
throw new InvalidInputException(this.bind("configure.incompatibleTargetForSource", (String) targetVersion, CompilerOptions.VERSION_1_5)); //$NON-NLS-1$ |
3920 |
} |
3978 |
} |
3921 |
// target must be 1.4 if source is 1.4 |
3979 |
// target must be 1.4 if source is 1.4 |
3922 |
if (CompilerOptions.versionToJdkLevel(sourceVersion) >= ClassFileConstants.JDK1_4 |
3980 |
if (CompilerOptions.versionToJdkLevel(sourceVersion) >= ClassFileConstants.JDK1_4 |
3923 |
&& CompilerOptions.versionToJdkLevel(targetVersion) < ClassFileConstants.JDK1_4){ |
3981 |
&& CompilerOptions.versionToJdkLevel(targetVersion) < ClassFileConstants.JDK1_4){ |
3924 |
throw new InvalidInputException(this.bind("configure.incompatibleTargetForSource", (String) targetVersion, CompilerOptions.VERSION_1_4)); //$NON-NLS-1$ |
3982 |
throw new InvalidInputException(this.bind("configure.incompatibleTargetForSource", (String) targetVersion, CompilerOptions.VERSION_1_4)); //$NON-NLS-1$ |
3925 |
} |
3983 |
} |
3926 |
// target cannot be greater than compliance level |
3984 |
// target cannot be greater than compliance level |
3927 |
if (CompilerOptions.versionToJdkLevel(compliance) < CompilerOptions.versionToJdkLevel(targetVersion)){ |
3985 |
if (CompilerOptions.versionToJdkLevel(compliance) < CompilerOptions.versionToJdkLevel(targetVersion)){ |
3928 |
throw new InvalidInputException(this.bind("configure.incompatibleComplianceForTarget", (String)this.options.get(CompilerOptions.OPTION_Compliance), (String) targetVersion)); //$NON-NLS-1$ |
3986 |
throw new InvalidInputException(this.bind("configure.incompatibleComplianceForTarget", (String)this.options.get(CompilerOptions.OPTION_Compliance), (String) targetVersion)); //$NON-NLS-1$ |