View | Details | Raw Unified | Return to bug 164707 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-1 / +9 lines)
Lines 42-47 Link Here
42
import org.eclipse.jdt.internal.codeassist.CompletionEngine;
42
import org.eclipse.jdt.internal.codeassist.CompletionEngine;
43
import org.eclipse.jdt.internal.codeassist.SelectionEngine;
43
import org.eclipse.jdt.internal.codeassist.SelectionEngine;
44
import org.eclipse.jdt.internal.compiler.Compiler;
44
import org.eclipse.jdt.internal.compiler.Compiler;
45
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
45
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
46
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
46
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
47
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
47
import org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt;
48
import org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt;
Lines 329-335 Link Here
329
		 */
330
		 */
330
		private int indexForSourceLevel(String sourceLevel) {
331
		private int indexForSourceLevel(String sourceLevel) {
331
			if (sourceLevel == null) return 0;
332
			if (sourceLevel == null) return 0;
332
			return sourceLevel.charAt(2) - 49;
333
			long jdkLevel = CompilerOptions.versionToJdkLevel(sourceLevel);
334
			if (jdkLevel == 0) {
335
				if (VERBOSE) {
336
					System.out.println(sourceLevel+" is not a valid compiler source level (1.1 -> 1.6 expected)"); //$NON-NLS-1$
337
				}
338
				return 0;
339
			}
340
			return ((int)(jdkLevel >>> 16)) - ClassFileConstants.MAJOR_VERSION_1_1;
333
		}
341
		}
334
		
342
		
335
		private int sortParticipants(ArrayList group, IConfigurationElement[] configElements, int index) {
343
		private int sortParticipants(ArrayList group, IConfigurationElement[] configElements, int index) {
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (-12 / +24 lines)
Lines 832-849 Link Here
832
		}
832
		}
833
	}				
833
	}				
834
	public static long versionToJdkLevel(Object versionID) {
834
	public static long versionToJdkLevel(Object versionID) {
835
		if (VERSION_1_1.equals(versionID)) {
835
		if (versionID instanceof String) {
836
			return ClassFileConstants.JDK1_1;
836
			String version = (String) versionID;
837
		} else if (VERSION_1_2.equals(versionID)) {
837
			// verification is optimized using the fact that all versions have same length and start with "1."
838
			return ClassFileConstants.JDK1_2;
838
			if (version.length() == 3 && version.charAt(0) == '1' && version.charAt(1) == '.') {
839
		} else if (VERSION_1_3.equals(versionID)) {
839
				switch (version.charAt(2)) {
840
			return ClassFileConstants.JDK1_3;
840
					case '1':
841
		} else if (VERSION_1_4.equals(versionID) || VERSION_JSR14.equals(versionID)) {
841
						return ClassFileConstants.JDK1_1;
842
			return ClassFileConstants.JDK1_4;
842
					case '2':
843
		} else if (VERSION_1_5.equals(versionID)) {
843
						return ClassFileConstants.JDK1_2;
844
			return ClassFileConstants.JDK1_5;
844
					case '3':
845
		} else if (VERSION_1_6.equals(versionID)) {
845
						return ClassFileConstants.JDK1_3;
846
			return ClassFileConstants.JDK1_6;
846
					case '4':
847
						return ClassFileConstants.JDK1_4;
848
					case '5':
849
						return ClassFileConstants.JDK1_5;
850
					case '6':
851
						return ClassFileConstants.JDK1_6;
852
					default:
853
						return 0; // unknown
854
				}
855
			}
856
			if (VERSION_JSR14.equals(versionID)) {
857
				return ClassFileConstants.JDK1_4;
858
			}
847
		}
859
		}
848
		return 0; // unknown
860
		return 0; // unknown
849
	}
861
	}
(-)src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java (+15 lines)
Lines 19-24 Link Here
19
import org.eclipse.core.resources.IMarker;
19
import org.eclipse.core.resources.IMarker;
20
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IPath;
22
import org.eclipse.jdt.core.IJavaProject;
22
import org.eclipse.jdt.core.JavaCore;
23
import org.eclipse.jdt.core.JavaCore;
23
import org.eclipse.jdt.core.JavaModelException;
24
import org.eclipse.jdt.core.JavaModelException;
24
import org.eclipse.jdt.core.tests.util.Util;
25
import org.eclipse.jdt.core.tests.util.Util;
Lines 402-405 Link Here
402
		fullBuild(projectPath);
403
		fullBuild(projectPath);
403
		expectingNoProblems();
404
		expectingNoProblems();
404
	}
405
	}
406
407
	/**
408
	 * @bug 164707: ArrayIndexOutOfBoundsException in JavaModelManager if source level == 6.0
409
	 * @test Ensure that AIIOB does not longer happen with invalid source level string
410
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=164707"
411
	 */
412
	public void testBug164707() throws JavaModelException {
413
		IPath projectPath = env.addProject("Project"); //$NON-NLS-1$
414
		IJavaProject javaProject = env.getJavaProject(projectPath); 
415
		javaProject.setOption(JavaCore.COMPILER_SOURCE, "invalid");
416
		env.addExternalJars(projectPath, Util.getJavaClassLibs());
417
		fullBuild(projectPath);
418
		expectingNoProblems();
419
	}
405
}
420
}

Return to bug 164707