diff -r 0173e45cf7ab java.source/src/org/netbeans/modules/java/source/parsing/JavacParser.java --- a/java.source/src/org/netbeans/modules/java/source/parsing/JavacParser.java Wed Jan 23 19:15:45 2013 +0100 +++ b/java.source/src/org/netbeans/modules/java/source/parsing/JavacParser.java Wed Jan 23 22:24:25 2013 +0100 @@ -822,6 +822,7 @@ private static @NonNull com.sun.tools.javac.code.Source validateSourceLevel(@NullAllowed String sourceLevel, ClasspathInfo cpInfo) { ClassPath bootClassPath = cpInfo.getClassPath(PathKind.BOOT); + ClassPath cmpClassPath = cpInfo.getClassPath(PathKind.COMPILE); ClassPath srcClassPath = cpInfo.getClassPath(PathKind.SOURCE); com.sun.tools.javac.code.Source[] sources = com.sun.tools.javac.code.Source.values(); Level warnLevel; @@ -837,22 +838,32 @@ if (source.compareTo(com.sun.tools.javac.code.Source.JDK1_4) >= 0) { if (bootClassPath != null && bootClassPath.findResource("java/lang/AssertionError.class") == null) { //NOI18N if (srcClassPath != null && srcClassPath.findResource("java/lang/AssertionError.java") == null) { - LOGGER.log(warnLevel, + if (bootClassPath.getRoots().length != 0 || + cmpClassPath == null || + cmpClassPath.findResource("java/lang/AssertionError.class") == null + ) { + LOGGER.log(warnLevel, "Even though the source level of {0} is set to: {1}, java.lang.AssertionError cannot be found on the bootclasspath: {2}\n" + "Changing source level to 1.3", new Object[]{cpInfo.getClassPath(PathKind.SOURCE), sourceLevel, bootClassPath}); //NOI18N - return com.sun.tools.javac.code.Source.JDK1_3; + return com.sun.tools.javac.code.Source.JDK1_3; + } } } } if (source.compareTo(com.sun.tools.javac.code.Source.JDK1_5) >= 0) { if (bootClassPath != null && bootClassPath.findResource("java/lang/StringBuilder.class") == null) { //NOI18N if (srcClassPath != null && srcClassPath.findResource("java/lang/StringBuilder.java")==null) { - LOGGER.log(warnLevel, + if (bootClassPath.getRoots().length != 0 || + cmpClassPath == null || + cmpClassPath.findResource("java/lang/StringBuilder.class") == null + ) { + LOGGER.log(warnLevel, "Even though the source level of {0} is set to: {1}, java.lang.StringBuilder cannot be found on the bootclasspath: {2}\n" + "Changing source level to 1.4", new Object[]{cpInfo.getClassPath(PathKind.SOURCE), sourceLevel, bootClassPath}); //NOI18N - return com.sun.tools.javac.code.Source.JDK1_4; + return com.sun.tools.javac.code.Source.JDK1_4; + } } } }