### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java,v retrieving revision 1.230 diff -u -r1.230 CompilerOptions.java --- compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 25 Feb 2010 19:17:04 -0000 1.230 +++ compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 30 Aug 2010 10:11:15 -0000 @@ -342,6 +342,8 @@ public boolean generateClassFiles; /** Indicate if method bodies should be ignored */ public boolean ignoreMethodBodies; + /** Indicate if generics (type parameters and such) should be retained */ + public boolean shouldRetainGenerics; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=323633 // keep in sync with warningTokenToIrritant and warningTokenFromIrritant public final static String[] warningTokens = { @@ -1048,6 +1050,9 @@ // ignore method bodies this.ignoreMethodBodies = false; + + // throw away generics + this.shouldRetainGenerics = false; } public void set(Map optionsMap) { Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java,v retrieving revision 1.123 diff -u -r1.123 BinaryTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 21 Sep 2009 23:37:04 -0000 1.123 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 30 Aug 2010 10:11:21 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -149,7 +149,7 @@ this.fPackage = packageBinding; this.fileName = binaryType.getFileName(); - char[] typeSignature = environment.globalOptions.sourceLevel >= ClassFileConstants.JDK1_5 ? binaryType.getGenericSignature() : null; + char[] typeSignature = (environment.globalOptions.sourceLevel >= ClassFileConstants.JDK1_5 || environment.globalOptions.shouldRetainGenerics) ? binaryType.getGenericSignature() : null; this.typeVariables = typeSignature != null && typeSignature.length > 0 && typeSignature[0] == '<' ? null // is initialized in cachePartsFrom (called from LookupEnvironment.createBinaryTypeFrom())... must set to null so isGenericType() answers true : Binding.NO_TYPE_VARIABLES; @@ -262,7 +262,7 @@ long sourceLevel = this.environment.globalOptions.sourceLevel; char[] typeSignature = null; - if (sourceLevel >= ClassFileConstants.JDK1_5) { + if (sourceLevel >= ClassFileConstants.JDK1_5 || this.environment.globalOptions.shouldRetainGenerics) { typeSignature = binaryType.getGenericSignature(); this.tagBits |= binaryType.getTagBits(); } @@ -360,7 +360,7 @@ int size = iFields.length; if (size > 0) { this.fields = new FieldBinding[size]; - boolean use15specifics = sourceLevel >= ClassFileConstants.JDK1_5; + boolean use15specifics = sourceLevel >= ClassFileConstants.JDK1_5 || this.environment.globalOptions.shouldRetainGenerics; boolean hasRestrictedAccess = hasRestrictedAccess(); int firstAnnotatedFieldIndex = -1; for (int i = 0; i < size; i++) { @@ -411,7 +411,7 @@ AnnotationBinding[][] paramAnnotations = null; TypeBinding returnType = null; - final boolean use15specifics = sourceLevel >= ClassFileConstants.JDK1_5; + final boolean use15specifics = sourceLevel >= ClassFileConstants.JDK1_5 || this.environment.globalOptions.shouldRetainGenerics; char[] methodSignature = use15specifics ? method.getGenericSignature() : null; if (methodSignature == null) { // no generics char[] methodDescriptor = method.getMethodDescriptor(); // of the form (I[Ljava/jang/String;)V Index: model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java,v retrieving revision 1.68 diff -u -r1.68 CompilationUnitProblemFinder.java --- model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java 19 Aug 2010 08:27:29 -0000 1.68 +++ model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java 30 Aug 2010 10:11:21 -0000 @@ -177,6 +177,7 @@ CompilerOptions compilerOptions = getCompilerOptions(project.getOptions(true), creatingAST, ((reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0)); boolean ignoreMethodBodies = (reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0; compilerOptions.ignoreMethodBodies = ignoreMethodBodies; + compilerOptions.shouldRetainGenerics = project.mayNeedGenerifiedAPIs(); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=323633 problemFinder = new CompilationUnitProblemFinder( environment, getHandlingPolicy(), Index: model/org/eclipse/jdt/internal/core/JavaProject.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java,v retrieving revision 1.433 diff -u -r1.433 JavaProject.java --- model/org/eclipse/jdt/internal/core/JavaProject.java 27 May 2010 10:10:34 -0000 1.433 +++ model/org/eclipse/jdt/internal/core/JavaProject.java 30 Aug 2010 10:11:31 -0000 @@ -66,6 +66,8 @@ import org.eclipse.jdt.core.compiler.CategorizedProblem; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.eval.IEvaluationContext; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.util.ObjectVector; import org.eclipse.jdt.internal.compiler.util.SuffixConstants; import org.eclipse.jdt.internal.core.JavaModelManager.PerProjectInfo; @@ -3167,4 +3169,24 @@ } return JavaModelStatus.VERIFIED_OK; } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=323633 + public boolean mayNeedGenerifiedAPIs() { + long sourceLevel = CompilerOptions.versionToJdkLevel(getOption(JavaCore.COMPILER_SOURCE, true)); + if (sourceLevel >= ClassFileConstants.JDK1_5) { + return true; + } + try { + String [] prerequisites = getRequiredProjectNames(); + for (int i = 0, length = prerequisites.length; i < length; i++) { + IJavaProject that = getJavaModel().getJavaProject(prerequisites[i]); + if (that instanceof JavaProject) { + if (((JavaProject) that).mayNeedGenerifiedAPIs()) + return true; + } + } + } catch (JavaModelException e) { + // ignore ... + } + return false; + } }