diff --git a/groovy-eclipse.setup b/groovy-eclipse.setup index 5e6719c510..28da0ecdb7 100644 --- a/groovy-eclipse.setup +++ b/groovy-eclipse.setup @@ -305,7 +305,7 @@ + url="https://download.eclipse.org/eclipse/updates/4.30-I-builds/I20231109-0710"/> diff --git a/ide-test/org.codehaus.groovy.eclipse.tests/src/org/codehaus/groovy/eclipse/test/actions/OrganizeImportsTestSuite.groovy b/ide-test/org.codehaus.groovy.eclipse.tests/src/org/codehaus/groovy/eclipse/test/actions/OrganizeImportsTestSuite.groovy index 876d0c4165..75a5f70690 100644 --- a/ide-test/org.codehaus.groovy.eclipse.tests/src/org/codehaus/groovy/eclipse/test/actions/OrganizeImportsTestSuite.groovy +++ b/ide-test/org.codehaus.groovy.eclipse.tests/src/org/codehaus/groovy/eclipse/test/actions/OrganizeImportsTestSuite.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ import org.codehaus.groovy.eclipse.test.GroovyEclipseTestSuite import org.eclipse.core.resources.IProject import org.eclipse.jdt.core.ICompilationUnit import org.eclipse.jdt.core.ISourceRange -import org.eclipse.jdt.core.JavaCore import org.eclipse.jdt.core.groovy.tests.ReconcilerUtils import org.eclipse.jdt.core.search.TypeNameMatch import org.eclipse.jdt.core.tests.util.Util @@ -78,10 +77,7 @@ abstract class OrganizeImportsTestSuite extends GroovyEclipseTestSuite { withProject { IProject project -> Util.delete(project.getFile('config.groovy')) } - - JavaCore.options = JavaCore.options.tap { - remove(OPTIONG_GroovyCompilerConfigScript) - } + setJavaPreference(OPTIONG_GroovyCompilerConfigScript, null) } protected void addConfigScript(CharSequence contents) { diff --git a/jdt-patch/e430/Feature-org.codehaus.groovy.jdt.patch/feature.xml b/jdt-patch/e430/Feature-org.codehaus.groovy.jdt.patch/feature.xml index b1e386dda6..27ea03ade5 100644 --- a/jdt-patch/e430/Feature-org.codehaus.groovy.jdt.patch/feature.xml +++ b/jdt-patch/e430/Feature-org.codehaus.groovy.jdt.patch/feature.xml @@ -18,7 +18,7 @@ - + = this.contents.length) { resizeContents(3); @@ -4702,7 +4698,6 @@ private boolean jdk16packageInfoAnnotation(final long annotationMask, final long return false; } /** - * @param annotations * @param targetMask allowed targets * @return the number of attributes created while dumping the annotations in the .class file */ diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/CompilationResult.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/CompilationResult.java index c10b3aa4f9..7bee2b6041 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/CompilationResult.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/CompilationResult.java @@ -68,7 +68,7 @@ public class CompilationResult { public ICompilationUnit compilationUnit; private Map problemsMap; private Set firstErrors; - private int maxProblemPerUnit; + private final int maxProblemPerUnit; public char[][][] qualifiedReferences; public char[][] simpleNameReferences; public char[][] rootReferences; @@ -87,6 +87,7 @@ public class CompilationResult { private int numberOfErrors; private boolean hasMandatoryErrors; public List annotations = new ArrayList<>(1); + private List scheduledProblems; private static final int[] EMPTY_LINE_ENDS = Util.EMPTY_INT_ARRAY; private static final Comparator PROBLEM_COMPARATOR = new Comparator() { @@ -480,4 +481,18 @@ public String toString(){ } return buffer.toString(); } + +public void scheduleProblem(Runnable task) { + if (this.scheduledProblems == null) + this.scheduledProblems = new ArrayList<>(); + this.scheduledProblems.add(task); +} + +public void materializeProblems() { + if (this.scheduledProblems != null) { + for (Runnable task : this.scheduledProblems) { + task.run(); + } + } +} } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/Compiler.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/Compiler.java index d40740549f..b5f40724a3 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/Compiler.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/Compiler.java @@ -30,7 +30,6 @@ import java.io.*; import java.util.*; -@SuppressWarnings("rawtypes") public class Compiler implements ITypeRequestor, ProblemSeverities { public Parser parser; public ICompilerRequestor requestor; @@ -162,7 +161,7 @@ public Compiler( public Compiler( INameEnvironment environment, IErrorHandlingPolicy policy, - Map settings, + Map settings, final ICompilerRequestor requestor, IProblemFactory problemFactory, boolean parseLiteralExpressionsAsConstants) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/DefaultErrorHandlingPolicies.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/DefaultErrorHandlingPolicies.java index 85b77255e5..c8d8bd9ac1 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/DefaultErrorHandlingPolicies.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/DefaultErrorHandlingPolicies.java @@ -20,7 +20,6 @@ public class DefaultErrorHandlingPolicies { * * Typically, the #proceedWithProblems(Problem[]) should * show the problems. - * */ public static IErrorHandlingPolicy exitAfterAllProblems() { return new IErrorHandlingPolicy() { @@ -41,7 +40,6 @@ public boolean ignoreAllErrors() { /* * Exit without proceeding on the first problem wich appears * to be an error. - * */ public static IErrorHandlingPolicy exitOnFirstError() { return new IErrorHandlingPolicy() { @@ -61,7 +59,6 @@ public boolean ignoreAllErrors() { } /* * Proceed on the first error met. - * */ public static IErrorHandlingPolicy proceedOnFirstError() { return new IErrorHandlingPolicy() { @@ -81,7 +78,6 @@ public boolean ignoreAllErrors() { } /* * Accumulate all problems, then proceed with them. - * */ public static IErrorHandlingPolicy proceedWithAllProblems() { return new IErrorHandlingPolicy() { @@ -101,7 +97,6 @@ public boolean ignoreAllErrors() { } /* * Accumulate all problems, then proceed with them, but never report them. - * */ public static IErrorHandlingPolicy ignoreAllProblems() { return new IErrorHandlingPolicy() { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseMessagerImpl.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseMessagerImpl.java index a8aa4cb6ef..fd51160eba 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseMessagerImpl.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseMessagerImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2020 BEA Systems, Inc. and others + * Copyright (c) 2007, 2023 BEA Systems, Inc. and others * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -57,6 +57,7 @@ public class BaseMessagerImpl { * @param e the element against which to report the message. If the element is not * in the set of elements being compiled in the current round, the reference context * and filename will be set to null. + * @return a new {@link AptProblem} */ public static AptProblem createProblem(Kind kind, CharSequence msg, Element e, AnnotationMirror a, AnnotationValue v) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java index 07f63a57eb..135fb7aede 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java @@ -58,11 +58,11 @@ public abstract class BaseProcessingEnvImpl implements ProcessingEnvironment { // Initialized in this base class: protected Elements _elementUtils; protected Types _typeUtils; - private List _addedUnits; - private List _addedClassFiles; - private List _deletedUnits; + private final List _addedUnits; + private final List _addedClassFiles; + private final List _deletedUnits; private boolean _errorRaised; - private Factory _factory; + private final Factory _factory; public ModuleBinding _current_module; public BaseProcessingEnvImpl() { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchAnnotationProcessorManager.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchAnnotationProcessorManager.java index 2751565e5f..c46738eb4e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchAnnotationProcessorManager.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchAnnotationProcessorManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2017 IBM Corporation and others. + * Copyright (c) 2005, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -34,7 +34,7 @@ /** * Java 6 annotation processor manager used when compiling from the command line - * or via the {@link javax.tools.JavaCompiler} interface. + * or via the javax.tools.JavaCompiler interface. */ public class BatchAnnotationProcessorManager extends BaseAnnotationProcessorManager { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/HookedJavaFileObject.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/HookedJavaFileObject.java index d9c035afc1..a668e44dde 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/HookedJavaFileObject.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/HookedJavaFileObject.java @@ -200,7 +200,7 @@ public String toString() { */ private boolean _closed = false; - private String _typeName; + private final String _typeName; public HookedJavaFileObject(JavaFileObject fileObject, String fileName, String typeName, BatchFilerImpl filer) { super(fileObject); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/IProcessorProvider.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/IProcessorProvider.java index 5e88da3580..ae4e7dc751 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/IProcessorProvider.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/IProcessorProvider.java @@ -44,7 +44,6 @@ public interface IProcessorProvider { * unchecked exception, etc; the caller should not assume that this method will return. * * @param p the processor, if known, or null if not. - * @param e */ void reportProcessorException(Processor p, Exception e); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundDispatcher.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundDispatcher.java index 78bb434bff..15131a4832 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundDispatcher.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundDispatcher.java @@ -49,7 +49,6 @@ public class RoundDispatcher { * avoid modifying the set passed in. * @param traceProcessorInfo a PrintWriter that processor trace output will be sent * to, or null if tracing is not desired. - * @param traceRounds */ public RoundDispatcher( IProcessorProvider provider, diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationValueImpl.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationValueImpl.java index 9377244594..d11e047d61 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationValueImpl.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationValueImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2017 IBM Corporation and others. + * Copyright (c) 2005, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -124,6 +124,7 @@ public AnnotationValueImpl(BaseProcessingEnvImpl env, Object value, TypeBinding * BaseTypeBinding, this is ignored and the value is inspected to determine type. * @param kind an int array whose first element will be set to the type of the * converted object, represented with T_* values from TypeIds or from this class. + * @return converted mirror type */ private Object convertToMirrorType(Object value, TypeBinding type, int kind[]) { if (type == null) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableTypeImpl.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableTypeImpl.java index a95bb4a72f..4beec43887 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableTypeImpl.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableTypeImpl.java @@ -34,7 +34,6 @@ /** * Implementation of the ExecutableType - * */ public class ExecutableTypeImpl extends TypeMirrorImpl implements ExecutableType { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java index f8503e1b67..75da09e4cc 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java @@ -585,7 +585,6 @@ public ErrorType getErrorType(ReferenceBinding binding) { * * @param value the current value from the annotation instance. * @param expectedType the expected type of the value. - * */ public static Object performNecessaryPrimitiveTypeConversion( final Class expectedType, @@ -776,9 +775,6 @@ else if( value instanceof Boolean ){ /** * Set an element of an array to the appropriate dummy value type - * @param array - * @param i - * @param expectedLeafType */ public static void setArrayMatchingDummyValue(Object array, int i, Class expectedLeafType) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java index 5ea8f05c49..4212db5f3f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2021 IBM Corporation and others. + * Copyright (c) 2005, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -56,7 +56,6 @@ public class TypeElementImpl extends ElementImpl implements TypeElement { /** * Compares Element instances possibly returned by * {@link TypeElement#getEnclosedElements()} based on their source location, if available. - * */ private static final class SourceLocationComparator implements Comparator { private final IdentityHashMap sourceStartCache = new IdentityHashMap<>(); @@ -128,7 +127,8 @@ private int determineSourceStart(ElementImpl e) { private final ElementKind _kindHint; /** - * In general, clients should call {@link Factory#newElement(Binding)} to create new instances. + * In general, clients should call {@link Factory#newElement(org.eclipse.jdt.internal.compiler.lookup.Binding)} + * to create new instances. */ TypeElementImpl(BaseProcessingEnvImpl env, ReferenceBinding binding, ElementKind kindHint) { super(env, binding); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeParameterElementImpl.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeParameterElementImpl.java index 493b865757..a6502f35b6 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeParameterElementImpl.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeParameterElementImpl.java @@ -38,9 +38,6 @@ import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding; -/** - * - */ public class TypeParameterElementImpl extends ElementImpl implements TypeParameterElement { private final Element _declaringElement; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ASTNode.java index c91855bfaf..21246d36fc 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ASTNode.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ASTNode.java @@ -1051,7 +1051,7 @@ public static void resolveAnnotations(BlockScope scope, Annotation[] sourceAnnot By construction the bindings associated with QTR, PQTR etc get resolved first and then annotations for different levels get resolved and applied at one go. Likewise for multidimensional arrays. - @Returns the annotated type binding. + @return the annotated type binding. */ public static TypeBinding resolveAnnotations(BlockScope scope, Annotation[][] sourceAnnotations, TypeBinding type) { int levels = sourceAnnotations == null ? 0 : sourceAnnotations.length; @@ -1071,7 +1071,6 @@ public static TypeBinding resolveAnnotations(BlockScope scope, Annotation[][] so /** * "early" handling of NonNullByDefault because for local variables annotations are resolved after their type because of bug * 96991. - * @param localDeclaration */ public static void handleNonNullByDefault(BlockScope scope, Annotation[] sourceAnnotations, LocalDeclaration localDeclaration) { if (sourceAnnotations == null || sourceAnnotations.length == 0) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java index 3ad1308086..c86fd84e0e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java @@ -257,8 +257,6 @@ public CompilationResult compilationResult() { /** * Bytecode generation for a method - * @param classScope - * @param classFile */ public void generateCode(ClassScope classScope, ClassFile classFile) { @@ -487,8 +485,6 @@ public boolean isStatic() { /** * Fill up the method body with statement - * @param parser - * @param unit */ public abstract void parseStatements(Parser parser, CompilationUnitDeclaration unit); @@ -651,14 +647,15 @@ public void resolveJavadoc() { // Set javadoc visibility int javadocVisibility = this.binding.modifiers & ExtraCompilerModifiers.AccVisibilityMASK; ClassScope classScope = this.scope.classScope(); - ProblemReporter reporter = this.scope.problemReporter(); - int severity = reporter.computeSeverity(IProblem.JavadocMissing); - if (severity != ProblemSeverities.Ignore) { - if (classScope != null) { - javadocVisibility = Util.computeOuterMostVisibility(classScope.referenceType(), javadocVisibility); + try (ProblemReporter reporter = this.scope.problemReporter()) { + int severity = reporter.computeSeverity(IProblem.JavadocMissing); + if (severity != ProblemSeverities.Ignore) { + if (classScope != null) { + javadocVisibility = Util.computeOuterMostVisibility(classScope.referenceType(), javadocVisibility); + } + int javadocModifiers = (this.binding.modifiers & ~ExtraCompilerModifiers.AccVisibilityMASK) | javadocVisibility; + reporter.javadocMissing(this.sourceStart, this.sourceEnd, severity, javadocModifiers); } - int javadocModifiers = (this.binding.modifiers & ~ExtraCompilerModifiers.AccVisibilityMASK) | javadocVisibility; - reporter.javadocMissing(this.sourceStart, this.sourceEnd, severity, javadocModifiers); } } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java index e7c62fd53d..da09b09f9c 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java @@ -597,13 +597,17 @@ public MethodBinding inferConstructorOfElidedParameterizedType(final Scope scope MethodBinding constructor = inferDiamondConstructor(scope, this, this.type.resolvedType, this.argumentTypes, inferredReturnTypeOut); if (constructor != null) { this.inferredReturnType = inferredReturnTypeOut[0]; - if (constructor instanceof ParameterizedGenericMethodBinding && scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_8) { - // force an inference context to be established for nested poly allocations (to be able to transfer b2), but avoid tunneling through overload resolution. We know this is the MSMB. - if (this.expressionContext == INVOCATION_CONTEXT && this.typeExpected == null) + if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_8 + && this.expressionContext == INVOCATION_CONTEXT && this.typeExpected == null) { // not ready for invocation type inference + if (constructor instanceof PolyParameterizedGenericMethodBinding) { + return constructor; // keep this placeholder binding, which also serves as a key into #inferenceContexts + } else if (constructor instanceof ParameterizedGenericMethodBinding) { + // force an inference context to be established for nested poly allocations (to be able to transfer b2), but avoid tunneling through overload resolution. We know this is the MSMB. constructor = ParameterizedGenericMethodBinding.computeCompatibleMethod18(constructor.shallowOriginal(), this.argumentTypes, scope, this); - } - if (this.typeExpected != null && this.typeExpected.isProperType(true)) + } + } else if (this.typeExpected != null && this.typeExpected.isProperType(true)) { registerResult(this.typeExpected, constructor); + } } return constructor; } @@ -616,6 +620,8 @@ public static MethodBinding inferDiamondConstructor(Scope scope, InvocationSite // Given the allocation type and the arguments to the constructor, see if we can infer the constructor of the elided parameterized type. MethodBinding factory = scope.getStaticFactory(allocationType, enclosingType, argumentTypes, site); if (factory instanceof ParameterizedGenericMethodBinding && factory.isValidBinding()) { + if (site.invocationTargetType() == null && site.getExpressionContext().definesTargetType() && factory instanceof PolyParameterizedGenericMethodBinding) + return factory; // during applicability inference keep the PolyParameterizedGenericMethodBinding ParameterizedGenericMethodBinding genericFactory = (ParameterizedGenericMethodBinding) factory; inferredReturnTypeOut[0] = genericFactory.inferredReturnType; SyntheticFactoryMethodBinding sfmb = (SyntheticFactoryMethodBinding) factory.original(); @@ -671,7 +677,7 @@ public void checkTypeArgumentRedundancy(ParameterizedTypeBinding allocationType, break; } if (i == allocationType.arguments.length) { - scope.problemReporter().redundantSpecificationOfTypeArguments(this.type, allocationType.arguments); + reportTypeArgumentRedundancyProblem(allocationType, scope); return; } } @@ -838,4 +844,4 @@ public int nameSourceEnd() { else return this.type.sourceEnd; } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CaseStatement.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CaseStatement.java index 7ebdb78807..c94d9a6613 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CaseStatement.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CaseStatement.java @@ -150,7 +150,6 @@ public StringBuffer printStatement(int tab, StringBuffer output) { /** * Case code generation - * */ @Override public void generateCode(BlockScope currentScope, CodeStream codeStream) { @@ -199,8 +198,8 @@ public static class ResolvedCase { public TypeBinding t; // For ease of access. This.e contains the type binding anyway. public int index; private int intValue; - private boolean isPattern; - private boolean isQualifiedEnum; + private final boolean isPattern; + private final boolean isQualifiedEnum; public int enumDescIdx; public int classDescIdx; ResolvedCase(Constant c, Expression e, TypeBinding t, int index, boolean isQualifiedEnum) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java index f1b2eb7173..17fb0f8e0e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java @@ -246,6 +246,7 @@ public TypeDeclaration declarationOfType(char[][] typeName) { } public void finalizeProblems() { + this.compilationResult.materializeProblems(); int problemCount = this.compilationResult.problemCount; CategorizedProblem[] problems = this.compilationResult.problems; if (this.suppressWarningsCount == 0) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/DoStatement.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/DoStatement.java index 8bd10b4613..6ef69c8b40 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/DoStatement.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/DoStatement.java @@ -155,7 +155,6 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl /** * Do statement code generation - * */ @Override public void generateCode(BlockScope currentScope, CodeStream codeStream) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java index 2e67a40201..bb662468eb 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java @@ -486,7 +486,6 @@ public void generateOptimizedBooleanEqual(BlockScope currentScope, CodeStream co } /** * Boolean generation for == with non-boolean operands - * */ public void generateNonBooleanEqual(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { @@ -695,7 +694,6 @@ public void generateNonBooleanEqual(BlockScope currentScope, CodeStream codeStre /** * Boolean generation for == with non-boolean operands - * */ public void generateOptimizedNonBooleanEqual(BlockScope currentScope, CodeStream codeStream, BranchLabel trueLabel, BranchLabel falseLabel, boolean valueRequired) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Expression.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Expression.java index f647d1ccfd..52a21ad7c4 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Expression.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Expression.java @@ -247,10 +247,6 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl * More sophisticated for of the flow analysis used for analyzing expressions, and be able to optimize out * portions of expressions where no actual value is required. * - * @param currentScope - * @param flowContext - * @param flowInfo - * @param valueRequired * @return The state of initialization after the analysis of the current expression */ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, boolean valueRequired) { @@ -825,11 +821,6 @@ public void propagatePatternVariablesInScope(LocalVariableBinding[] vars, BlockS /** * Default generation of a boolean value - * @param currentScope - * @param codeStream - * @param trueLabel - * @param falseLabel - * @param valueRequired */ public void generateOptimizedBoolean(BlockScope currentScope, CodeStream codeStream, BranchLabel trueLabel, BranchLabel falseLabel, boolean valueRequired) { // a label valued to nil means: by default we fall through the case... @@ -1174,7 +1165,6 @@ public TypeBinding resolveExpressionType(BlockScope scope) { /** * Resolve the type of this expression in the context of a blockScope * - * @param scope * @return * Return the actual type of this expression after resolution */ @@ -1186,7 +1176,6 @@ public TypeBinding resolveType(BlockScope scope) { /** * Resolve the type of this expression in the context of a classScope * - * @param scope * @return * Return the actual type of this expression after resolution */ @@ -1351,9 +1340,6 @@ public void tagAsNeedCheckCast() { /** * Record the fact a cast expression got detected as being unnecessary. - * - * @param scope - * @param castType */ public void tagAsUnnecessaryCast(Scope scope, TypeBinding castType) { // do nothing by default @@ -1372,8 +1358,6 @@ public Expression toTypeReference() { /** * Traverse an expression in the context of a blockScope - * @param visitor - * @param scope */ @Override public void traverse(ASTVisitor visitor, BlockScope scope) { @@ -1382,8 +1366,6 @@ public void traverse(ASTVisitor visitor, BlockScope scope) { /** * Traverse an expression in the context of a classScope - * @param visitor - * @param scope */ public void traverse(ASTVisitor visitor, ClassScope scope) { // nothing to do @@ -1426,4 +1408,4 @@ public boolean isPotentiallyCompatibleWith(TypeBinding targetType, Scope scope) protected Constant optimizedNullComparisonConstant() { return Constant.NotAConstant; } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakeDefaultLiteral.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakeDefaultLiteral.java index 9ea39f5656..7199c2a9e7 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakeDefaultLiteral.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakeDefaultLiteral.java @@ -20,7 +20,6 @@ * Sole purpose of {@link FakeDefaultLiteral} is to appear * in case 'default' of switch patterns (JEP 406 at the time * of writing this comment) - * */ public class FakeDefaultLiteral extends MagicLiteral { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java index 9dcd98b004..f36feebdd3 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java @@ -174,7 +174,6 @@ public void resolve (BlockScope scope) { *
  • value is a local variable reference, create tracking variable it if needed. *
  • value is an allocation expression, return a preliminary tracking variable if set. * - * @param expression * @return a new {@link FakedTrackingVariable} or null. */ public static FakedTrackingVariable getCloseTrackingVariable(Expression expression, FlowInfo flowInfo, FlowContext flowContext) { @@ -535,7 +534,6 @@ private static FakedTrackingVariable findCloseTracker(BlockScope scope, FlowInfo * @param scope scope containing the assignment * @param upstreamInfo info without analysis of the rhs, use this to determine the status of a resource being disconnected * @param flowInfo info with analysis of the rhs, use this for recording resource status because this will be passed downstream - * @param flowContext * @param location where to report warnigs/errors against * @param rhs the right hand side of the assignment, this expression is to be analyzed. * The caller has already checked that the rhs is either of a closeable type or null. @@ -796,8 +794,6 @@ public int findMostSpecificStatus(FlowInfo flowInfo, BlockScope currentScope, Bl /** * Get the null status looking even into unreachable flows - * @param local - * @param flowInfo * @return one of the constants FlowInfo.{NULL,POTENTIALLY_NULL,POTENTIALLY_NON_NULL,NON_NULL}. */ private int getNullStatusAggressively(LocalVariableBinding local, FlowInfo flowInfo) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FalseLiteral.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FalseLiteral.java index 14a0d1074b..6c19fac12c 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FalseLiteral.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FalseLiteral.java @@ -21,9 +21,9 @@ import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; public class FalseLiteral extends MagicLiteral { - + static final char[] source = {'f', 'a', 'l', 's', 'e'}; - + public FalseLiteral(int s , int e) { super(s,e); } @@ -66,9 +66,6 @@ public void generateOptimizedBoolean(BlockScope currentScope, CodeStream codeStr public TypeBinding literalType(BlockScope scope) { return TypeBinding.BOOLEAN; } -/** - * - */ @Override public char[] source() { return source; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java index 5708e444e3..d0ba20d89f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java @@ -242,10 +242,10 @@ protected TypeBinding reportSamProblem(BlockScope blockScope, MethodBinding sam) static class VisibilityInspector extends TypeBindingVisitor { - private Scope scope; - private boolean shouldChatter; + private final Scope scope; + private final boolean shouldChatter; private boolean visible = true; - private FunctionalExpression expression; + private final FunctionalExpression expression; public VisibilityInspector(FunctionalExpression expression, Scope scope, boolean shouldChatter) { this.scope = scope; @@ -392,4 +392,4 @@ boolean requiresBridges() { public void cleanUp() { // to be overridden by sub-classes } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IJavadocTypeReference.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IJavadocTypeReference.java index c21cdaec28..5c22566e59 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IJavadocTypeReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IJavadocTypeReference.java @@ -17,7 +17,6 @@ * Interface to allow Javadoc parser to collect both JavaSingleTypeReference and JavaQualifiedTypeReferences * * @author jjohnstn - * */ public interface IJavadocTypeReference { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IntLiteral.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IntLiteral.java index 36d1183428..05cff9baef 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IntLiteral.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IntLiteral.java @@ -30,7 +30,7 @@ public class IntLiteral extends NumberLiteral { private static final char[] DECIMAL_MIN_VALUE = "2147483648".toCharArray(); //$NON-NLS-1$ private static final char[] DECIMAL_MAX_VALUE = "2147483647".toCharArray(); //$NON-NLS-1$ - private char[] reducedForm; // no underscores + private final char[] reducedForm; // no underscores public int value; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Javadoc.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Javadoc.java index f52a9b7a2b..fef841670f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Javadoc.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Javadoc.java @@ -1055,14 +1055,14 @@ private void verifyTypeReference(Expression reference, Expression typeReference, int scopeModifiers = -1; // reference must have enough visibility to be used - if (!canBeSeen(scope.problemReporter().options.reportInvalidJavadocTagsVisibility, modifiers)) { + if (!canBeSeen(scope.compilerOptions().reportInvalidJavadocTagsVisibility, modifiers)) { scope.problemReporter().javadocHiddenReference(typeReference.sourceStart, reference.sourceEnd, scope, modifiers); return; } // type reference must have enough visibility to be used if (reference != typeReference) { - if (!canBeSeen(scope.problemReporter().options.reportInvalidJavadocTagsVisibility, resolvedType.modifiers)) { + if (!canBeSeen(scope.compilerOptions().reportInvalidJavadocTagsVisibility, resolvedType.modifiers)) { scope.problemReporter().javadocHiddenReference(typeReference.sourceStart, typeReference.sourceEnd, scope, resolvedType.modifiers); return; } @@ -1206,7 +1206,7 @@ private boolean verifyModuleReference(Expression reference, Expression typeRefer } if (!bindingFound) { - if (!canBeSeen(scope.problemReporter().options.reportInvalidJavadocTagsVisibility, moduleType.modifiers)) { + if (!canBeSeen(scope.compilerOptions().reportInvalidJavadocTagsVisibility, moduleType.modifiers)) { scope.problemReporter().javadocHiddenReference(typeReference.sourceStart, typeReference.sourceEnd, scope, moduleType.modifiers); return bindingFound; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocQualifiedTypeReference.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocQualifiedTypeReference.java index 8466b6dd7a..ae71c8040b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocQualifiedTypeReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocQualifiedTypeReference.java @@ -32,7 +32,7 @@ public class JavadocQualifiedTypeReference extends QualifiedTypeReference implem public int tagSourceStart, tagSourceEnd; public PackageBinding packageBinding; public ModuleBinding moduleBinding; - private boolean canBeModule; + private final boolean canBeModule; public JavadocQualifiedTypeReference(char[][] sources, long[] pos, int tagStart, int tagEnd) { this(sources, pos, tagStart, tagEnd, false); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java index a0abd3bf90..f5ca09aeb4 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java @@ -35,7 +35,7 @@ public class JavadocSingleTypeReference extends SingleTypeReference implements I public int tagSourceStart, tagSourceEnd; public PackageBinding packageBinding; public ModuleBinding moduleBinding; - private boolean canBeModule; + private final boolean canBeModule; public JavadocSingleTypeReference(char[] source, long pos, int tagStart, int tagEnd) { this(source, pos, tagStart, tagEnd, false); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java index 63dec4e1ce..710be87ff7 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java @@ -120,7 +120,7 @@ public class LambdaExpression extends FunctionalExpression implements IPolyExpre boolean voidCompatible = true; boolean valueCompatible = false; boolean returnsValue; - private boolean requiresGenericSignature; + private final boolean requiresGenericSignature; boolean returnsVoid; public LambdaExpression original = this; private boolean committed = false; @@ -299,6 +299,13 @@ public TypeBinding resolveType(BlockScope blockScope, boolean skipKosherCheck) { blockScope.enclosingSourceType()); this.binding.typeVariables = Binding.NO_TYPE_VARIABLES; + MethodScope enm = this.scope.namedMethodScope(); + MethodBinding enmb = enm == null ? null : enm.referenceMethodBinding(); + if (enmb != null && enmb.isViewedAsDeprecated()) { + this.binding.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly; + this.binding.tagBits |= enmb.tagBits & TagBits.AnnotationTerminallyDeprecated; + } + boolean argumentsHaveErrors = false; if (haveDescriptor) { int parametersLength = this.descriptor.parameters.length; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java index f037f02ba9..9f63c72af6 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java @@ -30,7 +30,7 @@ public class LongLiteral extends NumberLiteral { private static final char[] DECIMAL_MIN_VALUE = "9223372036854775808L".toCharArray(); //$NON-NLS-1$ private static final char[] DECIMAL_MAX_VALUE = "9223372036854775807L".toCharArray(); //$NON-NLS-1$ - private char[] reducedForm; // no underscores + private final char[] reducedForm; // no underscores public static LongLiteral buildLongLiteral(char[] token, int s, int e) { // remove '_' and prefix '0' first diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ModuleStatement.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ModuleStatement.java index a53484f630..ba1fbbbf02 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ModuleStatement.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ModuleStatement.java @@ -7,16 +7,15 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation - * + * *******************************************************************************/ package org.eclipse.jdt.internal.compiler.ast; /** * Just a marker class to represent statements that can occur in a module declaration - * */ public abstract class ModuleStatement extends ASTNode { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java index 682637452c..8afda56374 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java @@ -216,8 +216,6 @@ public static int checkAssignment(BlockScope currentScope, FlowContext flowConte /** * Find any mismatches between the two given types, which are caused by null type annotations. - * @param requiredType - * @param providedType * @param nullStatus we are only interested in NULL or NON_NULL, -1 indicates that we are in a recursion, where flow info is ignored * @return a status object representing the severity of mismatching plus optionally a supertype hint */ @@ -226,8 +224,6 @@ public static NullAnnotationMatching analyse(TypeBinding requiredType, TypeBindi } /** * Find any mismatches between the two given types, which are caused by null type annotations. - * @param requiredType - * @param providedType * @param providedSubstitute in inheritance situations this maps the providedType into the realm of the subclass, needed for TVB identity checks. * Pass null if not interested in these added checks. * @param substitution TODO diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java index 186a523a66..fd9be2c547 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java @@ -40,11 +40,6 @@ public class ParameterizedQualifiedTypeReference extends ArrayQualifiedTypeRefer public TypeReference[][] typeArguments; ReferenceBinding[] typesPerToken; - /** - * @param tokens - * @param dim - * @param positions - */ public ParameterizedQualifiedTypeReference(char[][] tokens, TypeReference[][] typeArguments, int dim, long[] positions) { super(tokens, dim, positions); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Pattern.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Pattern.java index edc9e839d4..16744debd1 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Pattern.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Pattern.java @@ -76,7 +76,6 @@ public void setEnclosingPattern(Pattern enclosingPattern) { /** * Implement the rules in the spec under 14.11.1.1 Exhaustive Switch Blocks * - * @param type * @return whether pattern covers the given type or not */ public boolean coversType(TypeBinding type) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java index 3014f1e67f..37ecfbe989 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java @@ -696,21 +696,21 @@ public void traverse(ASTVisitor visitor, BlockScope scope) { } @Override protected void reportTypeArgumentRedundancyProblem(ParameterizedTypeBinding allocationType, final BlockScope scope) { - if (checkDiamondOperatorCanbeRemoved(scope)) { + if (diamondOperatorCanbeDeployed(scope)) { scope.problemReporter().redundantSpecificationOfTypeArguments(this.type, allocationType.arguments); } } - private boolean checkDiamondOperatorCanbeRemoved(final BlockScope scope) { + private boolean diamondOperatorCanbeDeployed(final BlockScope scope) { if (this.anonymousType != null && this.anonymousType.methods != null && this.anonymousType.methods.length > 0) { //diamond operator is allowed for anonymous types only from java 9 if (scope.compilerOptions().complianceLevel < ClassFileConstants.JDK9) return false; for (AbstractMethodDeclaration method : this.anonymousType.methods) { - if ( method.binding != null && (method.binding.modifiers & ExtraCompilerModifiers.AccOverriding) == 0) + if (method.binding != null && !method.binding.isConstructor() && !method.binding.isPrivate() && (method.binding.modifiers & (ExtraCompilerModifiers.AccOverriding | ExtraCompilerModifiers.AccImplementing)) == 0) return false; } } return true; } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java index bf21f48d2d..ebad5c5b47 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java @@ -802,6 +802,7 @@ enclosing instance of this (8.1.3)", we will actually implement this check in co } } else { this.binding = null; + this.exactMethodBinding = null; this.bits &= ~ASTNode.DepthMASK; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java index 5d1409c8a5..7cd9229ec1 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java @@ -56,7 +56,7 @@ public class ReturnStatement extends Statement { public SubRoutineStatement[] subroutines; public LocalVariableBinding saveValueVariable; public int initStateIndex = -1; - private boolean implicitReturn; + private final boolean implicitReturn; public ReturnStatement(Expression expression, int sourceStart, int sourceEnd) { this(expression, sourceStart, sourceEnd, false); @@ -251,7 +251,6 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) { /** * Dump the suitable return bytecode for a return statement - * */ public void generateReturnBytecode(CodeStream codeStream) { codeStream.generateReturnBytecode(this.expression); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SubRoutineStatement.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SubRoutineStatement.java index 04d4b67e4f..044cfa17df 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SubRoutineStatement.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SubRoutineStatement.java @@ -62,11 +62,6 @@ public void exitDeclaredExceptionHandlers(CodeStream codeStream) { /** * Generate an invocation of a subroutine (e.g. jsr finally) in current context. - * @param currentScope - * @param codeStream - * @param targetLocation - * @param stateIndex - * @param secretLocal * @return boolean, true if the generated code will abrupt completion */ public abstract boolean generateSubRoutineInvocation(BlockScope currentScope, CodeStream codeStream, Object targetLocation, int stateIndex, LocalVariableBinding secretLocal); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java index 908e939e6c..547dd29f0b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java @@ -76,6 +76,7 @@ public class SwitchStatement extends Expression { public boolean containsPatterns; public boolean containsNull; + private boolean nullProcessed; /* package */ BranchLabel switchPatternRestartTarget; public Pattern totalPattern; @@ -970,6 +971,7 @@ private void generateCodePatternCaseEpilogue(CodeStream codeStream, int caseInde Pattern pattern = (Pattern) caseStatement.constantExpressions[caseStatement.patternIndex]; pattern.elseTarget.place(); pattern.suspendVariables(codeStream, this.scope); + caseIndex = this.nullProcessed ? caseIndex - 1 : caseIndex; if (!pattern.isAlwaysTrue()) { codeStream.loadInt(caseIndex); codeStream.store(this.restartIndexLocal, false); @@ -977,6 +979,8 @@ private void generateCodePatternCaseEpilogue(CodeStream codeStream, int caseInde } pattern.thenTarget.place(); pattern.resumeVariables(codeStream, this.scope); + } else if (this.containsNull && caseStatement != null) { + this.nullProcessed |= caseStatement.patternIndex == -1; } } private void generateCodeSwitchPatternPrologue(BlockScope currentScope, CodeStream codeStream) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java index 0cde48c265..86c395fae9 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java @@ -21,9 +21,9 @@ import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; public class TrueLiteral extends MagicLiteral { - + static final char[] source = {'t' , 'r' , 'u' , 'e'}; - + public TrueLiteral(int s , int e) { super(s,e); } @@ -67,9 +67,6 @@ public void generateOptimizedBoolean(BlockScope currentScope, CodeStream codeStr public TypeBinding literalType(BlockScope scope) { return TypeBinding.BOOLEAN; } -/** - * - */ @Override public char[] source() { return source; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TryStatement.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TryStatement.java index 6aab623916..7d63d179c9 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TryStatement.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TryStatement.java @@ -598,7 +598,9 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) { if (resourceCount > 0) { for (int i = resourceCount; i >= 0; i--) { BranchLabel exitLabel = new BranchLabel(codeStream); - this.resourceExceptionLabels[i].placeEnd(); // outer handler if any is the one that should catch exceptions out of close() + if (this.resourceExceptionLabels[i].getCount() % 2 != 0) { + this.resourceExceptionLabels[i].placeEnd(); // outer handler if any is the one that should catch exceptions out of close() + } Statement stmt = i > 0 ? this.resources[i - 1] : null; if ((this.bits & ASTNode.IsTryBlockExiting) == 0) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java index ddf5812293..275d3e98a5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java @@ -238,7 +238,6 @@ public MethodDeclaration addMissingAbstractMethodFor(MethodBinding methodBinding /** * Flow analysis for a local innertype - * */ @Override public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { @@ -261,7 +260,6 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl /** * Flow analysis for a member innertype - * */ public void analyseCode(ClassScope enclosingClassScope) { if (this.ignoreFurtherInvestigation) @@ -277,7 +275,6 @@ public void analyseCode(ClassScope enclosingClassScope) { /** * Flow analysis for a local member innertype - * */ public void analyseCode(ClassScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { if (this.ignoreFurtherInvestigation) @@ -298,7 +295,6 @@ public void analyseCode(ClassScope currentScope, FlowContext flowContext, FlowIn /** * Flow analysis for a package member type - * */ public void analyseCode(CompilationUnitScope unitScope) { if (this.ignoreFurtherInvestigation) @@ -1518,14 +1514,15 @@ public void resolve() { } else if (!sourceType.isLocalType()) { // Set javadoc visibility int visibility = sourceType.modifiers & ExtraCompilerModifiers.AccVisibilityMASK; - ProblemReporter reporter = this.scope.problemReporter(); - int severity = reporter.computeSeverity(IProblem.JavadocMissing); - if (severity != ProblemSeverities.Ignore) { - if (this.enclosingType != null) { - visibility = Util.computeOuterMostVisibility(this.enclosingType, visibility); + try (ProblemReporter reporter = this.scope.problemReporter()) { + int severity = reporter.computeSeverity(IProblem.JavadocMissing); + if (severity != ProblemSeverities.Ignore) { + if (this.enclosingType != null) { + visibility = Util.computeOuterMostVisibility(this.enclosingType, visibility); + } + int javadocModifiers = (this.binding.modifiers & ~ExtraCompilerModifiers.AccVisibilityMASK) | visibility; + reporter.javadocMissing(this.sourceStart, this.sourceEnd, severity, javadocModifiers); } - int javadocModifiers = (this.binding.modifiers & ~ExtraCompilerModifiers.AccVisibilityMASK) | visibility; - reporter.javadocMissing(this.sourceStart, this.sourceEnd, severity, javadocModifiers); } } updateNestHost(); @@ -1647,7 +1644,6 @@ public void tagAsHavingIgnoredMandatoryErrors(int problemId) { /** * Iteration for a package member type - * */ public void traverse(ASTVisitor visitor, CompilationUnitScope unitScope) { try { @@ -1779,7 +1775,6 @@ public void traverse(ASTVisitor visitor, BlockScope blockScope) { /** * Iteration for a member innertype - * */ public void traverse(ASTVisitor visitor, ClassScope classScope) { try { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeReference.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeReference.java index 5e055c869c..0021063a5b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/TypeReference.java @@ -430,9 +430,6 @@ public AnnotationContext[] getAllAnnotationContexts(int targetType) { } /** * info can be either a type index (superclass/superinterfaces) or a pc into the bytecode - * @param targetType - * @param info - * @param allAnnotationContexts */ public void getAllAnnotationContexts(int targetType, int info, List allAnnotationContexts) { AnnotationCollector collector = new AnnotationCollector(this, targetType, info, allAnnotationContexts); @@ -485,7 +482,6 @@ public Annotation[][] getAnnotationsOnDimensions() { * view since extended dimensions bind more readily than type components that precede the identifier. This is how it ought * to be encoded in bindings and how it ought to be persisted in class files. However for DOM/AST construction, we need the * dimensions in source order, so we provide a way for the clients to ask what they want. - * */ public Annotation[][] getAnnotationsOnDimensions(boolean useSourceOrder) { return null; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/UnlikelyArgumentCheck.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/UnlikelyArgumentCheck.java index f8ba8be906..84bb630bf0 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/UnlikelyArgumentCheck.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/UnlikelyArgumentCheck.java @@ -39,7 +39,6 @@ private UnlikelyArgumentCheck(DangerousMethod dangerousMethod, TypeBinding typeT /** * Check if the invocation is likely a bug. - * @param currentScope * @return false, if the typeToCheck does not seem to related to the expectedType */ public boolean isDangerous(BlockScope currentScope) { @@ -133,7 +132,7 @@ public boolean isDangerous(BlockScope currentScope) { ReferenceBinding argumentCollectionType = argumentType .findSuperTypeOriginatingFrom(TypeIds.T_JavaUtilCollection, false); if (collectionType != null && argumentCollectionType != null - && argumentCollectionType.isParameterizedTypeWithActualArguments() + && argumentCollectionType.isParameterizedTypeWithActualArguments() && collectionType.isParameterizedTypeWithActualArguments()) { return new UnlikelyArgumentCheck(suspect, ((ParameterizedTypeBinding) argumentCollectionType).typeArguments()[0], @@ -187,4 +186,4 @@ public boolean isDangerous(BlockScope currentScope) { } return null; } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/BasicModule.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/BasicModule.java index 2f027f835a..0cd3f56874 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/BasicModule.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/BasicModule.java @@ -102,7 +102,7 @@ private static PackageExportImpl createPackageOpen(OpensStatement ref) { char[][] uses; Service[] provides; IModule.IPackageExport[] opens; - private ICompilationUnit compilationUnit; + private final ICompilationUnit compilationUnit; public BasicModule(ModuleDeclaration descriptor, IModulePathEntry root) { this.compilationUnit = descriptor.compilationResult().compilationUnit; @@ -249,4 +249,4 @@ protected void toStringContent(StringBuffer buffer) { } buffer.append('\n').append('}').toString(); } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/BatchCompilerRequestor.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/BatchCompilerRequestor.java index 63530f38bd..1346de8e12 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/BatchCompilerRequestor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/BatchCompilerRequestor.java @@ -18,7 +18,7 @@ public class BatchCompilerRequestor implements ICompilerRequestor { - private Main compiler; + private final Main compiler; private int lineDelta = 0; public BatchCompilerRequestor(Main compiler) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java index b59f9fc4bf..6beddc7207 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java @@ -57,9 +57,9 @@ public class ClasspathDirectory extends ClasspathLocation { private Hashtable directoryCache; -private String[] missingPackageHolder = new String[1]; -private int mode; // ability to only consider one kind of files (source vs. binaries), by default use both -private String encoding; // only useful if referenced in the source path +private final String[] missingPackageHolder = new String[1]; +private final int mode; // ability to only consider one kind of files (source vs. binaries), by default use both +private final String encoding; // only useful if referenced in the source path private Hashtable> packageSecondaryTypes = null; Map options; @@ -80,6 +80,9 @@ public class ClasspathDirectory extends ClasspathLocation { this.encoding = encoding; } String[] directoryList(String qualifiedPackageName) { + if (File.separatorChar != '/' && qualifiedPackageName.indexOf('/') != -1) { + qualifiedPackageName = qualifiedPackageName.replace('/', File.separatorChar); + } String[] dirList = (String[]) this.directoryCache.get(qualifiedPackageName); if (dirList == this.missingPackageHolder) return null; // package exists in another classpath directory or jar if (dirList != null) return dirList; @@ -146,7 +149,7 @@ private NameEnvironmentAnswer findClassInternal(char[] typeName, String qualifie try { ClassFileReader reader = ClassFileReader.read(this.path + qualifiedBinaryFileName); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=321115, package names are to be treated case sensitive. - String typeSearched = qualifiedPackageName.length() > 0 ? + String typeSearched = qualifiedPackageName.length() > 0 ? qualifiedPackageName.replace(File.separatorChar, '/') + "/" + fileName //$NON-NLS-1$ : fileName; if (!CharOperation.equals(reader.getName(), typeSearched.toCharArray())) { @@ -205,8 +208,8 @@ private Hashtable getSecondaryTypes(String qualifiedPackageName) Hashtable packageEntry = new Hashtable<>(); String[] dirList = (String[]) this.directoryCache.get(qualifiedPackageName); - if (dirList == this.missingPackageHolder // package exists in another classpath directory or jar - || dirList == null) + if (dirList == this.missingPackageHolder // package exists in another classpath directory or jar + || dirList == null) return packageEntry; File dir = new File(this.path + qualifiedPackageName); @@ -221,7 +224,7 @@ private Hashtable getSecondaryTypes(String qualifiedPackageName) if (!(s.endsWith(SUFFIX_STRING_java) || s.endsWith(SUFFIX_STRING_JAVA))) continue; CompilationUnit cu = new CompilationUnit(null, s, this.encoding, this.destinationPath); CompilationResult compilationResult = new CompilationResult(s.toCharArray(), 1, 1, 10); - ProblemReporter problemReporter = + ProblemReporter problemReporter = new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), new CompilerOptions(this.options), @@ -235,14 +238,14 @@ private Hashtable getSecondaryTypes(String qualifiedPackageName) for (int j = 0, k = types.length; j < k; j++) { TypeDeclaration type = types[j]; char[] name = type.isSecondary() ? type.name : null; // add only secondary types - if (name != null) + if (name != null) packageEntry.put(new String(name), s); } } return packageEntry; } private NameEnvironmentAnswer findSourceSecondaryType(String typeName, String qualifiedPackageName, String qualifiedBinaryFileName) { - + if (this.packageSecondaryTypes == null) this.packageSecondaryTypes = new Hashtable<>(); Hashtable packageEntry = this.packageSecondaryTypes.get(qualifiedPackageName); if (packageEntry == null) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJsr199.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJsr199.java index 725dce6a84..9366e7dbf2 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJsr199.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathJsr199.java @@ -44,8 +44,8 @@ public class ClasspathJsr199 extends ClasspathLocation { fileTypes.add(JavaFileObject.Kind.CLASS); } - private JavaFileManager fileManager; - private JavaFileManager.Location location; + private final JavaFileManager fileManager; + private final JavaFileManager.Location location; private Classpath jrt; public ClasspathJsr199(JavaFileManager file, JavaFileManager.Location location) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathSourceJar.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathSourceJar.java index d906d7bb4b..8ff0c8e8b6 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathSourceJar.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ClasspathSourceJar.java @@ -23,7 +23,7 @@ import org.eclipse.jdt.internal.compiler.util.Util; public class ClasspathSourceJar extends ClasspathJar { - private String encoding; + private final String encoding; public ClasspathSourceJar(File file, boolean closeZipFileAtEnd, AccessRuleSet accessRuleSet, String encoding, diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java index aa9c1d100e..3a9c945f4b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java @@ -38,13 +38,13 @@ public class CompilationUnit implements ICompilationUnit { // == Main.NONE: absorbent element, do not output class files; // else: use as the path of the directory into which class files must // be written. - private boolean ignoreOptionalProblems; + private final boolean ignoreOptionalProblems; private ModuleBinding moduleBinding; /** * annotation path can only be retrieved once the qualified type name is known. * This is the provided function for computing the annotation path from that type name. */ - private Function annotationPathProvider; + private final Function annotationPathProvider; public CompilationUnit(char[] contents, String fileName, String encoding) { this(contents, fileName, encoding, null); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/FileSystem.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/FileSystem.java index a706fb8288..9e6acd33b0 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/FileSystem.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/FileSystem.java @@ -120,8 +120,6 @@ default boolean hasCUDeclaringPackage(String qualifiedPackageName, Function options, String release) { Classpath result = null; File file = new File(convertPathSeparators(classpathName)); - if (file.isDirectory() || classpathName.endsWith("-classes")) {//$NON-NLS-1$ + if (file.isDirectory() || classpathName.endsWith("-classes")) { //$NON-NLS-1$ if (file.exists()) { result = new ClasspathDirectory(file, encoding, isSourceOnly ? ClasspathLocation.SOURCE : diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/Main.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/Main.java index 5e3f834922..bf50534e58 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/Main.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/Main.java @@ -123,10 +123,10 @@ public class Main implements ProblemSeverities, SuffixConstants { public static class Logger { - private PrintWriter err; + private final PrintWriter err; private PrintWriter log; - private Main main; - private PrintWriter out; + private final Main main; + private final PrintWriter out; int tagBits; private static final String CLASS = "class"; //$NON-NLS-1$ private static final String CLASS_FILE = "classfile"; //$NON-NLS-1$ @@ -254,9 +254,6 @@ public void close() { } } - /** - * - */ public void compiling() { printlnOut(this.main.bind("progress.compiling")); //$NON-NLS-1$ } @@ -719,9 +716,6 @@ public void logIncorrectVMVersionForAnnotationProcessing() { this.printlnErr(this.main.bind("configure.incorrectVMVersionforAPT")); //$NON-NLS-1$ } - /** - * - */ public void logNoClassFileCreated(String outputDir, String relativeFileName, IOException e) { if ((this.tagBits & Logger.XML) != 0) { HashMap parameters = new HashMap<>(); @@ -741,9 +735,6 @@ public void logNoClassFileCreated(String outputDir, String relativeFileName, IOE })); } - /** - * @param exportedClassFilesCounter - */ public void logNumberOfClassFilesGenerated(int exportedClassFilesCounter) { if ((this.tagBits & Logger.XML) != 0) { HashMap parameters = new HashMap<>(); @@ -910,11 +901,6 @@ public int logProblems(CategorizedProblem[] problems, char[] unitSource, Main cu return localErrorCount; } - /** - * @param globalProblemsCount - * @param globalErrorsCount - * @param globalWarningsCount - */ public void logProblemsSummary(int globalProblemsCount, int globalErrorsCount, int globalWarningsCount, int globalInfoCount, int globalTasksCount) { if ((this.tagBits & Logger.XML) != 0) { @@ -1003,9 +989,6 @@ public void logProblemsSummary(int globalProblemsCount, } } - /** - * - */ public void logProgress() { printOut('.'); } @@ -1020,9 +1003,6 @@ public void logRepetition(int i, int repetitions) { printlnOut(this.main.bind("compile.repetition", //$NON-NLS-1$ String.valueOf(i + 1), String.valueOf(repetitions))); } - /** - * @param compilerStats - */ public void logTiming(CompilerStats compilerStats) { long time = compilerStats.elapsedTime(); long lineCount = compilerStats.lineCount; @@ -1066,7 +1046,6 @@ public void logTiming(CompilerStats compilerStats) { /** * Print the usage of the compiler - * @param usage */ public void logUsage(String usage) { printlnOut(usage); @@ -1222,9 +1201,6 @@ private void printlnOut(String s) { } } - /** - * - */ public void printNewLine() { this.out.println(); } @@ -5683,4 +5659,4 @@ protected void validateOptions(boolean didSpecifyCompliance) { } } } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ModuleFinder.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ModuleFinder.java index fb61cdcb3e..7b14c70dfe 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ModuleFinder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/ModuleFinder.java @@ -154,7 +154,6 @@ private static String getFileName(File file) { * element, first being the source module and second being the target module. * The expected format is: * --add-reads = - * @param option * @return a String[] with source and target module of the "reads" clause. */ protected static String[] extractAddonRead(String option) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java index 9c85ef424c..cad63a5b49 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java @@ -44,7 +44,6 @@ public class AnnotationInfo extends ClassFileStruct implements IBinaryAnnotation super(classFileBytes, contantPoolOffsets, offset); } /** - * @param classFileBytes * @param offset the offset into classFileBytes for the "type_index" of the annotation attribute. * @param populate true to indicate to build out the annotation structure. */ diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfoWithAnnotations.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfoWithAnnotations.java index 0d9c00d30e..519f31fda8 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfoWithAnnotations.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfoWithAnnotations.java @@ -16,7 +16,7 @@ import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation; public class AnnotationMethodInfoWithAnnotations extends AnnotationMethodInfo { - private AnnotationInfo[] annotations; + private final AnnotationInfo[] annotations; AnnotationMethodInfoWithAnnotations(MethodInfo methodInfo, Object defaultValue, AnnotationInfo[] annotations) { super(methodInfo, defaultValue); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfoWithTypeAnnotations.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfoWithTypeAnnotations.java index 1479ceacd9..70baa3afcc 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfoWithTypeAnnotations.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/AnnotationMethodInfoWithTypeAnnotations.java @@ -16,7 +16,7 @@ import org.eclipse.jdt.internal.compiler.env.IBinaryTypeAnnotation; class AnnotationMethodInfoWithTypeAnnotations extends AnnotationMethodInfoWithAnnotations { - private TypeAnnotationInfo[] typeAnnotations; + private final TypeAnnotationInfo[] typeAnnotations; AnnotationMethodInfoWithTypeAnnotations(MethodInfo methodInfo, Object defaultValue, AnnotationInfo[] annotations, TypeAnnotationInfo[] typeAnnotations) { super(methodInfo, defaultValue, annotations); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java index 202d763003..0af97034f8 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java @@ -53,7 +53,7 @@ public class ClassFileReader extends ClassFileStruct implements IBinaryType { private int accessFlags; - private char[] classFileName; + private final char[] classFileName; private char[] className; private int classNameIndex; private int constantPoolCount; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ComponentInfoWithAnnotation.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ComponentInfoWithAnnotation.java index 0ca00b6d14..43a91357d0 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ComponentInfoWithAnnotation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ComponentInfoWithAnnotation.java @@ -13,7 +13,7 @@ package org.eclipse.jdt.internal.compiler.classfmt; public class ComponentInfoWithAnnotation extends RecordComponentInfo { - private AnnotationInfo[] annotations; + private final AnnotationInfo[] annotations; ComponentInfoWithAnnotation(RecordComponentInfo info, AnnotationInfo[] annos) { super(info.reference, info.constantPoolOffsets, info.structOffset, info.version); @@ -57,4 +57,4 @@ public String toString() { toStringContent(buffer); return buffer.toString(); } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ComponentInfoWithTypeAnnotation.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ComponentInfoWithTypeAnnotation.java index 18b5b22f73..290c5bb6ae 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ComponentInfoWithTypeAnnotation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ComponentInfoWithTypeAnnotation.java @@ -15,7 +15,7 @@ import org.eclipse.jdt.internal.compiler.env.IBinaryTypeAnnotation; public final class ComponentInfoWithTypeAnnotation extends ComponentInfoWithAnnotation { - private TypeAnnotationInfo[] typeAnnotations; + private final TypeAnnotationInfo[] typeAnnotations; ComponentInfoWithTypeAnnotation(RecordComponentInfo info, AnnotationInfo[] annos, TypeAnnotationInfo[] typeAnnos) { super(info, annos); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java index 510a410746..b064be60f7 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ElementValuePairInfo.java @@ -22,8 +22,8 @@ public class ElementValuePairInfo implements org.eclipse.jdt.internal.compiler.e static final ElementValuePairInfo[] NoMembers = new ElementValuePairInfo[0]; - private char[] name; - private Object value; + private final char[] name; + private final Object value; public ElementValuePairInfo(char[] name, Object value) { this.name = name; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationDecorator.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationDecorator.java index 11cda3212d..a3ab58a4f3 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationDecorator.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationDecorator.java @@ -39,7 +39,7 @@ * result of {@link #enrichWithExternalAnnotationsFor} or {@link #getExternalAnnotationStatus}. */ public class ExternalAnnotationDecorator implements IBinaryType { - private IBinaryType inputType; + private final IBinaryType inputType; private ExternalAnnotationProvider annotationProvider; private boolean isFromSource; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationProvider.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationProvider.java index 330d35f9db..e2fcc659da 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationProvider.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ExternalAnnotationProvider.java @@ -335,7 +335,7 @@ void initAnnotations(final LookupEnvironment environment) { */ class DispatchingAnnotationWalker implements ITypeAnnotationWalker { - private LookupEnvironment environment; + private final LookupEnvironment environment; private TypeParametersAnnotationWalker typeParametersWalker; public DispatchingAnnotationWalker(LookupEnvironment environment) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/FieldInfoWithAnnotation.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/FieldInfoWithAnnotation.java index dd03e65f59..0875834ae0 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/FieldInfoWithAnnotation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/FieldInfoWithAnnotation.java @@ -16,7 +16,7 @@ package org.eclipse.jdt.internal.compiler.classfmt; public class FieldInfoWithAnnotation extends FieldInfo { - private AnnotationInfo[] annotations; + private final AnnotationInfo[] annotations; FieldInfoWithAnnotation(FieldInfo info, AnnotationInfo[] annos) { super(info.reference, info.constantPoolOffsets, info.structOffset, info.version); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/FieldInfoWithTypeAnnotation.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/FieldInfoWithTypeAnnotation.java index 00f8055a85..a3927cbadc 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/FieldInfoWithTypeAnnotation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/FieldInfoWithTypeAnnotation.java @@ -17,7 +17,7 @@ import org.eclipse.jdt.internal.compiler.env.IBinaryTypeAnnotation; public final class FieldInfoWithTypeAnnotation extends FieldInfoWithAnnotation { - private TypeAnnotationInfo[] typeAnnotations; + private final TypeAnnotationInfo[] typeAnnotations; FieldInfoWithTypeAnnotation(FieldInfo info, AnnotationInfo[] annos, TypeAnnotationInfo[] typeAnnos) { super(info, annos); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithParameterAnnotations.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithParameterAnnotations.java index 7a2a0ca30f..79bce007ad 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithParameterAnnotations.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithParameterAnnotations.java @@ -18,7 +18,7 @@ import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation; class MethodInfoWithParameterAnnotations extends MethodInfoWithAnnotations { - private AnnotationInfo[][] parameterAnnotations; + private final AnnotationInfo[][] parameterAnnotations; MethodInfoWithParameterAnnotations(MethodInfo methodInfo, AnnotationInfo[] annotations, AnnotationInfo[][] parameterAnnotations) { super(methodInfo, annotations); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithTypeAnnotations.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithTypeAnnotations.java index 010e0e75fb..d86137f9d5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithTypeAnnotations.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/MethodInfoWithTypeAnnotations.java @@ -17,7 +17,7 @@ import org.eclipse.jdt.internal.compiler.env.IBinaryTypeAnnotation; class MethodInfoWithTypeAnnotations extends MethodInfoWithParameterAnnotations { - private TypeAnnotationInfo[] typeAnnotations; + private final TypeAnnotationInfo[] typeAnnotations; MethodInfoWithTypeAnnotations(MethodInfo methodInfo, AnnotationInfo[] annotations, AnnotationInfo[][] parameterAnnotations, TypeAnnotationInfo[] typeAnnotations) { super(methodInfo, annotations, parameterAnnotations); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java index 0e34fc7a04..8fb2025617 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java @@ -3759,10 +3759,6 @@ final public byte[] getContents() { /** * Returns the type that should be substituted to original binding declaring class as the proper receiver type - * @param currentScope - * @param codegenBinding - * @param actualReceiverType - * @param isImplicitThisReceiver * @return the receiver type to use in constant pool */ public static TypeBinding getConstantPoolDeclaringClass(Scope currentScope, FieldBinding codegenBinding, TypeBinding actualReceiverType, boolean isImplicitThisReceiver) { @@ -3789,10 +3785,6 @@ public static TypeBinding getConstantPoolDeclaringClass(Scope currentScope, Fiel /** * Returns the type that should be substituted to original binding declaring class as the proper receiver type - * @param currentScope - * @param codegenBinding - * @param actualReceiverType - * @param isImplicitThisReceiver * @return the receiver type to use in constant pool */ public static TypeBinding getConstantPoolDeclaringClass(Scope currentScope, MethodBinding codegenBinding, TypeBinding actualReceiverType, boolean isImplicitThisReceiver) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/StackMapFrameCodeStream.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/StackMapFrameCodeStream.java index 3e44c49bf1..9b9c691686 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/StackMapFrameCodeStream.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/StackMapFrameCodeStream.java @@ -36,7 +36,7 @@ @SuppressWarnings({ "rawtypes", "unchecked" }) public class StackMapFrameCodeStream extends CodeStream { public static class ExceptionMarker implements Comparable { - private TypeBinding binding; + private final TypeBinding binding; public int pc; public ExceptionMarker(int pc, TypeBinding typeBinding) { @@ -213,7 +213,7 @@ public void generateClassLiteralAccessForType(Scope scope, TypeBinding accessedT /* * Macro for building a class descriptor object... using or not a field cache to store it into... this * sequence is responsible for building the actual class descriptor. - * + * * If the fieldCache is set, then it is supposed to be the body of a synthetic access method factoring the * actual descriptor creation out of the invocation site (saving space). If the fieldCache is nil, then we * are dumping the bytecode on the invocation site, since we have no way to get a hand on the field cache to diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/AccessRestriction.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/AccessRestriction.java index 405bf6bdd0..3e920078f5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/AccessRestriction.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/AccessRestriction.java @@ -15,7 +15,7 @@ public class AccessRestriction { - private AccessRule accessRule; + private final AccessRule accessRule; public byte classpathEntryType; public static final byte COMMAND_LINE = 0, diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java index 74a7589948..6d76210f84 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java @@ -21,7 +21,7 @@ */ public class AccessRuleSet { - private AccessRule[] accessRules; + private final AccessRule[] accessRules; public byte classpathEntryType; // one of AccessRestriction#COMMAND_LINE, LIBRARY, PROJECT public String classpathEntryName; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModuleAwareNameEnvironment.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModuleAwareNameEnvironment.java index 539caaba7c..07e086d8d4 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModuleAwareNameEnvironment.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModuleAwareNameEnvironment.java @@ -72,7 +72,7 @@ public boolean matchesWithName(T elem, Predicate isNamed, Predicate na public boolean matches(T elem, Predicate isNamed) { return matchesWithName(elem, isNamed, t -> true); } - + /** Get the lookup strategy corresponding to the given module name. */ public static LookupStrategy get(char[] moduleName) { if (moduleName == ModuleBinding.ANY) @@ -91,7 +91,7 @@ public static String getStringName(char[] moduleName) { } } } - + @Override default NameEnvironmentAnswer findType(char[][] compoundTypeName) { return findType(compoundTypeName, ModuleBinding.ANY); @@ -121,15 +121,14 @@ default char[][] getUniqueModulesDeclaringPackage(char[][] packageName, char[] m return allNames; } - + /** * Answer whether the given package (within the given module) contains any compilation unit. - * @param qualifiedPackageName * @param checkCUs - if true, check contained Compilation Units for a matching package declaration * @return true iff the package contains at least one compilation unit. */ boolean hasCompilationUnit(char[][] qualifiedPackageName, char[] moduleName, boolean checkCUs); - + /** Get the module with the given name, which must denote a named module. */ IModule getModule(char[] moduleName); char[][] getAllAutomaticModules(); @@ -142,9 +141,8 @@ default char[][] getUniqueModulesDeclaringPackage(char[][] packageName, char[] m default void applyModuleUpdates(IUpdatableModule module, IUpdatableModule.UpdateKind kind) { /* default: do nothing */ } /** - * Lists all packages in the module identified by the given, real module name + * Lists all packages in the module identified by the given, real module name * (i.e., this method is implemented only for {@link LookupStrategy#Named}). - * @param moduleName * @return array of flat, dot-separated package names */ char[][] listPackages(char[] moduleName); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModulePathEntry.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModulePathEntry.java index 86f24f73a0..bf68451a28 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModulePathEntry.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IModulePathEntry.java @@ -18,25 +18,24 @@ /** * Represents an entry on the module path of a project. Could be a single module or a collection of * modules (like a jimage or an exploded module directory structure) - * */ public interface IModulePathEntry { /** * Get the module that this entry contributes. May be null, for instance when this entry does not * represent a single module - * + * * @return The module that this entry contributes or null */ default IModule getModule() { return null; } - + /** * Get the module named name from this entry. May be null - * + * * @param name - The name of the module to look up - * + * * @return The module named name or null */ default IModule getModule(char[] name) { @@ -48,9 +47,9 @@ default IModule getModule(char[] name) { /** * Indicates whether this entry knows the module named name and can answer queries regarding the module - * + * * @param name The name of the module - * + * * @return True if this entry knows the module, false otherwise */ default boolean servesModule(char[] name) { @@ -84,10 +83,10 @@ default char[][] listPackages() { /** * Specifies whether this entry represents an automatic module. - * + * * @return true if this is an automatic module, false otherwise */ public default boolean isAutomaticModule() { return false; } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IMultiModuleEntry.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IMultiModuleEntry.java index 1d48ff9405..176acc5f0b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IMultiModuleEntry.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/IMultiModuleEntry.java @@ -18,12 +18,11 @@ /** * Represents a module path entry that represents a collection of modules * like a jimage or an exploded module directory structure - * */ public interface IMultiModuleEntry extends IModulePathEntry { /** - * Get the module named name that this entry contributes to the module path + * Get the module named name that this entry contributes to the module path */ @Override @@ -36,4 +35,4 @@ public interface IMultiModuleEntry extends IModulePathEntry { */ Collection getModuleNames(Collection limitModules); -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/INameEnvironmentExtension.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/INameEnvironmentExtension.java index 5fd197078c..fd678bb4bf 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/INameEnvironmentExtension.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/INameEnvironmentExtension.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -18,10 +18,9 @@ * can use to look up types, compilation units, and packages in the * current environment. The name environment is passed to the compiler * on creation. - * + * * This name environment adds a method to switch on/off the search for secondary types. * Refer {@link #findType(char[], char[][], boolean)}. - * */ public interface INameEnvironmentExtension extends INameEnvironment { /** @@ -48,7 +47,7 @@ public interface INameEnvironmentExtension extends INameEnvironment { * @return {@link NameEnvironmentAnswer} */ NameEnvironmentAnswer findType(char[] typeName, char[][] packageName, boolean searchWithSecondaryTypes, char[] moduleName); - + default NameEnvironmentAnswer findType(char[] typeName, char[][] packageName, boolean searchWithSecondaryTypes) { return findType(typeName, packageName, searchWithSecondaryTypes, null); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/ITypeAnnotationWalker.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/ITypeAnnotationWalker.java index cc846adcc2..c7a608fa84 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/ITypeAnnotationWalker.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/env/ITypeAnnotationWalker.java @@ -18,7 +18,7 @@ * A TypeAnnotationWalker is initialized with all type annotations found at a given element. * It can be used to walk into the types at the given element and finally answer the * actual annotations at any node of the walk. - * + * * The walker is implemented as immutable objects. During the walk either new instances * are created, or the current instance is shared if no difference is encountered. */ @@ -90,13 +90,12 @@ public interface ITypeAnnotationWalker { /** * Detail of {@link #toTypeParameterBounds(boolean, int)}: walk to the bounds - * of the previously selected type parameter. - * @param boundIndex + * of the previously selected type parameter. */ public abstract ITypeAnnotationWalker toTypeBound(short boundIndex); /** Walk to the specified supertype either index based or name based: - * @param index -1 is superclass, else index into the list of superinterfaces + * @param index -1 is superclass, else index into the list of superinterfaces * @param superTypeSignature name and type arguments of the super type to visit */ public abstract ITypeAnnotationWalker toSupertype(short index, char[] superTypeSignature); @@ -133,4 +132,4 @@ public interface ITypeAnnotationWalker { */ public abstract IBinaryAnnotation[] getAnnotationsAtCursor(int currentTypeId, boolean mayApplyArrayContentsDefaultNullness); -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java index 256bb09b7a..dd6d8a82e0 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java @@ -22,7 +22,6 @@ /** * Record conditional initialization status during definite assignment analysis - * */ public class ConditionalFlowInfo extends FlowInfo { @@ -121,7 +120,7 @@ public boolean isDefinitelyUnknown(LocalVariableBinding local) { @Override public boolean hasNullInfoFor(LocalVariableBinding local) { - return this.initsWhenTrue.hasNullInfoFor(local) + return this.initsWhenTrue.hasNullInfoFor(local) || this.initsWhenFalse.hasNullInfoFor(local); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java index d6489465e9..841a96fe6d 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java @@ -65,7 +65,7 @@ public class ExceptionHandlingFlowContext extends FlowContext { private static final Argument[] NO_ARGUMENTS = new Argument[0]; public Argument [] catchArguments; - private int[] exceptionToCatchBlockMap; + private final int[] exceptionToCatchBlockMap; public ExceptionHandlingFlowContext( FlowContext parent, diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java index e45954b760..3c871619f8 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java @@ -10,7 +10,7 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Stephan Herrmann - Contributions for + * Stephan Herrmann - Contributions for * bug 292478 - Report potentially null across variable assignment * bug 332637 - Dead Code detection removing code that isn't dead * bug 394768 - [compiler][resource] Incorrect resource leak warning when creating stream in conditional @@ -29,9 +29,9 @@ public abstract class FlowInfo { public int tagBits; // REACHABLE by default public final static int REACHABLE = 0; - /* unreachable code + /* unreachable code * eg. while (true); - * i++; --> unreachable code + * i++; --> unreachable code */ public final static int UNREACHABLE_OR_DEAD = 1; /* unreachable code as inferred by null analysis @@ -46,7 +46,7 @@ public abstract class FlowInfo { */ public final static int UNREACHABLE = UNREACHABLE_OR_DEAD | UNREACHABLE_BY_NULLANALYSIS; public final static int NULL_FLAG_MASK = 4; - + public final static int UNKNOWN = 1; public final static int NULL = 2; public final static int NON_NULL = 4; @@ -55,7 +55,7 @@ public abstract class FlowInfo { public final static int POTENTIALLY_NON_NULL = 32; public final static int UNROOTED = 64; // marks a flowInfo that may be appended to another flowInfo (accepting incoming nulls/nonnulls, see UFI.iNBit/iNNBit). - + public static final int FREE_TYPEVARIABLE = FlowInfo.POTENTIALLY_NULL | FlowInfo.POTENTIALLY_NON_NULL; public static final UnconditionalFlowInfo DEAD_END; // Represents a dead branch status of initialization @@ -324,7 +324,6 @@ public static UnconditionalFlowInfo initial(int maxFieldCount) { /** * Mark the null status of the given local according to the given status - * @param local * @param nullStatus bitset of FLowInfo.UNKNOWN ... FlowInfo.POTENTIALLY_NON_NULL */ public void markNullStatus(LocalVariableBinding local, int nullStatus) { @@ -355,7 +354,6 @@ public void markNullStatus(LocalVariableBinding local, int nullStatus) { /** * Answer the null status of the given local - * @param local * @return bitset of FlowInfo.UNKNOWN ... FlowInfo.POTENTIALLY_NON_NULL */ public int nullStatus(LocalVariableBinding local) { @@ -542,7 +540,7 @@ else if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0 && // if a variable is only initialized in one branch and not initialized in the other, // then we need to cast a doubt on its initialization in the merged info mergedInfo.mergeDefiniteInitsWith(initsWhenFalse.unconditionalCopy()); - + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=415997, classify unreachability precisely, IsElseStatementUnreachable could be due to null analysis if ((mergedInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) != 0 && (initsWhenFalse.tagBits & FlowInfo.UNREACHABLE) == FlowInfo.UNREACHABLE_BY_NULLANALYSIS) { mergedInfo.tagBits &= ~UNREACHABLE_OR_DEAD; @@ -556,7 +554,7 @@ else if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0 && // true or false (i.e if(true), etc) for sure // We don't do this if both if and else branches themselves are in an unreachable code // or if any of them is a DEAD_END (e.g. contains 'return' or 'throws') - mergedInfo = + mergedInfo = initsWhenFalse.addPotentialInitializationsFrom(initsWhenTrue. nullInfoLessUnconditionalCopy()). unconditionalInits(); @@ -674,7 +672,6 @@ public String toString(){ /** * Resets the definite and potential initialization info for the given local variable - * @param local */ abstract public void resetAssignmentInfo(LocalVariableBinding local); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java index d98fadcc61..d7236cfa39 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java @@ -59,7 +59,7 @@ public class LoopingFlowContext extends SwitchFlowContext { public BranchLabel continueLabel; public UnconditionalFlowInfo initsOnContinue = FlowInfo.DEAD_END; - private UnconditionalFlowInfo upstreamNullFlowInfo; + private final UnconditionalFlowInfo upstreamNullFlowInfo; private LoopingFlowContext innerFlowContexts[] = null; private UnconditionalFlowInfo innerFlowInfos[] = null; private int innerFlowContextsCount = 0; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java index 6f560e34e2..ff18abec9a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java @@ -15,7 +15,7 @@ public class BooleanConstant extends Constant { - private boolean value; + private final boolean value; private static final BooleanConstant TRUE = new BooleanConstant(true); private static final BooleanConstant FALSE = new BooleanConstant(false); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java index 91ffe68ae9..82cb38053a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java @@ -15,7 +15,7 @@ public class ByteConstant extends Constant { - private byte value; + private final byte value; public static Constant fromValue(byte value) { return new ByteConstant(value); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/CharConstant.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/CharConstant.java index 0f2c7a1e63..b18774f1fa 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/CharConstant.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/CharConstant.java @@ -15,7 +15,7 @@ public class CharConstant extends Constant { - private char value; + private final char value; public static Constant fromValue(char value) { return new CharConstant(value); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java index 6109b78fcf..40e2d2f111 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java @@ -45,7 +45,6 @@ import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; import org.eclipse.jdt.internal.compiler.util.Util; -@SuppressWarnings({ "rawtypes", "unchecked" }) public class CompilerOptions { /** @@ -618,7 +617,6 @@ public CompilerOptions(){ /** * Initializing the compiler options with external settings - * @param settings */ public CompilerOptions(Map settings){ resetDefaults(); @@ -630,7 +628,7 @@ public CompilerOptions(Map settings){ /** * @deprecated used to preserve 3.1 and 3.2M4 compatibility of some Compiler constructors */ - public CompilerOptions(Map settings, boolean parseLiteralExpressionsAsConstants){ + public CompilerOptions(Map settings, boolean parseLiteralExpressionsAsConstants){ this(settings); this.parseLiteralExpressionsAsConstants = parseLiteralExpressionsAsConstants; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/Constant.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/Constant.java index 29a45a3928..27173b324e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/Constant.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/Constant.java @@ -22,7 +22,7 @@ public abstract class Constant implements TypeIds, OperatorIds { public static final Constant NotAConstant = DoubleConstant.fromValue(Double.NaN); public static final Constant[] NotAConstantList = new Constant[] {DoubleConstant.fromValue(Double.NaN)}; - + public boolean booleanValue() { throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "boolean" })); //$NON-NLS-1$ } @@ -1469,10 +1469,9 @@ public double doubleValue() { public float floatValue() { throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "float" })); //$NON-NLS-1$ } - + /** * Returns true if both constants have the same type and the same actual value - * @param otherConstant */ public boolean hasSameValue(Constant otherConstant) { if (this == otherConstant) diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java index 2baaaf1e23..7b9336d74d 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java @@ -15,7 +15,7 @@ public class DoubleConstant extends Constant { - private double value; + private final double value; public static Constant fromValue(double value) { return new DoubleConstant(value); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java index 69c40b762c..afae7a0be0 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java @@ -78,7 +78,7 @@ public class IrritantSet { public static final IrritantSet JAVADOC = new IrritantSet(CompilerOptions.InvalidJavadoc); public static final IrritantSet PREVIEW = new IrritantSet(CompilerOptions.PreviewFeatureUsed); - public static final IrritantSet COMPILER_DEFAULT_ERRORS = new IrritantSet(0); // no optional error by default + public static final IrritantSet COMPILER_DEFAULT_ERRORS = new IrritantSet(0); // no optional error by default public static final IrritantSet COMPILER_DEFAULT_WARNINGS = new IrritantSet(0); // see static initializer below public static final IrritantSet COMPILER_DEFAULT_INFOS = new IrritantSet(0); // see static initializer below static { @@ -88,7 +88,7 @@ public class IrritantSet { CompilerOptions.UnlikelyEqualsArgumentType | CompilerOptions.SuppressWarningsNotAnalysed | CompilerOptions.AnnotatedTypeArgumentToUnannotated); - + COMPILER_DEFAULT_WARNINGS // group-0 warnings enabled by default .set( @@ -187,7 +187,7 @@ public class IrritantSet { if (suppressRawWhenUnchecked != null && "true".equalsIgnoreCase(suppressRawWhenUnchecked)) { //$NON-NLS-1$ UNCHECKED.set(CompilerOptions.RawTypeReference); } - + JAVADOC .set(CompilerOptions.MissingJavadocComments) .set(CompilerOptions.MissingJavadocTags); @@ -236,8 +236,6 @@ public IrritantSet clearAll() { /** * Initialize a set of irritants in one group - * - * @param singleGroupIrritants */ public void initialize(int singleGroupIrritants) { if (singleGroupIrritants == 0) @@ -254,7 +252,6 @@ public void initialize(IrritantSet other) { /** * Returns true if any of the irritants in given other set is positionned in receiver - * @param other */ public boolean isAnySet(IrritantSet other) { if (other == null) @@ -295,8 +292,6 @@ public IrritantSet set(int singleGroupIrritants) { /** * Return updated irritantSet or null if it was a no-op - * - * @param other */ public IrritantSet set(IrritantSet other) { if (other == null) @@ -313,7 +308,7 @@ public IrritantSet set(IrritantSet other) { } return wasNoOp ? null : this; } - + public IrritantSet setAll() { for (int i = 0; i < GROUP_MAX; i++) { this.bits[i] |= 0xFFFFFFFF & ~GROUP_MASK; // erase the group diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java index ea94292e52..c1d1c0f073 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java @@ -69,6 +69,10 @@ public enum JavaFeature { Messages.bind(Messages.unnammed_patterns_and_vars), new char[][] {}, true), + UNNAMMED_CLASSES_AND_INSTANCE_MAIN_METHODS(ClassFileConstants.JDK21, + Messages.bind(Messages.unnamed_classes_and_instance_main_methods), + new char[][] {}, + true), ; final long compliance; @@ -98,6 +102,11 @@ public boolean isSupported(long comp, boolean preview) { return preview; return this.getCompliance() <= comp; } + public boolean isSupported(String comp, boolean preview) { + if (this.isPreview) + return preview; + return this.getCompliance() <= CompilerOptions.versionToJdkLevel(comp); + } JavaFeature(long compliance, String name, char[][] restrictedKeywords, boolean isPreview) { this.compliance = compliance; @@ -105,4 +114,4 @@ public boolean isSupported(long comp, boolean preview) { this.isPreview = isPreview; this.restrictedKeywords = restrictedKeywords; } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/LongConstant.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/LongConstant.java index d21ee7bf9a..3a293a47a2 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/LongConstant.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/LongConstant.java @@ -17,8 +17,8 @@ public class LongConstant extends Constant { private static final LongConstant ZERO = new LongConstant(0L); private static final LongConstant MIN_VALUE = new LongConstant(Long.MIN_VALUE); - - private long value; + + private final long value; public static Constant fromValue(long value) { if (value == 0L) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java index 91c4623614..1677f1fd63 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java @@ -14,8 +14,8 @@ package org.eclipse.jdt.internal.compiler.impl; public class ShortConstant extends Constant { - - private short value; + + private final short value; public static Constant fromValue(short value) { return new ShortConstant(value); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/StringConstant.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/StringConstant.java index 6de9e0f1d8..9fa98872eb 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/StringConstant.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/StringConstant.java @@ -15,7 +15,7 @@ public class StringConstant extends Constant { - private String value; + private final String value; public static Constant fromValue(String value) { return new StringConstant(value); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotatableTypeSystem.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotatableTypeSystem.java index 228f1295cb..8dbc517fb1 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotatableTypeSystem.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotatableTypeSystem.java @@ -11,7 +11,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Stephan Herrmann - Contribution for - * Bug 432977 - [1.8][null] Incorrect 'type is not visible' compiler error + * Bug 432977 - [1.8][null] Incorrect 'type is not visible' compiler error * Bug 446434 - [1.8][null] Enable interned captures also when analysing null type annotations *******************************************************************************/ package org.eclipse.jdt.internal.compiler.lookup; @@ -20,29 +20,29 @@ import org.eclipse.jdt.internal.compiler.util.Util; /* AnnotatableTypeSystem: Keep track of annotated types so as to provide unique bindings for identically annotated versions identical underlying "naked" types. - As of now, we ensure uniqueness only for marker annotated types and for others that default to all default attribute values, i.e two instances of @NonNull String - would have the same binding, while @T(1) X and @T(2) X will not. Binding uniqueness is only a memory optimization and is not essential for correctness of compilation. + As of now, we ensure uniqueness only for marker annotated types and for others that default to all default attribute values, i.e two instances of @NonNull String + would have the same binding, while @T(1) X and @T(2) X will not. Binding uniqueness is only a memory optimization and is not essential for correctness of compilation. Various subsystems should expect to determine binding identity/equality by calling TypeBinding.equalsEquals and not by using == operator. - - ATS is AnnotatableTypeSystem and not AnnotatedTypeSystem, various methods may actually return unannotated types if the input arguments do not specify any annotations - and component types of the composite type being constructed are themselves also unannotated. We rely on the master type table maintained by TypeSystem and use + + ATS is AnnotatableTypeSystem and not AnnotatedTypeSystem, various methods may actually return unannotated types if the input arguments do not specify any annotations + and component types of the composite type being constructed are themselves also unannotated. We rely on the master type table maintained by TypeSystem and use getDerivedTypes() and cacheDerivedType() to get/put. */ public class AnnotatableTypeSystem extends TypeSystem { - private boolean isAnnotationBasedNullAnalysisEnabled; - + private final boolean isAnnotationBasedNullAnalysisEnabled; + public AnnotatableTypeSystem(LookupEnvironment environment) { super(environment); this.environment = environment; this.isAnnotationBasedNullAnalysisEnabled = environment.globalOptions.isAnnotationBasedNullAnalysisEnabled; } - + // Given a type, return all its annotated variants: parameter may be annotated. @Override public TypeBinding[] getAnnotatedTypes(TypeBinding type) { - + TypeBinding[] derivedTypes = getDerivedTypes(type); final int length = derivedTypes.length; TypeBinding [] annotatedVersions = new TypeBinding[length]; @@ -56,16 +56,16 @@ public TypeBinding[] getAnnotatedTypes(TypeBinding type) { if (derivedType.id == type.id) annotatedVersions[versions++] = derivedType; } - + if (versions != length) System.arraycopy(annotatedVersions, 0, annotatedVersions = new TypeBinding[versions], 0, versions); return annotatedVersions; } - - /* This method replaces the version that used to sit in LE. The parameter `annotations' is a flattened sequence of annotations, + + /* This method replaces the version that used to sit in LE. The parameter `annotations' is a flattened sequence of annotations, where each dimension's annotations end with a sentinel null. Leaf type can be an already annotated type. - - See ArrayBinding.swapUnresolved for further special case handling if incoming leafType is a URB that would resolve to a raw + + See ArrayBinding.swapUnresolved for further special case handling if incoming leafType is a URB that would resolve to a raw type later. */ @Override @@ -86,14 +86,14 @@ public ArrayBinding getArrayType(TypeBinding leafType, int dimensions, Annotatio if (derivedType == null) break; if (!derivedType.isArrayType() || derivedType.dimensions() != dimensions || derivedType.leafComponentType() != leafType) //$IDENTITY-COMPARISON$ continue; - if (Util.effectivelyEqual(derivedType.getTypeAnnotations(), annotations)) + if (Util.effectivelyEqual(derivedType.getTypeAnnotations(), annotations)) return (ArrayBinding) derivedType; if (!derivedType.hasTypeAnnotations()) nakedType = (ArrayBinding) derivedType; } if (nakedType == null) nakedType = super.getArrayType(leafType, dimensions); - + if (!haveTypeAnnotations(leafType, annotations)) return nakedType; @@ -114,29 +114,29 @@ public ReferenceBinding getMemberType(ReferenceBinding memberType, ReferenceBind return super.getMemberType(memberType, enclosingType); return (ReferenceBinding) getAnnotatedType(memberType, enclosingType, memberType.getTypeAnnotations()); } - + @Override public ParameterizedTypeBinding getParameterizedType(ReferenceBinding genericType, TypeBinding[] typeArguments, ReferenceBinding enclosingType, AnnotationBinding [] annotations) { - + if (genericType.hasTypeAnnotations()) // @NonNull (List) and not (@NonNull List) throw new IllegalStateException(); - + ParameterizedTypeBinding parameterizedType = this.parameterizedTypes.get(genericType, typeArguments, enclosingType, annotations); if (parameterizedType != null) return parameterizedType; - + ParameterizedTypeBinding nakedType = super.getParameterizedType(genericType, typeArguments, enclosingType); - + if (!haveTypeAnnotations(genericType, enclosingType, typeArguments, annotations)) return nakedType; - + parameterizedType = new ParameterizedTypeBinding(genericType, typeArguments, enclosingType, this.environment); parameterizedType.id = nakedType.id; parameterizedType.setTypeAnnotations(annotations, this.isAnnotationBasedNullAnalysisEnabled); this.parameterizedTypes.put(genericType, typeArguments, enclosingType, parameterizedType); return (ParameterizedTypeBinding) cacheDerivedType(genericType, nakedType, parameterizedType); } - + @Override public ParameterizedTypeBinding getParameterizedType(ReferenceBinding genericType, TypeBinding[] typeArguments, ReferenceBinding enclosingType) { return getParameterizedType(genericType, typeArguments, enclosingType, Binding.NO_ANNOTATIONS); @@ -149,7 +149,7 @@ public RawTypeBinding getRawType(ReferenceBinding genericType, ReferenceBinding if (!genericType.hasEnclosingInstanceContext() && enclosingType != null) { enclosingType = (ReferenceBinding) enclosingType.original(); } - + RawTypeBinding nakedType = null; TypeBinding[] derivedTypes = getDerivedTypes(genericType); for (int i = 0, length = derivedTypes.length; i < length; i++) { @@ -165,36 +165,36 @@ public RawTypeBinding getRawType(ReferenceBinding genericType, ReferenceBinding } if (nakedType == null) nakedType = super.getRawType(genericType, enclosingType); - + if (!haveTypeAnnotations(genericType, enclosingType, null, annotations)) return nakedType; - + RawTypeBinding rawType = new RawTypeBinding(genericType, enclosingType, this.environment); rawType.id = nakedType.id; rawType.setTypeAnnotations(annotations, this.isAnnotationBasedNullAnalysisEnabled); return (RawTypeBinding) cacheDerivedType(genericType, nakedType, rawType); } - + @Override public RawTypeBinding getRawType(ReferenceBinding genericType, ReferenceBinding enclosingType) { return getRawType(genericType, enclosingType, Binding.NO_ANNOTATIONS); } - + @Override public WildcardBinding getWildcard(ReferenceBinding genericType, int rank, TypeBinding bound, TypeBinding[] otherBounds, int boundKind, AnnotationBinding [] annotations) { - + if (genericType == null) // pseudo wildcard denoting composite bounds for lub computation genericType = ReferenceBinding.LUB_GENERIC; if (genericType.hasTypeAnnotations()) throw new IllegalStateException(); - + WildcardBinding nakedType = null; boolean useDerivedTypesOfBound = bound instanceof TypeVariableBinding || (bound instanceof ParameterizedTypeBinding && !(bound instanceof RawTypeBinding)) ; TypeBinding[] derivedTypes = getDerivedTypes(useDerivedTypesOfBound ? bound : genericType); for (int i = 0, length = derivedTypes.length; i < length; i++) { TypeBinding derivedType = derivedTypes[i]; - if (derivedType == null) + if (derivedType == null) break; if (!derivedType.isWildcard() || derivedType.actualType() != genericType || derivedType.rank() != rank) //$IDENTITY-COMPARISON$ continue; @@ -205,13 +205,13 @@ public WildcardBinding getWildcard(ReferenceBinding genericType, int rank, TypeB if (!derivedType.hasTypeAnnotations()) nakedType = (WildcardBinding) derivedType; } - + if (nakedType == null) nakedType = super.getWildcard(genericType, rank, bound, otherBounds, boundKind); - + if (!haveTypeAnnotations(genericType, bound, otherBounds, annotations)) return nakedType; - + WildcardBinding wildcard = new WildcardBinding(genericType, rank, bound, otherBounds, boundKind, this.environment); wildcard.id = nakedType.id; wildcard.setTypeAnnotations(annotations, this.isAnnotationBasedNullAnalysisEnabled); @@ -228,10 +228,10 @@ public WildcardBinding getWildcard(ReferenceBinding genericType, int rank, TypeB */ @Override public TypeBinding getAnnotatedType(TypeBinding type, AnnotationBinding[][] annotations) { - + if (type == null || !type.isValidBinding() || annotations == null || annotations.length == 0) return type; - + TypeBinding annotatedType = null; switch (type.kind()) { case Binding.ARRAY_TYPE: @@ -247,17 +247,17 @@ public TypeBinding getAnnotatedType(TypeBinding type, AnnotationBinding[][] anno case Binding.WILDCARD_TYPE: case Binding.INTERSECTION_TYPE: case Binding.INTERSECTION_TYPE18: - /* Taking the binding of QTR as an example, there could be different annotatable components, but we come in a with a single binding, e.g: + /* Taking the binding of QTR as an example, there could be different annotatable components, but we come in a with a single binding, e.g: @T Z; type => Z annotations => [[@T]] @T Y.@T Z type => Z annotations => [[@T][@T]] - @T X.@T Y.@T Z type => Z annotations => [[@T][@T][@T]] + @T X.@T Y.@T Z type => Z annotations => [[@T][@T][@T]] java.lang.@T X.@T Y.@T Z type => Z annotations => [[][][@T][@T][@T]] in all these cases the incoming type binding is for Z, but annotations are for different levels. We need to align their layout for proper attribution. */ - + if (type.isUnresolvedType() && CharOperation.indexOf('$', type.sourceName()) > 0) type = BinaryTypeBinding.resolveType(type, this.environment, true); // must resolve member types before asking for enclosingType - + int levels = type.depth() + 1; TypeBinding [] types = new TypeBinding[levels]; types[--levels] = type; @@ -273,7 +273,7 @@ public TypeBinding getAnnotatedType(TypeBinding type, AnnotationBinding[][] anno if (annotations[i] != null && annotations[i].length > 0) break; } - if (i == levels) // empty annotations array ? + if (i == levels) // empty annotations array ? return type; if (j < 0) // Not kosher, broken type that is not flagged as invalid while reporting compilation error ? don't touch. return type; @@ -292,10 +292,10 @@ public TypeBinding getAnnotatedType(TypeBinding type, AnnotationBinding[][] anno return annotatedType; } - /* Private subroutine for public APIs. Create an annotated version of the type. To materialize the annotated version, we can't use new since - this is a general purpose method designed to deal type bindings of all types. "Clone" the incoming type, specializing for any enclosing type - that may itself be possibly be annotated. This is so the binding for @Outer Outer.Inner != Outer.@Inner Inner != @Outer Outer.@Inner Inner. - Likewise so the bindings for @Readonly List<@NonNull String> != @Readonly List<@Nullable String> != @Readonly List<@Interned String> + /* Private subroutine for public APIs. Create an annotated version of the type. To materialize the annotated version, we can't use new since + this is a general purpose method designed to deal type bindings of all types. "Clone" the incoming type, specializing for any enclosing type + that may itself be possibly be annotated. This is so the binding for @Outer Outer.Inner != Outer.@Inner Inner != @Outer Outer.@Inner Inner. + Likewise so the bindings for @Readonly List<@NonNull String> != @Readonly List<@Nullable String> != @Readonly List<@Interned String> */ private TypeBinding getAnnotatedType(TypeBinding type, TypeBinding enclosingType, AnnotationBinding[] annotations) { if (type.kind() == Binding.PARAMETERIZED_TYPE) { @@ -306,10 +306,10 @@ private TypeBinding getAnnotatedType(TypeBinding type, TypeBinding enclosingType for (int i = 0, length = derivedTypes.length; i < length; i++) { TypeBinding derivedType = derivedTypes[i]; if (derivedType == null) break; - + if (derivedType.enclosingType() != enclosingType || !Util.effectivelyEqual(derivedType.typeArguments(), type.typeArguments())) //$IDENTITY-COMPARISON$ continue; - + switch(type.kind()) { case Binding.ARRAY_TYPE: if (!derivedType.isArrayType() || derivedType.dimensions() != type.dimensions() || derivedType.leafComponentType() != type.leafComponentType()) //$IDENTITY-COMPARISON$ @@ -345,10 +345,10 @@ private TypeBinding getAnnotatedType(TypeBinding type, TypeBinding enclosingType } if (nakedType == null) nakedType = getUnannotatedType(type); - + if (!haveTypeAnnotations(type, enclosingType, null, annotations)) return nakedType; - + TypeBinding annotatedType = type.clone(enclosingType); annotatedType.id = nakedType.id; annotatedType.setTypeAnnotations(annotations, this.isAnnotationBasedNullAnalysisEnabled); @@ -389,12 +389,12 @@ private boolean haveTypeAnnotations(TypeBinding baseType, TypeBinding someType, private boolean haveTypeAnnotations(TypeBinding leafType, AnnotationBinding[] annotations) { return haveTypeAnnotations(leafType, null, null, annotations); } - + private boolean haveTypeAnnotations(TypeBinding memberType, TypeBinding enclosingType) { return haveTypeAnnotations(memberType, enclosingType, null, null); } - /* Utility method to "flatten" annotations. For multidimensional arrays, we encode the annotations into a flat array + /* Utility method to "flatten" annotations. For multidimensional arrays, we encode the annotations into a flat array where a null separates the annotations of dimension n from dimension n - 1 as well as dimenion n + 1. There is a final null always. */ @@ -430,4 +430,4 @@ private boolean haveTypeAnnotations(TypeBinding memberType, TypeBinding enclosin public boolean isAnnotatedTypeSystem() { return true; } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java index d89877f94a..857cc6fc9b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java @@ -31,8 +31,6 @@ public class AnnotationBinding { * Add the standard annotations encoded in the tag bits to the recorded annotations. * * @param recordedAnnotations existing annotations already created - * @param annotationTagBits - * @param env * @return the combined list of annotations */ public static AnnotationBinding[] addStandardAnnotations(AnnotationBinding[] recordedAnnotations, long annotationTagBits, LookupEnvironment env) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AptSourceLocalVariableBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AptSourceLocalVariableBinding.java index c0ee6500f4..87ab911138 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AptSourceLocalVariableBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/AptSourceLocalVariableBinding.java @@ -17,7 +17,7 @@ public class AptSourceLocalVariableBinding extends LocalVariableBinding { // enclosing element public MethodBinding methodBinding; - private LocalVariableBinding local; + private final LocalVariableBinding local; public AptSourceLocalVariableBinding(LocalVariableBinding localVariableBinding, MethodBinding methodBinding) { super(localVariableBinding.name, localVariableBinding.type, localVariableBinding.modifiers, true); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BaseTypeBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BaseTypeBinding.java index a7f49f048e..1f793b7635 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BaseTypeBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BaseTypeBinding.java @@ -24,17 +24,17 @@ public class BaseTypeBinding extends TypeBinding { public static final int WIDENING = 2; public static final int NARROWING = 4; public static final int MAX_CONVERSIONS = 16*16; // well-known x well-known - + static { CONVERSIONS = initializeConversions(); } - + public static final int[] initializeConversions(){ // fromType destType --> conversion // 0000 0000 0000 int[] table = new int[MAX_CONVERSIONS]; - + table[TypeIds.Boolean2Boolean] = IDENTITY; table[TypeIds.Byte2Byte] = IDENTITY; @@ -92,7 +92,7 @@ public static final int[] initializeConversions(){ table[TypeIds.Double2Long] = NARROWING; table[TypeIds.Double2Float] = NARROWING; table[TypeIds.Double2Double]= IDENTITY; - + return table; } /** @@ -104,8 +104,8 @@ public static final int[] initializeConversions(){ */ public static final boolean isNarrowing(int left, int right) { int right2left = right + (left<<4); - return right2left >= 0 - && right2left < MAX_CONVERSIONS + return right2left >= 0 + && right2left < MAX_CONVERSIONS && (CONVERSIONS[right2left] & (IDENTITY|NARROWING)) != 0; } @@ -118,14 +118,14 @@ public static final boolean isNarrowing(int left, int right) { */ public static final boolean isWidening(int left, int right) { int right2left = right + (left<<4); - return right2left >= 0 - && right2left < MAX_CONVERSIONS + return right2left >= 0 + && right2left < MAX_CONVERSIONS && (CONVERSIONS[right2left] & (IDENTITY|WIDENING)) != 0; } - + public char[] simpleName; - private char[] constantPoolName; + private final char[] constantPoolName; BaseTypeBinding(int id, char[] name, char[] constantPoolName) { this.tagBits |= TagBits.IsBaseType; @@ -154,13 +154,13 @@ public char[] constantPoolName() { public TypeBinding clone(TypeBinding enclosingType) { return new BaseTypeBinding(this.id, this.simpleName, this.constantPoolName); } - + @Override public PackageBinding getPackage() { return null; } - + /* Answer true if the receiver type can be assigned to the argument type (right) */ @Override @@ -168,13 +168,13 @@ public final boolean isCompatibleWith(TypeBinding right, Scope captureScope) { if (equalsEquals(this, right)) return true; int right2left = this.id + (right.id<<4); - if (right2left >= 0 - && right2left < MAX_CONVERSIONS + if (right2left >= 0 + && right2left < MAX_CONVERSIONS && (CONVERSIONS[right2left] & (IDENTITY|WIDENING)) != 0) return true; return this == TypeBinding.NULL && !right.isBaseType(); } - + @Override public void setTypeAnnotations(AnnotationBinding[] annotations, boolean evalNullAnnotations) { super.setTypeAnnotations(annotations, false); // never set nullTagBits on base types diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java index ff7d856ca4..f9cca0e080 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java @@ -114,7 +114,7 @@ public class BinaryTypeBinding extends ReferenceBinding { protected ReferenceBinding[] memberTypes; protected TypeVariableBinding[] typeVariables; protected ModuleBinding module; - private BinaryTypeBinding prototype; + private final BinaryTypeBinding prototype; public URI path; // For the link with the principle structure @@ -288,19 +288,12 @@ public BinaryTypeBinding(BinaryTypeBinding prototype) { /** * Standard constructor for creating binary type bindings from binary models (classfiles) - * @param packageBinding - * @param binaryType - * @param environment */ public BinaryTypeBinding(PackageBinding packageBinding, IBinaryType binaryType, LookupEnvironment environment) { this(packageBinding, binaryType, environment, false); } /** * Standard constructor for creating binary type bindings from binary models (classfiles) - * @param packageBinding - * @param binaryType - * @param environment - * @param needFieldsAndMethods */ public BinaryTypeBinding(PackageBinding packageBinding, IBinaryType binaryType, LookupEnvironment environment, boolean needFieldsAndMethods) { @@ -523,15 +516,15 @@ void cachePartsFrom(IBinaryType binaryType, boolean needFieldsAndMethods) { this.typeVariables = addMethodTypeVariables(typeVars); } } + char[] superclassName = binaryType.getSuperclassName(); + if (CharOperation.equals(superclassName, TypeConstants.CharArray_JAVA_LANG_RECORD_SLASH)){ + this.modifiers |= ExtraCompilerModifiers.AccRecord; + } if (typeSignature == null) { - char[] superclassName = binaryType.getSuperclassName(); if (superclassName != null) { // attempt to find the superclass if it exists in the cache (otherwise - resolve it when requested) this.superclass = this.environment.getTypeFromConstantPoolName(superclassName, 0, -1, false, missingTypeNames, toplevelWalker.toSupertype((short) -1, superclassName)); this.tagBits |= TagBits.HasUnresolvedSuperclass; - if (CharOperation.equals(superclassName, TypeConstants.CharArray_JAVA_LANG_RECORD_SLASH)){ - this.modifiers |= ExtraCompilerModifiers.AccRecord; - } } this.superInterfaces = Binding.NO_SUPERINTERFACES; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java index b0f241377b..911836ea38 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java @@ -342,7 +342,7 @@ else if (type.hasNullTypeAnnotations()) private TypeBound[] incorporatedBounds = Binding.NO_TYPE_BOUNDS; private TypeBound[] unincorporatedBounds = new TypeBound[8]; private int unincorporatedBoundsCount = 0; - private TypeBound[] mostRecentBounds = new TypeBound[4]; // for quick & dirty duplicate elimination + private final TypeBound[] mostRecentBounds = new TypeBound[4]; // for quick & dirty duplicate elimination public BoundSet() {} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding18.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding18.java index 97d1e77cfb..f1631f99c1 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding18.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding18.java @@ -22,8 +22,8 @@ public class CaptureBinding18 extends CaptureBinding { TypeBinding[] upperBounds; - private char[] originalName; - private CaptureBinding18 prototype; + private final char[] originalName; + private final CaptureBinding18 prototype; public CaptureBinding18(ReferenceBinding contextType, char[] sourceName, char[] originalName, int start, int end, int captureID, LookupEnvironment environment) { super(contextType, sourceName, start, end, captureID, environment); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java index 74ae857a8a..08fc9371ba 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java @@ -48,6 +48,7 @@ import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; import org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression; import org.eclipse.jdt.internal.compiler.ast.RecordComponent; +import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference; import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.eclipse.jdt.internal.compiler.ast.TypeParameter; import org.eclipse.jdt.internal.compiler.ast.TypeReference; @@ -1334,42 +1335,72 @@ void connectImplicitPermittedTypes() { void connectPermittedTypes() { SourceTypeBinding sourceType = this.referenceContext.binding; sourceType.setPermittedTypes(Binding.NO_PERMITTEDTYPES); - if (this.referenceContext.permittedTypes == null) { - return; - } if (sourceType.id == TypeIds.T_JavaLangObject || sourceType.isEnum()) // already handled return; - int length = this.referenceContext.permittedTypes.length; - ReferenceBinding[] permittedTypeBindings = new ReferenceBinding[length]; - int count = 0; - nextPermittedType : for (int i = 0; i < length; i++) { - TypeReference permittedTypeRef = this.referenceContext.permittedTypes[i]; - ReferenceBinding permittedType = findPermittedtype(permittedTypeRef); - if (permittedType == null) { // detected cycle - continue nextPermittedType; - } - // check for simple interface collisions - // Check for a duplicate interface once the name is resolved, otherwise we may be confused (i.e. a.b.I and c.d.I) - for (int j = 0; j < i; j++) { - if (TypeBinding.equalsEquals(permittedTypeBindings[j], permittedType)) { - problemReporter().sealedDuplicateTypeInPermits(sourceType, permittedTypeRef, permittedType); + if (this.referenceContext.permittedTypes != null) { + int length = this.referenceContext.permittedTypes.length; + ReferenceBinding[] permittedTypeBindings = new ReferenceBinding[length]; + int count = 0; + nextPermittedType : for (int i = 0; i < length; i++) { + TypeReference permittedTypeRef = this.referenceContext.permittedTypes[i]; + ReferenceBinding permittedType = findPermittedtype(permittedTypeRef); + if (permittedType == null) { // detected cycle continue nextPermittedType; } + if (!isPermittedTypeInAllowedFormat(sourceType, permittedTypeRef, permittedType)) + continue nextPermittedType; + + // check for simple interface collisions + // Check for a duplicate interface once the name is resolved, otherwise we may be confused (i.e. a.b.I and c.d.I) + for (int j = 0; j < i; j++) { + if (TypeBinding.equalsEquals(permittedTypeBindings[j], permittedType)) { + problemReporter().sealedDuplicateTypeInPermits(sourceType, permittedTypeRef, permittedType); + continue nextPermittedType; + } + } + // only want to reach here when no errors are reported + permittedTypeBindings[count++] = permittedType; + } + // hold onto all correctly resolved superinterfaces + if (count > 0) { + if (count != length) + System.arraycopy(permittedTypeBindings, 0, permittedTypeBindings = new ReferenceBinding[count], 0, count); + sourceType.setPermittedTypes(permittedTypeBindings); + } else { + sourceType.setPermittedTypes(Binding.NO_PERMITTEDTYPES); } - // only want to reach here when no errors are reported - permittedTypeBindings[count++] = permittedType; } - // hold onto all correctly resolved superinterfaces - if (count > 0) { - if (count != length) - System.arraycopy(permittedTypeBindings, 0, permittedTypeBindings = new ReferenceBinding[count], 0, count); - sourceType.setPermittedTypes(permittedTypeBindings); - } else { - sourceType.setPermittedTypes(Binding.NO_PERMITTEDTYPES); + ReferenceBinding[] memberTypes = sourceType.memberTypes; + if (memberTypes != null && memberTypes != Binding.NO_MEMBER_TYPES) { + for (int j = 0, size = memberTypes.length; j < size; j++) + ((SourceTypeBinding) memberTypes[j]).scope.connectPermittedTypes(); } } + private boolean isPermittedTypeInAllowedFormat(SourceTypeBinding sourceType, TypeReference permittedTypeRef, + ReferenceBinding permittedType) { + if (!(permittedType.isMemberType() && permittedTypeRef instanceof SingleTypeReference)) + return true; + ReferenceBinding enclosingType = permittedType.enclosingType(); + while (enclosingType != null) { + if (TypeBinding.equalsEquals(sourceType, enclosingType)) { + CompilationUnitScope cu = this.compilationUnitScope(); + if (cu.imports != null || cu.imports.length > 0) { + for (ImportBinding ib : cu.imports) { + Binding resolvedImport = cu.resolveSingleImport(ib, Binding.TYPE); + if (resolvedImport instanceof TypeBinding && + TypeBinding.equalsEquals(permittedType, (TypeBinding) resolvedImport)) + return true; + } + } + return false; + } + enclosingType = enclosingType.enclosingType(); + } + return true; + } + private boolean connectRecordSuperclass() { SourceTypeBinding sourceType = this.referenceContext.binding; ReferenceBinding rootRecordType = getJavaLangRecord(); @@ -1473,7 +1504,7 @@ void connectTypeHierarchy() { noProblems &= connectSuperInterfaces(); environment().typesBeingConnected.remove(sourceType); sourceType.tagBits |= TagBits.EndHierarchyCheck; - connectPermittedTypes(); +// connectPermittedTypes(); noProblems &= connectTypeVariables(this.referenceContext.typeParameters, false); sourceType.tagBits |= TagBits.TypeVariablesAreConnected; if (noProblems && sourceType.isHierarchyInconsistent()) diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java index 658fbd17c4..8a96b509f5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java @@ -448,19 +448,26 @@ public char[] computeConstantPoolName(LocalTypeBinding localType) { return candidateName; } -void connectTypeHierarchy1() { +void connectTypeHierarchy() { for (int i = 0, length = this.topLevelTypes.length; i < length; i++) this.topLevelTypes[i].scope.connectTypeHierarchy(); } -void connectTypeHierarchy2() { +void integrateAnnotationsInHierarchy() { // Only now that all hierarchy information is built we're ready for ... // ... integrating annotations for (int i = 0, length = this.topLevelTypes.length; i < length; i++) this.topLevelTypes[i].scope.referenceType().updateSupertypesWithAnnotations(Collections.emptyMap()); // ... checking on permitted types + connectPermittedTypes(); for (int i = 0, length = this.topLevelTypes.length; i < length; i++) this.topLevelTypes[i].scope.connectImplicitPermittedTypes(); } +private void connectPermittedTypes() { + for (int i = 0, length = this.topLevelTypes.length; i < length; i++) { + SourceTypeBinding sourceType = this.topLevelTypes[i]; + sourceType.scope.connectPermittedTypes(); + } +} void faultInImports() { if (this.tempImports != null) return; // faultInImports already in progress @@ -1065,10 +1072,6 @@ private void recordImportBinding(ImportBinding bindingToAdd) { * Checks additional bindings (methods or types) imported from a single static import. * Method is tried first, followed by type. If found, records them. * If in the process, import is flagged as duplicate, -1 is returned. - * @param compoundName - * @param typesBySimpleNames - * @param mask - * @param importReference */ private void checkMoreStaticBindings( char[][] compoundName, @@ -1098,10 +1101,6 @@ private void checkMoreStaticBindings( /** * Checks for duplicates. If all ok, records the importBinding * returns -1 when this import is flagged as duplicate. - * @param importBinding - * @param typesBySimpleNames - * @param importReference - * @param compoundName * @return -1 when this import is flagged as duplicate, importPtr otherwise. */ private int checkAndRecordImportBinding( diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java index 540272cc0c..e5c35fc374 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java @@ -245,7 +245,7 @@ public Constant constant(Scope scope) { return this.constant; ProblemReporter problemReporter = scope.problemReporter(); IErrorHandlingPolicy suspendedPolicy = problemReporter.suspendTempErrorHandlingPolicy(); - try { + try (problemReporter) { return constant(); } finally { problemReporter.resumeTempErrorHandlingPolicy(suspendedPolicy); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java index 8161215460..059f518ec4 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java @@ -59,7 +59,7 @@ static class InheritedNonNullnessInfo { // delegate which to ask for recursive analysis of super methods // can be 'this', but is never a MethodVerifier (to avoid infinite recursion). ImplicitNullAnnotationVerifier buddyImplicitNullAnnotationsVerifier; - private boolean inheritNullAnnotations; + private final boolean inheritNullAnnotations; protected LookupEnvironment environment; @@ -97,15 +97,15 @@ public void checkImplicitNullAnnotations(MethodBinding currentMethod, AbstractMe // compatibility & inheritance do not consider constructors / static methods: boolean isInstanceMethod = !currentMethod.isConstructor() && !currentMethod.isStatic(); complain &= isInstanceMethod; - if (!needToApplyNonNullDefault - && !complain + if (!needToApplyNonNullDefault + && !complain && !(this.inheritNullAnnotations && isInstanceMethod)) { return; // short cut, no work to be done } if (isInstanceMethod) { List superMethodList = new ArrayList(); - + // need super types connected: if (currentType instanceof SourceTypeBinding && !currentType.isHierarchyConnected() && !currentType.isAnonymousType()) { ((SourceTypeBinding) currentType).scope.connectTypeHierarchy(); @@ -114,8 +114,8 @@ public void checkImplicitNullAnnotations(MethodBinding currentMethod, AbstractMe int paramLen = currentMethod.parameters.length; findAllOverriddenMethods(currentMethod.original(), currentMethod.selector, paramLen, currentType, new HashSet(), superMethodList); - - // prepare interim storage for nullness info so we don't pollute currentMethod before we know its conflict-free: + + // prepare interim storage for nullness info so we don't pollute currentMethod before we know its conflict-free: InheritedNonNullnessInfo[] inheritedNonNullnessInfos = new InheritedNonNullnessInfo[paramLen+1]; // index 0 is for the return type for (int i=0; inull elements for any type variable that could not be substituted. */ @@ -1146,7 +1144,6 @@ public boolean reduceAndIncorporate(ConstraintFormula constraint) throws Inferen /** JLS 18.4 Resolution * @param isRecordPatternTypeInference for 18.5.5_item_3_bullet_5 * @return answer null if some constraint resolved to FALSE, otherwise the boundset representing the solution - * @throws InferenceFailureException */ private /*@Nullable*/ BoundSet resolve( InferenceVariable[] toResolve, @@ -1299,7 +1296,6 @@ public TypeBinding substitute(TypeVariableBinding typeVariable) { /** * JLS 18.4 Resolution * @return answer null if some constraint resolved to FALSE, otherwise the boundset representing the solution - * @throws InferenceFailureException */ private /*@Nullable*/ BoundSet resolve(InferenceVariable[] toResolve) throws InferenceFailureException { return resolve(toResolve, false); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/InferenceSubstitution.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/InferenceSubstitution.java index 938bfec376..52a5528ae9 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/InferenceSubstitution.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/InferenceSubstitution.java @@ -18,7 +18,7 @@ */ public class InferenceSubstitution extends Scope.Substitutor implements Substitution { - private LookupEnvironment environment; + private final LookupEnvironment environment; private InferenceVariable[] variables; private InvocationSite[] sites; @@ -55,7 +55,7 @@ protected boolean isSameParameter(TypeBinding p1, TypeBinding originalType) { return false; } }; - + int l1 = this.sites.length; subst.sites = new InvocationSite[l1+1]; System.arraycopy(this.sites, 0, subst.sites, 0, l1); @@ -74,7 +74,7 @@ protected boolean isSameParameter(TypeBinding p1, TypeBinding originalType) { } /** - * Override method {@link Scope.Substitutor#substitute(Substitution, TypeBinding)}, + * Override method {@link Scope.Substitutor#substitute(Substitution, TypeBinding)}, * to add substitution of types other than type variables. */ @Override @@ -127,7 +127,7 @@ public TypeBinding substitute(TypeVariableBinding typeVariable) { continue; } if (superInterfaces != null) { - int ifcLen = superInterfaces.length; + int ifcLen = superInterfaces.length; for (int j = 0; j < ifcLen; j++) { if (TypeBinding.equalsEquals(pi, superInterfaces[j])) { if (superInterfaces == typeVariable.superInterfaces) diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java index 83ddf12553..a684ba71db 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java @@ -25,7 +25,6 @@ import java.util.Set; -import org.eclipse.jdt.core.compiler.InvalidInputException; import org.eclipse.jdt.internal.compiler.ast.Wildcard; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; @@ -69,7 +68,7 @@ public TypeBinding clone(TypeBinding enclosingType) { } @Override - protected MethodBinding[] getInterfaceAbstractContracts(Scope scope, boolean replaceWildcards, boolean filterDefaultMethods) throws InvalidInputException { + protected MethodBinding[] getInterfaceAbstractContracts(Scope scope, boolean replaceWildcards, boolean filterDefaultMethods) throws InvalidBindingException { int typesLength = this.intersectingTypes.length; MethodBinding[][] methods = new MethodBinding[typesLength][]; int contractsLength = 0; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java index b24d30b4f7..ea2d7ba1e5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java @@ -98,10 +98,7 @@ public class LookupEnvironment implements ProblemReasons, TypeConstants { public ProblemReporter problemReporter; // SHARED public ClassFilePool classFilePool; // SHARED // indicate in which step on the compilation we are. - // step 1 : build the reference binding - // step 2 : conect the hierarchy (connect bindings) - // step 3 : build fields and method bindings. - private int stepCompleted; // ROOT_ONLY + private CompleteTypeBindingsSteps stepCompleted = CompleteTypeBindingsSteps.NONE; // ROOT_ONLY public ITypeRequestor typeRequestor; // SHARED private SimpleLookupTable uniqueParameterizedGenericMethodBindings; @@ -149,11 +146,37 @@ public class LookupEnvironment implements ProblemReasons, TypeConstants { public String moduleVersion; // ROOT_ONLY - static final int BUILD_TYPE_HIERARCHY = 1; - static final int CHECK_AND_SET_IMPORTS = 2; - static final int CONNECT_TYPE_HIERARCHY1 = 3; - static final int CONNECT_TYPE_HIERARCHY2 = 4; - static final int BUILD_FIELDS_AND_METHODS = 5; + static enum CompleteTypeBindingsSteps { + NONE, + CHECK_AND_SET_IMPORTS, + CONNECT_TYPE_HIERARCHY, + BUILD_FIELDS_AND_METHODS, + INTEGRATE_ANNOTATIONS_IN_HIERARCHY, + CHECK_PARAMETERIZED_TYPES; + + /** Answer the next step in sequence or {@code this} when we are at the last step already. */ + CompleteTypeBindingsSteps next() { + CompleteTypeBindingsSteps[] values = values(); + int nextOrdinal = ordinal() + 1; + if (nextOrdinal < values.length) + return values[nextOrdinal]; + return this; // no-change to signal "at end" + } + + /** values without NONE */ + static final CompleteTypeBindingsSteps[] realValues = Arrays.copyOfRange(values(), 1, values().length-1); + + void perform(CompilationUnitScope scope) { + switch (this) { + case CHECK_AND_SET_IMPORTS -> scope.checkAndSetImports(); + case CONNECT_TYPE_HIERARCHY -> scope.connectTypeHierarchy(); + case BUILD_FIELDS_AND_METHODS -> scope.buildFieldsAndMethods(); + case INTEGRATE_ANNOTATIONS_IN_HIERARCHY -> scope.integrateAnnotationsInHierarchy(); + case CHECK_PARAMETERIZED_TYPES -> scope.checkParameterizedTypes(); + default -> throw new IllegalArgumentException("No implementation for: " + this); //$NON-NLS-1$ + } + } + } static final ProblemPackageBinding TheNotFoundPackage = new ProblemPackageBinding(CharOperation.NO_CHAR, NotFound, null/*not perfect*/); static final ProblemReferenceBinding TheNotFoundType = new ProblemReferenceBinding(CharOperation.NO_CHAR_CHAR, null, NotFound); @@ -517,34 +540,18 @@ public void completeTypeBindings() { this.root.completeTypeBindings(); return; } - this.stepCompleted = BUILD_TYPE_HIERARCHY; - - for (int i = this.lastCompletedUnitIndex + 1; i <= this.lastUnitIndex; i++) { - (this.unitBeingCompleted = this.units[i]).scope.checkAndSetImports(); - } - this.stepCompleted = CHECK_AND_SET_IMPORTS; - - for (int i = this.lastCompletedUnitIndex + 1; i <= this.lastUnitIndex; i++) { - (this.unitBeingCompleted = this.units[i]).scope.connectTypeHierarchy1(); - } - this.stepCompleted = CONNECT_TYPE_HIERARCHY1; - for (int i = this.lastCompletedUnitIndex + 1; i <= this.lastUnitIndex; i++) { - (this.unitBeingCompleted = this.units[i]).scope.connectTypeHierarchy2(); - } - this.stepCompleted = CONNECT_TYPE_HIERARCHY2; - - for (int i = this.lastCompletedUnitIndex + 1; i <= this.lastUnitIndex; i++) { - var unit = (this.unitBeingCompleted = this.units[i]); // GROOVY null test - if (unit != null) { - CompilationUnitScope unitScope = unit.scope; - unitScope.checkParameterizedTypes(); - unitScope.buildFieldsAndMethods(); - this.units[i] = null; // release + this.stepCompleted = CompleteTypeBindingsSteps.NONE; + for (CompleteTypeBindingsSteps step : CompleteTypeBindingsSteps.values()) { + CompleteTypeBindingsSteps next = step.next(); + for (int i = this.lastCompletedUnitIndex + 1; i <= this.lastUnitIndex; i++) { + if (next != step) + next.perform((this.unitBeingCompleted = this.units[i]).scope); + else + this.units[i] = null; // at last step clean up } + this.stepCompleted = next; } - this.stepCompleted = BUILD_FIELDS_AND_METHODS; - this.lastCompletedUnitIndex = this.lastUnitIndex; this.unitBeingCompleted = null; } @@ -566,7 +573,7 @@ public void completeTypeBindings(CompilationUnitDeclaration parsedUnit) { this.root.completeTypeBindings(parsedUnit); return; } - if (this.stepCompleted == BUILD_FIELDS_AND_METHODS) { + if (this.stepCompleted == this.stepCompleted.next()) { // This can only happen because the original set of units are completely built and // are now being processed, so we want to treat all the additional units as a group // until they too are completely processed. @@ -574,15 +581,10 @@ public void completeTypeBindings(CompilationUnitDeclaration parsedUnit) { } else { if (parsedUnit.scope == null) return; // parsing errors were too severe - if (this.stepCompleted >= CHECK_AND_SET_IMPORTS) - (this.unitBeingCompleted = parsedUnit).scope.checkAndSetImports(); - - if (this.stepCompleted >= CONNECT_TYPE_HIERARCHY1) - (this.unitBeingCompleted = parsedUnit).scope.connectTypeHierarchy1(); - - if (this.stepCompleted >= CONNECT_TYPE_HIERARCHY2) - (this.unitBeingCompleted = parsedUnit).scope.connectTypeHierarchy2(); - + for (CompleteTypeBindingsSteps step : CompleteTypeBindingsSteps.realValues) { + if (this.stepCompleted.compareTo(step) >= 0) + step.perform((this.unitBeingCompleted = parsedUnit).scope); + } this.unitBeingCompleted = null; } } @@ -604,12 +606,11 @@ public void completeTypeBindings(CompilationUnitDeclaration parsedUnit, boolean if (parsedUnit.scope == null) return; // parsing errors were too severe LookupEnvironment rootEnv = this.root; CompilationUnitDeclaration previousUnitBeingCompleted = rootEnv.unitBeingCompleted; - (rootEnv.unitBeingCompleted = parsedUnit).scope.checkAndSetImports(); - parsedUnit.scope.connectTypeHierarchy1(); - parsedUnit.scope.connectTypeHierarchy2(); - parsedUnit.scope.checkParameterizedTypes(); - if (buildFieldsAndMethods) - parsedUnit.scope.buildFieldsAndMethods(); + for (CompleteTypeBindingsSteps step : CompleteTypeBindingsSteps.realValues) { + if (step != CompleteTypeBindingsSteps.BUILD_FIELDS_AND_METHODS || buildFieldsAndMethods) + step.perform((rootEnv.unitBeingCompleted = parsedUnit).scope); + } + rootEnv.unitBeingCompleted = previousUnitBeingCompleted; } @@ -623,29 +624,13 @@ public void completeTypeBindings(CompilationUnitDeclaration parsedUnit, boolean */ public void completeTypeBindings(CompilationUnitDeclaration[] parsedUnits, boolean[] buildFieldsAndMethods, int unitCount) { LookupEnvironment rootEnv = this.root; - for (int i = 0; i < unitCount; i++) { - CompilationUnitDeclaration parsedUnit = parsedUnits[i]; - if (parsedUnit.scope != null) - (rootEnv.unitBeingCompleted = parsedUnit).scope.checkAndSetImports(); - } - - for (int i = 0; i < unitCount; i++) { - CompilationUnitDeclaration parsedUnit = parsedUnits[i]; - if (parsedUnit.scope != null) - (rootEnv.unitBeingCompleted = parsedUnit).scope.connectTypeHierarchy1(); - } - for (int i = 0; i < unitCount; i++) { - CompilationUnitDeclaration parsedUnit = parsedUnits[i]; - if (parsedUnit.scope != null) - (rootEnv.unitBeingCompleted = parsedUnit).scope.connectTypeHierarchy2(); - } - - for (int i = 0; i < unitCount; i++) { - CompilationUnitDeclaration parsedUnit = parsedUnits[i]; - if (parsedUnit.scope != null) { - (rootEnv.unitBeingCompleted = parsedUnit).scope.checkParameterizedTypes(); - if (buildFieldsAndMethods[i]) - parsedUnit.scope.buildFieldsAndMethods(); + for (CompleteTypeBindingsSteps step : CompleteTypeBindingsSteps.realValues) { + for (int i = 0; i < unitCount; i++) { + CompilationUnitDeclaration parsedUnit = parsedUnits[i]; + if (parsedUnit.scope != null) + if (step != CompleteTypeBindingsSteps.BUILD_FIELDS_AND_METHODS || buildFieldsAndMethods[i]) { + step.perform((rootEnv.unitBeingCompleted = parsedUnit).scope); + } } } @@ -2212,7 +2197,7 @@ public void reset() { this.root.reset(); return; } - this.stepCompleted = 0; + this.stepCompleted = CompleteTypeBindingsSteps.NONE; this.knownModules = new HashtableOfModule(); this.UnNamedModule = new ModuleBinding.UnNamedModule(this); this.module = this.UnNamedModule; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java index 8003ebfd13..176c59a048 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java @@ -501,8 +501,6 @@ public final char[] constantPoolName() { /** * After method verifier has finished, fill in missing @NonNull specification from the applicable default. - * @param needToApplyParameterNonNullDefault - * @param needToApplyReturnNonNullDefault */ protected void fillInDefaultNonNullness(AbstractMethodDeclaration sourceMethod, boolean needToApplyReturnNonNullDefault, ParameterNonNullDefaultProvider needToApplyParameterNonNullDefault) { if (this.parameterNonNullness == null) @@ -1474,7 +1472,6 @@ public void updateTypeVariableBinding(TypeVariableBinding previousBinding, TypeV *
  • It has a single variable arity parameter (§8.4.1) whose declared type is Object[].
  • *
  • It is native.
  • *
    - * @param scope * @return true if the method has Polymorphic Signature */ public boolean hasPolymorphicSignature(Scope scope) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/MissingTypeBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/MissingTypeBinding.java index 5448343441..aa1d0f1784 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/MissingTypeBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/MissingTypeBinding.java @@ -23,9 +23,6 @@ public class MissingTypeBinding extends BinaryTypeBinding { /** * Special constructor for constructing proxies of missing types (114349) - * @param packageBinding - * @param compoundName - * @param environment */ public MissingTypeBinding(PackageBinding packageBinding, char[][] compoundName, LookupEnvironment environment) { this.compoundName = compoundName; @@ -76,7 +73,6 @@ public int problemId() { /** * Only used to fixup the superclass hierarchy of proxy binary types - * @param missingSuperclass * @see LookupEnvironment#createMissingType(PackageBinding, char[][]) */ void setMissingSuperclass(ReferenceBinding missingSuperclass) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java index f30e61acd4..98feeb97b3 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java @@ -145,7 +145,7 @@ public String toString() { public int defaultNullness = NO_NULL_DEFAULT; ModuleBinding[] requiredModules = null; boolean isAuto = false; - private boolean[] isComplete = new boolean[UpdateKind.values().length]; + private final boolean[] isComplete = new boolean[UpdateKind.values().length]; private Set transitiveRequires; SimpleLookupTable storedAnnotations = null; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/MostSpecificExceptionMethodBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/MostSpecificExceptionMethodBinding.java index bc89a8fd01..07c34c0837 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/MostSpecificExceptionMethodBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/MostSpecificExceptionMethodBinding.java @@ -22,21 +22,21 @@ */ public class MostSpecificExceptionMethodBinding extends MethodBinding { - private MethodBinding originalMethod; - + private final MethodBinding originalMethod; + public MostSpecificExceptionMethodBinding (MethodBinding originalMethod, ReferenceBinding[] mostSpecificExceptions) { super( - originalMethod.modifiers, - originalMethod.selector, - originalMethod.returnType, - originalMethod.parameters, - mostSpecificExceptions, + originalMethod.modifiers, + originalMethod.selector, + originalMethod.returnType, + originalMethod.parameters, + mostSpecificExceptions, originalMethod.declaringClass); this.originalMethod = originalMethod; this.parameterNonNullness = originalMethod.parameterNonNullness; this.defaultNullness = originalMethod.defaultNullness; } - + @Override public MethodBinding original() { return this.originalMethod.original(); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java index d666d9d5a3..128759c199 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java @@ -785,9 +785,7 @@ private static class LingeringTypeVariableEliminator implements Substitution { final private Scope scope; /** - * @param variables * @param substitutes when null, substitute type variable by unbounded wildcard - * @param scope */ public LingeringTypeVariableEliminator(TypeVariableBinding [] variables, TypeBinding [] substitutes, Scope scope) { this.variables = variables; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java index ad9e23f8d3..f15f95591b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java @@ -54,7 +54,6 @@ import java.util.Set; import org.eclipse.jdt.core.compiler.CharOperation; -import org.eclipse.jdt.core.compiler.InvalidInputException; import org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching; import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference; @@ -1724,7 +1723,7 @@ public RecordComponentBinding[] unResolvedComponents() { } @Override - protected MethodBinding[] getInterfaceAbstractContracts(Scope scope, boolean replaceWildcards, boolean filterDefaultMethods) throws InvalidInputException { + protected MethodBinding[] getInterfaceAbstractContracts(Scope scope, boolean replaceWildcards, boolean filterDefaultMethods) throws InvalidBindingException { if (replaceWildcards) { TypeBinding[] types = getNonWildcardParameters(scope); if (types == null) diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/PolyParameterizedGenericMethodBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/PolyParameterizedGenericMethodBinding.java index 238f2f5421..3f41a87f3f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/PolyParameterizedGenericMethodBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/PolyParameterizedGenericMethodBinding.java @@ -15,12 +15,12 @@ public class PolyParameterizedGenericMethodBinding extends ParameterizedGenericMethodBinding { // confused citizen. - private ParameterizedGenericMethodBinding wrappedBinding; + private final ParameterizedGenericMethodBinding wrappedBinding; public PolyParameterizedGenericMethodBinding(ParameterizedGenericMethodBinding applicableMethod) { super(applicableMethod.originalMethod, applicableMethod.typeArguments, applicableMethod.environment, applicableMethod.inferredWithUncheckedConversion, false, applicableMethod.targetType); this.wrappedBinding = applicableMethod; } - + @Override public boolean equals(Object other) { if (other instanceof PolyParameterizedGenericMethodBinding) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemBinding.java index 77ae76105d..dc99d21b48 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemBinding.java @@ -18,7 +18,7 @@ public class ProblemBinding extends Binding { public char[] name; public ReferenceBinding searchType; - private int problemId; + private final int problemId; // NOTE: must only answer the subset of the name related to the problem public ProblemBinding(char[][] compoundName, int problemId) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemFieldBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemFieldBinding.java index a647fb377d..b946479681 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemFieldBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemFieldBinding.java @@ -14,7 +14,7 @@ package org.eclipse.jdt.internal.compiler.lookup; public class ProblemFieldBinding extends FieldBinding { - private int problemId; + private final int problemId; public FieldBinding closestMatch; // NOTE: must only answer the subset of the name related to the problem diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java index 2c120b0ab7..9c1a8ffb27 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java @@ -18,7 +18,7 @@ public class ProblemMethodBinding extends MethodBinding { - private int problemReason; + private final int problemReason; public MethodBinding closestMatch; // TODO (philippe) should rename into #alternateMatch public InferenceContext18 inferenceContext; // inference context may help to coordinate error reporting diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemPackageBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemPackageBinding.java index efe9f8b301..77e447395a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemPackageBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemPackageBinding.java @@ -14,7 +14,7 @@ package org.eclipse.jdt.internal.compiler.lookup; public class ProblemPackageBinding extends PlainPackageBinding { - private int problemId; + private final int problemId; // NOTE: must only answer the subset of the name related to the problem ProblemPackageBinding(char[][] compoundName, int problemId, LookupEnvironment environment) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java index e76b8ff968..0e1710f57d 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java @@ -21,7 +21,7 @@ @SuppressWarnings("rawtypes") public class ProblemReferenceBinding extends ReferenceBinding { ReferenceBinding closestMatch; - private int problemReason; + private final int problemReason; // NOTE: must only answer the subset of the name related to the problem diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java index c469d10ea1..f4f2d7b6e5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java @@ -57,7 +57,6 @@ import java.util.Comparator; import org.eclipse.jdt.core.compiler.CharOperation; -import org.eclipse.jdt.core.compiler.InvalidInputException; import org.eclipse.jdt.internal.compiler.ast.LambdaExpression; import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching; @@ -175,8 +174,6 @@ public static FieldBinding binarySearch(char[] name, FieldBinding[] sortedFields * (remember methods are sorted alphabetically on selectors), and end is the index of last contiguous methods with same * selector. * -1 means no method got found - * @param selector - * @param sortedMethods * @return (start + (end<<32)) or -1 if no method found */ public static long binarySearch(char[] selector, MethodBinding[] sortedMethods) { @@ -2041,7 +2038,7 @@ public char[] sourceName() { * Perform an upwards type projection as per JLS 4.10.5 * @param scope Relevant scope for evaluating type projection * @param mentionedTypeVariables Filter for mentioned type variabled - * @returns Upwards type projection of 'this', or null if downwards projection is undefined + * @return Upwards type projection of 'this', or null if downwards projection is undefined */ @Override public ReferenceBinding upwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) { @@ -2052,7 +2049,7 @@ public ReferenceBinding upwardsProjection(Scope scope, TypeBinding[] mentionedTy * Perform a downwards type projection as per JLS 4.10.5 * @param scope Relevant scope for evaluating type projection * @param mentionedTypeVariables Filter for mentioned type variabled - * @returns Downwards type projection of 'this', or null if downwards projection is undefined + * @return Downwards type projection of 'this', or null if downwards projection is undefined */ @Override public ReferenceBinding downwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) { @@ -2225,10 +2222,10 @@ protected int applyCloseableInterfaceWhitelists() { return 0; } -protected MethodBinding [] getInterfaceAbstractContracts(Scope scope, boolean replaceWildcards, boolean filterDefaultMethods) throws InvalidInputException { +protected MethodBinding [] getInterfaceAbstractContracts(Scope scope, boolean replaceWildcards, boolean filterDefaultMethods) throws InvalidBindingException { if (!isInterface() || !isValidBinding()) { - throw new InvalidInputException("Not a functional interface"); //$NON-NLS-1$ + throw new InvalidBindingException("Not a functional interface"); //$NON-NLS-1$ } MethodBinding [] methods = methods(); @@ -2255,7 +2252,7 @@ protected int applyCloseableInterfaceWhitelists() { if (method == null || method.isStatic() || method.redeclaresPublicObjectMethod(scope) || method.isPrivate()) continue; if (!method.isValidBinding()) - throw new InvalidInputException("Not a functional interface"); //$NON-NLS-1$ + throw new InvalidBindingException("Not a functional interface"); //$NON-NLS-1$ for (int j = 0; j < contractsCount;) { if ( contracts[j] != null && MethodVerifier.doesMethodOverride(method, contracts[j], environment)) { contractsCount--; @@ -2348,7 +2345,7 @@ public MethodBinding getSingleAbstractMethod(Scope scope, boolean replaceWildcar return this.singleAbstractMethod[index] = samProblemBinding; } } - } catch (InvalidInputException e) { + } catch (InvalidBindingException e) { return this.singleAbstractMethod[index] = samProblemBinding; } if (methods.length == 1) @@ -2496,4 +2493,11 @@ public boolean hasEnclosingInstanceContext() { return !enclosingMethod.isStatic(); return false; } +static class InvalidBindingException extends Exception { + private static final long serialVersionUID = 1L; + + InvalidBindingException(String message) { + super(message); + } +} } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBindingSetWrapper.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBindingSetWrapper.java index e411ed14ad..bea72766b5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBindingSetWrapper.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBindingSetWrapper.java @@ -23,7 +23,7 @@ final class ReferenceBindingSetWrapper { final ReferenceBinding referenceBinding; - private int hashCode; + private final int hashCode; ReferenceBindingSetWrapper(ReferenceBinding referenceBinding) { this.referenceBinding = referenceBinding; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Scope.java index 9806a6b336..5157082ff3 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Scope.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Scope.java @@ -892,8 +892,6 @@ protected final MethodBinding computeCompatibleMethod(MethodBinding method, Type /** * Connect type variable supertypes, and returns true if no problem was detected - * @param typeParameters - * @param checkForErasedCandidateCollisions */ protected boolean connectTypeVariables(TypeParameter[] typeParameters, boolean checkForErasedCandidateCollisions) { /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259 - We used to not bother with connecting @@ -2247,7 +2245,12 @@ public Binding getBinding(char[] name, int mask, InvocationSite invocationSite, if (importReference != null && needResolve) { importReference.bits |= ASTNode.Used; } - invocationSite.setActualReceiverType(foundField.declaringClass); + TypeBinding importedType = this.getType(importBinding.compoundName, importBinding.compoundName.length-1); + if (importedType instanceof ReferenceBinding && importBinding.isValidBinding()) { + invocationSite.setActualReceiverType((ReferenceBinding) importedType); + } else { + invocationSite.setActualReceiverType(foundField.declaringClass); + } if (foundField.isValidBinding()) { return foundField; } @@ -2259,12 +2262,14 @@ public Binding getBinding(char[] name, int mask, InvocationSite invocationSite, } // check on demand imports boolean foundInImport = false; + ReferenceBinding sourceCodeReceiver = null; for (int i = 0, length = imports.length; i < length; i++) { ImportBinding importBinding = imports[i]; if (importBinding.isStatic() && importBinding.onDemand) { Binding resolvedImport = importBinding.resolvedImport; if (resolvedImport instanceof ReferenceBinding) { - FieldBinding temp = findField((ReferenceBinding) resolvedImport, name, invocationSite, needResolve); + ReferenceBinding importedReferenceBinding = (ReferenceBinding) resolvedImport; + FieldBinding temp = findField(importedReferenceBinding, name, invocationSite, needResolve); if (temp != null) { if (!temp.isValidBinding()) { if (problemField == null) @@ -2283,6 +2288,7 @@ public Binding getBinding(char[] name, int mask, InvocationSite invocationSite, name, ProblemReasons.Ambiguous); foundField = temp; + sourceCodeReceiver = importedReferenceBinding; foundInImport = true; } } @@ -2290,7 +2296,10 @@ public Binding getBinding(char[] name, int mask, InvocationSite invocationSite, } } if (foundField != null) { - invocationSite.setActualReceiverType(foundField.declaringClass); + if (sourceCodeReceiver != null) + invocationSite.setActualReceiverType(sourceCodeReceiver); + else + invocationSite.setActualReceiverType(foundField.declaringClass); return foundField; } } @@ -2726,6 +2735,7 @@ public MethodBinding getImplicitMethod(char[] selector, TypeBinding[] argumentTy scope = scope.parent; } + Map method2sourceDeclaring = new HashMap<>(); if (insideStaticContext && options.sourceLevel >= ClassFileConstants.JDK1_5) { if (foundProblem != null) { if (foundProblem.declaringClass != null && foundProblem.declaringClass.id == TypeIds.T_JavaLangObject) @@ -2748,15 +2758,25 @@ public MethodBinding getImplicitMethod(char[] selector, TypeBinding[] argumentTy Binding resolvedImport = importBinding.resolvedImport; MethodBinding possible = null; if (importBinding.onDemand) { - if (!skipOnDemand && resolvedImport instanceof ReferenceBinding) + if (!skipOnDemand && resolvedImport instanceof ReferenceBinding) { // answers closest approximation, may not check argumentTypes or visibility - possible = findMethod((ReferenceBinding) resolvedImport, selector, argumentTypes, invocationSite, true); + ReferenceBinding resolvedImportReferenceBinding = (ReferenceBinding) resolvedImport; + possible = findMethod(resolvedImportReferenceBinding, selector, argumentTypes, invocationSite, true); + if (possible != null && possible.isValidBinding()) + method2sourceDeclaring.put(possible, resolvedImportReferenceBinding); + } } else { if (resolvedImport instanceof MethodBinding) { MethodBinding staticMethod = (MethodBinding) resolvedImport; - if (CharOperation.equals(staticMethod.selector, selector)) + if (CharOperation.equals(staticMethod.selector, selector)) { // answers closest approximation, may not check argumentTypes or visibility possible = findMethod(staticMethod.declaringClass, selector, argumentTypes, invocationSite, true); + if (possible != null && possible.isValidBinding()) { + TypeBinding importedType = getType(importBinding.compoundName, importBinding.compoundName.length-1); + if (importedType instanceof ReferenceBinding && importedType.isValidBinding()) + method2sourceDeclaring.put(possible, (ReferenceBinding) importedType); + } + } } else if (resolvedImport instanceof FieldBinding) { // check to see if there are also methods with the same name FieldBinding staticField = (FieldBinding) resolvedImport; @@ -2778,6 +2798,7 @@ public MethodBinding getImplicitMethod(char[] selector, TypeBinding[] argumentTy MethodBinding compatibleMethod = computeCompatibleMethod(possible, argumentTypes, invocationSite); if (compatibleMethod != null) { if (compatibleMethod.isValidBinding()) { + method2sourceDeclaring.put(compatibleMethod, method2sourceDeclaring.get(possible)); if (compatibleMethod.canBeSeenBy(unitScope.fPackage)) { if (!skipOnDemand && !importBinding.onDemand) { visible = null; // forget previous matches from on demand imports @@ -2818,7 +2839,12 @@ public MethodBinding getImplicitMethod(char[] selector, TypeBinding[] argumentTy } if (foundMethod != null) { - invocationSite.setActualReceiverType(foundMethod.declaringClass); + ReferenceBinding sourceDeclaring = method2sourceDeclaring.get(foundMethod); + if (sourceDeclaring != null) { + invocationSite.setActualReceiverType(sourceDeclaring); + } else { + invocationSite.setActualReceiverType(foundMethod.declaringClass); + } return foundMethod; } if (foundProblem != null) @@ -5177,6 +5203,7 @@ private int parameterCompatibilityLevel(TypeBinding arg, TypeBinding param, Look return NOT_COMPATIBLE; } + /** See also the contract of {@link ProblemReporter#close()}. */ public abstract ProblemReporter problemReporter(); public final CompilationUnitDeclaration referenceCompilationUnit() { @@ -5457,7 +5484,6 @@ public boolean recordNonNullByDefault(Binding target, int value, Annotation anno /** * Check whether the given null default is redundant at the given position inside this scope. * @param nullBits locally defined nullness default, see Binding.NullnessDefaultMASK - * @param sourceStart * @return enclosing binding that already has a matching NonNullByDefault annotation, * or the special binding {@link #NOT_REDUNDANT}, indicating that a different enclosing nullness default was found, * or null to indicate that no enclosing nullness default was found. diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SignatureWrapper.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SignatureWrapper.java index 4e4fa4b504..c5aed51d26 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SignatureWrapper.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SignatureWrapper.java @@ -23,7 +23,7 @@ public class SignatureWrapper { public int start; public int end; public int bracket; - private boolean use15specifics; + private final boolean use15specifics; private boolean useExternalAnnotations; public SignatureWrapper(char[] signature, boolean use15specifics) { @@ -106,7 +106,6 @@ else if (this.end == -1) *

    * But for the signature (Lp18/Klass<TT;>.MethodInfo<Ljava/lang/String;>.InnerMethodInfo<Ljava/lang/String;>;)V * it produces (Lp18/Klass.MethodInfo.InnerMethodInfo;)V - * */ private void removeTypeArguments() { StringBuilder buffer = new StringBuilder(); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java index b26ceba6b7..d789b6a759 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java @@ -1478,7 +1478,8 @@ public RecordComponentBinding[] components() { for (MethodBinding method : this.methods) { if (method instanceof SyntheticMethodBinding) { SyntheticMethodBinding smb = (SyntheticMethodBinding) method; - if (smb.purpose == SyntheticMethodBinding.RecordCanonicalConstructor) { + if (smb.purpose == SyntheticMethodBinding.RecordCanonicalConstructor + && smb.parameters.length == this.components.length) { for (int i = 0, l = smb.parameters.length; i < l; ++i) { smb.parameters[i] = this.components[i].type; } @@ -1706,6 +1707,17 @@ public long getAnnotationTagBits() { } return this.tagBits; } +@Override +public boolean isReadyForAnnotations() { + if ((this.tagBits & TagBits.AnnotationResolved) != 0) + return true; + TypeDeclaration type; + if (this.scope != null && (type = this.scope.referenceType()) != null) { + if (type.annotations == null) + return true; // nothing here to resolve + } + return false; +} public MethodBinding[] getDefaultAbstractMethods() { if (!isPrototype()) return this.prototype.getDefaultAbstractMethods(); @@ -2271,7 +2283,7 @@ public boolean hasMemberTypes() { private int getImplicitCanonicalConstructor() { if (this.methods != null && this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK14) { - for (int i = 0, n = this.methods.length; i < n; i += 1) { + for (int i = 0, l = this.methods.length; i < l; ++i) { MethodBinding method = this.methods[i]; if (method.isCanonicalConstructor() && method.isImplicit()) return i; @@ -2805,7 +2817,7 @@ public FieldBinding resolveTypeFor(FieldBinding field) { public MethodBinding resolveTypesFor(MethodBinding method) { ProblemReporter problemReporter = this.scope.problemReporter(); IErrorHandlingPolicy suspendedPolicy = problemReporter.suspendTempErrorHandlingPolicy(); - try { + try (problemReporter) { return resolveTypesWithSuspendedTempErrorHandlingPolicy(method); } finally { problemReporter.resumeTempErrorHandlingPolicy(suspendedPolicy); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SyntheticFactoryMethodBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SyntheticFactoryMethodBinding.java index b17afb0a7a..789c996591 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SyntheticFactoryMethodBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/SyntheticFactoryMethodBinding.java @@ -20,10 +20,10 @@ */ public class SyntheticFactoryMethodBinding extends MethodBinding { - private MethodBinding staticFactoryFor; - private LookupEnvironment environment; - private ReferenceBinding enclosingType; - + private final MethodBinding staticFactoryFor; + private final LookupEnvironment environment; + private final ReferenceBinding enclosingType; + public SyntheticFactoryMethodBinding(MethodBinding method, LookupEnvironment environment, ReferenceBinding enclosingType) { super(method.modifiers | ClassFileConstants.AccStatic, TypeConstants.SYNTHETIC_STATIC_FACTORY, null, null, null, method.declaringClass); @@ -31,14 +31,13 @@ public SyntheticFactoryMethodBinding(MethodBinding method, LookupEnvironment env this.staticFactoryFor = method; this.enclosingType = enclosingType; } - + public MethodBinding getConstructor() { return this.staticFactoryFor; } - + /** Apply the given type arguments on the (declaring class of the) actual constructor being represented by this factory method and - if method type arguments is not empty materialize the parameterized generic constructor - * @param targetType + if method type arguments is not empty materialize the parameterized generic constructor */ public ParameterizedMethodBinding applyTypeArgumentsOnConstructor(TypeBinding[] typeArguments, TypeBinding[] constructorTypeArguments, boolean inferredWithUncheckedConversion, TypeBinding targetType) { ReferenceBinding parameterizedType = typeArguments == null diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java index c6978b1d59..ed03aa77ec 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java @@ -235,7 +235,6 @@ public TypeBinding closestMatch() { /** * Iterate through the type components to collect instances of leaf missing types - * @param missingTypes * @return missing types */ public List collectMissingTypes(List missingTypes) { @@ -306,7 +305,7 @@ public TypeBinding erasure() { * Perform an upwards type projection as per JLS 4.10.5 * @param scope Relevant scope for evaluating type projection * @param mentionedTypeVariables Filter for mentioned type variabled - * @returns Upwards type projection of 'this', or null if downwards projection is undefined + * @return Upwards type projection of 'this', or null if downwards projection is undefined */ public TypeBinding upwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) { return this; @@ -316,7 +315,7 @@ public TypeBinding upwardsProjection(Scope scope, TypeBinding[] mentionedTypeVar * Perform a downwards type projection as per JLS 4.10.5 * @param scope Relevant scope for evaluating type projection * @param mentionedTypeVariables Filter for mentioned type variabled - * @returns Downwards type projection of 'this', or null if downwards projection is undefined + * @return Downwards type projection of 'this', or null if downwards projection is undefined */ public TypeBinding downwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) { return this; @@ -1175,6 +1174,9 @@ private boolean isProvablyDistinctTypeArgument(TypeBinding otherArgument, final } } +public boolean isReadyForAnnotations() { + return true; +} /** * Answer true if the receiver is an annotation which may be repeatable. Overridden as appropriate. */ diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/messages.properties b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/messages.properties index 1e8135c5e7..e6a02818e1 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/messages.properties +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/messages.properties @@ -74,4 +74,5 @@ records = Records sealed_types = Sealed Types pattern_matching_switch = Pattern Matching in Switch record_patterns = Record Pattern -unnammed_patterns_and_vars = Unnammed Patterns and Variables \ No newline at end of file +unnammed_patterns_and_vars = Unnammed Patterns and Variables +unnamed_classes_and_instance_main_methods = Unnamed Classes and Instance Main Methods diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java index 96717b188b..4e3c5a0898 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java @@ -683,7 +683,7 @@ protected Object parseArguments(Object receiver, boolean checkVerifySpaceOrEndCo } // Something wrong happened => Invalid input - throw new InvalidInputException(); + throw Scanner.invalidInput(); } finally { // we have to make sure that this is reset to the previous value even if an exception occurs this.scanner.tokenizeWhiteSpace = tokenWhiteSpace; @@ -1175,11 +1175,11 @@ protected Object parseQualifiedName(boolean reset, boolean allowModule) throws I break; case TerminalTokens.TokenNameRestrictedIdentifierYield: - throw new InvalidInputException(); // unexpected. + throw Scanner.invalidInput(); // unexpected. case TerminalTokens.TokenNameDOT : if ((iToken & 1) == 0) { // dots must be even tokens - throw new InvalidInputException(); + throw Scanner.invalidInput(); } consumeToken(); break; @@ -1246,7 +1246,7 @@ protected Object parseQualifiedName(boolean reset, boolean allowModule) throws I case TerminalTokens.TokenNameDIVIDE: if (parsingJava15Plus && lookForModule) { if (((iToken & 1) == 0) || (moduleRefTokenCount > 0)) { // '/' must be even token - throw new InvalidInputException(); + throw Scanner.invalidInput(); } moduleRefTokenCount = (iToken+1) / 2; consumeToken(); @@ -1284,7 +1284,7 @@ protected Object parseQualifiedName(boolean reset, boolean allowModule) throws I } // $FALL-THROUGH$ - fall through default case to raise exception default: - throw new InvalidInputException(); + throw Scanner.invalidInput(); } } break nextToken; @@ -1505,7 +1505,7 @@ protected boolean parseSnippet() throws InvalidInputException { boolean parsingJava18Plus = this.scanner != null ? this.scanner.sourceLevel >= ClassFileConstants.JDK18 : false; boolean valid = true; if (!parsingJava18Plus) { - throw new InvalidInputException(); + throw Scanner.invalidInput(); } Object snippetTag = null; this.nonRegionTagCount = 0; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/ConflictedParser.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/ConflictedParser.java index a4d973657b..ddb9b68aa2 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/ConflictedParser.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/ConflictedParser.java @@ -21,6 +21,13 @@ public interface ConflictedParser { we treat the type annotation as a declarative annotation. */ boolean atConflictScenario(int token); + + /* Return true if at the configuration the parser finds itself in, it would shift the token. + It is axiomatic of the push down automaton that corresponds to the LALR grammar that it + will never shift on invalid input. + */ + boolean automatonWillShift(int token); + /* * Return true if the parser is parsing a module declaration. In Java 9, module, requires, exports, * to, uses, provides, and with are restricted keywords (i.e. they are keywords solely where they diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java index f782f377c2..890bbf9eb0 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java @@ -70,7 +70,7 @@ public class JavadocParser extends AbstractCommentParser { // see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=222900" private int tagWaitingForDescription; - private ArrayList regionNames = new ArrayList<>(); + private final ArrayList regionNames = new ArrayList<>(); private int regionPosition = -1; public JavadocParser(Parser sourceParser) { @@ -201,7 +201,7 @@ protected Object createArgumentReference(char[] name, int dim, boolean isVarargs return new JavadocArgumentExpression(name, argTypeRef.sourceStart, argEnd, argTypeRef); } catch (ClassCastException ex) { - throw new InvalidInputException(); + throw Scanner.invalidInput(); } } @@ -233,7 +233,7 @@ protected Object createFieldReference(Object receiver) throws InvalidInputExcept return field; } catch (ClassCastException ex) { - throw new InvalidInputException(); + throw Scanner.invalidInput(); } } @@ -284,7 +284,7 @@ protected Object createMethodReference(Object receiver, List arguments) throws I } } } else { - throw new InvalidInputException(); + throw Scanner.invalidInput(); } } // Create node @@ -336,7 +336,7 @@ protected Object createMethodReference(Object receiver, List arguments) throws I } } catch (ClassCastException ex) { - throw new InvalidInputException(); + throw Scanner.invalidInput(); } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocScanner.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocScanner.java index cc21b6c977..46a46b352a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocScanner.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocScanner.java @@ -19,9 +19,9 @@ public class JavadocScanner extends Scanner{ public boolean tokenizeSingleQuotes = false; - + public boolean considerRegexInStringLiteral = false; - + public JavadocScanner() { this(false /*comment*/, false /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_3 /*sourceLevel*/, null/*taskTag*/, null/*taskPriorities*/, true /*taskCaseSensitive*/); } @@ -71,7 +71,7 @@ public JavadocScanner( taskPriorities, isTaskCaseSensitive, isPreviewEnabled); - + } public JavadocScanner( @@ -94,7 +94,7 @@ public JavadocScanner( isTaskCaseSensitive, false); } - + public JavadocScanner( boolean tokenizeComments, boolean tokenizeWhiteSpace, @@ -144,7 +144,7 @@ protected int scanForStringLiteral() throws InvalidInputException { while (this.currentCharacter != '"') { boolean isRegex = false; if (this.currentPosition >= this.eofPosition) { - throw new InvalidInputException(UNTERMINATED_STRING); + throw unterminatedString(); } /**** \r and \n are not valid in string literals ****/ if ((this.currentCharacter == '\n') || (this.currentCharacter == '\r')) { @@ -167,13 +167,13 @@ protected int scanForStringLiteral() throws InvalidInputException { break; } if (this.currentCharacter == '\"') { - throw new InvalidInputException(INVALID_CHAR_IN_STRING); + throw invalidCharInString(); } } } else { this.currentPosition--; // set current position on new line character } - throw new InvalidInputException(INVALID_CHAR_IN_STRING); + throw invalidCharInString(); } if (this.currentCharacter == '\\') { if (this.unicodeAsBackSlash) { @@ -225,7 +225,7 @@ protected int scanForStringLiteral() throws InvalidInputException { } } catch (IndexOutOfBoundsException e) { this.currentPosition--; - throw new InvalidInputException(UNTERMINATED_STRING); + throw unterminatedString(); } catch (InvalidInputException e) { if (e.getMessage().equals(INVALID_ESCAPE)) { // relocate if finding another quote fairly close: thus unicode '/u000D' will be fully consumed @@ -246,9 +246,9 @@ protected int scanForStringLiteral() throws InvalidInputException { return TokenNameStringLiteral; } else { return super.scanForStringLiteral(); - } + } } - + @Override protected int processSingleQuotes(boolean checkIfUnicode) throws InvalidInputException{ if (this.tokenizeSingleQuotes) { @@ -278,7 +278,7 @@ protected int scanForSingleQuoteStringLiteral() throws InvalidInputException { while (this.currentCharacter != '\'') { boolean isRegex = false; if (this.currentPosition >= this.eofPosition) { - throw new InvalidInputException(UNTERMINATED_STRING); + throw unterminatedString(); } /**** \r and \n are not valid in string literals ****/ if ((this.currentCharacter == '\n') || (this.currentCharacter == '\r')) { @@ -301,13 +301,13 @@ protected int scanForSingleQuoteStringLiteral() throws InvalidInputException { break; } if (this.currentCharacter == '\'') { - throw new InvalidInputException(INVALID_CHAR_IN_STRING); + throw invalidCharInString(); } } } else { this.currentPosition--; // set current position on new line character } - throw new InvalidInputException(INVALID_CHAR_IN_STRING); + throw invalidCharInString(); } if (this.currentCharacter == '\\') { if (this.unicodeAsBackSlash) { @@ -361,7 +361,7 @@ protected int scanForSingleQuoteStringLiteral() throws InvalidInputException { } } catch (IndexOutOfBoundsException e) { this.currentPosition--; - throw new InvalidInputException(UNTERMINATED_STRING); + throw unterminatedString(); } catch (InvalidInputException e) { if (e.getMessage().equals(INVALID_ESCAPE)) { // relocate if finding another quote fairly close: thus unicode '/u000D' will be fully consumed @@ -379,7 +379,7 @@ protected int scanForSingleQuoteStringLiteral() throws InvalidInputException { } throw e; // rethrow } - return TokenNameSingleQuoteStringLiteral; + return TokenNameSingleQuoteStringLiteral; } protected boolean scanRegexCharacter() { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java index 61e3b3a721..d44dd97cad 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java @@ -15,6 +15,7 @@ package org.eclipse.jdt.internal.compiler.parser; import org.eclipse.jdt.core.compiler.CharOperation; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; /** * Javadoc tag constants. @@ -180,97 +181,69 @@ public interface JavadocTagConstants { // href tag public final static char[] HREF_TAG = {'h', 'r', 'e', 'f'}; + + /** + * A record class representing additional tags to be made + * available at specific java version levels. + * + * This class is intended to prevent maintainers from having to add + * empty arrays for each new java version that is released. + */ + record LevelTags(int level, char[][] tags) { } + /** + * Convert an array of LevelTags into the char[][][] structure that is currently used to + * discover the additional tags available at a given java version. + * + * @param input A LevelTags array representing additional tags available for each java version + * @return a char[][][] array representing newly available tags for all java class version + */ + public static char[][][] levelTagsToChar3d(LevelTags[] input) { + int expectedLength = ClassFileConstants.MAJOR_LATEST_VERSION - ClassFileConstants.MAJOR_VERSION_0 + 1; + char[][][] ret = new char[expectedLength][][]; + for( int i = 0; i < ret.length; i++ ) { + ret[i] = new char[][] {}; + } + for( int i = 0; i < input.length; i++ ) { + int nextLevel = input[i].level - ClassFileConstants.MAJOR_VERSION_0; + ret[nextLevel] = input[i].tags; + } + return ret; + } + /* * Tags versions + * + * Maintainers should add a new LevelTag only for versions in which new tags are made available */ - public static final char[][][] BLOCK_TAGS = { - // since 1.0 - { TAG_AUTHOR, TAG_DEPRECATED, TAG_EXCEPTION, TAG_PARAM, TAG_RETURN, TAG_SEE, TAG_VERSION, TAG_CATEGORY /* 1.6 tag but put here as we support it for all compliances */ }, - // since 1.1 - { TAG_SINCE }, - // since 1.2 - { TAG_SERIAL, TAG_SERIAL_DATA, TAG_SERIAL_FIELD , TAG_THROWS }, - // since 1.3 - {}, - // since 1.4 - {}, - // since 1.5 - {}, - // since 1.6 - {}, - // since 1.7 - {}, - // since 1.8 - {TAG_API_NOTE, TAG_IMPL_SPEC, TAG_IMPL_NOTE}, - // since 9 - { TAG_HIDDEN, TAG_USES, TAG_PROVIDES }, - // since 10 - {}, - // since 11 - {}, - // since 12 - {}, - // since 13 - {}, - // since 14 - {}, - // since 15 - {}, - // since 16 - {}, - // since 17 - {}, - // since 18 - {}, - // since 19 - {}, - // since 20 - {}, - }; - public static final char[][][] INLINE_TAGS = { - // since 1.0 - {}, - // since 1.1 - {}, - // since 1.2 - { TAG_LINK }, - // since 1.3 - { TAG_DOC_ROOT }, - // since 1.4 - { TAG_INHERITDOC, TAG_LINKPLAIN, TAG_VALUE }, - // since 1.5 - { TAG_CODE, TAG_LITERAL }, - // since 1.6 - {}, - // since 1.7 - {}, - // since 1.8 - {}, - // since 9 - { TAG_INDEX }, - // since 10 - { TAG_SUMMARY }, - // since 11 - {}, - // since 12 - {TAG_SYSTEM_PROPERTY}, - // since 13 - {}, - // since 14 - {}, - // since 15 - {}, - // since 16 - {TAG_RETURN}, - // since 17 - {}, - // since 18 - { TAG_SNIPPET }, - // since 19 - {}, - // since 20 - {}, + public static final LevelTags[] BLOCK_TAGS_RAW = { + new LevelTags(ClassFileConstants.MAJOR_VERSION_0, new char[][]{ TAG_AUTHOR, TAG_DEPRECATED, TAG_EXCEPTION, TAG_PARAM, TAG_RETURN, TAG_SEE, TAG_VERSION, TAG_CATEGORY /* 1.6 tag but put here as we support it for all compliances */ }), + new LevelTags(ClassFileConstants.MAJOR_VERSION_1_1, new char[][]{ TAG_SINCE }), + new LevelTags(ClassFileConstants.MAJOR_VERSION_1_2, new char[][]{ TAG_SERIAL, TAG_SERIAL_DATA, TAG_SERIAL_FIELD , TAG_THROWS }), + new LevelTags(ClassFileConstants.MAJOR_VERSION_1_8, new char[][]{TAG_API_NOTE, TAG_IMPL_SPEC, TAG_IMPL_NOTE}), + new LevelTags(ClassFileConstants.MAJOR_VERSION_9, new char[][]{ TAG_HIDDEN, TAG_USES, TAG_PROVIDES }) }; + public static final char[][][] BLOCK_TAGS = levelTagsToChar3d(BLOCK_TAGS_RAW); + + /* + * Inline Tags versions + * + * Maintainers should add a new LevelTag only for versions in which new tags are made available + */ + public static final LevelTags[] INLINE_TAGS_RAW = { + new LevelTags(ClassFileConstants.MAJOR_VERSION_1_2, new char[][]{ TAG_LINK }), + new LevelTags(ClassFileConstants.MAJOR_VERSION_1_3, new char[][]{ TAG_DOC_ROOT }), + new LevelTags(ClassFileConstants.MAJOR_VERSION_1_4, new char[][]{ TAG_INHERITDOC, TAG_LINKPLAIN, TAG_VALUE }), + new LevelTags(ClassFileConstants.MAJOR_VERSION_1_5, new char[][]{ TAG_CODE, TAG_LITERAL }), + new LevelTags(ClassFileConstants.MAJOR_VERSION_9, new char[][]{ TAG_INDEX }), + new LevelTags(ClassFileConstants.MAJOR_VERSION_10, new char[][]{ TAG_SUMMARY }), + new LevelTags(ClassFileConstants.MAJOR_VERSION_12, new char[][]{ TAG_SYSTEM_PROPERTY }), + new LevelTags(ClassFileConstants.MAJOR_VERSION_16, new char[][]{ TAG_RETURN }), + new LevelTags(ClassFileConstants.MAJOR_VERSION_18, new char[][]{ TAG_SNIPPET }), + }; + public static final char[][][] INLINE_TAGS = levelTagsToChar3d(INLINE_TAGS_RAW); + + + public static final char[][][] IN_SNIPPET_TAGS = { // since 18 { TAG_HIGHLIGHT, TAG_REPLACE, TAG_LINK } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Parser.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Parser.java index 2b2ba1da4b..054cc4513b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Parser.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Parser.java @@ -2950,9 +2950,6 @@ protected void consumeConditionalExpression(int op) { this.expressionStack[this.expressionPtr + 1], this.expressionStack[this.expressionPtr + 2]); } -/** - * @param op - */ protected void consumeConditionalExpressionWithName(int op) { // ConditionalExpression ::= Name '?' Expression ':' ConditionalExpression this.intPtr -= 2;//consume position of the question mark @@ -3471,6 +3468,9 @@ protected void consumeEnhancedForStatementHeaderInitRecord(boolean hasModifiers) this.intStack[this.intPtr--]); pushOnAstStack(forEachWithPattern); this.forStartPosition = 0; + if (recordPattern != null) { + problemReporter().illegalRecordPattern(recordPattern.sourceStart, recordPattern.sourceEnd); + } } protected void consumeEnhancedForStatementHeaderInit(boolean hasModifiers) { TypeReference type; @@ -4142,7 +4142,6 @@ protected void consumeEqualityExpression(int op) { op); } /* - * @param op */ protected void consumeEqualityExpressionWithName(int op) { // EqualityExpression ::= Name '==' RelationalExpression @@ -14771,6 +14770,12 @@ public boolean automatonWillShift(int token, int lastAction) { return lastAction != ERROR_ACTION; } } + +@Override +public boolean automatonWillShift(int token) { + return automatonWillShift(token, this.unstackedAct); +} + @Override public boolean isParsingJava14() { return this.parsingJava14Plus; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredAnnotation.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredAnnotation.java index 712e86150c..149a0b1d45 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredAnnotation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/RecoveredAnnotation.java @@ -30,9 +30,9 @@ public class RecoveredAnnotation extends RecoveredElement { public static final int SINGLE_MEMBER = 2; private int kind; - private int identifierPtr; - private int identifierLengthPtr; - private int sourceStart; + private final int identifierPtr; + private final int identifierLengthPtr; + private final int sourceStart; public boolean hasPendingMemberValueName; public int memberValuPairEqualEnd = -1; public Annotation annotation; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java index 519fd0682e..0c285dfc80 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2022 IBM Corporation and others. + * Copyright (c) 2000, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -122,7 +122,6 @@ public class Scanner implements TerminalTokens { boolean breakPreviewAllowed = false; /** * The current context of the scanner w.r.t restricted keywords - * */ enum ScanContext { EXPECTING_KEYWORD, EXPECTING_IDENTIFIER, AFTER_REQUIRES, INACTIVE @@ -213,7 +212,7 @@ enum ScanContext { //Java 15 - first _ keyword appears Map _Keywords = null; - private CharDeduplication deduplication = CharDeduplication.getThreadLocalInstance(); + private final CharDeduplication deduplication = CharDeduplication.getThreadLocalInstance(); public Scanner() { this(false /*comment*/, false /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_3 /*sourceLevel*/, null/*taskTag*/, null/*taskPriorities*/, true /*taskCaseSensitive*/); @@ -1038,16 +1037,17 @@ private final void consumeDigits(int radix, boolean expectingDigitFirst) throws switch(consumeDigits0(radix, USING_UNDERSCORE, INVALID_POSITION, expectingDigitFirst)) { case USING_UNDERSCORE : if (this.sourceLevel < ClassFileConstants.JDK1_7) { - throw new InvalidInputException(UNDERSCORES_IN_LITERALS_NOT_BELOW_17); + throw invalidUnderscoresInLiterals(); } break; case INVALID_POSITION : if (this.sourceLevel < ClassFileConstants.JDK1_7) { - throw new InvalidInputException(UNDERSCORES_IN_LITERALS_NOT_BELOW_17); + throw invalidUnderscoresInLiterals(); } - throw new InvalidInputException(INVALID_UNDERSCORE); + throw invalidUnderscore(); } } + private final int consumeDigits0(int radix, int usingUnderscore, int invalidPosition, boolean expectingDigitFirst) throws InvalidInputException { int kind = 0; if (getNextChar('_')) { @@ -1370,20 +1370,20 @@ public int scanIdentifier() throws InvalidInputException { boolean isJavaIdStart; if (c >= HIGH_SURROGATE_MIN_VALUE && c <= HIGH_SURROGATE_MAX_VALUE) { if (this.complianceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + throw invalidUnicodeEscape(); } // Unicode 4 detection char low = (char) getNextCharWithBoundChecks(); if (low < LOW_SURROGATE_MIN_VALUE || low > LOW_SURROGATE_MAX_VALUE) { // illegal low surrogate - throw new InvalidInputException(INVALID_LOW_SURROGATE); + throw invalidLowSurrogate(); } isJavaIdStart = ScannerHelper.isJavaIdentifierStart(this.complianceLevel, c, low); } else if (c >= LOW_SURROGATE_MIN_VALUE && c <= LOW_SURROGATE_MAX_VALUE) { if (this.complianceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + throw invalidUnicodeEscape(); } - throw new InvalidInputException(INVALID_HIGH_SURROGATE); + throw invalidHighSurrogate(); } else { // optimized case already checked isJavaIdStart = ScannerHelper.isJavaIdentifierStart(this.complianceLevel, c); @@ -1828,7 +1828,7 @@ protected int getNextToken0() throws InvalidInputException { int firstTag = 0; while ((this.currentCharacter != '/') || (!star)) { if (this.currentPosition >= this.eofPosition) { - throw new InvalidInputException(UNTERMINATED_COMMENT); + throw unterminatedComment(); } if ((this.currentCharacter == '\r') || (this.currentCharacter == '\n')) { if (this.recordLineSeparator) { @@ -1881,7 +1881,7 @@ protected int getNextToken0() throws InvalidInputException { } } catch (IndexOutOfBoundsException e) { this.currentPosition--; - throw new InvalidInputException(UNTERMINATED_COMMENT); + throw unterminatedComment(); } break; } @@ -1893,7 +1893,7 @@ protected int getNextToken0() throws InvalidInputException { if (atEnd()) return TokenNameEOF; //the atEnd may not be if source is only some part of a real (external) stream - throw new InvalidInputException("Ctrl-Z"); //$NON-NLS-1$ + throw invalidEof(); default : char c = this.currentCharacter; if (c < ScannerHelper.MAX_OBVIOUS) { @@ -1908,21 +1908,21 @@ protected int getNextToken0() throws InvalidInputException { boolean isJavaIdStart; if (c >= HIGH_SURROGATE_MIN_VALUE && c <= HIGH_SURROGATE_MAX_VALUE) { if (this.complianceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + throw invalidUnicodeEscape(); } // Unicode 4 detection char low = (char) getNextChar(); if (low < LOW_SURROGATE_MIN_VALUE || low > LOW_SURROGATE_MAX_VALUE) { // illegal low surrogate - throw new InvalidInputException(INVALID_LOW_SURROGATE); + throw invalidLowSurrogate(); } isJavaIdStart = ScannerHelper.isJavaIdentifierStart(this.complianceLevel, c, low); } else if (c >= LOW_SURROGATE_MIN_VALUE && c <= LOW_SURROGATE_MAX_VALUE) { if (this.complianceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + throw invalidUnicodeEscape(); } - throw new InvalidInputException(INVALID_HIGH_SURROGATE); + throw invalidHighSurrogate(); } else { // optimized case already checked isJavaIdStart = ScannerHelper.isJavaIdentifierStart(this.complianceLevel, c); @@ -1950,7 +1950,7 @@ protected int processSingleQuotes(boolean checkIfUnicode) throws InvalidInputExc { int test; if ((test = getNextChar('\n', '\r')) == 0) { - throw new InvalidInputException(INVALID_CHARACTER_CONSTANT); + throw invalidCharacter(); } if (test > 0) { // relocate if finding another quote fairly close: thus unicode '/u000D' will be fully consumed @@ -1964,7 +1964,7 @@ protected int processSingleQuotes(boolean checkIfUnicode) throws InvalidInputExc break; } } - throw new InvalidInputException(INVALID_CHARACTER_CONSTANT); + throw invalidCharacter(); } } if (getNextChar('\'')) { @@ -1979,7 +1979,7 @@ protected int processSingleQuotes(boolean checkIfUnicode) throws InvalidInputExc break; } } - throw new InvalidInputException(INVALID_CHARACTER_CONSTANT); + throw invalidCharacter(); } if (getNextChar('\\')) { if (this.unicodeAsBackSlash) { @@ -2004,7 +2004,7 @@ protected int processSingleQuotes(boolean checkIfUnicode) throws InvalidInputExc && (this.source[this.currentPosition] == 'u'); } catch(IndexOutOfBoundsException e) { this.currentPosition--; - throw new InvalidInputException(INVALID_CHARACTER_CONSTANT); + throw invalidCharacter(); } if (checkIfUnicode) { getNextUnicodeChar(); @@ -2027,7 +2027,7 @@ protected int processSingleQuotes(boolean checkIfUnicode) throws InvalidInputExc break; } } - throw new InvalidInputException(INVALID_CHARACTER_CONSTANT); + throw invalidCharacter(); } protected int scanForStringLiteral() throws InvalidInputException { boolean isTextBlock = false; @@ -2055,7 +2055,7 @@ protected int scanForStringLiteral() throws InvalidInputException { while (this.currentCharacter != '"') { if (this.currentPosition >= this.eofPosition) { - throw new InvalidInputException(UNTERMINATED_STRING); + throw unterminatedString(); } /**** \r and \n are not valid in string literals ****/ if ((this.currentCharacter == '\n') || (this.currentCharacter == '\r')) { @@ -2078,13 +2078,13 @@ protected int scanForStringLiteral() throws InvalidInputException { break; } if (this.currentCharacter == '\"') { - throw new InvalidInputException(INVALID_CHAR_IN_STRING); + throw invalidCharInString(); } } } else { this.currentPosition--; // set current position on new line character } - throw new InvalidInputException(INVALID_CHAR_IN_STRING); + throw invalidCharInString(); } if (this.currentCharacter == '\\') { if (this.unicodeAsBackSlash) { @@ -2127,7 +2127,7 @@ protected int scanForStringLiteral() throws InvalidInputException { } } catch (IndexOutOfBoundsException e) { this.currentPosition--; - throw new InvalidInputException(UNTERMINATED_STRING); + throw unterminatedString(); } catch (InvalidInputException e) { if (e.getMessage().equals(INVALID_ESCAPE)) { // relocate if finding another quote fairly close: thus unicode '/u000D' will be fully consumed @@ -2243,10 +2243,10 @@ protected int scanForTextBlock() throws InvalidInputException { if (lastQuotePos > 0) this.currentPosition = lastQuotePos; this.currentPosition = (lastQuotePos > 0) ? lastQuotePos : this.startPosition + this.rawStart; - throw new InvalidInputException(UNTERMINATED_TEXT_BLOCK); + throw unterminatedTextBlock(); } catch (IndexOutOfBoundsException e) { this.currentPosition = (lastQuotePos > 0) ? lastQuotePos : this.startPosition + this.rawStart; - throw new InvalidInputException(UNTERMINATED_TEXT_BLOCK); + throw unterminatedTextBlock(); } } public void getNextUnicodeChar() @@ -2265,18 +2265,18 @@ public void getNextUnicodeChar() this.currentPosition++; if (this.currentPosition >= this.eofPosition) { this.currentPosition--; - throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + throw invalidUnicodeEscape(); } unicodeSize++; } } else { this.currentPosition--; - throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + throw invalidUnicodeEscape(); } if ((this.currentPosition + 4) > this.eofPosition) { this.currentPosition += (this.eofPosition - this.currentPosition); - throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + throw invalidUnicodeEscape(); } if ((c1 = ScannerHelper.getHexadecimalValue(this.source[this.currentPosition++])) > 15 || c1 < 0 @@ -2286,7 +2286,7 @@ public void getNextUnicodeChar() || c3 < 0 || (c4 = ScannerHelper.getHexadecimalValue(this.source[this.currentPosition++])) > 15 || c4 < 0){ - throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + throw invalidUnicodeEscape(); } this.currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4); //need the unicode buffer @@ -2698,7 +2698,7 @@ public final void jumpOverMethodBody() { boolean isJavaIdStart; if (c >= HIGH_SURROGATE_MIN_VALUE && c <= HIGH_SURROGATE_MAX_VALUE) { if (this.complianceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + throw invalidUnicodeEscape(); } // Unicode 4 detection char low = (char) getNextChar(); @@ -3095,7 +3095,7 @@ protected final void scanEscapeCharacter() throws InvalidInputException { break; case 's' : if (this.sourceLevel < ClassFileConstants.JDK15) { - throw new InvalidInputException(INVALID_ESCAPE); + throw invalidEscape(); } this.currentCharacter = ' '; break; @@ -3136,12 +3136,13 @@ protected final void scanEscapeCharacter() throws InvalidInputException { this.currentPosition--; } if (number > 255) - throw new InvalidInputException(INVALID_ESCAPE); + throw invalidEscape(); this.currentCharacter = (char) number; } else - throw new InvalidInputException(INVALID_ESCAPE); + throw invalidEscape(); } } + public int scanIdentifierOrKeywordWithBoundCheck() { //test keywords @@ -3989,7 +3990,7 @@ public int scanNumber(boolean dotPrefix) throws InvalidInputException { int end = this.currentPosition; if (getNextChar('l', 'L') >= 0) { if (end == start) { - throw new InvalidInputException(INVALID_HEXA); + throw invalidHexa(); } return TokenNameLongLiteral; } else if (getNextChar('.')) { @@ -4001,9 +4002,9 @@ public int scanNumber(boolean dotPrefix) throws InvalidInputException { end = this.currentPosition; if (hasNoDigitsBeforeDot && end == start) { if (this.sourceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(ILLEGAL_HEXA_LITERAL); + throw illegalHexaLiteral(); } - throw new InvalidInputException(INVALID_HEXA); + throw invalidHexa(); } if (getNextChar('p', 'P') >= 0) { // consume next character @@ -4031,50 +4032,50 @@ public int scanNumber(boolean dotPrefix) throws InvalidInputException { } if (!ScannerHelper.isDigit(this.currentCharacter)) { if (this.sourceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(ILLEGAL_HEXA_LITERAL); + throw illegalHexaLiteral(); } if (this.currentCharacter == '_') { // wrongly place '_' consumeDigits(10); - throw new InvalidInputException(INVALID_UNDERSCORE); + throw invalidUnderscore(); } - throw new InvalidInputException(INVALID_HEXA); + throw invalidHexa(); } consumeDigits(10); if (getNextChar('f', 'F') >= 0) { if (this.sourceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(ILLEGAL_HEXA_LITERAL); + throw illegalHexaLiteral(); } return TokenNameFloatingPointLiteral; } if (getNextChar('d', 'D') >= 0) { if (this.sourceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(ILLEGAL_HEXA_LITERAL); + throw illegalHexaLiteral(); } return TokenNameDoubleLiteral; } if (getNextChar('l', 'L') >= 0) { if (this.sourceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(ILLEGAL_HEXA_LITERAL); + throw illegalHexaLiteral(); } - throw new InvalidInputException(INVALID_HEXA); + throw invalidHexa(); } if (this.sourceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(ILLEGAL_HEXA_LITERAL); + throw illegalHexaLiteral(); } return TokenNameDoubleLiteral; } else { if (this.sourceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(ILLEGAL_HEXA_LITERAL); + throw illegalHexaLiteral(); } - throw new InvalidInputException(INVALID_HEXA); + throw invalidHexa(); } } else if (getNextChar('p', 'P') >= 0) { // consume next character if (end == start) { // Has no digits before exponent if (this.sourceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(ILLEGAL_HEXA_LITERAL); + throw illegalHexaLiteral(); } - throw new InvalidInputException(INVALID_HEXA); + throw invalidHexa(); } this.unicodeAsBackSlash = false; if (((this.currentCharacter = this.source[this.currentPosition++]) == '\\') @@ -4100,41 +4101,41 @@ public int scanNumber(boolean dotPrefix) throws InvalidInputException { } if (!ScannerHelper.isDigit(this.currentCharacter)) { if (this.sourceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(ILLEGAL_HEXA_LITERAL); + throw illegalHexaLiteral(); } if (this.currentCharacter == '_') { // wrongly place '_' consumeDigits(10); - throw new InvalidInputException(INVALID_UNDERSCORE); + throw invalidUnderscore(); } - throw new InvalidInputException(INVALID_FLOAT); + throw invalidFloat(); } consumeDigits(10); if (getNextChar('f', 'F') >= 0) { if (this.sourceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(ILLEGAL_HEXA_LITERAL); + throw illegalHexaLiteral(); } return TokenNameFloatingPointLiteral; } if (getNextChar('d', 'D') >= 0) { if (this.sourceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(ILLEGAL_HEXA_LITERAL); + throw illegalHexaLiteral(); } return TokenNameDoubleLiteral; } if (getNextChar('l', 'L') >= 0) { if (this.sourceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(ILLEGAL_HEXA_LITERAL); + throw illegalHexaLiteral(); } - throw new InvalidInputException(INVALID_HEXA); + throw invalidHexa(); } if (this.sourceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(ILLEGAL_HEXA_LITERAL); + throw illegalHexaLiteral(); } return TokenNameDoubleLiteral; } else { if (end == start) - throw new InvalidInputException(INVALID_HEXA); + throw invalidHexa(); return TokenNameIntegerLiteral; } } else if (getNextChar('b', 'B') >= 0) { //----------binary----------------- @@ -4143,18 +4144,18 @@ public int scanNumber(boolean dotPrefix) throws InvalidInputException { int end = this.currentPosition; if (end == start) { if (this.sourceLevel < ClassFileConstants.JDK1_7) { - throw new InvalidInputException(BINARY_LITERAL_NOT_BELOW_17); + throw invalidBinaryLiteral(); } - throw new InvalidInputException(INVALID_BINARY); + throw invalidBinary(); } if (getNextChar('l', 'L') >= 0) { if (this.sourceLevel < ClassFileConstants.JDK1_7) { - throw new InvalidInputException(BINARY_LITERAL_NOT_BELOW_17); + throw invalidBinaryLiteral(); } return TokenNameLongLiteral; } if (this.sourceLevel < ClassFileConstants.JDK1_7) { - throw new InvalidInputException(BINARY_LITERAL_NOT_BELOW_17); + throw invalidBinaryLiteral(); } return TokenNameIntegerLiteral; } @@ -4208,9 +4209,9 @@ public int scanNumber(boolean dotPrefix) throws InvalidInputException { if (this.currentCharacter == '_') { // wrongly place '_' consumeDigits(10); - throw new InvalidInputException(INVALID_UNDERSCORE); + throw invalidUnderscore(); } - throw new InvalidInputException(INVALID_FLOAT); + throw invalidFloat(); } consumeDigits(10); } @@ -4266,9 +4267,9 @@ public int scanNumber(boolean dotPrefix) throws InvalidInputException { if (this.currentCharacter == '_') { // wrongly place '_' consumeDigits(10); - throw new InvalidInputException(INVALID_UNDERSCORE); + throw invalidUnderscore(); } - throw new InvalidInputException(INVALID_FLOAT); + throw invalidFloat(); } // current character is a digit so we expect no digit first (the next character could be an underscore) consumeDigits(10); @@ -4780,10 +4781,8 @@ private static class Goal { static int BlockStatementoptRule = 0; static int YieldStatementRule = 0; static int SwitchLabelCaseLhsRule = 0; - static int GuardRule = 0; static int[] RestrictedIdentifierSealedRule; static int[] RestrictedIdentifierPermitsRule; - static int[] RestrictedIdentifierWhenRule; static int[] PatternRules; static int RecordPatternRule = 0; @@ -4796,16 +4795,13 @@ private static class Goal { static Goal SwitchLabelCaseLhsGoal; static Goal RestrictedIdentifierSealedGoal; static Goal RestrictedIdentifierPermitsGoal; - static Goal RestrictedIdentifierWhenGoal; static Goal PatternGoal; static Goal RecordPatternGoal; - static int[] EMPTY_FOLLOW_SET = new int[0]; static int[] RestrictedIdentifierSealedFollow = { TokenNameclass, TokenNameinterface, TokenNameenum, TokenNameRestrictedIdentifierrecord };// Note: enum/record allowed as error flagging rules. static int[] RestrictedIdentifierPermitsFollow = { TokenNameLBRACE }; static int[] PatternCaseLabelFollow = {TokenNameCOLON, TokenNameARROW, TokenNameCOMMA, TokenNameBeginCaseExpr, TokenNameRestrictedIdentifierWhen}; - static int[] GuardFollow = EMPTY_FOLLOW_SET; static int[] RecordPatternFollow = {TokenNameCOLON}; // disambiguate only for enh for static { @@ -4854,10 +4850,7 @@ private static class Goal { if ("RecordPattern".equals(Parser.name[Parser.non_terminal_index[Parser.lhs[i]]])) {//$NON-NLS-1$ patternStates.add(i); RecordPatternRule = i; - } else - if ("Expression".equals(Parser.name[Parser.non_terminal_index[Parser.lhs[i]]])) //$NON-NLS-1$ - GuardRule = i; - + } } RestrictedIdentifierSealedRule = ridSealed.stream().mapToInt(Integer :: intValue).toArray(); // overkill but future-proof RestrictedIdentifierPermitsRule = ridPermits.stream().mapToInt(Integer :: intValue).toArray(); @@ -4872,7 +4865,6 @@ private static class Goal { SwitchLabelCaseLhsGoal = new Goal(TokenNameARROW, new int [0], SwitchLabelCaseLhsRule); RestrictedIdentifierSealedGoal = new Goal(TokenNameRestrictedIdentifiersealed, RestrictedIdentifierSealedFollow, RestrictedIdentifierSealedRule); RestrictedIdentifierPermitsGoal = new Goal(TokenNameRestrictedIdentifierpermits, RestrictedIdentifierPermitsFollow, RestrictedIdentifierPermitsRule); - RestrictedIdentifierWhenGoal = new Goal(TokenNameRestrictedIdentifierWhen, GuardFollow, GuardRule); PatternGoal = new Goal(TokenNameBeginCaseElement, PatternCaseLabelFollow, PatternRules); RecordPatternGoal = new Goal(TokenNameQUESTION, RecordPatternFollow, RecordPatternRule); } @@ -4985,6 +4977,11 @@ protected boolean parse(Goal goal) { do { /* reduce */ if (goal.hasBeenReached(act, this.currentToken)) return SUCCESS; + if (this.currentToken == TokenNameIdentifier) { + int reskw = TerminalTokens.getRestrictedKeyword(this.scanner.getCurrentIdentifierSource()); + if (reskw != TokenNameNotAToken && goal.hasBeenReached(act, reskw)) + return SUCCESS; + } this.stateStackTop -= (Parser.rhs[act] - 1); act = Parser.ntAction(this.stack[this.stateStackTop], Parser.lhs[act]); } while (act <= NUM_RULES); @@ -5080,25 +5077,6 @@ protected final boolean mayBeAtCasePattern(int token) { return (!isInModuleDeclaration() && JavaFeature.PATTERN_MATCHING_IN_SWITCH.isSupported(this.complianceLevel, this.previewEnabled)) && (token == TokenNamecase || this.multiCaseLabelComma); } -protected boolean mayBeAtGuard(int token) { - if (isInModuleDeclaration()) - return false; - if (!JavaFeature.PATTERN_MATCHING_IN_SWITCH.isSupported(this.complianceLevel, this.previewEnabled)) - return false; - /* - * A simple elimination optimization for some common possible cases. According to the JLS 19 including - * patterns-switch and record-patterns Section 14.30.1, a guard may only be preceded by either right parentheses or - * an identifier. However, we may still encounter comments, whitespace or the not-a-token token. - */ - switch (this.lookBack[1]) { - case TokenNameRPAREN: - case TokenNameIdentifier: - case TokenNameNotAToken: // TODO is this useful? Some tests start scanning at "when", but this makes no sense as a Pattern is required by the JLS - return true; - } - return false; -} - protected final boolean maybeAtLambdaOrCast() { // Could the '(' we saw just now herald a lambda parameter list or a cast expression ? (the possible locations for both are identical.) if (isInModuleDeclaration()) @@ -5112,6 +5090,7 @@ protected final boolean maybeAtLambdaOrCast() { // Could the '(' we saw just now case TokenNameswitch: case TokenNamewhile: case TokenNamefor: + case TokenNamecase: case TokenNamesynchronized: case TokenNametry: return false; // not a viable prefix for cast or lambda. @@ -5407,8 +5386,8 @@ int disambiguatedRestrictedIdentifierWhen(int restrictedIdentifierToken) { if (!JavaFeature.PATTERN_MATCHING_IN_SWITCH.isSupported(this.complianceLevel, this.previewEnabled)) return TokenNameIdentifier; - return disambiguatesRestrictedIdentifierWithLookAhead(this::mayBeAtGuard, - restrictedIdentifierToken, Goal.RestrictedIdentifierWhenGoal); + return this.activeParser == null || !this.activeParser.automatonWillShift(TokenNameRestrictedIdentifierWhen) ? + TokenNameIdentifier : TokenNameRestrictedIdentifierWhen; } int disambiguatedRestrictedIdentifierYield(int restrictedIdentifierToken) { // and here's the kludge @@ -5665,4 +5644,65 @@ We use FOLLOW rather than FIRST since we want to recognize empty statements. i.e protected int getNextNotFakedToken() throws InvalidInputException { return getNextToken(); } + +protected static InvalidInputException invalidCharacter() { + return new InvalidInputException(INVALID_CHARACTER_CONSTANT); +} +protected static InvalidInputException invalidCharInString() { + return new InvalidInputException(INVALID_CHAR_IN_STRING); +} +protected static InvalidInputException unterminatedString() { + return new InvalidInputException(UNTERMINATED_STRING); +} +protected static InvalidInputException invalidUnicodeEscape() { + return new InvalidInputException(INVALID_UNICODE_ESCAPE); +} +protected static InvalidInputException invalidLowSurrogate() { + return new InvalidInputException(INVALID_LOW_SURROGATE); +} +protected static InvalidInputException invalidHighSurrogate() { + return new InvalidInputException(INVALID_HIGH_SURROGATE); +} +protected static InvalidInputException unterminatedComment() { + return new InvalidInputException(UNTERMINATED_COMMENT); +} +protected static InvalidInputException unterminatedTextBlock() { + return new InvalidInputException(UNTERMINATED_TEXT_BLOCK); +} +protected static InvalidInputException invalidEof() { + return new InvalidInputException("Ctrl-Z"); //$NON-NLS-1$ +} +protected static InvalidInputException invalidUnderscore() { + return new InvalidInputException(INVALID_UNDERSCORE); +} +protected static InvalidInputException invalidUnderscoresInLiterals() { + return new InvalidInputException(UNDERSCORES_IN_LITERALS_NOT_BELOW_17); +} +protected static InvalidInputException invalidEscape() { + return new InvalidInputException(INVALID_ESCAPE); +} +protected static InvalidInputException invalidHexa() { + return new InvalidInputException(INVALID_HEXA); +} +protected static InvalidInputException illegalHexaLiteral() { + return new InvalidInputException(ILLEGAL_HEXA_LITERAL); +} +protected static InvalidInputException invalidFloat() { + return new InvalidInputException(INVALID_FLOAT); +} +protected static InvalidInputException invalidBinaryLiteral() { + return new InvalidInputException(BINARY_LITERAL_NOT_BELOW_17); +} +protected static InvalidInputException invalidBinary() { + return new InvalidInputException(INVALID_BINARY); +} +public static InvalidInputException invalidToken(int token) { + return new InvalidInputException("Unknown token (check Scanner/TerminalTokens): " + token); //$NON-NLS-1$ +} +public static InvalidInputException invalidInput() { + return new InvalidInputException(); +} + + + } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java index c09d815b10..c716f1d6e7 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java @@ -38,6 +38,38 @@ public interface TerminalTokens { TokenNameCOMMENT_JAVADOC = 1003, TokenNameSingleQuoteStringLiteral = 1004; + static boolean isRestrictedKeyword(int tokenType) { + return switch (tokenType) { + case TokenNameRestrictedIdentifierYield, TokenNameRestrictedIdentifierrecord,TokenNameRestrictedIdentifierWhen, + TokenNameRestrictedIdentifiersealed, TokenNameRestrictedIdentifierpermits -> true; + default -> false; + }; + } + + static int getRestrictedKeyword(char [] text) { + if (text != null) { + int len = text.length; + if (len == 4 && text[0] == 'w' || + len == 5 && text[0] == 'y' || + len == 6 && (text[0] == 'r' || text[0] == 's') || + len == 7 && text[0] == 'p') { + return getRestrictedKeyword(new String(text)); + } + } + return TokenNameNotAToken; + } + + static int getRestrictedKeyword(String text) { + return switch (text) { + case "yield" -> TokenNameRestrictedIdentifierYield; //$NON-NLS-1$ + case "record" -> TokenNameRestrictedIdentifierrecord; //$NON-NLS-1$ + case "when" -> TokenNameRestrictedIdentifierWhen; //$NON-NLS-1$ + case "sealed" -> TokenNameRestrictedIdentifiersealed; //$NON-NLS-1$ + case "permits" -> TokenNameRestrictedIdentifierpermits; //$NON-NLS-1$ + default -> TokenNameNotAToken; + }; + } + // BEGIN_AUTOGENERATED_REGION int TokenNameIdentifier = 19, TokenNameabstract = 42, diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/diagnose/DiagnoseParser.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/diagnose/DiagnoseParser.java index 64220a34f2..15b95434af 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/diagnose/DiagnoseParser.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/diagnose/DiagnoseParser.java @@ -28,7 +28,7 @@ public class DiagnoseParser implements ParserBasicInformation, TerminalTokens, ConflictedParser { private static final boolean DEBUG = false; - private boolean DEBUG_PARSECHECK = false; + private final boolean DEBUG_PARSECHECK = false; private static final int STACK_INCREMENT = 256; @@ -49,9 +49,9 @@ public class DiagnoseParser implements ParserBasicInformation, TerminalTokens, C private static final int MAX_DISTANCE = 30; private static final int MIN_DISTANCE = 3; - private CompilerOptions options; + private final CompilerOptions options; - private LexStream lexStream; + private final LexStream lexStream; private int errorToken; private int errorTokenStart; @@ -85,9 +85,9 @@ public class DiagnoseParser implements ParserBasicInformation, TerminalTokens, C int statePoolTop; StateInfo[] statePool; - private Parser parser; + private final Parser parser; - private RecoveryScanner recoveryScanner; + private final RecoveryScanner recoveryScanner; private boolean reportProblem; private int deferredErrorStart; @@ -198,12 +198,14 @@ public void diagnoseParse(boolean record) { this.deferredErrorStart = this.deferredErrorEnd = -1; diagnoseParse0(record); } finally { - ReferenceContext referenceContext = this.problemReporter().referenceContext; - CompilationResult compilationResult = referenceContext != null ? referenceContext.compilationResult() : null; - if (compilationResult != null && !compilationResult.hasSyntaxError) { - reportMisplacedConstruct(this.deferredErrorStart, this.deferredErrorEnd, true); + try (ProblemReporter problemReporter = this.problemReporter()) { + ReferenceContext referenceContext = problemReporter.referenceContext; + CompilationResult compilationResult = referenceContext != null ? referenceContext.compilationResult() : null; + if (compilationResult != null && !compilationResult.hasSyntaxError) { + reportMisplacedConstruct(this.deferredErrorStart, this.deferredErrorEnd, true); + } + this.deferredErrorStart = this.deferredErrorEnd = -1; } - this.deferredErrorStart = this.deferredErrorEnd = -1; } } @@ -404,9 +406,11 @@ private void diagnoseParse0(boolean record) { return; } - if(this.parser.problemReporter().options.maxProblemsPerUnit < this.parser.compilationUnit.compilationResult.problemCount) { - if(this.recoveryScanner == null || !this.recoveryScanner.record) return; - this.reportProblem = false; + try (ProblemReporter problemReporter = this.parser.problemReporter()) { + if(problemReporter.options.maxProblemsPerUnit < this.parser.compilationUnit.compilationResult.problemCount) { + if(this.recoveryScanner == null || !this.recoveryScanner.record) return; + this.reportProblem = false; + } } act = this.stack[this.stateStackTop]; @@ -2611,6 +2615,11 @@ public boolean atConflictScenario(int token) { return (token == TokenNameLPAREN || token == TokenNameAT || (token == TokenNameLESS && !this.lexStream.awaitingColonColon())); } + @Override + public boolean automatonWillShift(int token) { + return false; // Some day we will understand the world well enough, for now say no and deal with it (sigh) + } + @Override public boolean isParsingModuleDeclaration() { // diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/diagnose/LexStream.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/diagnose/LexStream.java index d0845a6f58..3cb1a959b5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/diagnose/LexStream.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/diagnose/LexStream.java @@ -43,14 +43,14 @@ public String toString() { private int tokenCacheIndex; private int tokenCacheEOFIndex; - private Token[] tokenCache; + private final Token[] tokenCache; private int currentIndex = -1; - private Scanner scanner; - private int[] intervalStartToSkip; - private int[] intervalEndToSkip; - private int[] intervalFlagsToSkip; + private final Scanner scanner; + private final int[] intervalStartToSkip; + private final int[] intervalEndToSkip; + private final int[] intervalFlagsToSkip; private int previousInterval = -1; private int currentInterval = -1; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java index 24ebdb312a..03a9a6673e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java @@ -21,14 +21,14 @@ public class DefaultProblem extends CategorizedProblem { private char[] fileName; - private int id; + private final int id; private int startPosition; private int endPosition; private int line; public int column; public int severity; - private String[] arguments; - private String message; + private final String[] arguments; + private final String message; // cannot directly point to IJavaModelMarker constants from within batch compiler private static final String MARKER_TYPE_PROBLEM = "org.eclipse.jdt.core.problem"; //$NON-NLS-1$ diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java index 7dc5c372be..1f86557844 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java @@ -53,7 +53,6 @@ public class ProblemHandler { * Problem handler can be supplied with a policy to specify * its behavior in error handling. Also see static methods for * built-in policies. - * */ public ProblemHandler(IErrorHandlingPolicy policy, CompilerOptions options, IProblemFactory problemFactory) { this.policy = policy; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java index cd954a2f8a..5b13e1a7c3 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java @@ -221,8 +221,9 @@ import org.eclipse.jdt.internal.compiler.util.Messages; import org.eclipse.jdt.internal.compiler.util.Util; +/** See contract of {@link #close()}. */ @SuppressWarnings("rawtypes") -public class ProblemReporter extends ProblemHandler { +public class ProblemReporter extends ProblemHandler implements AutoCloseable { public ReferenceContext referenceContext; private Scanner positionScanner; @@ -732,7 +733,6 @@ public static int getIrritant(int problemID) { } /** * Compute problem category ID based on problem ID - * @param problemID * @return a category ID * @see CategorizedProblem */ @@ -1971,6 +1971,8 @@ public void deprecatedType(TypeBinding type, ASTNode location) { public void deprecatedType(TypeBinding type, ASTNode location, int index) { if (location == null) return; // 1G828DN - no type ref for synthetic arguments final TypeBinding leafType = type.leafComponentType(); + if (!leafType.isReadyForAnnotations() && scheduleProblemForContext(() -> deprecatedType(type, location, index))) + return; int sourceStart = -1; if (location instanceof QualifiedTypeReference) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=300031 QualifiedTypeReference ref = (QualifiedTypeReference) location; @@ -2028,7 +2030,7 @@ String deprecatedSinceValue(Supplier annotations) { } } } finally { - this.referenceContext = contextSave; + this.referenceContext = contextSave; // resolving could have manipulated the referenceContext } } return null; @@ -4901,130 +4903,132 @@ public void invalidParenthesizedExpression(ASTNode reference) { reference.sourceEnd); } public void invalidType(ASTNode location, TypeBinding type) { - if (type instanceof ReferenceBinding) { - if (isRecoveredName(((ReferenceBinding)type).compoundName)) return; - } - else if (type instanceof ArrayBinding) { - TypeBinding leafType = ((ArrayBinding)type).leafComponentType; - if (leafType instanceof ReferenceBinding) { - if (isRecoveredName(((ReferenceBinding)leafType).compoundName)) return; + try (this) { // ensure clean-up despite the many exits without calling handle(..) + if (type instanceof ReferenceBinding) { + if (isRecoveredName(((ReferenceBinding)type).compoundName)) return; + } + else if (type instanceof ArrayBinding) { + TypeBinding leafType = ((ArrayBinding)type).leafComponentType; + if (leafType instanceof ReferenceBinding) { + if (isRecoveredName(((ReferenceBinding)leafType).compoundName)) return; + } } - } - if (type.isParameterizedType()) { - List missingTypes = type.collectMissingTypes(null); - if (missingTypes != null) { - ReferenceContext savedContext = this.referenceContext; - for (Iterator iterator = missingTypes.iterator(); iterator.hasNext(); ) { - try { - invalidType(location, (TypeBinding) iterator.next()); - } finally { - this.referenceContext = savedContext; + if (type.isParameterizedType()) { + List missingTypes = type.collectMissingTypes(null); + if (missingTypes != null) { + ReferenceContext savedContext = this.referenceContext; + for (Iterator iterator = missingTypes.iterator(); iterator.hasNext(); ) { + try { + invalidType(location, (TypeBinding) iterator.next()); + } finally { + this.referenceContext = savedContext; // nested reporting will have reset referenceContext + } } + return; } - return; } - } - int id = IProblem.UndefinedType; // default - switch (type.problemId()) { - case ProblemReasons.NotFound : - id = IProblem.UndefinedType; - break; - case ProblemReasons.NotVisible : - id = IProblem.NotVisibleType; - break; - case ProblemReasons.NotAccessible : - id = IProblem.NotAccessibleType; - break; - case ProblemReasons.Ambiguous : - id = IProblem.AmbiguousType; - break; - case ProblemReasons.InternalNameProvided : - id = IProblem.InternalTypeNameProvided; - break; - case ProblemReasons.InheritedNameHidesEnclosingName : - id = IProblem.InheritedTypeHidesEnclosingName; - break; - case ProblemReasons.NonStaticReferenceInStaticContext : - id = IProblem.NonStaticTypeFromStaticInvocation; - break; - case ProblemReasons.IllegalSuperTypeVariable : - id = IProblem.IllegalTypeVariableSuperReference; - break; - case ProblemReasons.NoError : // 0 - default : - needImplementation(location); // want to fail to see why we were here... - break; - } + int id = IProblem.UndefinedType; // default + switch (type.problemId()) { + case ProblemReasons.NotFound : + id = IProblem.UndefinedType; + break; + case ProblemReasons.NotVisible : + id = IProblem.NotVisibleType; + break; + case ProblemReasons.NotAccessible : + id = IProblem.NotAccessibleType; + break; + case ProblemReasons.Ambiguous : + id = IProblem.AmbiguousType; + break; + case ProblemReasons.InternalNameProvided : + id = IProblem.InternalTypeNameProvided; + break; + case ProblemReasons.InheritedNameHidesEnclosingName : + id = IProblem.InheritedTypeHidesEnclosingName; + break; + case ProblemReasons.NonStaticReferenceInStaticContext : + id = IProblem.NonStaticTypeFromStaticInvocation; + break; + case ProblemReasons.IllegalSuperTypeVariable : + id = IProblem.IllegalTypeVariableSuperReference; + break; + case ProblemReasons.NoError : // 0 + default : + needImplementation(location); // want to fail to see why we were here... + break; + } - int end = location.sourceEnd; - if (location instanceof QualifiedNameReference) { - QualifiedNameReference ref = (QualifiedNameReference) location; - if (isRecoveredName(ref.tokens)) return; - if (ref.indexOfFirstFieldBinding >= 1) - end = (int) ref.sourcePositions[ref.indexOfFirstFieldBinding - 1]; - } else if (location instanceof ParameterizedQualifiedTypeReference) { - // must be before instanceof ArrayQualifiedTypeReference - ParameterizedQualifiedTypeReference ref = (ParameterizedQualifiedTypeReference) location; - if (isRecoveredName(ref.tokens)) return; - if (type instanceof ReferenceBinding) { - char[][] name = ((ReferenceBinding) type).compoundName; - if (name.length <= ref.sourcePositions.length) { - end = (int) ref.sourcePositions[name.length - 1]; + int end = location.sourceEnd; + if (location instanceof QualifiedNameReference) { + QualifiedNameReference ref = (QualifiedNameReference) location; + if (isRecoveredName(ref.tokens)) return; + if (ref.indexOfFirstFieldBinding >= 1) + end = (int) ref.sourcePositions[ref.indexOfFirstFieldBinding - 1]; + } else if (location instanceof ParameterizedQualifiedTypeReference) { + // must be before instanceof ArrayQualifiedTypeReference + ParameterizedQualifiedTypeReference ref = (ParameterizedQualifiedTypeReference) location; + if (isRecoveredName(ref.tokens)) return; + if (type instanceof ReferenceBinding) { + char[][] name = ((ReferenceBinding) type).compoundName; + if (name.length <= ref.sourcePositions.length) { + end = (int) ref.sourcePositions[name.length - 1]; + } } - } - } else if (location instanceof ArrayQualifiedTypeReference) { - ArrayQualifiedTypeReference arrayQualifiedTypeReference = (ArrayQualifiedTypeReference) location; - if (isRecoveredName(arrayQualifiedTypeReference.tokens)) return; - TypeBinding leafType = type.leafComponentType(); - if (leafType instanceof ReferenceBinding) { - char[][] name = ((ReferenceBinding) leafType).compoundName; // problem type will tell how much got resolved - if (name.length <= arrayQualifiedTypeReference.sourcePositions.length) { - end = (int) arrayQualifiedTypeReference.sourcePositions[name.length-1]; + } else if (location instanceof ArrayQualifiedTypeReference) { + ArrayQualifiedTypeReference arrayQualifiedTypeReference = (ArrayQualifiedTypeReference) location; + if (isRecoveredName(arrayQualifiedTypeReference.tokens)) return; + TypeBinding leafType = type.leafComponentType(); + if (leafType instanceof ReferenceBinding) { + char[][] name = ((ReferenceBinding) leafType).compoundName; // problem type will tell how much got resolved + if (name.length <= arrayQualifiedTypeReference.sourcePositions.length) { + end = (int) arrayQualifiedTypeReference.sourcePositions[name.length-1]; + } + } else { + long[] positions = arrayQualifiedTypeReference.sourcePositions; + end = (int) positions[positions.length - 1]; } - } else { - long[] positions = arrayQualifiedTypeReference.sourcePositions; - end = (int) positions[positions.length - 1]; - } - } else if (location instanceof QualifiedTypeReference) { - QualifiedTypeReference ref = (QualifiedTypeReference) location; - if (isRecoveredName(ref.tokens)) return; - if (type instanceof ReferenceBinding) { - char[][] name = ((ReferenceBinding) type).compoundName; - if (name.length <= ref.sourcePositions.length) + } else if (location instanceof QualifiedTypeReference) { + QualifiedTypeReference ref = (QualifiedTypeReference) location; + if (isRecoveredName(ref.tokens)) return; + if (type instanceof ReferenceBinding) { + char[][] name = ((ReferenceBinding) type).compoundName; + if (name.length <= ref.sourcePositions.length) + end = (int) ref.sourcePositions[name.length - 1]; + } + } else if (location instanceof ImportReference) { + ImportReference ref = (ImportReference) location; + if (isRecoveredName(ref.tokens)) return; + if (type instanceof ReferenceBinding) { + char[][] name = ((ReferenceBinding) type).compoundName; end = (int) ref.sourcePositions[name.length - 1]; + } + } else if (location instanceof ArrayTypeReference) { + ArrayTypeReference arrayTypeReference = (ArrayTypeReference) location; + if (isRecoveredName(arrayTypeReference.token)) return; + end = arrayTypeReference.originalSourceEnd; } - } else if (location instanceof ImportReference) { - ImportReference ref = (ImportReference) location; - if (isRecoveredName(ref.tokens)) return; - if (type instanceof ReferenceBinding) { - char[][] name = ((ReferenceBinding) type).compoundName; - end = (int) ref.sourcePositions[name.length - 1]; + + int start = location.sourceStart; + if (location instanceof org.eclipse.jdt.internal.compiler.ast.SingleTypeReference) { + org.eclipse.jdt.internal.compiler.ast.SingleTypeReference ref = + (org.eclipse.jdt.internal.compiler.ast.SingleTypeReference) location; + if (ref.annotations != null) + start = end - ref.token.length + 1; + } else if (location instanceof QualifiedTypeReference) { + QualifiedTypeReference ref = (QualifiedTypeReference) location; + if (ref.annotations != null) + start = (int) (ref.sourcePositions[0] & 0x00000000FFFFFFFFL ) - ref.tokens[0].length + 1; } - } else if (location instanceof ArrayTypeReference) { - ArrayTypeReference arrayTypeReference = (ArrayTypeReference) location; - if (isRecoveredName(arrayTypeReference.token)) return; - end = arrayTypeReference.originalSourceEnd; - } - int start = location.sourceStart; - if (location instanceof org.eclipse.jdt.internal.compiler.ast.SingleTypeReference) { - org.eclipse.jdt.internal.compiler.ast.SingleTypeReference ref = - (org.eclipse.jdt.internal.compiler.ast.SingleTypeReference) location; - if (ref.annotations != null) - start = end - ref.token.length + 1; - } else if (location instanceof QualifiedTypeReference) { - QualifiedTypeReference ref = (QualifiedTypeReference) location; - if (ref.annotations != null) - start = (int) (ref.sourcePositions[0] & 0x00000000FFFFFFFFL ) - ref.tokens[0].length + 1; + this.handle( + id, + new String[] {new String(type.leafComponentType().readableName()) }, + new String[] {new String(type.leafComponentType().shortReadableName())}, + start, + end); } - - this.handle( - id, - new String[] {new String(type.leafComponentType().readableName()) }, - new String[] {new String(type.leafComponentType().shortReadableName())}, - start, - end); } public void invalidTypeForCollection(Expression expression) { this.handle( @@ -8511,7 +8515,14 @@ private boolean handleSyntaxErrorOnNewTokens( String errorTokenName, String expectedToken) { if (isIdentifier(currentKind)) { - return validateRestrictedKeywords(errorTokenSource, expectedToken, start, end, true); + if (expectedToken != null) { + String tokenName= new String(errorTokenSource); + String restrictedIdentifier= permittedRestrictedKeyWordMap.get(tokenName); + if (restrictedIdentifier == null || !restrictedIdentifier.equals(expectedToken)) { + return false; + } + } + return validateRestrictedKeywords(errorTokenSource, start, end, true); } return false; } @@ -9811,18 +9822,8 @@ public void previewAPIUsed(int sourceStart, int sourceEnd, boolean isFatal) { sourceEnd); } //Returns true if the problem is handled and reported (only errors considered and not warnings) -public boolean validateRestrictedKeywords(char[] name, int start, int end, boolean reportSyntaxError) { - return validateRestrictedKeywords(name, null, start, end, reportSyntaxError); -} -private boolean validateRestrictedKeywords(char[] name, String expectedToken, int start, int end, boolean reportSyntaxError) { +private boolean validateRestrictedKeywords(char[] name, int start, int end, boolean reportSyntaxError) { boolean isPreviewEnabled = this.options.enablePreviewFeatures; - if (expectedToken != null) { - String tokenName= new String(name); - String restrictedIdentifier= permittedRestrictedKeyWordMap.get(tokenName); - if (restrictedIdentifier == null || !restrictedIdentifier.equals(expectedToken)) { - return false; - } - } for (JavaFeature feature : JavaFeature.values()) { char[][] restrictedKeywords = feature.getRestrictedKeywords(); for (char[] k : restrictedKeywords) { @@ -9854,7 +9855,10 @@ private boolean validateRestrictedKeywords(char[] name, String expectedToken, in return false; } public boolean validateRestrictedKeywords(char[] name, ASTNode node) { - return validateRestrictedKeywords(name, node.sourceStart, node.sourceEnd, false); + // ensure clean-up because inner method is not guaranteed to invoke handle(..) + try (this) { + return validateRestrictedKeywords(name, node.sourceStart, node.sourceEnd, false); + } } //Returns true if the problem is handled and reported (only errors considered and not warnings) public boolean validateJavaFeatureSupport(JavaFeature feature, int sourceStart, int sourceEnd) { @@ -11744,7 +11748,7 @@ public void conflictingPackageInModules(char[][] wellKnownTypeName, CompilationU start, end); } finally { - this.referenceContext = savedContext; + this.referenceContext = savedContext; // unsure from which phase we are called, so better to reset to previous } } @@ -12560,6 +12564,14 @@ public void cannotInferRecordPatternTypes(RecordPattern pattern) { pattern.sourceStart, pattern.sourceEnd); } +public void illegalRecordPattern(int recordPatternSourceStart, int recordPatternSourceEnd) { + this.handle( + IProblem.IllegalRecordPattern, + NoArgument, + NoArgument, + recordPatternSourceStart, + recordPatternSourceEnd); +} public void falseLiteralInGuard(Expression exp) { this.handle( IProblem.FalseConstantInGuard, @@ -12568,4 +12580,40 @@ public void falseLiteralInGuard(Expression exp) { exp.sourceStart, exp.sourceEnd); } -} \ No newline at end of file +public boolean scheduleProblemForContext(Runnable problemComputation) { + if (this.referenceContext != null) { + CompilationResult result = this.referenceContext.compilationResult(); + if (result != null) { + try (this) { + ReferenceContext capturedContext = this.referenceContext; + result.scheduleProblem(() -> { + ReferenceContext save = this.referenceContext; + this.referenceContext = capturedContext; + try { + problemComputation.run(); + } finally { + this.referenceContext = save; + } + }); + } + return true; + } + } + return false; +} +/** + * General strategy: + *

      + *
    • clients are responsible for assigning {@link #referenceContext} prior to invoking any + * reporting method (usually, by obtaining an instance using {@link Scope#problemReporter()}). + *
    • individual methods should ensure that {@link #referenceContext} is reset to {@code null} afterwards. This may + * happen in two ways: + *
      • by calling any of the {@code handle(..)} methods on all paths, or failing that + *
      • wrap their body in {@code try(this) { ... }}. + *
    + */ +@Override +public void close() { + this.referenceContext = null; +} +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties index 8241af0c58..fbb7c33afa 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties @@ -1153,6 +1153,8 @@ 1914 = Record component with type {0} is not compatible with type {1} 1916 = A case label guard cannot have a constant expression with value as 'false' 1940 = Cannot infer record pattern types for {0} +1941 = Syntax error, record patterns are not allowed here + 1990 = Access to {1}({2}) from the type {0} is emulated by a synthetic accessor method diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseDiagnostic.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseDiagnostic.java index ff748af1f5..26aa09be1e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseDiagnostic.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseDiagnostic.java @@ -25,7 +25,7 @@ public class EclipseDiagnostic implements Diagnostic { - private Kind kind; + private final Kind kind; private final int problemId; private final String[] problemArguments; private final char[] originatingFileName; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileObject.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileObject.java index c70520f7de..c870341251 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileObject.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileObject.java @@ -46,7 +46,7 @@ */ public class EclipseFileObject extends SimpleJavaFileObject { File f; - private Charset charset; + private final Charset charset; private boolean parentsExist; // parent directories exist public EclipseFileObject(String className, URI uri, Kind kind, Charset charset) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/PathFileObject.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/PathFileObject.java index 2470b93ed7..af6e2e0ce9 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/PathFileObject.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/PathFileObject.java @@ -38,8 +38,8 @@ */ public class PathFileObject implements JavaFileObject { Path path; - private Charset charset; - private Kind kind; + private final Charset charset; + private final Kind kind; public PathFileObject(Path path, Kind kind, Charset charset) { this.path = path; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/Util.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/Util.java index 203b28370d..fe016d904a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/Util.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/Util.java @@ -29,7 +29,6 @@ /** * Util class that defines helper methods to read class contents with handling of wrong encoding - * */ public final class Util { public static String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$ diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/CtSym.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/CtSym.java index e585215ea5..a496b1de18 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/CtSym.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/CtSym.java @@ -225,7 +225,6 @@ public List releaseRoots(String releaseCode) { * * @param releaseCode release number encoded (7,8,9,A,B...) * @param qualifiedSignatureFileName signature file name (without module) - * @param moduleName * @return corresponding path in ct.sym file system or null if not found */ public Path getFullPath(String releaseCode, String qualifiedSignatureFileName, String moduleName) { @@ -458,4 +457,4 @@ public static String getReleaseCode(String release) { return String.valueOf((char) ('A' + (numericVersion - 10))); } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/GenericXMLWriter.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/GenericXMLWriter.java index 44156e6579..86299cb1f7 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/GenericXMLWriter.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/GenericXMLWriter.java @@ -58,7 +58,7 @@ private static String getReplacement(char c) { } return null; } - private String lineSeparator; + private final String lineSeparator; private int tab; public GenericXMLWriter(OutputStream stream, String lineSeparator, boolean printXmlVersion) { this(new PrintWriter(stream), lineSeparator, printXmlVersion); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java index 2633884a0f..1976b30c50 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java @@ -13,12 +13,14 @@ *******************************************************************************/ package org.eclipse.jdt.internal.compiler.util; +import java.util.Arrays; + import org.eclipse.jdt.core.compiler.CharOperation; /** * Hashtable of {char[] --> Object } */ -public final class HashtableOfObject implements Cloneable { +public final class HashtableOfObject { /** Max array size accepted by JVM */ public static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 2; @@ -28,7 +30,7 @@ public final class HashtableOfObject implements Cloneable { public Object valueTable[]; public int elementSize; // number of elements in the table - int threshold; + private int threshold; public HashtableOfObject() { this(13); @@ -43,7 +45,6 @@ public HashtableOfObject(int size) { if (size < 0) { throw new NegativeArraySizeException("Bad attempt to create table with " + size + " elements"); //$NON-NLS-1$ //$NON-NLS-2$ } - this.elementSize = 0; this.threshold = size; // size represents the expected number of elements int extraRoom = (int) (size * 1.75f); if (this.threshold == extraRoom) { @@ -58,37 +59,20 @@ public HashtableOfObject(int size) { } public void clear() { - for (int i = this.keyTable.length; --i >= 0;) { - this.keyTable[i] = null; - this.valueTable[i] = null; - } + Arrays.fill(this.keyTable, null); + Arrays.fill(this.valueTable, null); this.elementSize = 0; } - @Override - public Object clone() throws CloneNotSupportedException { - HashtableOfObject result = (HashtableOfObject) super.clone(); - result.elementSize = this.elementSize; - result.threshold = this.threshold; - + public boolean containsKey(char[] key) { int length = this.keyTable.length; - result.keyTable = new char[length][]; - System.arraycopy(this.keyTable, 0, result.keyTable, 0, length); - - length = this.valueTable.length; - result.valueTable = new Object[length]; - System.arraycopy(this.valueTable, 0, result.valueTable, 0, length); - return result; - } + int index = CharOperation.hashCode(key) % length; - public boolean containsKey(char[] key) { - int length = this.keyTable.length, - index = CharOperation.hashCode(key) % length; - int keyLength = key.length; char[] currentKey; while ((currentKey = this.keyTable[index]) != null) { - if (currentKey.length == keyLength && CharOperation.equals(currentKey, key)) + if (CharOperation.equals(currentKey, key)) { return true; + } if (++index == length) { index = 0; } @@ -97,13 +81,13 @@ public boolean containsKey(char[] key) { } public Object get(char[] key) { - int length = this.keyTable.length, - index = CharOperation.hashCode(key) % length; - int keyLength = key.length; + int length = this.keyTable.length; + int index = CharOperation.hashCode(key) % length; char[] currentKey; while ((currentKey = this.keyTable[index]) != null) { - if (currentKey.length == keyLength && CharOperation.equals(currentKey, key)) + if (CharOperation.equals(currentKey, key)) { return this.valueTable[index]; + } if (++index == length) { index = 0; } @@ -112,13 +96,13 @@ public Object get(char[] key) { } public Object put(char[] key, Object value) { - int length = this.keyTable.length, - index = CharOperation.hashCode(key) % length; - int keyLength = key.length; + int length = this.keyTable.length; + int index = CharOperation.hashCode(key) % length; char[] currentKey; while ((currentKey = this.keyTable[index]) != null) { - if (currentKey.length == keyLength && CharOperation.equals(currentKey, key)) + if (CharOperation.equals(currentKey, key)) { return this.valueTable[index] = value; + } if (++index == length) { index = 0; } @@ -127,8 +111,9 @@ public Object put(char[] key, Object value) { this.valueTable[index] = value; // assumes the threshold is never equal to the size of the table - if (++this.elementSize > this.threshold) + if (++this.elementSize > this.threshold) { rehash(); + } return value; } @@ -142,8 +127,8 @@ public Object put(char[] key, Object value) { * @param value The value of the table entry */ public void putUnsafely(char[] key, Object value) { - int length = this.keyTable.length, - index = CharOperation.hashCode(key) % length; + int length = this.keyTable.length; + int index = CharOperation.hashCode(key) % length; while (this.keyTable[index] != null) { if (++index == length) { index = 0; @@ -158,34 +143,15 @@ public void putUnsafely(char[] key, Object value) { } } - public Object removeKey(char[] key) { - int length = this.keyTable.length, - index = CharOperation.hashCode(key) % length; - int keyLength = key.length; - char[] currentKey; - while ((currentKey = this.keyTable[index]) != null) { - if (currentKey.length == keyLength && CharOperation.equals(currentKey, key)) { - Object value = this.valueTable[index]; - this.elementSize--; - this.keyTable[index] = null; - this.valueTable[index] = null; - rehash(); - return value; - } - if (++index == length) { - index = 0; - } - } - return null; - } - private void rehash() { int newSize = calculateNewSize(this.elementSize); HashtableOfObject newHashtable = new HashtableOfObject(newSize); char[] currentKey; - for (int i = this.keyTable.length; --i >= 0;) - if ((currentKey = this.keyTable[i]) != null) + for (int i = this.keyTable.length; --i >= 0;) { + if ((currentKey = this.keyTable[i]) != null) { newHashtable.putUnsafely(currentKey, this.valueTable[i]); + } + } this.keyTable = newHashtable.keyTable; this.valueTable = newHashtable.valueTable; @@ -236,9 +202,11 @@ public int size() { public String toString() { String s = ""; //$NON-NLS-1$ Object object; - for (int i = 0, length = this.valueTable.length; i < length; i++) - if ((object = this.valueTable[i]) != null) + for (int i = 0, length = this.valueTable.length; i < length; i++) { + if ((object = this.valueTable[i]) != null) { s += new String(this.keyTable[i]) + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$ + } + } return s; } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/JRTUtil.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/JRTUtil.java index 8fce764e61..ed4bf4a463 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/JRTUtil.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/JRTUtil.java @@ -40,7 +40,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Predicate; @@ -77,6 +76,8 @@ public class JRTUtil { */ private static final Map ctSymFiles = new ConcurrentHashMap<>(); + static final SoftClassCache classCache = new SoftClassCache(); + public interface JrtFileVisitor { public default FileVisitResult visitPackage(T dir, T mod, BasicFileAttributes attrs) throws IOException { @@ -141,8 +142,8 @@ public static JrtFileSystem getJrtSystem(File image) { * @param release --release version */ public static JrtFileSystem getJrtSystem(File image, String release) throws IOException { - String key = image.toString(); Jdk jdk = new Jdk(image); + String key = jdk.path; if (release != null && !jdk.sameRelease(release)) { key = key + "|" + release; //$NON-NLS-1$ @@ -175,7 +176,6 @@ public static JrtFileSystem getJrtSystem(File image, String release) throws IOEx * @param path * absolute file path to a jar archive * @return never null - * @throws IOException */ public static FileSystem getJarFileSystem(Path path) throws IOException { URI uri = URI.create("jar:file:" + path.toUri().getRawPath()); //$NON-NLS-1$ @@ -216,6 +216,7 @@ public static CtSym getCtSym(Path jdkHome) throws IOException { /** TEST ONLY (use when changing the "modules.to.load" property). */ public static void reset() { images.clear(); + classCache.clear(); MODULE_TO_LOAD = System.getProperty("modules.to.load"); //$NON-NLS-1$ } @@ -234,7 +235,6 @@ public static void reset() { * @param image a java.io.File handle to the JRT image. * @param visitor an instance of JrtFileVisitor to be notified of the entries in the JRT image. * @param notify flag indicating the notifications the client is interested in. - * @throws IOException */ public static void walkModuleImage(File image, final JRTUtil.JrtFileVisitor visitor, int notify) throws IOException { JrtFileSystem system = getJrtSystem(image, null); @@ -314,7 +314,6 @@ public static String sanitizedFileName(Path path) { /** * Tries to read all bytes of the file denoted by path, * returns null if the file could not be found or if the read was interrupted. - * @param path * @return bytes or null * @throws IOException any IO exception other than NoSuchFileException */ @@ -350,15 +349,14 @@ public static String getJdkRelease(File image) throws IOException { class JrtFileSystemWithOlderRelease extends JrtFileSystem { - private List releaseRoots; - private CtSym ctSym; + private final List releaseRoots; + private final CtSym ctSym; /** * The jrt file system is based on the location of the JRE home whose libraries * need to be loaded. * * @param release the older release where classes and modules should be searched for. - * @throws IOException */ JrtFileSystemWithOlderRelease(Jdk jdkHome, String release) throws IOException { super(jdkHome, release); @@ -510,9 +508,6 @@ class JrtFileSystem { private final Map> packageToModules = new HashMap>(); - - private final Map> classCache = new ConcurrentHashMap<>(10007); - FileSystem fs; Path modRoot; Jdk jdk; @@ -529,9 +524,6 @@ public static JrtFileSystem getNewJrtFileSystem(Jdk jdk, String release) throws /** * The jrt file system is based on the location of the JRE home whose libraries * need to be loaded. - * - * @param jdkHome - * @throws IOException */ JrtFileSystem(Jdk jdkHome, String release) throws IOException { this.jdk = jdkHome; @@ -663,18 +655,7 @@ private byte[] getFileBytes(String fileName, String module) throws IOException { if(JRTUtil.DISABLE_CACHE) { return JRTUtil.safeReadBytes(path); } else { - try { - Optional bytes = this.classCache.computeIfAbsent(path, key -> { - try { - return Optional.ofNullable(JRTUtil.safeReadBytes(key)); - } catch (IOException e) { - throw new RuntimeIOException(e); - } - }); - return bytes.orElse(null); - } catch (RuntimeIOException rio) { - throw rio.getCause(); - } + return JRTUtil.classCache.getClassBytes(this.jdk, path); } } @@ -684,18 +665,7 @@ ClassFileReader getClassfileFromModule(String fileName, String module) throws IO if(JRTUtil.DISABLE_CACHE) { content = JRTUtil.safeReadBytes(path); } else { - try { - Optional bytes = this.classCache.computeIfAbsent(path, key -> { - try { - return Optional.ofNullable(JRTUtil.safeReadBytes(key)); - } catch (IOException e) { - throw new RuntimeIOException(e); - } - }); - content = bytes.orElse(null); - } catch (RuntimeIOException rio) { - throw rio.getCause(); - } + content = JRTUtil.classCache.getClassBytes(this.jdk, path); } if (content != null) { ClassFileReader reader = new ClassFileReader(path.toUri(), content, fileName.toCharArray()); @@ -831,4 +801,4 @@ synchronized void cachePackage(String packageName, String module) { public String getJdkRelease() { return this.jdk.release; } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Messages.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Messages.java index d079a6cdca..525fb152c8 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Messages.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Messages.java @@ -125,6 +125,7 @@ private Messages() { public static String pattern_matching_switch; public static String record_patterns; public static String unnammed_patterns_and_vars; + public static String unnamed_classes_and_instance_main_methods; static { initializeMessages(BUNDLE_NAME, Messages.class); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/SoftClassCache.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/SoftClassCache.java new file mode 100644 index 0000000000..e28375c4f3 --- /dev/null +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/SoftClassCache.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2023 Christoph Läubrich. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christoph Läubrich - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.internal.compiler.util; + +import java.io.IOException; +import java.lang.ref.SoftReference; +import java.nio.file.Path; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +/** + * Implements a soft cache for reading class files from disk, as these caches can grow quite large but data can be + * recovered afterwards we only hold a soft reference to the bytes itself. + */ +class SoftClassCache { + + private final ConcurrentMap jdks = new ConcurrentHashMap<>(); + + void clear() { + this.jdks.clear(); + } + + public byte[] getClassBytes(Jdk jdk, Path path) throws IOException { + return this.jdks.computeIfAbsent(jdk.path, JdkClasses::new).get(path); + } + + private static final class JdkClasses { + private final ConcurrentMap classes = new ConcurrentHashMap<>(10007); + private final String jdkPath; + + public JdkClasses(String jdkPath) { + this.jdkPath = jdkPath; + } + + public byte[] get(Path path) throws IOException { + return this.classes.computeIfAbsent(path, ClassBytes::new).getBytes(); + } + + @Override + public String toString() { + return "Class Cache for " + this.jdkPath; //$NON-NLS-1$ + } + } + + private static final class ClassBytes { + private final Path path; + private volatile boolean empty; + private volatile SoftReference bytes; + + public ClassBytes(Path path) { + this.path = path; + } + + public byte[] getBytes() throws IOException { + if (this.empty) { + return null; + } + SoftReference reference = this.bytes; + if (reference != null) { + byte[] bs = reference.get(); + if (bs != null) { + return bs; + } + } + byte[] readBytes = JRTUtil.safeReadBytes(this.path); + if (readBytes == null) { + this.empty = true; + return null; + } + this.bytes = new SoftReference(readBytes); + return readBytes; + } + } + +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Util.java b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Util.java index 27c21a5300..def3e77ac7 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Util.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Util.java @@ -554,7 +554,6 @@ private static boolean startsWith(byte[] a, byte[] start) { /** * Returns a one line summary for an exception (extracted from its stacktrace: name + first frame) - * @param exception * @return one line summary for an exception */ public static String getExceptionSummary(Throwable exception) { @@ -984,7 +983,6 @@ public static String toString(Object[] objects, Displayable renderer) { * @param outputPath the given output directory * @param relativeFileName the given relative file name * @param classFile the given classFile to write - * */ public static void writeToDisk(boolean generatePackagesStructure, String outputPath, String relativeFileName, ClassFile classFile) throws IOException { FileOutputStream file = getFileOutputStream(generatePackagesStructure, outputPath, relativeFileName); @@ -1666,4 +1664,4 @@ public static void appendEscapedChar(StringBuffer buffer, char c, boolean string private static IllegalArgumentException newIllegalArgumentException(char[] string, int start) { return new IllegalArgumentException("\"" + String.valueOf(string) + "\" at " + start); //$NON-NLS-1$ //$NON-NLS-2$ } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyCompilerRequestor.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyCompilerRequestor.java index 1a7db581b9..4bfe2837cf 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyCompilerRequestor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyCompilerRequestor.java @@ -22,9 +22,9 @@ public class EfficiencyCompilerRequestor implements IDebugRequestor { private boolean isActive = false; - private ArrayList compiledClasses = new ArrayList<>(); - private ArrayList compiledFiles = new ArrayList<>(); - private ArrayList classes = new ArrayList<>(); + private final ArrayList compiledClasses = new ArrayList<>(); + private final ArrayList compiledFiles = new ArrayList<>(); + private final ArrayList classes = new ArrayList<>(); public void acceptDebugResult(CompilationResult result){ diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java index 67f061434c..efbcdeab01 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java @@ -31,6 +31,9 @@ @SuppressWarnings({"rawtypes", "unchecked"}) public class IncrementalTests extends BuilderTests { + static { +// TESTS_NAMES = new String [] { "testBinaryInnerRecordClass" }; + } public IncrementalTests(String name) { super(name); } @@ -606,22 +609,22 @@ public void testMemberTypeFromClassFile() throws JavaModelException { public void testMemberTypeOfOtherProject() throws JavaModelException { IPath projectPath1 = env.addProject("Project1", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$ env.addExternalJars(projectPath1, Util.getJavaClassLibs()); - + IPath projectPath2 = env.addProject("Project2", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$ env.addExternalJars(projectPath2, Util.getJavaClassLibs()); - + // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(projectPath1, ""); //$NON-NLS-1$ IPath root1 = env.addPackageFragmentRoot(projectPath1, "src"); //$NON-NLS-1$ env.setOutputFolder(projectPath1, "bin"); //$NON-NLS-1$ - + // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(projectPath2, ""); //$NON-NLS-1$ IPath root2 = env.addPackageFragmentRoot(projectPath2, "src"); //$NON-NLS-1$ IPath output2 = env.setOutputFolder(projectPath2, "bin"); //$NON-NLS-1$ - + env.addClassFolder(projectPath1, output2, true); env.addRequiredProject(projectPath2, projectPath1); @@ -633,14 +636,14 @@ public void testMemberTypeOfOtherProject() throws JavaModelException { " }\n" + //$NON-NLS-1$ " }\n" + //$NON-NLS-1$ "}\n");//$NON-NLS-1$ - + env.addClass(root1, "pR", "ReferencingClass", //$NON-NLS-1$ //$NON-NLS-2$ "package pR; \n"+ //$NON-NLS-1$ "import pD.DerivedClass.Builder;\n"+ //$NON-NLS-1$ "public class ReferencingClass {\n" + //$NON-NLS-1$ " Builder builder = new Builder(null);\n" + //$NON-NLS-1$ "}\n"); //$NON-NLS-1$ - + env.addClass(root2, "pD", "DerivedClass", //$NON-NLS-1$ //$NON-NLS-2$ "package pD; \n"+ //$NON-NLS-1$ "public class DerivedClass extends pB.BaseClass {\n" + //$NON-NLS-1$ @@ -667,22 +670,22 @@ public void testMemberTypeOfOtherProject() throws JavaModelException { public void test$InTypeName() throws JavaModelException { IPath projectPath1 = env.addProject("Project1", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$ env.addExternalJars(projectPath1, Util.getJavaClassLibs()); - + IPath projectPath2 = env.addProject("Project2", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$ env.addExternalJars(projectPath2, Util.getJavaClassLibs()); - + // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(projectPath1, ""); //$NON-NLS-1$ IPath root1 = env.addPackageFragmentRoot(projectPath1, "src"); //$NON-NLS-1$ env.setOutputFolder(projectPath1, "bin"); //$NON-NLS-1$ - + // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(projectPath2, ""); //$NON-NLS-1$ IPath root2 = env.addPackageFragmentRoot(projectPath2, "src"); //$NON-NLS-1$ IPath output2 = env.setOutputFolder(projectPath2, "bin"); //$NON-NLS-1$ - + env.addClassFolder(projectPath1, output2, true); env.addRequiredProject(projectPath2, projectPath1); @@ -692,14 +695,14 @@ public void testMemberTypeOfOtherProject() throws JavaModelException { " public Builder$a(T t) {\n" + //$NON-NLS-1$ " }\n" + //$NON-NLS-1$ "}\n");//$NON-NLS-1$ - + env.addClass(root1, "pR", "ReferencingClass", //$NON-NLS-1$ //$NON-NLS-2$ "package pR; \n"+ //$NON-NLS-1$ "import pD.DerivedClass$a;\n"+ //$NON-NLS-1$ "public class ReferencingClass {\n" + //$NON-NLS-1$ " DerivedClass$a builder = new DerivedClass$a(null);\n" + //$NON-NLS-1$ "}\n"); //$NON-NLS-1$ - + env.addClass(root2, "pD", "DerivedClass$a", //$NON-NLS-1$ //$NON-NLS-2$ "package pD; \n"+ //$NON-NLS-1$ "public class DerivedClass$a extends pB.Builder$a {\n" + //$NON-NLS-1$ @@ -1149,13 +1152,13 @@ public void testBug334377() throws JavaModelException { IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$ - env.addClass(root, "", "Upper", + env.addClass(root, "", "Upper", "public abstract class Upper {\n" + " public static enum Mode {IN,OUT;}\n" + "}\n"); - env.addClass(root, "", "Lower", + env.addClass(root, "", "Lower", "public class Lower extends Upper {};\n"); - env.addClass(root, "", "Bug", + env.addClass(root, "", "Bug", "public class Bug {\n" + " Upper.Mode m1;\n" + " void usage(){\n" + @@ -1173,7 +1176,7 @@ public void testBug334377() throws JavaModelException { fullBuild(projectPath); expectingNoProblems(); - env.addClass(root, "", "Bug", + env.addClass(root, "", "Bug", "public class Bug {\n" + " Upper.Mode m1;\n" + " void usage(){\n" + @@ -1197,7 +1200,7 @@ public void testBug334377() throws JavaModelException { JavaCore.setOptions(options); } } - + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=364450 // Incremental build should not generate buildpath error // NOT generated by full build. @@ -1237,28 +1240,28 @@ public void testBug364450() throws JavaModelException { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=520640 public void testRemovePackageInDependencyProject() throws JavaModelException { - IPath projectPath1 = env.addProject("Project1"); + IPath projectPath1 = env.addProject("Project1"); env.addExternalJars(projectPath1, Util.getJavaClassLibs()); - - IPath projectPath2 = env.addProject("Project2"); + + IPath projectPath2 = env.addProject("Project2"); env.addExternalJars(projectPath2, Util.getJavaClassLibs()); - - + + env.addRequiredProject(projectPath1, projectPath2); - - env.addPackage(projectPath2, "emptypackage"); + + env.addPackage(projectPath2, "emptypackage"); fullBuild(); expectingNoProblems(); - - env.removePackage(projectPath2, "emptypackage"); + + env.removePackage(projectPath2, "emptypackage"); incrementalBuild(); expectingNoProblems(); - + env.removeProject(projectPath2); env.removeProject(projectPath1); } - + public void testBug526376() throws JavaModelException { IPath projectPath = env.addProject("Project"); env.addExternalJars(projectPath, Util.getJavaClassLibs()); @@ -1285,4 +1288,111 @@ public void testBug526376() throws JavaModelException { env.removeProject(projectPath); } + // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1497 + public void testBinaryRecordClass() throws JavaModelException { + IPath projectPath = env.addProject("Project", "16"); + env.addExternalJars(projectPath, Util.getJavaClassLibs()); + + // remove old package fragment root so that names don't collide + env.removePackageFragmentRoot(projectPath, ""); + + IPath root = env.addPackageFragmentRoot(projectPath, "src"); + env.setOutputFolder(projectPath, "bin"); + + env.addClass(root, "", "R", + "public record R(int x, int y) {}\n"); + + fullBuild(projectPath); + expectingNoProblems(); + + IPath aPath = env.addClass(root, "", "X", + "public class X extends R {}\n"); + + incrementalBuild(projectPath); + expectingSpecificProblemFor(aPath, new Problem("X", "The record R cannot be the superclass of X; a record is final and cannot be extended", aPath, 23, 24, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ + + env.removeProject(projectPath); + } + // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1497 + public void testBinaryRecordClassWithGenericSuper() throws JavaModelException { + IPath projectPath = env.addProject("Project", "16"); + env.addExternalJars(projectPath, Util.getJavaClassLibs()); + + // remove old package fragment root so that names don't collide + env.removePackageFragmentRoot(projectPath, ""); + + IPath root = env.addPackageFragmentRoot(projectPath, "src"); + env.setOutputFolder(projectPath, "bin"); + + env.addClass(root, "", "R", + "interface I {}\n" + + "public record R(int x, int y) implements I {}\n"); + + fullBuild(projectPath); + expectingNoProblems(); + + IPath aPath = env.addClass(root, "", "X", + "public class X extends R {}\n"); + + incrementalBuild(projectPath); + expectingSpecificProblemFor(aPath, new Problem("X", "The record R cannot be the superclass of X; a record is final and cannot be extended", aPath, 23, 24, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ + + env.removeProject(projectPath); + } + + // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1497 + public void testBinaryInnerRecordClass() throws JavaModelException { + IPath projectPath = env.addProject("Project", "16"); + env.addExternalJars(projectPath, Util.getJavaClassLibs()); + + // remove old package fragment root so that names don't collide + env.removePackageFragmentRoot(projectPath, ""); + + IPath root = env.addPackageFragmentRoot(projectPath, "src"); + env.setOutputFolder(projectPath, "bin"); + + env.addClass(root, "", "O", + "public class O {\n" + + " public static record R(int x, int y) {}\n" + + "}\n"); + + fullBuild(projectPath); + expectingNoProblems(); + + IPath aPath = env.addClass(root, "", "X", + "public class X extends O.R {}\n"); + + incrementalBuild(projectPath); + expectingSpecificProblemFor(aPath, new Problem("X", "The record O.R cannot be the superclass of X; a record is final and cannot be extended", aPath, 23, 26, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ + + env.removeProject(projectPath); + } + // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1497 + public void testBinaryInnerRecordClassWithGenericSuper() throws JavaModelException { + IPath projectPath = env.addProject("Project", "16"); + env.addExternalJars(projectPath, Util.getJavaClassLibs()); + + // remove old package fragment root so that names don't collide + env.removePackageFragmentRoot(projectPath, ""); + + IPath root = env.addPackageFragmentRoot(projectPath, "src"); + env.setOutputFolder(projectPath, "bin"); + + env.addClass(root, "", "O", + "public class O {\n" + + " interface I {}\n" + + " public static record R(int x, int y) implements I {}\n" + + "}\n"); + + fullBuild(projectPath); + expectingNoProblems(); + + IPath aPath = env.addClass(root, "", "X", + "public class X extends O.R {}\n"); + + incrementalBuild(projectPath); + expectingSpecificProblemFor(aPath, new Problem("X", "The record O.R cannot be the superclass of X; a record is final and cannot be extended", aPath, 23, 26, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ + + env.removeProject(projectPath); + } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java index b4325803a1..1077a7773f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ParticipantBuildTests.java @@ -380,7 +380,6 @@ public void processAnnotations(BuildContext[] files) { /** * Test that a build participant can inspect the declared annotations by name - * @throws JavaModelException */ public void testProcessAnnotationHasAnnotation() throws JavaModelException { IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Problem.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Problem.java index f2f334876c..7fd81b99f5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Problem.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Problem.java @@ -19,9 +19,9 @@ @SuppressWarnings("rawtypes") public class Problem implements Comparable { - private String location; - private String message; - private IPath resourcePath; + private final String location; + private final String message; + private final IPath resourcePath; private int start = -1, end = -1, categoryId = -1; private String sourceId; private int severity = IMarker.SEVERITY_ERROR; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF index 80b0b71fed..c0648592ae 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF @@ -23,6 +23,7 @@ Require-Bundle: org.junit;bundle-version="3.8.1", org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", org.eclipse.jdt.annotation;bundle-version="[1.1.0,2.0.0)";resolution:=optional, org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional +Import-Package: jakarta.annotation;version="[2.1.0,3.0.0)" Bundle-RequiredExecutionEnvironment: JavaSE-17 Eclipse-BundleShape: dir Bundle-Activator: org.eclipse.jdt.core.tests.compiler.Activator diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java index aec47f4dbe..3936585a6b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java @@ -62,8 +62,8 @@ public class AbstractSyntaxTreeTest extends AbstractCompilerTest implements IDoc CHECK_DOCUMENT_ELEMENT_PARSER | CHECK_COMMENT_RECORDER_PARSER | CHECK_SOURCE_ELEMENT_PARSER | CHECK_INDEXING_PARSER); public static boolean optimizeStringLiterals = false; - private String referenceCompiler; - private String referenceCompilerTestsScratchArea; + private final String referenceCompiler; + private final String referenceCompilerTestsScratchArea; public AbstractSyntaxTreeTest(String name, String referenceCompiler, String referenceCompilerTestsScratchArea) { super(name); @@ -482,4 +482,4 @@ public void exitType(int declarationEnd) { } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietCompletionTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietCompletionTest.java index c2a2e01089..95a31bba31 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietCompletionTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietCompletionTest.java @@ -1308,7 +1308,6 @@ public void test35() { } /* * Invalid completion inside a comment - * */ public void test36() { @@ -1342,7 +1341,6 @@ public void test36() { } /* * Invalid completion inside a string literal - * */ public void test37() { @@ -1378,7 +1376,6 @@ public void test37() { } /* * Invalid completion inside a number literal - * */ public void test38() { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java index 627a9a2484..ee0297ad63 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java @@ -5197,7 +5197,6 @@ public void test76() { /** * Bug 99662:[1.5] JavaModel returns inexistent IType for package-info ICompilationUnits * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=99662" - * */ public void testBug99662() { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceMethod.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceMethod.java index 7e2bf6ae11..b2de2d5f53 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceMethod.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceMethod.java @@ -17,17 +17,17 @@ import org.eclipse.jdt.internal.compiler.env.ISourceMethod; public class SourceMethod implements ISourceMethod { - private int modifiers; - private int declarationStart; + private final int modifiers; + private final int declarationStart; private int declarationEnd; - private char[] returnTypeName; - private char[] selector; - private int nameSourceStart; - private int nameSourceEnd; - private char[][] argumentTypeNames; - private char[][] argumentNames; - private char[][] exceptionTypeNames; - private char[] source; + private final char[] returnTypeName; + private final char[] selector; + private final int nameSourceStart; + private final int nameSourceEnd; + private final char[][] argumentTypeNames; + private final char[][] argumentNames; + private final char[][] exceptionTypeNames; + private final char[] source; private String explicitConstructorCall; char[][] typeParameterNames; char[][][] typeParameterBounds; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceType.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceType.java index ac6ad0df47..3123737ad2 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceType.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceType.java @@ -16,16 +16,16 @@ import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; public final class SourceType { - private int modifiers; - private int declarationStart; + private final int modifiers; + private final int declarationStart; private int declarationEnd; private char[] fileName; private SourcePackage packageName; private SourceImport[] imports; - private char[] enclosingTypeName; - private char[] name; - private int nameSourceStart; - private int nameSourceEnd; + private final char[] enclosingTypeName; + private final char[] name; + private final int nameSourceStart; + private final int nameSourceEnd; private char[] superclassName; private char[][] interfaceNames; private SourceType[] memberTypes; @@ -36,7 +36,7 @@ public final class SourceType { private SourceField[] recordComponents; private int numberOfFields; private int numberOfComponents; - private char[] source; + private final char[] source; SourceType parent; char[][] typeParameterNames; char[][][] typeParameterBounds; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java index f65865550b..b64cfb025e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java @@ -254,6 +254,18 @@ public static TestSuite getTestSuite(boolean addComplianceDiagnoseTest) { TestCase.RUN_ONLY_ID = null; all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_19), tests_19)); } + if ((possibleComplianceLevels & AbstractCompilerTest.F_21) != 0) { + ArrayList tests_21 = (ArrayList)testClasses.clone(); + tests_21.addAll(TEST_CLASSES_1_5); + addJava16Tests(tests_21); + // Reset forgotten subsets tests + TestCase.TESTS_PREFIX = null; + TestCase.TESTS_NAMES = null; + TestCase.TESTS_NUMBERS= null; + TestCase.TESTS_RANGE = null; + TestCase.RUN_ONLY_ID = null; + all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_21), tests_21)); + } return all; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractBatchCompilerTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractBatchCompilerTest.java index 475714913d..ea599e6ca6 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractBatchCompilerTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractBatchCompilerTest.java @@ -52,7 +52,7 @@ public static boolean isJREVersionEqualTo(String compilerVersion) { * here, that is {@link #normalized(String) normalized}. */ protected static abstract class Normalizer { - private Normalizer nextInChain; + private final Normalizer nextInChain; Normalizer(Normalizer nextInChain) { this.nextInChain = nextInChain; } @@ -71,9 +71,9 @@ String normalized(String originalValue) { * placeholder. */ protected static class StringNormalizer extends Normalizer { - private String match; - private int matchLength; - private String placeholder; + private final String match; + private final int matchLength; + private final String placeholder; StringNormalizer(Normalizer nextInChain, String match, String placeholder) { super(nextInChain); this.match = match; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java index d24aa18753..48504c3e61 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractComparableTest.java @@ -44,7 +44,7 @@ public class AbstractComparableTest extends AbstractRegressionTest { protected static final String JAVAX_INJECT_NAME = "javax/inject/Inject.java"; protected static final String JAVAX_INJECT_CONTENT = - "package javax.inject;\n" + + "package jakarta.inject;\n" + "import static java.lang.annotation.ElementType.*;\n" + "import java.lang.annotation.Retention;\n" + "import static java.lang.annotation.RetentionPolicy.RUNTIME;\n" + diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java index 3050be97a2..298d77d74a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java @@ -595,8 +595,8 @@ long compile(File directory, String options, String[] sourceFileNames, StringBuf } } static class JavaRuntime { - private String rootDirectoryPath; - private String javaPathName; + private final String rootDirectoryPath; + private final String javaPathName; String version; // not intended to be modified - one of JavaCore.VERSION_1_* String rawVersion; // not intended to be modified - more complete version name int minor; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java index a81267098b..97002614d6 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java @@ -10732,7 +10732,7 @@ public void testBug376590a() { JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); } // https://bugs.eclipse.org/376590 - Private fields with @Inject are ignored by unused field validation -// using javax.inject.Inject - slight variation +// using jakarta.inject.Inject - slight variation public void testBug376590b() { Map customOptions = getCompilerOptions(); customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); @@ -10744,17 +10744,17 @@ public void testBug376590b() { JAVAX_INJECT_CONTENT, "Example.java", "class Example {\n" + - " private @javax.inject.Inject Object o;\n" + + " private @jakarta.inject.Inject Object o;\n" + " private Example() {} // also warn here: no @Inject\n" + " public Example(Object o) { this.o = o; }\n" + - " private @javax.inject.Inject void setO(Object o) { this.o = o;}\n" + + " private @jakarta.inject.Inject void setO(Object o) { this.o = o;}\n" + "}\n" }, null, customOptions, "----------\n" + "1. ERROR in Example.java (at line 2)\n" + - " private @javax.inject.Inject Object o;\n" + - " ^\n" + + " private @jakarta.inject.Inject Object o;\n" + + " ^\n" + "The value of the field Example.o is not used\n" + "----------\n" + "2. ERROR in Example.java (at line 3)\n" + @@ -10765,7 +10765,7 @@ public void testBug376590b() { JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); } // https://bugs.eclipse.org/376590 - Private fields with @Inject are ignored by unused field validation -// using javax.inject.Inject, combined with standard as well as custom annotations +// using jakarta.inject.Inject, combined with standard as well as custom annotations public void testBug376590c() { Map customOptions = getCompilerOptions(); customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); @@ -10778,7 +10778,7 @@ public void testBug376590c() { JAVAX_INJECT_NAME, JAVAX_INJECT_CONTENT, "Example.java", - "import javax.inject.Inject;\n" + + "import jakarta.inject.Inject;\n" + "class Example {\n" + " private @Inject @p.NonNull Object o; // do warn, annotations don't signal a read\n" + " private @Deprecated @Inject String old; // do warn, annotations don't signal a read\n" + diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java index 11c211a41e..07cc7187af 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java @@ -89,8 +89,8 @@ public static Class testClass() { return BatchCompilerTest.class; } static class StringMatcher extends Matcher { - private String expected; - private Normalizer normalizer; + private final String expected; + private final Normalizer normalizer; StringMatcher(String expected, Normalizer normalizer) { this.expected = expected; this.normalizer = normalizer; @@ -111,7 +111,7 @@ String expected() { } } static class SubstringMatcher extends Matcher { - private String substring; + private final String substring; SubstringMatcher(String substring) { this.substring = substring; } @@ -169,7 +169,8 @@ String normalized(String originalValue) { * This normalizer removes a selected range of lines from a log file. */ private static class LinesRangeNormalizer extends Normalizer { - private int first, number; + private final int first; + private int number; LinesRangeNormalizer() { super(null); @@ -13520,4 +13521,4 @@ public void testGitHub1122(){ + "", true); } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java index fcd4671cf3..931c1f2497 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java @@ -1324,6 +1324,7 @@ class ProblemAttributes { expectedProblemAttributes.put("RawTypeInRecordPattern", new ProblemAttributes(true)); expectedProblemAttributes.put("FalseConstantInGuard", new ProblemAttributes(true)); expectedProblemAttributes.put("CannotInferRecordPatternTypes", new ProblemAttributes(true)); + expectedProblemAttributes.put("IllegalRecordPattern", new ProblemAttributes(true)); expectedProblemAttributes.put("ClassExtendFinalRecord", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); expectedProblemAttributes.put("RecordErasureIncompatibilityInCanonicalConstructor", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); expectedProblemAttributes.put("JavadocInvalidModule", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); @@ -2424,6 +2425,7 @@ class ProblemAttributes { expectedProblemAttributes.put("RawTypeInRecordPattern", SKIP); expectedProblemAttributes.put("FalseConstantInGuard", SKIP); expectedProblemAttributes.put("CannotInferRecordPatternTypes", SKIP); + expectedProblemAttributes.put("IllegalRecordPattern", SKIP); expectedProblemAttributes.put("ClassExtendFinalRecord", SKIP); expectedProblemAttributes.put("RecordErasureIncompatibilityInCanonicalConstructor", SKIP); expectedProblemAttributes.put("JavadocInvalidModule", SKIP); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated18Test.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated18Test.java index 7068824a67..33c0705072 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated18Test.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated18Test.java @@ -37,7 +37,7 @@ public void test412555() { "X.java", "public class X {\n" + " public static void main(String[] args) {\n" + - " Runnable r = () -> {\n" + + " Runnable r = () -> {\n" + " Y.callMe();\n" + " };\n" + " }\n" + @@ -48,16 +48,72 @@ public void test412555() { " public static void callMe() {}\n" + "}\n", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " Y.callMe();\n" + - " ^^^^^^^^\n" + - "The method callMe() from the type Y is deprecated\n" + + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " Y.callMe();\n" + + " ^^^^^^^^\n" + + "The method callMe() from the type Y is deprecated\n" + "----------\n", null, true, options); } +// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1370 +// Deprecation warnings are not suppressed in lambdas of deprecated methods +public void testGH1370() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR); + this.runNegativeTest( + false /* skipJavac */, + JavacTestOptions.Excuse.EclipseWarningConfiguredAsError, + new String[] { + "X.java", + """ + public class X { + @Deprecated + static void deprecatedMethod(Object o) {} + } + """, + "Y.java", + """ + import java.util.List; + public class Y { + @Deprecated + void callDeprecated() { + X.deprecatedMethod(null); // no warning + List.of().forEach(X::deprecatedMethod); // no warning + List.of().forEach(o -> X.deprecatedMethod(o)); // warning + } + void callDeprecated2() { + X.deprecatedMethod(null); + List.of().forEach(X::deprecatedMethod); + List.of().forEach(o -> X.deprecatedMethod(o)); + } + } + """, + }, + """ + ---------- + 1. ERROR in Y.java (at line 10) + X.deprecatedMethod(null); + ^^^^^^^^^^^^^^^^^^^^^^ + The method deprecatedMethod(Object) from the type X is deprecated + ---------- + 2. ERROR in Y.java (at line 11) + List.of().forEach(X::deprecatedMethod); + ^^^^^^^^^^^^^^^^^^^ + The method deprecatedMethod(Object) from the type X is deprecated + ---------- + 3. ERROR in Y.java (at line 12) + List.of().forEach(o -> X.deprecatedMethod(o)); + ^^^^^^^^^^^^^^^^^^^ + The method deprecatedMethod(Object) from the type X is deprecated + ---------- + """, + null, + true, + options); +} public static Class testClass() { return Deprecated18Test.class; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated9Test.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated9Test.java index 460219383c..5caa9f7d67 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated9Test.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated9Test.java @@ -221,20 +221,20 @@ public void test005a() { }, null, customOptions, "----------\n" + - "1. ERROR in p2\\C.java (at line 3)\n" + - " void bar(p1.X.Inner a) {\n" + - " ^\n" + - "The type X has been deprecated and marked for removal\n" + - "----------\n" + - "2. ERROR in p2\\C.java (at line 3)\n" + - " void bar(p1.X.Inner a) {\n" + - " ^^^^^\n" + - "The type X.Inner has been deprecated and marked for removal\n" + - "----------\n" + - "3. ERROR in p2\\C.java (at line 4)\n" + - " a.foo();\n" + - " ^^^^^\n" + - "The method foo() from the type X.Inner has been deprecated and marked for removal\n" + + "1. ERROR in p2\\C.java (at line 3)\n" + + " void bar(p1.X.Inner a) {\n" + + " ^\n" + + "The type X has been deprecated and marked for removal\n" + + "----------\n" + + "2. ERROR in p2\\C.java (at line 3)\n" + + " void bar(p1.X.Inner a) {\n" + + " ^^^^^\n" + + "The type X.Inner has been deprecated and marked for removal\n" + + "----------\n" + + "3. ERROR in p2\\C.java (at line 4)\n" + + " a.foo();\n" + + " ^^^^^\n" + + "The method foo() from the type X.Inner has been deprecated and marked for removal\n" + "----------\n", JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); } @@ -275,7 +275,7 @@ public void test005c() { "package p1;\n" + "public class X {\n" + " public static class Inner {\n" + - " @java.lang.Deprecated(forRemoval=true)\n" + + " @java.lang.Deprecated(forRemoval=true)\n" + " public void foo() {}\n" + " }\n" + "}\n", @@ -293,10 +293,10 @@ public void test005c() { }; runner.expectedCompilerLog = "----------\n" + - "1. WARNING in p2\\C.java (at line 5)\n" + - " a.foo();\n" + - " ^^^^^\n" + - "The method foo() from the type X.Inner has been deprecated and marked for removal\n" + + "1. WARNING in p2\\C.java (at line 5)\n" + + " a.foo();\n" + + " ^^^^^\n" + + "The method foo() from the type X.Inner has been deprecated and marked for removal\n" + "----------\n"; runner.runWarningTest(); } @@ -322,11 +322,11 @@ public void test006() { "}" }; runner.expectedCompilerLog = - "----------\n" + - "1. WARNING in test1\\E02.java (at line 3)\n" + - " public void foo(E01 arg) {\n" + - " ^^^\n" + - "The type E01 is deprecated since version 4\n" + + "----------\n" + + "1. WARNING in test1\\E02.java (at line 3)\n" + + " public void foo(E01 arg) {\n" + + " ^^^\n" + + "The type E01 is deprecated since version 4\n" + "----------\n"; runner.runWarningTest(); } @@ -356,16 +356,16 @@ public void test007() { "}\n", }, null, customOptions, - "----------\n" + - "1. WARNING in p2\\C.java (at line 4)\n" + - " @Override public void foo() {}\n" + - " ^^^^^\n" + - "The method C.foo() overrides a deprecated method from X\n" + - "----------\n" + - "2. ERROR in p2\\C.java (at line 5)\n" + - " @Override public void bar() {}\n" + - " ^^^^^\n" + - "The method C.bar() overrides a method from X that has been deprecated and marked for removal\n" + + "----------\n" + + "1. WARNING in p2\\C.java (at line 4)\n" + + " @Override public void foo() {}\n" + + " ^^^^^\n" + + "The method C.foo() overrides a deprecated method from X\n" + + "----------\n" + + "2. ERROR in p2\\C.java (at line 5)\n" + + " @Override public void bar() {}\n" + + " ^^^^^\n" + + "The method C.bar() overrides a method from X that has been deprecated and marked for removal\n" + "----------\n", JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); } @@ -401,46 +401,46 @@ public void testSinceSource() { "}" }; runner.expectedCompilerLog = - "----------\n" + - "1. WARNING in test1\\E02.java (at line 4)\n" + - " System.out.println(new E01.Old());\n" + - " ^^^^^^^^^\n" + - "The constructor E01.Old() is deprecated since version 1.0\n" + - "----------\n" + - "2. WARNING in test1\\E02.java (at line 4)\n" + - " System.out.println(new E01.Old());\n" + - " ^^^\n" + - "The type E01.Old is deprecated since version 1.0\n" + - "----------\n" + - "3. WARNING in test1\\E02.java (at line 5)\n" + - " E01 e = new E01();\n" + - " ^^^^^\n" + - "The constructor E01() is deprecated since version 3.0.0\n" + - "----------\n" + - "4. WARNING in test1\\E02.java (at line 6)\n" + - " e.old();\n" + - " ^^^^^\n" + - "The method old() from the type E01 is deprecated since version 4-SNAPSHOT\n" + - "----------\n" + - "5. WARNING in test1\\E02.java (at line 7)\n" + - " System.out.println(E01.x);\n" + - " ^\n" + - "The field E01.x is deprecated since version 2\n" + - "----------\n" + - "6. WARNING in test1\\E02.java (at line 8)\n" + - " System.out.println(E01.y);\n" + - " ^\n" + - "The field E01.y is deprecated since version 2\n" + - "----------\n" + - "7. WARNING in test1\\E02.java (at line 10)\n" + - " class E03 extends E01 {\n" + - " ^^^\n" + - "The constructor E01() is deprecated since version 3.0.0\n" + - "----------\n" + - "8. WARNING in test1\\E02.java (at line 11)\n" + - " protected void old() {}\n" + - " ^^^^^\n" + - "The method E02.E03.old() overrides a method from E01 that is deprecated since version 4-SNAPSHOT\n" + + "----------\n" + + "1. WARNING in test1\\E02.java (at line 4)\n" + + " System.out.println(new E01.Old());\n" + + " ^^^^^^^^^\n" + + "The constructor E01.Old() is deprecated since version 1.0\n" + + "----------\n" + + "2. WARNING in test1\\E02.java (at line 4)\n" + + " System.out.println(new E01.Old());\n" + + " ^^^\n" + + "The type E01.Old is deprecated since version 1.0\n" + + "----------\n" + + "3. WARNING in test1\\E02.java (at line 5)\n" + + " E01 e = new E01();\n" + + " ^^^^^\n" + + "The constructor E01() is deprecated since version 3.0.0\n" + + "----------\n" + + "4. WARNING in test1\\E02.java (at line 6)\n" + + " e.old();\n" + + " ^^^^^\n" + + "The method old() from the type E01 is deprecated since version 4-SNAPSHOT\n" + + "----------\n" + + "5. WARNING in test1\\E02.java (at line 7)\n" + + " System.out.println(E01.x);\n" + + " ^\n" + + "The field E01.x is deprecated since version 2\n" + + "----------\n" + + "6. WARNING in test1\\E02.java (at line 8)\n" + + " System.out.println(E01.y);\n" + + " ^\n" + + "The field E01.y is deprecated since version 2\n" + + "----------\n" + + "7. WARNING in test1\\E02.java (at line 10)\n" + + " class E03 extends E01 {\n" + + " ^^^\n" + + "The constructor E01() is deprecated since version 3.0.0\n" + + "----------\n" + + "8. WARNING in test1\\E02.java (at line 11)\n" + + " protected void old() {}\n" + + " ^^^^^\n" + + "The method E02.E03.old() overrides a method from E01 that is deprecated since version 4-SNAPSHOT\n" + "----------\n"; runner.runWarningTest(); } @@ -482,46 +482,46 @@ public void testSinceBinary() { "}" }; runner.expectedCompilerLog = - "----------\n" + - "1. WARNING in test1\\E02.java (at line 4)\n" + - " System.out.println(new E01.Old());\n" + - " ^^^^^^^^^\n" + - "The constructor E01.Old() is deprecated since version 1.0\n" + - "----------\n" + - "2. WARNING in test1\\E02.java (at line 4)\n" + - " System.out.println(new E01.Old());\n" + - " ^^^\n" + - "The type E01.Old is deprecated since version 1.0\n" + - "----------\n" + - "3. WARNING in test1\\E02.java (at line 5)\n" + - " E01 e = new E01();\n" + - " ^^^^^\n" + - "The constructor E01() is deprecated since version 3.0.0\n" + - "----------\n" + - "4. WARNING in test1\\E02.java (at line 6)\n" + - " e.old();\n" + - " ^^^^^\n" + - "The method old() from the type E01 is deprecated since version 4-SNAPSHOT\n" + - "----------\n" + - "5. WARNING in test1\\E02.java (at line 7)\n" + - " System.out.println(E01.x);\n" + - " ^\n" + - "The field E01.x is deprecated since version 2\n" + - "----------\n" + - "6. WARNING in test1\\E02.java (at line 8)\n" + - " System.out.println(E01.y);\n" + - " ^\n" + - "The field E01.y is deprecated since version 2\n" + - "----------\n" + - "7. WARNING in test1\\E02.java (at line 10)\n" + - " class E03 extends E01 {\n" + - " ^^^\n" + - "The constructor E01() is deprecated since version 3.0.0\n" + - "----------\n" + - "8. WARNING in test1\\E02.java (at line 11)\n" + - " protected void old() {}\n" + - " ^^^^^\n" + - "The method E02.E03.old() overrides a method from E01 that is deprecated since version 4-SNAPSHOT\n" + + "----------\n" + + "1. WARNING in test1\\E02.java (at line 4)\n" + + " System.out.println(new E01.Old());\n" + + " ^^^^^^^^^\n" + + "The constructor E01.Old() is deprecated since version 1.0\n" + + "----------\n" + + "2. WARNING in test1\\E02.java (at line 4)\n" + + " System.out.println(new E01.Old());\n" + + " ^^^\n" + + "The type E01.Old is deprecated since version 1.0\n" + + "----------\n" + + "3. WARNING in test1\\E02.java (at line 5)\n" + + " E01 e = new E01();\n" + + " ^^^^^\n" + + "The constructor E01() is deprecated since version 3.0.0\n" + + "----------\n" + + "4. WARNING in test1\\E02.java (at line 6)\n" + + " e.old();\n" + + " ^^^^^\n" + + "The method old() from the type E01 is deprecated since version 4-SNAPSHOT\n" + + "----------\n" + + "5. WARNING in test1\\E02.java (at line 7)\n" + + " System.out.println(E01.x);\n" + + " ^\n" + + "The field E01.x is deprecated since version 2\n" + + "----------\n" + + "6. WARNING in test1\\E02.java (at line 8)\n" + + " System.out.println(E01.y);\n" + + " ^\n" + + "The field E01.y is deprecated since version 2\n" + + "----------\n" + + "7. WARNING in test1\\E02.java (at line 10)\n" + + " class E03 extends E01 {\n" + + " ^^^\n" + + "The constructor E01() is deprecated since version 3.0.0\n" + + "----------\n" + + "8. WARNING in test1\\E02.java (at line 11)\n" + + " protected void old() {}\n" + + " ^^^^^\n" + + "The method E02.E03.old() overrides a method from E01 that is deprecated since version 4-SNAPSHOT\n" + "----------\n"; runner.runWarningTest(); } @@ -557,46 +557,46 @@ public void testSinceTerminally() { "}" }; runner.expectedCompilerLog = - "----------\n" + - "1. ERROR in test1\\E02.java (at line 4)\n" + - " System.out.println(new E01.Old());\n" + - " ^^^^^^^^^\n" + - "The constructor E01.Old() has been deprecated since version 1.0 and marked for removal\n" + - "----------\n" + - "2. ERROR in test1\\E02.java (at line 4)\n" + - " System.out.println(new E01.Old());\n" + - " ^^^\n" + - "The type E01.Old has been deprecated since version 1.0 and marked for removal\n" + - "----------\n" + - "3. ERROR in test1\\E02.java (at line 5)\n" + - " E01 e = new E01();\n" + - " ^^^^^\n" + - "The constructor E01() has been deprecated since version 3.0.0 and marked for removal\n" + - "----------\n" + - "4. ERROR in test1\\E02.java (at line 6)\n" + - " e.old();\n" + - " ^^^^^\n" + - "The method old() from the type E01 has been deprecated since version 4-SNAPSHOT and marked for removal\n" + - "----------\n" + - "5. ERROR in test1\\E02.java (at line 7)\n" + - " System.out.println(E01.x);\n" + - " ^\n" + - "The field E01.x has been deprecated since version 2 and marked for removal\n" + - "----------\n" + - "6. ERROR in test1\\E02.java (at line 8)\n" + - " System.out.println(E01.y);\n" + - " ^\n" + - "The field E01.y has been deprecated since version 2 and marked for removal\n" + - "----------\n" + - "7. ERROR in test1\\E02.java (at line 10)\n" + - " class E03 extends E01 {\n" + - " ^^^\n" + - "The constructor E01() has been deprecated since version 3.0.0 and marked for removal\n" + - "----------\n" + - "8. ERROR in test1\\E02.java (at line 11)\n" + - " protected void old() {}\n" + - " ^^^^^\n" + - "The method E02.E03.old() overrides a method from E01 that has been deprecated since version 4-SNAPSHOT and marked for removal\n" + + "----------\n" + + "1. ERROR in test1\\E02.java (at line 4)\n" + + " System.out.println(new E01.Old());\n" + + " ^^^^^^^^^\n" + + "The constructor E01.Old() has been deprecated since version 1.0 and marked for removal\n" + + "----------\n" + + "2. ERROR in test1\\E02.java (at line 4)\n" + + " System.out.println(new E01.Old());\n" + + " ^^^\n" + + "The type E01.Old has been deprecated since version 1.0 and marked for removal\n" + + "----------\n" + + "3. ERROR in test1\\E02.java (at line 5)\n" + + " E01 e = new E01();\n" + + " ^^^^^\n" + + "The constructor E01() has been deprecated since version 3.0.0 and marked for removal\n" + + "----------\n" + + "4. ERROR in test1\\E02.java (at line 6)\n" + + " e.old();\n" + + " ^^^^^\n" + + "The method old() from the type E01 has been deprecated since version 4-SNAPSHOT and marked for removal\n" + + "----------\n" + + "5. ERROR in test1\\E02.java (at line 7)\n" + + " System.out.println(E01.x);\n" + + " ^\n" + + "The field E01.x has been deprecated since version 2 and marked for removal\n" + + "----------\n" + + "6. ERROR in test1\\E02.java (at line 8)\n" + + " System.out.println(E01.y);\n" + + " ^\n" + + "The field E01.y has been deprecated since version 2 and marked for removal\n" + + "----------\n" + + "7. ERROR in test1\\E02.java (at line 10)\n" + + " class E03 extends E01 {\n" + + " ^^^\n" + + "The constructor E01() has been deprecated since version 3.0.0 and marked for removal\n" + + "----------\n" + + "8. ERROR in test1\\E02.java (at line 11)\n" + + " protected void old() {}\n" + + " ^^^^^\n" + + "The method E02.E03.old() overrides a method from E01 that has been deprecated since version 4-SNAPSHOT and marked for removal\n" + "----------\n"; runner.javacTestOptions = JavacTestOptions.Excuse.EclipseWarningConfiguredAsError; @@ -664,26 +664,26 @@ public void testDeprecatedModule() { "}\n" }; runner.expectedCompilerLog = - "----------\n" + - "1. WARNING in module-info.java (at line 2)\n" + - " requires mod.dep;\n" + - " ^^^^^^^\n" + - "The module mod.dep is deprecated\n" + - "----------\n" + - "2. WARNING in module-info.java (at line 3)\n" + - " requires mod.dep.since;\n" + - " ^^^^^^^^^^^^^\n" + - "The module mod.dep.since is deprecated since version 42\n" + - "----------\n" + - "3. ERROR in module-info.java (at line 4)\n" + - " requires mod.dep.terminally;\n" + - " ^^^^^^^^^^^^^^^^^^\n" + - "The module mod.dep.terminally has been deprecated and marked for removal\n" + - "----------\n" + - "4. ERROR in module-info.java (at line 5)\n" + - " requires mod.dep.since.terminally;\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "The module mod.dep.since.terminally has been deprecated since version 42 and marked for removal\n" + + "----------\n" + + "1. WARNING in module-info.java (at line 2)\n" + + " requires mod.dep;\n" + + " ^^^^^^^\n" + + "The module mod.dep is deprecated\n" + + "----------\n" + + "2. WARNING in module-info.java (at line 3)\n" + + " requires mod.dep.since;\n" + + " ^^^^^^^^^^^^^\n" + + "The module mod.dep.since is deprecated since version 42\n" + + "----------\n" + + "3. ERROR in module-info.java (at line 4)\n" + + " requires mod.dep.terminally;\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "The module mod.dep.terminally has been deprecated and marked for removal\n" + + "----------\n" + + "4. ERROR in module-info.java (at line 5)\n" + + " requires mod.dep.since.terminally;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "The module mod.dep.since.terminally has been deprecated since version 42 and marked for removal\n" + "----------\n"; runner.runNegativeTest(); } @@ -743,46 +743,46 @@ public void testDeprecatedProvidedServices() { "}\n" }; runner.expectedCompilerLog = - "----------\n" + - "1. INFO in mod1\\module-info.java (at line 3)\n" + - " provides p1.IServiceDep with p1impl.ServiceDep;\n" + - " ^^^^^^^^^^^\n" + - "The type IServiceDep is deprecated\n" + - "----------\n" + - "2. INFO in mod1\\module-info.java (at line 3)\n" + - " provides p1.IServiceDep with p1impl.ServiceDep;\n" + - " ^^^^^^^^^^\n" + - "The type ServiceDep is deprecated\n" + - "----------\n" + - "3. INFO in mod1\\module-info.java (at line 4)\n" + - " provides p1.IServiceDepSince with p1impl.ServiceDepSince;\n" + - " ^^^^^^^^^^^^^^^^\n" + - "The type IServiceDepSince is deprecated since version 2\n" + - "----------\n" + - "4. INFO in mod1\\module-info.java (at line 4)\n" + - " provides p1.IServiceDepSince with p1impl.ServiceDepSince;\n" + - " ^^^^^^^^^^^^^^^\n" + - "The type ServiceDepSince is deprecated since version 2\n" + - "----------\n" + - "5. WARNING in mod1\\module-info.java (at line 5)\n" + - " provides p1.IServiceTermDep with p1impl.ServiceTermDep;\n" + - " ^^^^^^^^^^^^^^^\n" + - "The type IServiceTermDep has been deprecated and marked for removal\n" + - "----------\n" + - "6. WARNING in mod1\\module-info.java (at line 5)\n" + - " provides p1.IServiceTermDep with p1impl.ServiceTermDep;\n" + - " ^^^^^^^^^^^^^^\n" + - "The type ServiceTermDep has been deprecated and marked for removal\n" + - "----------\n" + - "7. WARNING in mod1\\module-info.java (at line 6)\n" + - " provides p1.IServiceTermDepSince with p1impl.ServiceTermDepSince;\n" + - " ^^^^^^^^^^^^^^^^^^^^\n" + - "The type IServiceTermDepSince has been deprecated since version 3 and marked for removal\n" + - "----------\n" + - "8. WARNING in mod1\\module-info.java (at line 6)\n" + - " provides p1.IServiceTermDepSince with p1impl.ServiceTermDepSince;\n" + - " ^^^^^^^^^^^^^^^^^^^\n" + - "The type ServiceTermDepSince has been deprecated since version 3 and marked for removal\n" + + "----------\n" + + "1. INFO in mod1\\module-info.java (at line 3)\n" + + " provides p1.IServiceDep with p1impl.ServiceDep;\n" + + " ^^^^^^^^^^^\n" + + "The type IServiceDep is deprecated\n" + + "----------\n" + + "2. INFO in mod1\\module-info.java (at line 3)\n" + + " provides p1.IServiceDep with p1impl.ServiceDep;\n" + + " ^^^^^^^^^^\n" + + "The type ServiceDep is deprecated\n" + + "----------\n" + + "3. INFO in mod1\\module-info.java (at line 4)\n" + + " provides p1.IServiceDepSince with p1impl.ServiceDepSince;\n" + + " ^^^^^^^^^^^^^^^^\n" + + "The type IServiceDepSince is deprecated since version 2\n" + + "----------\n" + + "4. INFO in mod1\\module-info.java (at line 4)\n" + + " provides p1.IServiceDepSince with p1impl.ServiceDepSince;\n" + + " ^^^^^^^^^^^^^^^\n" + + "The type ServiceDepSince is deprecated since version 2\n" + + "----------\n" + + "5. WARNING in mod1\\module-info.java (at line 5)\n" + + " provides p1.IServiceTermDep with p1impl.ServiceTermDep;\n" + + " ^^^^^^^^^^^^^^^\n" + + "The type IServiceTermDep has been deprecated and marked for removal\n" + + "----------\n" + + "6. WARNING in mod1\\module-info.java (at line 5)\n" + + " provides p1.IServiceTermDep with p1impl.ServiceTermDep;\n" + + " ^^^^^^^^^^^^^^\n" + + "The type ServiceTermDep has been deprecated and marked for removal\n" + + "----------\n" + + "7. WARNING in mod1\\module-info.java (at line 6)\n" + + " provides p1.IServiceTermDepSince with p1impl.ServiceTermDepSince;\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "The type IServiceTermDepSince has been deprecated since version 3 and marked for removal\n" + + "----------\n" + + "8. WARNING in mod1\\module-info.java (at line 6)\n" + + " provides p1.IServiceTermDepSince with p1impl.ServiceTermDepSince;\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "The type ServiceTermDepSince has been deprecated since version 3 and marked for removal\n" + "----------\n"; runner.runWarningTest(); } @@ -818,7 +818,7 @@ public void testDeprecatedUsedServices() { "}\n", }; runner.runConformTest(); - + runner.shouldFlushOutputDirectory = false; runner.testFiles = new String[] { @@ -832,26 +832,26 @@ public void testDeprecatedUsedServices() { "}\n" }; runner.expectedCompilerLog = - "----------\n" + - "1. INFO in module-info.java (at line 3)\n" + - " uses p1.IServiceDep;\n" + - " ^^^^^^^^^^^\n" + - "The type IServiceDep is deprecated\n" + - "----------\n" + - "2. INFO in module-info.java (at line 4)\n" + - " uses p1.IServiceDepSince;\n" + - " ^^^^^^^^^^^^^^^^\n" + - "The type IServiceDepSince is deprecated since version 2\n" + - "----------\n" + - "3. WARNING in module-info.java (at line 5)\n" + - " uses p1.IServiceTermDep;\n" + - " ^^^^^^^^^^^^^^^\n" + - "The type IServiceTermDep has been deprecated and marked for removal\n" + - "----------\n" + - "4. WARNING in module-info.java (at line 6)\n" + - " uses p1.IServiceTermDepSince;\n" + - " ^^^^^^^^^^^^^^^^^^^^\n" + - "The type IServiceTermDepSince has been deprecated since version 3 and marked for removal\n" + + "----------\n" + + "1. INFO in module-info.java (at line 3)\n" + + " uses p1.IServiceDep;\n" + + " ^^^^^^^^^^^\n" + + "The type IServiceDep is deprecated\n" + + "----------\n" + + "2. INFO in module-info.java (at line 4)\n" + + " uses p1.IServiceDepSince;\n" + + " ^^^^^^^^^^^^^^^^\n" + + "The type IServiceDepSince is deprecated since version 2\n" + + "----------\n" + + "3. WARNING in module-info.java (at line 5)\n" + + " uses p1.IServiceTermDep;\n" + + " ^^^^^^^^^^^^^^^\n" + + "The type IServiceTermDep has been deprecated and marked for removal\n" + + "----------\n" + + "4. WARNING in module-info.java (at line 6)\n" + + " uses p1.IServiceTermDepSince;\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "The type IServiceTermDepSince has been deprecated since version 3 and marked for removal\n" + "----------\n"; runner.runWarningTest(); } @@ -869,20 +869,20 @@ public void testBug533063_1() throws Exception { }; if (isJRE11Plus) { runner.expectedCompilerLog = - "----------\n" + - "1. ERROR in module-info.java (at line 2)\n" + - " requires jdk.xml.bind;\n" + - " ^^^^^^^^^^^^\n" + - "jdk.xml.bind cannot be resolved to a module\n" + + "----------\n" + + "1. ERROR in module-info.java (at line 2)\n" + + " requires jdk.xml.bind;\n" + + " ^^^^^^^^^^^^\n" + + "jdk.xml.bind cannot be resolved to a module\n" + "----------\n"; runner.runNegativeTest(); } else { runner.expectedCompilerLog = - "----------\n" + - "1. WARNING in module-info.java (at line 2)\n" + - " requires jdk.xml.bind;\n" + - " ^^^^^^^^^^^^\n" + - "The module jdk.xml.bind has been deprecated since version 9 and marked for removal\n" + + "----------\n" + + "1. WARNING in module-info.java (at line 2)\n" + + " requires jdk.xml.bind;\n" + + " ^^^^^^^^^^^^\n" + + "The module jdk.xml.bind has been deprecated since version 9 and marked for removal\n" + "----------\n"; runner.runWarningTest(); } @@ -907,11 +907,11 @@ public void testBug533063_2() throws Exception { "}\n" }; runner.expectedCompilerLog = - "----------\n" + - "1. WARNING in my.mod\\module-info.java (at line 2)\n" + - " requires dont.use;\n" + - " ^^^^^^^^\n" + - "The module dont.use has been deprecated since version 9 and marked for removal\n" + + "----------\n" + + "1. WARNING in my.mod\\module-info.java (at line 2)\n" + + " requires dont.use;\n" + + " ^^^^^^^^\n" + + "The module dont.use has been deprecated since version 9 and marked for removal\n" + "----------\n"; runner.runWarningTest(); } @@ -919,45 +919,45 @@ public void testBug534304() throws Exception { runNegativeTest( new String[] { "p1/C1.java", - "package p1;\n" + - "\n" + - "import pdep.Dep1;\n" + - "\n" + - "public class C1 {\n" + - " Dep1 f;\n" + + "package p1;\n" + + "\n" + + "import pdep.Dep1;\n" + + "\n" + + "public class C1 {\n" + + " Dep1 f;\n" + "}\n", "pdep/Dep1.java", - "package pdep;\n" + - "\n" + - "import pmissing.CMissing;\n" + - "\n" + - "@Deprecated(since=\"13\")\n" + - "@CMissing\n" + - "public class Dep1 {\n" + - "\n" + + "package pdep;\n" + + "\n" + + "import pmissing.CMissing;\n" + + "\n" + + "@Deprecated(since=\"13\")\n" + + "@CMissing\n" + + "public class Dep1 {\n" + + "\n" + "}\n" - }, - "----------\n" + - "1. WARNING in p1\\C1.java (at line 3)\n" + - " import pdep.Dep1;\n" + - " ^^^^^^^^^\n" + - "The type Dep1 is deprecated since version 13\n" + - "----------\n" + - "2. WARNING in p1\\C1.java (at line 6)\n" + - " Dep1 f;\n" + - " ^^^^\n" + - "The type Dep1 is deprecated since version 13\n" + - "----------\n" + - "----------\n" + - "1. ERROR in pdep\\Dep1.java (at line 3)\n" + - " import pmissing.CMissing;\n" + - " ^^^^^^^^\n" + - "The import pmissing cannot be resolved\n" + - "----------\n" + - "2. ERROR in pdep\\Dep1.java (at line 6)\n" + - " @CMissing\n" + - " ^^^^^^^^\n" + - "CMissing cannot be resolved to a type\n" + + }, + "----------\n" + + "1. WARNING in p1\\C1.java (at line 3)\n" + + " import pdep.Dep1;\n" + + " ^^^^^^^^^\n" + + "The type Dep1 is deprecated since version 13\n" + + "----------\n" + + "2. WARNING in p1\\C1.java (at line 6)\n" + + " Dep1 f;\n" + + " ^^^^\n" + + "The type Dep1 is deprecated since version 13\n" + + "----------\n" + + "----------\n" + + "1. ERROR in pdep\\Dep1.java (at line 3)\n" + + " import pmissing.CMissing;\n" + + " ^^^^^^^^\n" + + "The import pmissing cannot be resolved\n" + + "----------\n" + + "2. ERROR in pdep\\Dep1.java (at line 6)\n" + + " @CMissing\n" + + " ^^^^^^^^\n" + + "CMissing cannot be resolved to a type\n" + "----------\n"); } public void testBug542795() throws Exception { @@ -983,30 +983,83 @@ public void testBug542795() throws Exception { "}\n", }; runner.expectedCompilerLog = - "----------\n" + - "1. ERROR in Test.java (at line 1)\n" + - " public class Test implements test.Screen.Component {}\n" + - " ^^^^\n" + - "The hierarchy of the type Test is inconsistent\n" + - "----------\n" + - "2. ERROR in Test.java (at line 1)\n" + - " public class Test implements test.Screen.Component {}\n" + - " ^^^^^^\n" + - "The type Screen is deprecated\n" + - "----------\n" + - "3. ERROR in Test.java (at line 1)\n" + - " public class Test implements test.Screen.Component {}\n" + - " ^^^^^^^^^\n" + - "The type Screen.Component is deprecated\n" + - "----------\n" + - "----------\n" + - "1. ERROR in test\\Screen.java (at line 7)\n" + - " public interface Component extends test.ReaderWarningView.Component {\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "test.ReaderWarningView.Component cannot be resolved to a type\n" + + "----------\n" + + "1. ERROR in Test.java (at line 1)\n" + + " public class Test implements test.Screen.Component {}\n" + + " ^^^^\n" + + "The hierarchy of the type Test is inconsistent\n" + + "----------\n" + + "2. ERROR in Test.java (at line 1)\n" + + " public class Test implements test.Screen.Component {}\n" + + " ^^^^^^\n" + + "The type Screen is deprecated\n" + + "----------\n" + + "3. ERROR in Test.java (at line 1)\n" + + " public class Test implements test.Screen.Component {}\n" + + " ^^^^^^^^^\n" + + "The type Screen.Component is deprecated\n" + + "----------\n" + + "----------\n" + + "1. ERROR in test\\Screen.java (at line 7)\n" + + " public interface Component extends test.ReaderWarningView.Component {\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "test.ReaderWarningView.Component cannot be resolved to a type\n" + "----------\n"; runner.runNegativeTest(); } + public void testGH1431() { + Runner runner = new Runner(); + runner.testFiles = new String[] { + "Parent.java", + """ + @Deprecated(since = AbstractChild.TEST_CONSTANT) // this now fails + public class Parent extends AbstractChild { + private static final String REF_OK = AbstractChild.TEST_CONSTANT; // this compiles OK + } + """, + "AbstractChild.java", + """ + public abstract class AbstractChild implements Constants { + // redacted for brevity + } + """, + "Constants.java", + """ + public interface Constants { + public static final String TEST_CONSTANT = "this is a test"; + } + """ + }; + runner.runConformTest(); + } + public void testGH1412() { + Runner runner = new Runner(); + runner.testFiles = new String[] { + "AbstractClass.java", + """ + public abstract class AbstractClass {} + """, + "AnnotationWithClassValue.java", + """ + public @interface AnnotationWithClassValue { + Class> value(); + } + """, + "ConcreteClass.java", + """ + //Adding @Deprecated here fixes the bug + //@Deprecated + public class ConcreteClass extends AbstractClass {} + """, + "AnnotatedClass.java", + """ + @Deprecated + @AnnotationWithClassValue(ConcreteClass.class) //Type mismatch: cannot convert from Class to Class> + public class AnnotatedClass {} + """ + }; + runner.runConformTest(); + } public static Class testClass() { return Deprecated9Test.class; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeSignatureTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeSignatureTest.java index 19bbb872a0..655ced38cb 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeSignatureTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeSignatureTest.java @@ -92,8 +92,6 @@ public GenericTypeSignatureTest(String name) { super(name); } - /** - */ protected void cleanUp() { Util.flushDirectoryContent(new File(OUTPUT_DIR)); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java index 1634453d8e..8f3aec64cf 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java @@ -10495,4 +10495,52 @@ public Parameter(final String name, final String value) { """ }); } + public void testGH973() { + runConformTest( + new String[] { + "Seq.java", + """ + import java.util.List; + import java.util.function.Consumer; + import java.util.function.Function; + + public interface Seq { + + void consume(Consumer consumer); + + default Seq map(Function mapFunction) { + return c -> consume(t -> c.accept(mapFunction.apply(t))); + } + + default Seq flatMap(Function> mapFunction) { + return c -> consume(t -> mapFunction.apply(t).consume(c)); + } + + static void main(String[] args) { + Seq seq = List.of(1, 2, 3)::forEach; + seq.map(e -> e * 2).flatMap(e -> List.of(e - 1, e)::forEach).consume(System.out::println); + } + + } + """ + }); + } + public void testGH1427_class() { + runConformTest( + new String[] { + "Main.java", + """ + import java.util.List; + import java.util.function.Supplier; + + public class Main { + private static final List>> ATTRIBUTE = List.of(new Pair<>(String::new)); + + static class Pair { Pair(T first) {} } + + public static void main(String[] args) {} + } + """ + }); + } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_9.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_9.java index 9469484856..15bab7385b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_9.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_9.java @@ -671,7 +671,7 @@ public void testBug533644() { runner.runConformTest(); } //As All non-private methods of an anonymous class instantiated with '<>' must be treated as being annotated with @override, -//"Remove redundant type arguments" error should be reported if all the non-private methods defined in the anonymous class +//"Remove redundant type arguments" diagnostic should be reported ONLY if all the non-private methods defined in the anonymous class //are also present in the parent class. public void testBug551913_001() { Map options = getCompilerOptions(); @@ -696,7 +696,7 @@ public void testBug551913_001() { },"10", options); } // As All non-private methods of an anonymous class instantiated with '<>' must be treated as being annotated with @override, -// "Remove redundant type arguments" error should be reported if all the non-private methods defined in the anonymous class +// "Remove redundant type arguments" diagnostic should be reported ONLY if all the non-private methods defined in the anonymous class // are also present in the parent class. public void testBug551913_002() { Map options = getCompilerOptions(); @@ -722,6 +722,291 @@ public void testBug551913_002() { "----------\n", null, true, options); } + +// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1506 +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=551913 +public void testBug551913_003() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo() {\n" + + " java.util.HashSet a = new java.util.HashSet<>();\n" + + " java.util.HashSet b = new java.util.HashSet(a) {\n" + + " private static final long serialVersionUID = 1L;\n" + + " public String toString() {return asString();}\n" + + " private String asString() { return null;}\n" + + " };\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " java.util.HashSet b = new java.util.HashSet(a) {\n" + + " ^^^^^^^\n" + + "Redundant specification of type arguments \n" + + "----------\n", + null, true, options); +} +// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1506 +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=551913 +public void testBug551913_004() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo() {\n" + + " java.util.HashSet a = new java.util.HashSet<>();\n" + + " java.util.HashSet b = new java.util.HashSet(a) {\n" + + " private static final long serialVersionUID = 1L;\n" + + " public String toString() {return asString();}\n" + + " public String asString() { return null;}\n" + + " };\n" + + " }\n" + + "}", + }, + "", + null, true, options); +} +// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1506 +// Recommendation from compiler to drop type arguments leads to compile error +public void testGH1506() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); + this.runNegativeTest( + new String[] { + "X.java", + "import java.io.File;\n" + + "import java.util.Arrays;\n" + + "import java.util.Iterator;\n" + + "\n" + + "public class X {\n" + + "\n" + + " public Iterable getStackFramesClassesLocations(Object element) {\n" + + " return new Iterable() {\n" + + " @Override\n" + + " public Iterator iterator() {\n" + + " return Arrays.stream(new Object[0]) //\n" + + " .map(frame -> getClassesLocation(frame)) //\n" + + " .iterator();\n" + + " }\n" + + " \n" + + " File getClassesLocation(Object frame) {\n" + + " return null;\n" + + " }\n" + + " };\n" + + " }\n" + + "}\n", + }, + "", + null, true, options); +} +// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1506 +// Recommendation from compiler to drop type arguments leads to compile error +public void testGH1506_2() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); + this.runNegativeTest( + new String[] { + "X.java", + "import java.io.File;\n" + + "import java.util.Arrays;\n" + + "import java.util.Iterator;\n" + + "\n" + + "public class X {\n" + + "\n" + + " public Iterable getStackFramesClassesLocations(Object element) {\n" + + " return new Iterable() {\n" + + " @Override\n" + + " public Iterator iterator() {\n" + + " return Arrays.stream(new Object[0]) //\n" + + " .map(frame -> getClassesLocation(frame)) //\n" + + " .iterator();\n" + + " }\n" + + " \n" + + " private File getClassesLocation(Object frame) {\n" + + " return null;\n" + + " }\n" + + " };\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " return new Iterable() {\n" + + " ^^^^^^^^\n" + + "Redundant specification of type arguments \n" + + "----------\n", + null, true, options); +} +// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1506 +// Recommendation from compiler to drop type arguments leads to compile error +public void testGH1506_3() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " static class AX{}\n" + + " X(E e) {}\n" + + " X() {}\n" + + " public static void main(String[] args) {\n" + + " X x5 = new X>(new AX() { private void foo() {} });\n" + + " }\n" + + "} \n", + }, + "----------\n" + + "1. WARNING in X.java (at line 6)\n" + + " X x5 = new X>(new AX() { private void foo() {} });\n" + + " ^^\n" + + "X.AX is a raw type. References to generic type X.AX should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 6)\n" + + " X x5 = new X>(new AX() { private void foo() {} });\n" + + " ^^^^^\n" + + "The method foo() from the type new X.AX(){} is never used locally\n" + + "----------\n", + null, true, options); +} +// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1506 +// Recommendation from compiler to drop type arguments leads to compile error +public void testGH1506_4() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " static class AX{}\n" + + " X(E e) {}\n" + + " X() {}\n" + + " public static void main(String[] args) {\n" + + " X x5 = new X>(new AX() { public void foo() {} });\n" + + " }\n" + + "} \n", + }, + "----------\n" + + "1. WARNING in X.java (at line 6)\n" + + " X x5 = new X>(new AX() { public void foo() {} });\n" + + " ^^\n" + + "X.AX is a raw type. References to generic type X.AX should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 6)\n" + + " X x5 = new X>(new AX() { public void foo() {} });\n" + + " ^^^^^\n" + + "The method foo() from the type new X.AX(){} is never used locally\n" + + "----------\n", + null, true, options); +} +// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1560 +// ECJ recommends diamond when using it would result in non-denotable types. +public void testGH1560() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); + this.runNegativeTest( + new String[] { + "X.java", + """ + import java.util.Collection; + import java.util.List; + + public class X { + + public interface MMenuElement {} + public interface IObservable {} + public static class ListDiffVisitor {} + public interface IObservablesListener {} + public interface IObservableCollection extends IObservable, Collection {} + public static class ObservableEvent {} + public interface IDiff {} + public static class ListDiff implements IDiff { + public void accept(ListDiffVisitor visitor) {} + } + public static class ListChangeEvent extends ObservableEvent { + public ListDiff diff; + } + public interface IListChangeListener extends IObservablesListener { + void handleListChange(ListChangeEvent event); + } + public interface IObservableList extends List, IObservableCollection { + void addListChangeListener(IListChangeListener listener); + } + + public void foo() { + + IObservableList l; + + l.addListChangeListener(event -> event.diff.accept(new ListDiffVisitor() {})); // <> should not be recommended here!!! + + } + } + """, + }, + "----------\n" + + "1. ERROR in X.java (at line 30)\n" + + " l.addListChangeListener(event -> event.diff.accept(new ListDiffVisitor() {})); // <> should not be recommended here!!!\n" + + " ^\n" + + "The local variable l may not have been initialized\n" + + "----------\n", + null, true, options); +} +// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1560 +// ECJ recommends diamond when using it would result in non-denotable types. +public void testGH1560_2() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); + this.runNegativeTest( + new String[] { + "X.java", + """ + import java.util.Collection; + import java.util.List; + + public class X { + + public interface MMenuElement {} + public interface IObservable {} + public static class ListDiffVisitor {} + public interface IObservablesListener {} + public interface IObservableCollection extends IObservable, Collection {} + public static class ObservableEvent {} + public interface IDiff {} + public static class ListDiff implements IDiff { + public void accept(ListDiffVisitor visitor) {} + } + public static class ListChangeEvent extends ObservableEvent { + public ListDiff diff; + } + public interface IListChangeListener extends IObservablesListener { + void handleListChange(ListChangeEvent event); + } + public interface IObservableList extends List, IObservableCollection { + void addListChangeListener(IListChangeListener listener); + } + + public void foo() { + + IObservableList l; + + l.addListChangeListener(event -> event.diff.accept(new ListDiffVisitor<>() {})); // non-denotable type error + + } + } + """, + }, + "----------\n" + + "1. ERROR in X.java (at line 30)\n" + + " l.addListChangeListener(event -> event.diff.accept(new ListDiffVisitor<>() {})); // non-denotable type error\n" + + " ^^^^^^^^^^^^^^^\n" + + "Type X.ListDiffVisitor inferred for ListDiffVisitor<>, is not valid for an anonymous class with '<>'\n" + + "----------\n", + null, true, options); +} public static Class testClass() { return GenericsRegressionTest_9.class; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InternalHexFloatTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InternalHexFloatTest.java index c3ba04082b..d5bd847356 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InternalHexFloatTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InternalHexFloatTest.java @@ -52,8 +52,6 @@ public static Class testClass() { return InternalHexFloatTest.class; } - /** - */ public void test001() { List x = new ArrayList(); @@ -187,8 +185,6 @@ public void test001() { } } - /** - */ public void test002() { List x = new ArrayList(); // various forms of zero diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java index 485a6317dc..9ab267f732 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java @@ -134,9 +134,6 @@ public void test003() { "SUCCESS" ); } -/** - * - */ public void test004() { this.runConformTest( new String[] { @@ -174,9 +171,6 @@ public void test004() { "SUCCESS" ); } -/** - * - */ public void test005() { this.runConformTest( new String[] { @@ -359,9 +353,6 @@ public void test010() { "Cannot make a static reference to the non-static field A.success\n" + "----------\n"); } -/** - * - */ public void test011() { this.runNegativeTest( new String[] { @@ -399,9 +390,6 @@ public void test011() { "----------\n" ); } -/** - * - */ public void test012() { this.runConformTest( new String[] { @@ -428,9 +416,6 @@ public void test012() { "SUCCESS" ); } -/** - * - */ public void test013() { this.runNegativeTest( new String[] { @@ -485,9 +470,6 @@ public void test013() { "----------\n" ); } -/** - * - */ public void test014() { this.runNegativeTest( new String[] { @@ -512,9 +494,6 @@ public void test014() { "----------\n" ); } -/** - * - */ public void test015() { this.runConformTest( new String[] { @@ -535,9 +514,6 @@ public void test015() { "SUCCESS" ); } -/** - * - */ public void test016() { this.runConformTest( new String[] { @@ -583,9 +559,6 @@ public void test016() { } ); } -/** - * - */ public void test017() { this.runConformTest( new String[] { @@ -751,9 +724,6 @@ public void test021() { } ); } -/** - * - */ public void test022() { this.runConformTest( new String[] { @@ -791,9 +761,6 @@ public void test022() { } ); } -/** - * - */ public void test023() { this.runConformTest( new String[] { @@ -820,9 +787,6 @@ public void test023() { } ); } -/** - * - */ public void test024() { this.runConformTest( new String[] { @@ -847,9 +811,6 @@ public void test024() { } ); } -/** - * - */ public void test025() { this.runConformTest( new String[] { @@ -887,9 +848,6 @@ public void test025() { "SUCCESS" ); } -/** - * - */ public void test026() { this.runNegativeTest( new String[] { @@ -930,9 +888,6 @@ public void test026() { "The field A.B.B is not visible\n" + "----------\n"); } -/** - * - */ public void test027() { this.runNegativeTest( new String[] { @@ -974,9 +929,6 @@ public void test027() { "----------\n" ); } -/** - * - */ public void test028() { this.runConformTest( new String[] { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationBatchCompilerTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationBatchCompilerTest.java index 784a5a00f6..a3362d0513 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationBatchCompilerTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationBatchCompilerTest.java @@ -1223,4 +1223,159 @@ public void testGH703() { "", true); } + public void testGH1452_src() throws IOException { + String annotationPath = "/annotations"; + new File(OUTPUT_DIR+annotationPath+"/some/sillyPackage").mkdirs(); + Util.createFile(OUTPUT_DIR+annotationPath+"/some/sillyPackage/Foo.eea", + "class some/sillyPackage/Foo\n" + + "get\n" + + " (Ljava/lang/String;)Ljava/lang/String;\n" + + " (L1java/lang/String;)L0java/lang/String;\n"); + + String[] testFiles = new String[] { + "java/lang/annotation/ElementType.java", + ELEMENT_TYPE_18_CONTENT, + "org/eclipse/jdt/annotation/NonNull.java", + NONNULL_ANNOTATION_18_CONTENT, + "org/eclipse/jdt/annotation/Nullable.java", + NULLABLE_ANNOTATION_18_CONTENT, + "org/eclipse/jdt/annotation/DefaultLocation.java", + DEFAULT_LOCATION_CONTENT, + "org/eclipse/jdt/annotation/NonNullByDefault.java", + NONNULL_BY_DEFAULT_ANNOTATION_18_CONTENT, + "sillyPackage/Foo.java", + "package some.sillyPackage;\n" + + "public class Foo {\n" + + " public String get(String s) { return null; }\n" + + "}\n", + "test1/Test1.java", + "package test1;\n" + + "\n" + + "import some.sillyPackage.Foo;\n" + + "import org.eclipse.jdt.annotation.*;\n" + + "\n" + + "@NonNullByDefault\n" + + "public class Test1 {\n" + + " void test(Foo f) {\n" + + " System.out.print(f.get(null).toUpperCase());\n" + + " }\n" + + "}\n" + }; + + String o_e_j_annotation_dir = OUTPUT_DIR + File.separator + + "org" + File.separator + "eclipse" + File.separator + "jdt" + File.separator + "annotation"; + String j_l_annotation_dir = OUTPUT_DIR + File.separator + + "java" + File.separator + "lang" + File.separator + "annotation"; + + String commandLine = " -1.8 -proc:none -d none -err:+nullAnnot,null -annotationpath CLASSPATH " + + " -classpath \"" + OUTPUT_DIR + annotationPath +"\" " + + // explicitly mention all files to ensure a good order, cannot pull in source of NNBD on demand + "\"" + j_l_annotation_dir + File.separator + "ElementType.java\" " + + "\"" + o_e_j_annotation_dir + File.separator + "NonNull.java\" " + + "\"" + o_e_j_annotation_dir + File.separator + "Nullable.java\" " + + "\"" + o_e_j_annotation_dir + File.separator + "DefaultLocation.java\" " + + "\"" + o_e_j_annotation_dir + File.separator + "NonNullByDefault.java\" " + + "\"" + OUTPUT_DIR + File.separator + "sillyPackage" + File.separator + "Foo.java\" " + + "\"" + OUTPUT_DIR + File.separator + "test1" + File.separator + "Test1.java\""; + + String expectedCompilerMessage = + "----------\n" + + "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 9)\n" + + " System.out.print(f.get(null).toUpperCase());\n" + + " ^^^^^^^^^^^\n" + + "Potential null pointer access: The method get(String) may return null\n" + + "----------\n" + + "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 9)\n" + + " System.out.print(f.get(null).toUpperCase());\n" + + " ^^^^\n" + + "Null type mismatch: required \'@NonNull String\' but the provided value is null\n" + + "----------\n" + + "2 problems (2 errors)\n"; + try { + this.runNegativeTest(testFiles, commandLine, "", expectedCompilerMessage, false); + } finally { + Util.delete(Util.getOutputDirectory()); + } + } + public void testGH1452_bin() throws IOException { + String jarPath = OUTPUT_DIR+"/lib.jar"; + String annotationZip = OUTPUT_DIR+"/annotations.zip"; + Util.createJar(new String[] { + "some/sillyPackage/Foo.java", + "package some.sillyPackage;\n" + + "public class Foo {\n" + + " public String get(String s) { return null; }\n" + + "}\n" + }, + jarPath, + "1.8"); + Util.createSourceZip( + new String[] { + "some/sillyPackage/Foo.eea", + "class some/sillyPackage/Foo\n" + + "get\n" + + " (Ljava/lang/String;)Ljava/lang/String;\n" + + " (L1java/lang/String;)L0java/lang/String;\n" + }, + annotationZip); + + String[] testFiles = new String[] { + "java/lang/annotation/ElementType.java", + ELEMENT_TYPE_18_CONTENT, + "org/eclipse/jdt/annotation/NonNull.java", + NONNULL_ANNOTATION_18_CONTENT, + "org/eclipse/jdt/annotation/Nullable.java", + NULLABLE_ANNOTATION_18_CONTENT, + "org/eclipse/jdt/annotation/DefaultLocation.java", + DEFAULT_LOCATION_CONTENT, + "org/eclipse/jdt/annotation/NonNullByDefault.java", + NONNULL_BY_DEFAULT_ANNOTATION_18_CONTENT, + "test1/Test1.java", + "package test1;\n" + + "\n" + + "import some.sillyPackage.Foo;\n" + + "import org.eclipse.jdt.annotation.*;\n" + + "\n" + + "@NonNullByDefault\n" + + "public class Test1 {\n" + + " void test(Foo f) {\n" + + " System.out.print(f.get(null).toUpperCase());\n" + + " }\n" + + "}\n" + }; + + String o_e_j_annotation_dir = OUTPUT_DIR + File.separator + + "org" + File.separator + "eclipse" + File.separator + "jdt" + File.separator + "annotation"; + String j_l_annotation_dir = OUTPUT_DIR + File.separator + + "java" + File.separator + "lang" + File.separator + "annotation"; + + String commandLine = " -1.8 -proc:none -d none -err:+nullAnnot,null -annotationpath CLASSPATH " + + " -classpath \"" + annotationZip +"\""+ File.pathSeparator + "\"" + jarPath + "\" " + + // explicitly mention all files to ensure a good order, cannot pull in source of NNBD on demand + "\"" + j_l_annotation_dir + File.separator + "ElementType.java\" " + + "\"" + o_e_j_annotation_dir + File.separator + "NonNull.java\" " + + "\"" + o_e_j_annotation_dir + File.separator + "Nullable.java\" " + + "\"" + o_e_j_annotation_dir + File.separator + "DefaultLocation.java\" " + + "\"" + o_e_j_annotation_dir + File.separator + "NonNullByDefault.java\" " + + "\"" + OUTPUT_DIR + File.separator + "test1" + File.separator + "Test1.java\""; + + String expectedCompilerMessage = + "----------\n" + + "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 9)\n" + + " System.out.print(f.get(null).toUpperCase());\n" + + " ^^^^^^^^^^^\n" + + "Potential null pointer access: The method get(String) may return null\n" + + "----------\n" + + "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/test1/Test1.java (at line 9)\n" + + " System.out.print(f.get(null).toUpperCase());\n" + + " ^^^^\n" + + "Null type mismatch: required \'@NonNull String\' but the provided value is null\n" + + "----------\n" + + "2 problems (2 errors)\n"; + try { + this.runNegativeTest(testFiles, commandLine, "", expectedCompilerMessage, false); + } finally { + Util.delete(Util.getOutputDirectory()); + } + } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java index 24c106ebb4..0af7669129 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java @@ -4567,7 +4567,7 @@ public void test_nonnull_field_16() { "----------\n"); } -// Using javax.inject.Inject, slight variations +// Using jakarta.inject.Inject, slight variations // [compiler] Null analysis for fields does not take @com.google.inject.Inject into account // https://bugs.eclipse.org/bugs/show_bug.cgi?id=400421 public void test_nonnull_field_17() { @@ -4577,7 +4577,7 @@ public void test_nonnull_field_17() { JAVAX_INJECT_CONTENT, "X.java", "import org.eclipse.jdt.annotation.*;\n" + - "import javax.inject.Inject;\n" + + "import jakarta.inject.Inject;\n" + "public class X {\n" + " @NonNull @Inject static String s; // warn since injection of static field is less reliable\n" + // variation: static field " @NonNull @Inject @Deprecated Object o;\n" + @@ -8764,12 +8764,12 @@ public void testBug418236() { } public void testBug461878() { Map compilerOptions = getCompilerOptions(); - compilerOptions.put(JavaCore.COMPILER_NONNULL_ANNOTATION_NAME, "javax.annotation.Nonnull"); + compilerOptions.put(JavaCore.COMPILER_NONNULL_ANNOTATION_NAME, "jakarta.annotation.Nonnull"); runNegativeTest( true, /*flush*/ new String[] { - "javax/annotation/Nonnull.java", - "package javax.annotation;\n" + + "jakarta/annotation/Nonnull.java", + "package jakarta.annotation;\n" + "import java.lang.annotation.Retention;\n" + "import java.lang.annotation.RetentionPolicy;\n" + "@Retention(RetentionPolicy.RUNTIME)\n" + @@ -8777,7 +8777,7 @@ public void testBug461878() { "}\n", "edu/umd/cs/findbugs/annotations/PossiblyNull.java", "package edu.umd.cs.findbugs.annotations;\n" + - "@javax.annotation.Nonnull // <-- error!!!\n" + + "@jakarta.annotation.Nonnull // <-- error!!!\n" + "public @interface PossiblyNull {\n" + "}\n" }, @@ -8785,8 +8785,8 @@ public void testBug461878() { compilerOptions, "----------\n" + "1. WARNING in edu\\umd\\cs\\findbugs\\annotations\\PossiblyNull.java (at line 2)\n" + - " @javax.annotation.Nonnull // <-- error!!!\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + " @jakarta.annotation.Nonnull // <-- error!!!\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + "The nullness annotation \'Nonnull\' is not applicable at this location\n" + "----------\n", JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings); diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordPatternTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordPatternTest.java index 918970df1c..49581cdb37 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordPatternTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordPatternTest.java @@ -1741,7 +1741,7 @@ public void testRemoveNamedRecordPatterns_001() { "----------\n"); } public void testEnhancedForWithRecordPattern_001() { - runConformTest(new String[] { + runNegativeTest(new String[] { "X.java", "import java.util.ArrayList;\n" + "import java.util.List;\n" + @@ -1760,11 +1760,15 @@ public void testEnhancedForWithRecordPattern_001() { "}\n" + "record R(Integer i) {}" }, - "1\n" + - "2"); + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " for (R(Integer a) : rList) { \n" + + " ^^^^^^^^^^^^\n" + + "Syntax error, record patterns are not allowed here\n" + + "----------\n"); } public void testEnhancedForWithRecordPattern_002() { - runConformTest(new String[] { + runNegativeTest(new String[] { "X.java", "public class X {\n" + " public static boolean foo() {\n" + @@ -1781,7 +1785,12 @@ public void testEnhancedForWithRecordPattern_002() { "}\n" + "record R(int i) {}" }, - "true"); + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " for (R(int x) : recArray) {\n" + + " ^^^^^^^^\n" + + "Syntax error, record patterns are not allowed here\n" + + "----------\n"); } public void testRecordPatternTypeInference_001() { runNegativeTest(new String[] { @@ -2029,7 +2038,12 @@ public void testIssue882() { + "}" }, "----------\n" + - "1. ERROR in X.java (at line 8)\n" + + "1. ERROR in X.java (at line 5)\n" + + " for(R(Integer abcs):rList) {\n" + + " ^^^^^^^^^^^^^^^\n" + + "Syntax error, record patterns are not allowed here\n" + + "----------\n" + + "2. ERROR in X.java (at line 8)\n" + " zork();\n" + " ^^^^\n" + "The method zork() is undefined for the type X\n" + @@ -2292,10 +2306,15 @@ public void testIssue945_1() { " R99[] array = {new R99(new R98(new R97(new R96(new R95(new R94(new R93(new R92(new R91(new R90(new R89(new R88(new R87(new R86(new R85(new R84(new R83(new R82(new R81(new R80(new R79(new R78(new R77(new R76(new R75(new R74(new R73(new R72(new R71(new R70(new R69(new R68(new R67(new R66(new R65(new R64(new R63(new R62(new R61(new R60(new R59(new R58(new R57(new R56(new R55(new R54(new R53(new R52(new R51(new R50(new R49(new R48(new R47(new R46(new R45(new R44(new R43(new R42(new R41(new R40(new R39(new R38(new R37(new R36(new R35(new R34(new R33(new R32(new R31(new R30(new R29(new R28(new R27(new R26(new R25(new R24(new R23(new R22(new R21(new R20(new R19(new R18(new R17(new R16(new R15(new R14(new R13(new R12(new R11(new R10(new R9(new R8(new R7(new R6(new R5(new R4(new R3(new R2(new R1(new R0(\"\"), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50), 51), 52), 53), 54), 55), 56), 57), 58), 59), 60), 61), 62), 63), 64), 65), 66), 67), 68), 69), 70), 71), 72), 73), 74), 75), 76), 77), 78), 79), 80), 81), 82), 83), 84), 85), 86), 87), 88), 89), 90), 91), 92), 93), 94), 95), 96), 97), 98), 99)};\n" + " ^^^^^^^^^^\n" + "The constructor X.R0(String) is undefined\n" + + "----------\n" + + "2. ERROR in X.java (at line 105)\n" + + " for (R99(R98(R97(R96(R95(R94(R93(R92(R91(R90(R89(R88(R87(R86(R85(R84(R83(R82(R81(R80(R79(R78(R77(R76(R75(R74(R73(R72(R71(R70(R69(R68(R67(R66(R65(R64(R63(R62(R61(R60(R59(R58(R57(R56(R55(R54(R53(R52(R51(R50(R49(R48(R47(R46(R45(R44(R43(R42(R41(R40(R39(R38(R37(R36(R35(R34(R33(R32(R31(R30(R29(R28(R27(R26(R25(R24(R23(R22(R21(R20(R19(R18(R17(R16(R15(R14(R13(R12(R11(R10(R9(R8(R7(R6(R5(R4(R3(R2(R1(R0(int i0), int i1), int i2), int i3), int i4), int i5), int i6), int i7), int i8), int i9), int i10), int i11), int i12), int i13), int i14), int i15), int i16), int i17), int i18), int i19), int i20), int i21), int i22), int i23), int i24), int i25), int i26), int i27), int i28), int i29), int i30), int i31), int i32), int i33), int i34), int i35), int i36), int i37), int i38), int i39), int i40), int i41), int i42), int i43), int i44), int i45), int i46), int i47), int i48), int i49), int i50), int i51), int i52), int i53), int i54), int i55), int i56), int i57), int i58), int i59), int i60), int i61), int i62), int i63), int i64), int i65), int i66), int i67), int i68), int i69), int i70), int i71), int i72), int i73), int i74), int i75), int i76), int i77), int i78), int i79), int i80), int i81), int i82), int i83), int i84), int i85), int i86), int i87), int i88), int i89), int i90), int i91), int i92), int i93), int i94), int i95), int i96), int i97), int i98), int i99) : array) {\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, record patterns are not allowed here\n" + "----------\n"); } public void testIssue945_2() { - runConformTest(new String[] { + runNegativeTest(new String[] { "X.java", "public class X {\n" + " record R0(int x) {}\n" @@ -2409,7 +2428,12 @@ public void testIssue945_2() { + " }\n" + "} " }, - "true"); + "----------\n" + + "1. ERROR in X.java (at line 106)\n" + + " for (R99(R98(R97(R96(R95(R94(R93(R92(R91(R90(R89(R88(R87(R86(R85(R84(R83(R82(R81(R80(R79(R78(R77(R76(R75(R74(R73(R72(R71(R70(R69(R68(R67(R66(R65(R64(R63(R62(R61(R60(R59(R58(R57(R56(R55(R54(R53(R52(R51(R50(R49(R48(R47(R46(R45(R44(R43(R42(R41(R40(R39(R38(R37(R36(R35(R34(R33(R32(R31(R30(R29(R28(R27(R26(R25(R24(R23(R22(R21(R20(R19(R18(R17(R16(R15(R14(R13(R12(R11(R10(R9(R8(R7(R6(R5(R4(R3(R2(R1(R0(int i0), int i1), int i2), int i3), int i4), int i5), int i6), int i7), int i8), int i9), int i10), int i11), int i12), int i13), int i14), int i15), int i16), int i17), int i18), int i19), int i20), int i21), int i22), int i23), int i24), int i25), int i26), int i27), int i28), int i29), int i30), int i31), int i32), int i33), int i34), int i35), int i36), int i37), int i38), int i39), int i40), int i41), int i42), int i43), int i44), int i45), int i46), int i47), int i48), int i49), int i50), int i51), int i52), int i53), int i54), int i55), int i56), int i57), int i58), int i59), int i60), int i61), int i62), int i63), int i64), int i65), int i66), int i67), int i68), int i69), int i70), int i71), int i72), int i73), int i74), int i75), int i76), int i77), int i78), int i79), int i80), int i81), int i82), int i83), int i84), int i85), int i86), int i87), int i88), int i89), int i90), int i91), int i92), int i93), int i94), int i95), int i96), int i97), int i98), int i99) : array) {\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, record patterns are not allowed here\n" + + "----------\n"); } public void testRecordPatternMatchException_001() { runConformTest(new String[] { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java index 525e69ceff..ad68f42086 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2022 IBM Corporation and others. + * Copyright (c) 2019, 2023 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 @@ -30,7 +30,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest { static { // TESTS_NUMBERS = new int [] { 40 }; // TESTS_RANGE = new int[] { 1, -1 }; -// TESTS_NAMES = new String[] { "testBug577251_001"}; +// TESTS_NAMES = new String[] { "testIssue1218_001"}; } public static Class testClass() { @@ -9436,4 +9436,24 @@ record MyRecord(int field1, int field2) { } """}); } +public void testIssue1218_001() { + runNegativeTest( + new String[] { + "X.java", + "public class X {\n"+ + " record R(T x);\n"+ + "}" + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " record R(T x);\n" + + " ^\n" + + "Cannot make a static reference to the non-static type T\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " record R(T x);\n" + + " ^\n" + + "Syntax error, insert \"RecordBody\" to complete ClassBodyDeclarations\n" + + "----------\n"); +} } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Requestor.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Requestor.java index 5388cfcb40..9e410ffeef 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Requestor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Requestor.java @@ -26,7 +26,7 @@ public class Requestor implements ICompilerRequestor { public boolean hasErrors = false; public String outputPath; - private boolean forceOutputGeneration; + private final boolean forceOutputGeneration; public Hashtable expectedProblems = new Hashtable(); public String problemLog = ""; public ICompilerRequestor clientRequestor; diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java index 7e16430b15..ad93939506 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java @@ -1790,28 +1790,6 @@ public void testModule() { // insufficient context, all module words are identif assertTrue(false); } } - public void testWhenOK() { - String source = ("public void foo(Object obj) {\n switch(obj) {\n case String s when s.length() > 0 -> {}\n}\n}"); - IScanner scanner = ToolFactory.createScanner(false, true, false, "21", "21", false); - scanner.setSource(source.toCharArray()); - scanner.resetTo(source.indexOf("when")-1, source.length() - 1); // start directly at "when" - try { - int token; - while ((token = scanner.getNextToken()) != ITerminalSymbols.TokenNameEOF) { - switch (token) { - case ITerminalSymbols.TokenNameWHITESPACE: - break; - case ITerminalSymbols.TokenNameRestrictedIdentifierWhen: - return; // success - default: - fail("Unexpected token "+token); - } - } - fail("TokenNameRestrictedIdentifierYield was not detected"); - } catch (InvalidInputException e) { - assertTrue(false); - } - } @SuppressWarnings("deprecation") public void testWhenKO() { String source = ("public void foo(Object obj) {\n switch(obj) {\n case String s when s.length() > 0 -> {}\n}\n}"); @@ -1857,4 +1835,24 @@ public void testWhenAsIdentifier() { assertTrue(false); } } + + public void testTerminalTokensAPIs() { + char [][] ids = { "when".toCharArray(), "record".toCharArray(), "sealed".toCharArray(), + "permits".toCharArray(), "yield".toCharArray()}; + int [] reskw = { TerminalTokens.TokenNameRestrictedIdentifierWhen, + TerminalTokens.TokenNameRestrictedIdentifierrecord, + TerminalTokens.TokenNameRestrictedIdentifiersealed, + TerminalTokens.TokenNameRestrictedIdentifierpermits, + TerminalTokens.TokenNameRestrictedIdentifierYield,}; + int i = -1; + for (char [] id : ids) { + i++; + int t = TerminalTokens.getRestrictedKeyword(id); + assertTrue(t != TerminalTokens.TokenNameNotAToken); + assertTrue(TerminalTokens.isRestrictedKeyword(t)); + assertTrue(t == reskw[i]); + } + assertTrue(TerminalTokens.getRestrictedKeyword("When".toCharArray()) == TerminalTokens.TokenNameNotAToken); + assertTrue(TerminalTokens.getRestrictedKeyword("blah".toCharArray()) == TerminalTokens.TokenNameNotAToken); + } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypesTests.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypesTests.java index 6d6c04c091..7321384dd5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypesTests.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypesTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2022 IBM Corporation and others. + * Copyright (c) 2020, 2023 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 @@ -31,7 +31,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 { static { // TESTS_NUMBERS = new int [] { 40 }; // TESTS_RANGE = new int[] { 1, -1 }; -// TESTS_NAMES = new String[] { "testBug564638_056"}; +// TESTS_NAMES = new String[] { "testBug564498_6"}; } public static Class testClass() { @@ -1611,12 +1611,7 @@ public void testBug564498_5() throws IOException, ClassFormatException { "}", }, "----------\n" + - "1. ERROR in p1\\X.java (at line 6)\n" + - " sealed class Y extends X permits SubInnerY {\n" + - " ^^^^^^^^^\n" + - "SubInnerY cannot be resolved to a type\n" + - "----------\n" + - "2. ERROR in p1\\X.java (at line 7)\n" + + "1. ERROR in p1\\X.java (at line 7)\n" + " final class SubInnerY extends Y {}\n" + " ^\n" + "The type SubInnerY extending a sealed class A.Y should be a permitted subtype of A.Y\n" + @@ -5711,12 +5706,7 @@ public void testBug573450_005() { "}" }, "----------\n" - + "1. ERROR in X.java (at line 1)\n" - + " public sealed class X permits Y {\n" - + " ^\n" - + "Y cannot be resolved to a type\n" - + "----------\n" - + "2. ERROR in X.java (at line 2)\n" + + "1. ERROR in X.java (at line 2)\n" + " final class Y extends X {}\n" + " ^\n" + "The type Y extending a sealed class X should be a permitted subtype of X\n" diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java index d76b71d28d..96a3cf3582 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java @@ -498,46 +498,46 @@ public void test013() { " public static class WW { public static final int WWW = 0; }\n" + "}\n", }, - "----------\n" + - "1. ERROR in X.java (at line 6)\n" + - " import static p.Y.Zz;\n" + - " ^^^^^^\n" + - "The import p.Y.Zz cannot be resolved\n" + - "----------\n" + - "2. ERROR in X.java (at line 7)\n" + - " import static p.Z.Zz.WW.*;\n" + - " ^^^^^^^^^\n" + - "The import p.Z.Zz.WW cannot be resolved\n" + - "----------\n" + - "3. ERROR in X.java (at line 8)\n" + - " import p.Y.ZZ;\n" + - " ^^^^^^\n" + - "The import p.Y.ZZ cannot be resolved\n" + - "----------\n" + - "4. ERROR in X.java (at line 9)\n" + - " import static p.Y.ZZ.*;\n" + - " ^^^^^^\n" + - "The import p.Y.ZZ cannot be resolved\n" + - "----------\n" + - "5. ERROR in X.java (at line 10)\n" + - " import static p.Y.ZZ.WW;\n" + - " ^^^^^^\n" + - "The import p.Y.ZZ cannot be resolved\n" + - "----------\n" + - "6. ERROR in X.java (at line 11)\n" + - " import static p.Y.ZZ.WW.*;\n" + - " ^^^^^^\n" + - "The import p.Y.ZZ cannot be resolved\n" + - "----------\n" + - "7. ERROR in X.java (at line 12)\n" + - " import static p.Y.ZZ.ZZZ;\n" + - " ^^^^^^\n" + - "The import p.Y.ZZ cannot be resolved\n" + - "----------\n" + - "8. ERROR in X.java (at line 13)\n" + - " import static p.Y.ZZ.WW.WWW;\n" + - " ^^^^^^\n" + - "The import p.Y.ZZ cannot be resolved\n" + + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " import static p.Y.Zz;\n" + + " ^^^^^^\n" + + "The import p.Y.Zz cannot be resolved\n" + + "----------\n" + + "2. ERROR in X.java (at line 7)\n" + + " import static p.Z.Zz.WW.*;\n" + + " ^^^^^^^^^\n" + + "The import p.Z.Zz.WW cannot be resolved\n" + + "----------\n" + + "3. ERROR in X.java (at line 8)\n" + + " import p.Y.ZZ;\n" + + " ^^^^^^\n" + + "The import p.Y.ZZ cannot be resolved\n" + + "----------\n" + + "4. ERROR in X.java (at line 9)\n" + + " import static p.Y.ZZ.*;\n" + + " ^^^^^^\n" + + "The import p.Y.ZZ cannot be resolved\n" + + "----------\n" + + "5. ERROR in X.java (at line 10)\n" + + " import static p.Y.ZZ.WW;\n" + + " ^^^^^^\n" + + "The import p.Y.ZZ cannot be resolved\n" + + "----------\n" + + "6. ERROR in X.java (at line 11)\n" + + " import static p.Y.ZZ.WW.*;\n" + + " ^^^^^^\n" + + "The import p.Y.ZZ cannot be resolved\n" + + "----------\n" + + "7. ERROR in X.java (at line 12)\n" + + " import static p.Y.ZZ.ZZZ;\n" + + " ^^^^^^\n" + + "The import p.Y.ZZ cannot be resolved\n" + + "----------\n" + + "8. ERROR in X.java (at line 13)\n" + + " import static p.Y.ZZ.WW.WWW;\n" + + " ^^^^^^\n" + + "The import p.Y.ZZ cannot be resolved\n" + "----------\n" ); } @@ -827,18 +827,18 @@ public void test022() { // test field/method collisions "package p;\n" + "public class B { public static int F = 2; }\n", }, - this.complianceLevel < ClassFileConstants.JDK1_8 ? + this.complianceLevel < ClassFileConstants.JDK1_8 ? "----------\n" + "1. ERROR in X.java (at line 2)\n" + " import static p.B.F;\n" + " ^^^^^\n" + "The import p.B.F collides with another import statement\n" + "----------\n" : - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " int i = F;\n" + - " ^\n" + - "The field F is ambiguous\n" + + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " int i = F;\n" + + " ^\n" + + "The field F is ambiguous\n" + "----------\n" // F is already defined in a single-type import ); @@ -2426,51 +2426,51 @@ public void test070() { this.runConformTest( new String[] { "node/Test.java",//------------------------------ - "package node;\n" + - "public class Test {\n" + - " public static void node() {}\n" + + "package node;\n" + + "public class Test {\n" + + " public static void node() {}\n" + "}\n", "node2/Test2.java",//------------------------------ - "package node2;\n" + - "import static node.Test.node;\n" + - "public class Test2 {\n" + + "package node2;\n" + + "import static node.Test.node;\n" + + "public class Test2 {\n" + "}\n", }, ""); - } + } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=250211 - variation public void test071() { this.runNegativeTest( new String[] { "node/Test/node.java",//------------------------------ - "package node.Test;\n" + - "public class node {\n" + - "}\n", + "package node.Test;\n" + + "public class node {\n" + + "}\n", "node/Test.java",//------------------------------ - "package node;\n" + - "public class Test {\n" + - " public static void node() {}\n" + + "package node;\n" + + "public class Test {\n" + + " public static void node() {}\n" + "}\n", "node2/Test2.java",//------------------------------ - "package node2;\n" + + "package node2;\n" + "import node.Test;\n" + - "import static Test.node;\n" + - "public class Test2 {\n" + - "}\n", - }, - "----------\n" + - "1. ERROR in node\\Test.java (at line 2)\n" + - " public class Test {\n" + - " ^^^^\n" + - "The type Test collides with a package\n" + - "----------\n" + - "----------\n" + - "1. ERROR in node2\\Test2.java (at line 3)\n" + - " import static Test.node;\n" + - " ^^^^\n" + - "The import Test cannot be resolved\n" + + "import static Test.node;\n" + + "public class Test2 {\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in node\\Test.java (at line 2)\n" + + " public class Test {\n" + + " ^^^^\n" + + "The type Test collides with a package\n" + + "----------\n" + + "----------\n" + + "1. ERROR in node2\\Test2.java (at line 3)\n" + + " import static Test.node;\n" + + " ^^^^\n" + + "The import Test cannot be resolved\n" + "----------\n"); - } + } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=93913 - variation public void test072() { this.runNegativeTest( @@ -2499,57 +2499,57 @@ public void test072() { " public static int B;\n" + "}\n", }, - "----------\n" + - "1. ERROR in p1\\A.java (at line 6)\n" + - " int v1 = b.fooB;\n" + - " ^^^^\n" + - "fooB cannot be resolved or is not a field\n" + + "----------\n" + + "1. ERROR in p1\\A.java (at line 6)\n" + + " int v1 = b.fooB;\n" + + " ^^^^\n" + + "fooB cannot be resolved or is not a field\n" + "----------\n"); - } + } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=256375 public void test073() { this.runNegativeTest( new String[] { "test/Outer.java", - "package test;\n" + - "import static test.Outer.Inner.VALUE;\n" + - "public class Outer {\n" + - " int i = VALUE;\n" + - " int i2 = Inner.VALUE;\n" + - " static class Inner {\n" + - " private static final int VALUE = 0;\n" + - " }\n" + - "}\n", - }, - "----------\n" + - "1. ERROR in test\\Outer.java (at line 2)\n" + - " import static test.Outer.Inner.VALUE;\n" + - " ^^^^^^^^^^^^^^^^^^^^^^\n" + - "The field Outer.Inner.test.Outer.Inner.VALUE is not visible\n" + - "----------\n" + - "2. ERROR in test\\Outer.java (at line 4)\n" + - " int i = VALUE;\n" + - " ^^^^^\n" + - "VALUE cannot be resolved to a variable\n" + + "package test;\n" + + "import static test.Outer.Inner.VALUE;\n" + + "public class Outer {\n" + + " int i = VALUE;\n" + + " int i2 = Inner.VALUE;\n" + + " static class Inner {\n" + + " private static final int VALUE = 0;\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in test\\Outer.java (at line 2)\n" + + " import static test.Outer.Inner.VALUE;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^\n" + + "The field Outer.Inner.test.Outer.Inner.VALUE is not visible\n" + + "----------\n" + + "2. ERROR in test\\Outer.java (at line 4)\n" + + " int i = VALUE;\n" + + " ^^^^^\n" + + "VALUE cannot be resolved to a variable\n" + "----------\n"); - } + } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=256375 - variation public void test074() { this.runConformTest( new String[] { "test/Outer.java", - "package test;\n" + - "import static test.Outer.Inner.*;\n" + - "public class Outer {\n" + - " int i = VALUE;\n" + - " int i2 = Inner.VALUE;\n" + - " static class Inner {\n" + - " private static final int VALUE = 0;\n" + - " }\n" + + "package test;\n" + + "import static test.Outer.Inner.*;\n" + + "public class Outer {\n" + + " int i = VALUE;\n" + + " int i2 = Inner.VALUE;\n" + + " static class Inner {\n" + + " private static final int VALUE = 0;\n" + + " }\n" + "}\n", }, ""); - } + } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=302865 // To verify that a static import importing a type which has already been // imported by a single type import is reported as duplicate @@ -2613,28 +2613,28 @@ public void test077() { this.runConformTest( new String[] { "p1/X.java", - "package p1;\n" + - "import p2.A;\n" + - "import static p2.A.C;\n" + - "import static p1.B.C;\n" + - "public class X {\n" + - " public static void main(String[] args) {\n" + - " foo();\n" + - " }\n" + - " public static void foo() {\n" + - " if (C.CONST == 1) {\n" + + "package p1;\n" + + "import p2.A;\n" + + "import static p2.A.C;\n" + + "import static p1.B.C;\n" + + "public class X {\n" + + " public static void main(String[] args) {\n" + + " foo();\n" + + " }\n" + + " public static void foo() {\n" + + " if (C.CONST == 1) {\n" + " System.out.println(\"SUCCESS\");\n" + - " return;\n" + - " }\n" + - " System.out.println(\"FAILED\");\n" + - " }\n" + - "}\n" + + " return;\n" + + " }\n" + + " System.out.println(\"FAILED\");\n" + + " }\n" + + "}\n" + "class B extends A {}", "p2/A.java", - "package p2;\n" + - "public class A {\n" + - " public static class C {\n" + - " public static int CONST = 1;\n" + + "package p2;\n" + + "public class A {\n" + + " public static class C {\n" + + " public static int CONST = 1;\n" + " }\n" + "}" }, @@ -2666,11 +2666,11 @@ public void test078() { " }\n" + "}\n", }, - "----------\n" + - "1. ERROR in A\\A.java (at line 3)\n" + - " import B.B.C1;\n" + - " ^^^^^^\n" + - "The import B.B.C1 collides with another import statement\n" + + "----------\n" + + "1. ERROR in A\\A.java (at line 3)\n" + + " import B.B.C1;\n" + + " ^^^^^^\n" + + "The import B.B.C1 collides with another import statement\n" + "----------\n" ); } @@ -2695,11 +2695,11 @@ public void test079() { " public static class C1 {}\n" + "}\n", }, - "----------\n" + - "1. WARNING in A\\A.java (at line 2)\n" + - " import static B.B.C1;\n" + - " ^^^^^^\n" + - "The import B.B.C1 is never used\n" + + "----------\n" + + "1. WARNING in A\\A.java (at line 2)\n" + + " import static B.B.C1;\n" + + " ^^^^^^\n" + + "The import B.B.C1 is never used\n" + "----------\n" ); } @@ -2708,31 +2708,31 @@ public void test080() { this.runNegativeTest( new String[] { "a/B.java", - "package a;\n" + + "package a;\n" + "public class B {}", "external/Lib.java", - "package external;\n" + - "public class Lib {\n" + - " public static void m() {}\n" + + "package external;\n" + + "public class Lib {\n" + + " public static void m() {}\n" + "}", "a/B/C.java", - "package a.B;\n" + - "import static external.Lib.m;\n" + - "public class C {\n" + - " public void main() {\n" + - " m();\n" + - " }\n" + + "package a.B;\n" + + "import static external.Lib.m;\n" + + "public class C {\n" + + " public void main() {\n" + + " m();\n" + + " }\n" + "}" }, - "----------\n" + - "1. ERROR in a\\B\\C.java (at line 1)\n" + - " package a.B;\n" + - " ^^^\n" + - "The package a.B collides with a type\n" + + "----------\n" + + "1. ERROR in a\\B\\C.java (at line 1)\n" + + " package a.B;\n" + + " ^^^\n" + + "The package a.B collides with a type\n" + "----------\n" ); } - + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=318401 public void test081() { this.runConformTest( @@ -2773,7 +2773,7 @@ public void test081() { }, "1 + 1 = 2"); } - + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=318401 public void test082() { this.runNegativeTest( @@ -2814,13 +2814,13 @@ public void test082() { "}\n", }, "----------\n" + - "1. ERROR in p2\\Test.java (at line 15)\n" + - " int abc = b.a;\n" + - " ^\n" + - "a cannot be resolved or is not a field\n" + + "1. ERROR in p2\\Test.java (at line 15)\n" + + " int abc = b.a;\n" + + " ^\n" + + "a cannot be resolved or is not a field\n" + "----------\n"); } - + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=318401 public void test083() { this.runConformTest( @@ -2854,12 +2854,12 @@ public void test083() { " }\n" + "}\n" }, - "random\n" + - "random\n" + - "p1.Bar.B\n" + + "random\n" + + "random\n" + + "p1.Bar.B\n" + "p1.Bar.B"); } - + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=318401 // Check if we're able to find the correct static member type being imported, // even though the import originally resolved to the static field of the same name, @@ -2898,7 +2898,7 @@ public void test084() { " }\n" + "}\n" }, - "p1.Bar.B\n" + + "p1.Bar.B\n" + "p1.Bar.B"); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=361327 @@ -2931,20 +2931,20 @@ public void test085() { " }\n" + "}\n" }, - this.complianceLevel < ClassFileConstants.JDK1_8 ? - "----------\n" + - "1. ERROR in Test.java (at line 2)\n" + - " import static p3.Foo.B;\n" + - " ^^^^^^^^\n" + - "The import p3.Foo.B collides with another import statement\n" + - "----------\n" : - "----------\n" + - "1. ERROR in Test.java (at line 7)\n" + - " System.out.println(B.class.getCanonicalName().toString());\n" + - " ^\n" + - "The type B is ambiguous\n" + + this.complianceLevel < ClassFileConstants.JDK1_8 ? + "----------\n" + + "1. ERROR in Test.java (at line 2)\n" + + " import static p3.Foo.B;\n" + + " ^^^^^^^^\n" + + "The import p3.Foo.B collides with another import statement\n" + + "----------\n" : + "----------\n" + + "1. ERROR in Test.java (at line 7)\n" + + " System.out.println(B.class.getCanonicalName().toString());\n" + + " ^\n" + + "The type B is ambiguous\n" + "----------\n" - + ); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=361327 @@ -2983,14 +2983,14 @@ public void test085a() { " }\n" + "}\n" }, - "----------\n" + - "1. ERROR in Test.java (at line 2)\n" + - " import static p3.Foo.B;\n" + - " ^^^^^^^^\n" + - "The import p3.Foo.B collides with another import statement\n" + + "----------\n" + + "1. ERROR in Test.java (at line 2)\n" + + " import static p3.Foo.B;\n" + + " ^^^^^^^^\n" + + "The import p3.Foo.B collides with another import statement\n" + "----------\n"); } - + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=361327 // To verify that all static members are imported with a single static import statement // this tests checks collision with single type import @@ -3022,14 +3022,14 @@ public void test085b() { " }\n" + "}\n" }, - "----------\n" + - "1. ERROR in Test.java (at line 2)\n" + - " import p3.Foo.B;\n" + - " ^^^^^^^^\n" + - "The import p3.Foo.B collides with another import statement\n" + + "----------\n" + + "1. ERROR in Test.java (at line 2)\n" + + " import p3.Foo.B;\n" + + " ^^^^^^^^\n" + + "The import p3.Foo.B collides with another import statement\n" + "----------\n"); } - + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=361327 // To verify that all static members are imported with a single static import statement // this tests checks collision with top level type @@ -3056,14 +3056,14 @@ public void test085c() { " public static String B = new String(\"random\");\n" + "}\n", }, - "----------\n" + - "1. ERROR in Test.java (at line 1)\n" + - " import static p1.Bar.B;\n" + - " ^^^^^^^^\n" + - "The import p1.Bar.B conflicts with a type defined in the same file\n" + + "----------\n" + + "1. ERROR in Test.java (at line 1)\n" + + " import static p1.Bar.B;\n" + + " ^^^^^^^^\n" + + "The import p1.Bar.B conflicts with a type defined in the same file\n" + "----------\n"); } - + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=361327 // Test obscuring rules defined in JLS 7.5.3 public void test086() { @@ -3094,7 +3094,7 @@ public void test086() { " public static String B = new String(\"Foo's field B\");\n" + "}\n" }, - "Bar\'s method B\n" + + "Bar\'s method B\n" + "Bar\'s field B"); } @@ -3107,24 +3107,24 @@ public void testBug401271() { "public class a {}\n", "a/b/c/C.java", "package a.b.c;\n" + - "public class C {\n" + - " public static final int a = 3;\n" + + "public class C {\n" + + " public static final int a = 3;\n" + "}\n", "x/y/R.java", - "package x.y;\n" + - "import static a.b.c.C.a;\n" + - "//import a.b.c.a;\n" + - "\n" + - "public class R { \n" + - " a b; \n" + - " char h = a; \n" + + "package x.y;\n" + + "import static a.b.c.C.a;\n" + + "//import a.b.c.a;\n" + + "\n" + + "public class R { \n" + + " a b; \n" + + " char h = a; \n" + "}" }, - "----------\n" + - "1. ERROR in x\\y\\R.java (at line 6)\n" + - " a b; \n" + - " ^\n" + - "a cannot be resolved to a type\n" + + "----------\n" + + "1. ERROR in x\\y\\R.java (at line 6)\n" + + " a b; \n" + + " ^\n" + + "a cannot be resolved to a type\n" + "----------\n"); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=426544 - [1.8][compiler] Compiler over-eagerly detects collision of single static imports @@ -3146,50 +3146,50 @@ public void test426544() { " public static class I {}\n" + "}\n", "X.java", - "import static p.X.f;\n" + - "import static q.X.f;\n" + - "import static p.X.C;\n" + - "import static p.X.I;\n" + - "import static q.X.C;\n" + - "import static q.X.I;\n" + - "public class X { \n" + + "import static p.X.f;\n" + + "import static q.X.f;\n" + + "import static p.X.C;\n" + + "import static p.X.I;\n" + + "import static q.X.C;\n" + + "import static q.X.I;\n" + + "public class X { \n" + " { f = 0; }\n" + " { C c = null; }\n" + " { I i = null; }\n" + "}\n" }, - this.complianceLevel < ClassFileConstants.JDK1_8 ? - "----------\n" + - "1. ERROR in X.java (at line 2)\n" + - " import static q.X.f;\n" + - " ^^^^^\n" + - "The import q.X.f collides with another import statement\n" + - "----------\n" + - "2. ERROR in X.java (at line 5)\n" + - " import static q.X.C;\n" + - " ^^^^^\n" + - "The import q.X.C collides with another import statement\n" + - "----------\n" + - "3. ERROR in X.java (at line 6)\n" + - " import static q.X.I;\n" + - " ^^^^^\n" + - "The import q.X.I collides with another import statement\n" + + this.complianceLevel < ClassFileConstants.JDK1_8 ? + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " import static q.X.f;\n" + + " ^^^^^\n" + + "The import q.X.f collides with another import statement\n" + + "----------\n" + + "2. ERROR in X.java (at line 5)\n" + + " import static q.X.C;\n" + + " ^^^^^\n" + + "The import q.X.C collides with another import statement\n" + + "----------\n" + + "3. ERROR in X.java (at line 6)\n" + + " import static q.X.I;\n" + + " ^^^^^\n" + + "The import q.X.I collides with another import statement\n" + "----------\n" : - "----------\n" + - "1. ERROR in X.java (at line 8)\n" + - " { f = 0; }\n" + - " ^\n" + - "The field f is ambiguous\n" + - "----------\n" + - "2. ERROR in X.java (at line 9)\n" + - " { C c = null; }\n" + - " ^\n" + - "The type C is ambiguous\n" + - "----------\n" + - "3. ERROR in X.java (at line 10)\n" + - " { I i = null; }\n" + - " ^\n" + - "The type I is ambiguous\n" + + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " { f = 0; }\n" + + " ^\n" + + "The field f is ambiguous\n" + + "----------\n" + + "2. ERROR in X.java (at line 9)\n" + + " { C c = null; }\n" + + " ^\n" + + "The type C is ambiguous\n" + + "----------\n" + + "3. ERROR in X.java (at line 10)\n" + + " { I i = null; }\n" + + " ^\n" + + "The type I is ambiguous\n" + "----------\n"); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=479287 @@ -3198,30 +3198,30 @@ public void testBug479287() { this.runConformTest( new String[] { "joetest/GenericsIssue.java", - "package joetest;\n" + - "import static joetest.GenericsIssueCollaborator.takesAnything;\n" + - "import java.util.Collection;\n" + - "import java.util.Collections;\n" + - "public class GenericsIssue {\n" + - " private void oddCompileError() {\n" + - " takesAnything(returnThings(\"works without wildcard in return value\"));\n" + - " GenericsIssueCollaborator.takesAnything(returnThingsWildcard(\"works without static import\"));\n" + - " takesAnything(returnThingsWildcard(\"doesn\'t work with static import\"));\n" + - " }\n" + - " private Collection returnThings(T thing) {\n" + - " return Collections.singleton(thing);\n" + - " }\n" + - " \n" + - " private Collection returnThingsWildcard(T toReturn) {\n" + - " return Collections.singleton(toReturn);\n" + - " }\n" + + "package joetest;\n" + + "import static joetest.GenericsIssueCollaborator.takesAnything;\n" + + "import java.util.Collection;\n" + + "import java.util.Collections;\n" + + "public class GenericsIssue {\n" + + " private void oddCompileError() {\n" + + " takesAnything(returnThings(\"works without wildcard in return value\"));\n" + + " GenericsIssueCollaborator.takesAnything(returnThingsWildcard(\"works without static import\"));\n" + + " takesAnything(returnThingsWildcard(\"doesn\'t work with static import\"));\n" + + " }\n" + + " private Collection returnThings(T thing) {\n" + + " return Collections.singleton(thing);\n" + + " }\n" + + " \n" + + " private Collection returnThingsWildcard(T toReturn) {\n" + + " return Collections.singleton(toReturn);\n" + + " }\n" + "}", "joetest/GenericsIssueCollaborator.java", - "package joetest;\n" + - "public class GenericsIssueCollaborator {\n" + - " public static void takesAnything(T thing) {\n" + - " System.out.println(\"TOOK IT: \" + thing);\n" + - " }\n" + + "package joetest;\n" + + "public class GenericsIssueCollaborator {\n" + + " public static void takesAnything(T thing) {\n" + + " System.out.println(\"TOOK IT: \" + thing);\n" + + " }\n" + "}" }); } @@ -3230,30 +3230,30 @@ public void testBug479287() { public void testBug442580() { this.runConformTest(new String [] { "a/A.java", - "package a;\n" + - "\n" + - "public class A {\n" + - " public static void foo() {\n" + - " System.out.println(\"A.foo\");\n" + - " }\n" + + "package a;\n" + + "\n" + + "public class A {\n" + + " public static void foo() {\n" + + " System.out.println(\"A.foo\");\n" + + " }\n" + "}", "b/B.java", - "package b;\n" + - "\n" + - "public class B {\n" + - " public static void foo() {\n" + - " System.out.println(\"B.foo\");\n" + - " }\n" + + "package b;\n" + + "\n" + + "public class B {\n" + + " public static void foo() {\n" + + " System.out.println(\"B.foo\");\n" + + " }\n" + "}", "Test.java", - "import static a.A.*;\n" + - "import static b.B.*;\n" + - "import static b.B.foo;\n" + - "\n" + - "public class Test {\n" + - " public static void main(String[] args) {\n" + - " foo();\n" + - " }\n" + + "import static a.A.*;\n" + + "import static b.B.*;\n" + + "import static b.B.foo;\n" + + "\n" + + "public class Test {\n" + + " public static void main(String[] args) {\n" + + " foo();\n" + + " }\n" + "}" }); } @@ -3272,21 +3272,21 @@ public void testBug520874a() { " static class Outer {\n" + " private static interface Inner {}\n" + " }\n" + - " static class AnotherOuter {\n" + - " private static class Inner {}\n" + - " }\n" + + " static class AnotherOuter {\n" + + " private static class Inner {}\n" + + " }\n" + "}\n" }, - "----------\n" + - "1. ERROR in p\\X.java (at line 3)\n" + - " import static p.A1.AnotherOuter.Inner;\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^\n" + - "The type p.A1.AnotherOuter.Inner is not visible\n" + - "----------\n" + - "2. ERROR in p\\X.java (at line 6)\n" + - " static class Outer {\n" + - " ^^^^^\n" + - "The type Inner is not visible\n" + + "----------\n" + + "1. ERROR in p\\X.java (at line 3)\n" + + " import static p.A1.AnotherOuter.Inner;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^\n" + + "The type p.A1.AnotherOuter.Inner is not visible\n" + + "----------\n" + + "2. ERROR in p\\X.java (at line 6)\n" + + " static class Outer {\n" + + " ^^^^^\n" + + "The type Inner is not visible\n" + "----------\n"); } public void testBug520874b() { @@ -3305,11 +3305,11 @@ public void testBug520874b() { " }\n" + "}\n" }, - "----------\n" + - "1. ERROR in p\\X.java (at line 5)\n" + - " static class Outer {\n" + - " ^^^^^\n" + - "The type Inner is not visible\n" + + "----------\n" + + "1. ERROR in p\\X.java (at line 5)\n" + + " static class Outer {\n" + + " ^^^^^\n" + + "The type Inner is not visible\n" + "----------\n"); } public void testBug520874c() { @@ -3327,31 +3327,31 @@ public void testBug520874c() { " static class Outer {\n" + " private static interface Inner {}\n" + " }\n" + - " static class AnotherOuter {\n" + - " private static class Inner {}\n" + - " }\n" + + " static class AnotherOuter {\n" + + " private static class Inner {}\n" + + " }\n" + "}\n" }, - "----------\n" + - "1. ERROR in p\\X.java (at line 2)\n" + - " import static p.A1.Outer.Inner;\n" + - " ^^^^^^^^^^^^^^^^\n" + - "The type p.A1.Outer.Inner is not visible\n" + - "----------\n" + - "2. ERROR in p\\X.java (at line 3)\n" + - " import static p.A1.AnotherOuter.Inner;\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^\n" + - "The type p.A1.AnotherOuter.Inner is not visible\n" + - "----------\n" + - "3. ERROR in p\\X.java (at line 6)\n" + - " static class Outer {\n" + - " ^^^^^\n" + - "Inner cannot be resolved to a type\n" + - "----------\n" + - "4. ERROR in p\\X.java (at line 9)\n" + - " static class AnotherOuter {\n" + - " ^^^^^\n" + - "Inner cannot be resolved to a type\n" + + "----------\n" + + "1. ERROR in p\\X.java (at line 2)\n" + + " import static p.A1.Outer.Inner;\n" + + " ^^^^^^^^^^^^^^^^\n" + + "The type p.A1.Outer.Inner is not visible\n" + + "----------\n" + + "2. ERROR in p\\X.java (at line 3)\n" + + " import static p.A1.AnotherOuter.Inner;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^\n" + + "The type p.A1.AnotherOuter.Inner is not visible\n" + + "----------\n" + + "3. ERROR in p\\X.java (at line 6)\n" + + " static class Outer {\n" + + " ^^^^^\n" + + "Inner cannot be resolved to a type\n" + + "----------\n" + + "4. ERROR in p\\X.java (at line 9)\n" + + " static class AnotherOuter {\n" + + " ^^^^^\n" + + "Inner cannot be resolved to a type\n" + "----------\n"); } public void testBug520874d() { @@ -3374,16 +3374,16 @@ public void testBug520874d() { " public static class Inner {}\n" + "}\n" }, - "----------\n" + - "1. WARNING in p\\X.java (at line 2)\n" + - " import static p.A.B.Inner;\n" + - " ^^^^^^^^^^^\n" + - "The import p.A.B.Inner is never used\n" + - "----------\n" + - "2. WARNING in p\\X.java (at line 3)\n" + - " import p.Bar.Inner;\n" + - " ^^^^^^^^^^^\n" + - "The import p.Bar.Inner is never used\n" + + "----------\n" + + "1. WARNING in p\\X.java (at line 2)\n" + + " import static p.A.B.Inner;\n" + + " ^^^^^^^^^^^\n" + + "The import p.A.B.Inner is never used\n" + + "----------\n" + + "2. WARNING in p\\X.java (at line 3)\n" + + " import p.Bar.Inner;\n" + + " ^^^^^^^^^^^\n" + + "The import p.Bar.Inner is never used\n" + "----------\n"); } public void testBug520874e() { @@ -3406,16 +3406,190 @@ public void testBug520874e() { " public static class Inner {}\n" + "}\n" }, - "----------\n" + - "1. WARNING in p\\X.java (at line 2)\n" + - " import static p.A.B.Inner;\n" + - " ^^^^^^^^^^^\n" + - "The import p.A.B.Inner is never used\n" + - "----------\n" + - "2. WARNING in p\\X.java (at line 3)\n" + - " import p.Bar.*;\n" + - " ^^^^^\n" + - "The import p.Bar is never used\n" + + "----------\n" + + "1. WARNING in p\\X.java (at line 2)\n" + + " import static p.A.B.Inner;\n" + + " ^^^^^^^^^^^\n" + + "The import p.A.B.Inner is never used\n" + + "----------\n" + + "2. WARNING in p\\X.java (at line 3)\n" + + " import p.Bar.*;\n" + + " ^^^^^\n" + + "The import p.Bar is never used\n" + "----------\n"); } -} \ No newline at end of file + public void testGH809_field_a() { + Runner runner = new Runner(); + runner.testFiles = new String[] { + "p2/Client.java", + """ + package p2; + import static p1.Sub.*; + public class Client { + public static void main(String... args) { + System.out.println(ONE); + } + } + """, + "p1/Super.java", + """ + package p1; + class Super { + public static int ONE = 1; + } + """, + "p1/Sub.java", + """ + package p1; + public class Sub extends Super {} + """ + }; + runner.expectedOutputString = "1"; + runner.runConformTest(); + } + public void testGH809_field_b() { + Runner runner = new Runner(); + runner.testFiles = new String[] { + "p2/Client.java", + """ + package p2; + import static p1.Sub.ONE; + public class Client { + public static void main(String... args) { + System.out.println(ONE); + } + } + """, + "p1/Super.java", + """ + package p1; + class Super { + public static int ONE = 1; + } + """, + "p1/Sub.java", + """ + package p1; + public class Sub extends Super {} + """ + }; + runner.expectedOutputString = "1"; + runner.runConformTest(); + } + public void testGH809_field_c() { + Runner runner = new Runner(); + runner.testFiles = new String[] { + "p2/Client.java", + """ + package p2; + import p1.Sub; + public class Client { + public static void main(String... args) { + System.out.println(Sub.ONE); + } + } + """, + "p1/Super.java", + """ + package p1; + class Super { + public static int ONE = 1; + } + """, + "p1/Sub.java", + """ + package p1; + public class Sub extends Super {} + """ + }; + runner.expectedOutputString = "1"; + runner.runConformTest(); + } + public void testGH809_method_a() { + Runner runner = new Runner(); + runner.testFiles = new String[] { + "p2/Client.java", + """ + package p2; + import static p1.Sub.*; + public class Client { + public static void main(String... args) { + System.out.println(ONE()); + } + } + """, + "p1/Super.java", + """ + package p1; + class Super { + public static int ONE() { return 1; } + } + """, + "p1/Sub.java", + """ + package p1; + public class Sub extends Super {} + """ + }; + runner.expectedOutputString = "1"; + runner.runConformTest(); + } + public void testGH809_method_b() { + Runner runner = new Runner(); + runner.testFiles = new String[] { + "p2/Client.java", + """ + package p2; + import static p1.Sub.ONE; + public class Client { + public static void main(String... args) { + System.out.println(ONE()); + } + } + """, + "p1/Super.java", + """ + package p1; + class Super { + public static int ONE() { return 1; } + } + """, + "p1/Sub.java", + """ + package p1; + public class Sub extends Super {} + """ + }; + runner.expectedOutputString = "1"; + runner.runConformTest(); + } + public void testGH809_method_c() { + Runner runner = new Runner(); + runner.testFiles = new String[] { + "p2/Client.java", + """ + package p2; + import p1.Sub; + public class Client { + public static void main(String... args) { + System.out.println(Sub.ONE()); + } + } + """, + "p1/Super.java", + """ + package p1; + class Super { + public static int ONE() { return 1; } + } + """, + "p1/Sub.java", + """ + package p1; + public class Sub extends Super {} + """ + }; + runner.expectedOutputString = "1"; + runner.runConformTest(); + } +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java index 84763f0185..315455f66b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java @@ -694,7 +694,6 @@ public void testBug544073_020() { expectedProblemLog); } /* - * */ public void testBug544073_021() { String[] testFiles = new String[] { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java index f168ec7f71..6dbae7389a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest.java @@ -30,7 +30,7 @@ public class SwitchPatternTest extends AbstractRegressionTest9 { static { // TESTS_NUMBERS = new int [] { 40 }; // TESTS_RANGE = new int[] { 1, -1 }; -// TESTS_NAMES = new String[] { "testIssueExhaustiveness_005"}; +// TESTS_NAMES = new String[] { "testIssue1466_02"}; } private static String previewLevel = "21"; @@ -2886,12 +2886,20 @@ public void testBug575249_03() { " }\n"+ "}", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case (String s) -> 0;\n" + - " ^\n" + - "Syntax error, insert \":\" to complete SwitchLabel\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case (String s) -> 0; + ^^^^ + Syntax error on token "case", ( expected after this token + ---------- + 2. ERROR in X.java (at line 4) + case (String s) -> 0; + ^ + Syntax error, insert ":" to complete SwitchLabel + ---------- + """ + ); } public void testBug575249_04() { runConformTest( @@ -4490,22 +4498,29 @@ public void testBug578553_1() { + " }\n" + "}", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case (Long l) when l.toString().equals(\"0\") -> {\n" + - " ^^^^\n" + - "Syntax error on token(s), misplaced construct(s)\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " case (Long l) when l.toString().equals(\"0\") -> {\n" + - " ^^^^\n" + - "Syntax error on token \"RestrictedIdentifierWhen\", delete this token\n" + - "----------\n" + - "3. ERROR in X.java (at line 4)\n" + - " case (Long l) when l.toString().equals(\"0\") -> {\n" + - " ^\n" + - "Syntax error on token \")\", -> expected after this token\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case (Long l) when l.toString().equals("0") -> { + ^ + Syntax error on token "l", delete this token + ---------- + 2. ERROR in X.java (at line 4) + case (Long l) when l.toString().equals("0") -> { + ^^^^ + Syntax error, insert ":: IdentifierOrNew" to complete ReferenceExpression + ---------- + 3. ERROR in X.java (at line 4) + case (Long l) when l.toString().equals("0") -> { + ^^^^ + Syntax error, insert ":" to complete SwitchLabel + ---------- + 4. ERROR in X.java (at line 4) + case (Long l) when l.toString().equals("0") -> { + ^^ + Syntax error on token "->", ; expected + ---------- + """); } public void testBug578553_2() { runNegativeTest( @@ -4530,22 +4545,34 @@ public void testBug578553_2() { + " }\n" + "}", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case (Long l) when l.toString().equals(\"0\") -> {\n" + - " ^^^^\n" + - "Syntax error on token(s), misplaced construct(s)\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " case (Long l) when l.toString().equals(\"0\") -> {\n" + - " ^^^^\n" + - "Syntax error on token \"RestrictedIdentifierWhen\", delete this token\n" + - "----------\n" + - "3. ERROR in X.java (at line 4)\n" + - " case (Long l) when l.toString().equals(\"0\") -> {\n" + - " ^\n" + - "Syntax error on token \")\", -> expected after this token\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case (Long l) when l.toString().equals("0") -> { + ^ + Syntax error on token "l", delete this token + ---------- + 2. ERROR in X.java (at line 4) + case (Long l) when l.toString().equals("0") -> { + ^^^^ + Syntax error, insert ":: IdentifierOrNew" to complete ReferenceExpression + ---------- + 3. ERROR in X.java (at line 4) + case (Long l) when l.toString().equals("0") -> { + ^^^^ + Syntax error, insert ":" to complete SwitchLabel + ---------- + 4. ERROR in X.java (at line 4) + case (Long l) when l.toString().equals("0") -> { + ^^ + Syntax error on token "->", ; expected + ---------- + 5. ERROR in X.java (at line 6) + case Long l1 when l1.toString().equals(l1.toString()) -> { + ^^^^ + Syntax error on token "when", , expected + ---------- + """); } public void testBug578553_3() { runNegativeTest( @@ -4567,22 +4594,34 @@ public void testBug578553_3() { + " }\n" + "}", }, - "----------\n" + - "1. ERROR in X.java (at line 4)\n" + - " case (Long l) when l.toString().equals(\"0\") -> {\n" + - " ^^^^\n" + - "Syntax error on token(s), misplaced construct(s)\n" + - "----------\n" + - "2. ERROR in X.java (at line 4)\n" + - " case (Long l) when l.toString().equals(\"0\") -> {\n" + - " ^^^^\n" + - "Syntax error on token \"RestrictedIdentifierWhen\", delete this token\n" + - "----------\n" + - "3. ERROR in X.java (at line 4)\n" + - " case (Long l) when l.toString().equals(\"0\") -> {\n" + - " ^\n" + - "Syntax error on token \")\", -> expected after this token\n" + - "----------\n"); + """ + ---------- + 1. ERROR in X.java (at line 4) + case (Long l) when l.toString().equals("0") -> { + ^ + Syntax error on token "l", delete this token + ---------- + 2. ERROR in X.java (at line 4) + case (Long l) when l.toString().equals("0") -> { + ^^^^ + Syntax error, insert ":: IdentifierOrNew" to complete ReferenceExpression + ---------- + 3. ERROR in X.java (at line 4) + case (Long l) when l.toString().equals("0") -> { + ^^^^ + Syntax error, insert ":" to complete SwitchLabel + ---------- + 4. ERROR in X.java (at line 4) + case (Long l) when l.toString().equals("0") -> { + ^^ + Syntax error on token "->", ; expected + ---------- + 5. ERROR in X.java (at line 6) + case Long l1 when l.toString().equals(l1.toString()) -> { + ^^^^ + Syntax error on token "when", , expected + ---------- + """); } public void testBug578553_4() { runNegativeTest( @@ -6779,4 +6818,152 @@ public void testIssue1351_11() { "Cannot mix pattern with other case labels\n" + "----------\n"); } + + public void testDisambiguatedRestrictedIdentifierWhenAsFirstMethodInvokation() { + runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String argv[]) {\n" + + " when(\"Pass\");\n" + + " }\n" + + " static void when(String arg) {\n" + + " System.out.println(arg);\n" + + " }\n" + + "}" + }, + "Pass"); + } + + public void testDisambiguatedRestrictedIdentifierWhenAsFirstVariableDeclaration() { + runConformTest( + new String[] { + "when.java", + "public class when {\n" + + " public static void main(String argv[]) {\n" + + " when x = new when();\n" + + " System.out.println(x);\n" + + " }\n" + + " public String toString() {\n" + + " return \"Pass\";\n" + + " }\n" + + "}" + }, + "Pass"); + } + + public void testDisambiguatedRestrictedIdentifierWhenAsTypeInACase() { + runConformTest( + new String[] { + "when.java", + "public class when {\n" + + " public String toString() {\n" + + " return switch((Object) this) {\n" + + " case when x -> \"Pass\";\n" + + " default -> \"Fail\";\n" + + " };\n" + + " }\n" + + " public static void main(String argv[]) {\n" + + " System.out.println(new when());\n" + + " }\n" + + "}" + }, + "Pass"); + } + + public void testDisambiguatedRestrictedIdentifierWhenAfterAParenthesis() { + runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String argv[]) {\n" + + " System.out.println( (Boolean) when(true) );\n" + + " }\n" + + " static Object when(Object arg) {\n" + + " return arg;\n" + + " }\n" + + "}" + }, + "true"); + } + + public void testValidCodeWithVeryAmbiguousUsageOfWhen() { + runConformTest( + new String[] { + "when.java", + "class when {\n" + + " boolean when = true;\n" + + " static boolean when(when arg) {\n" + + " return switch(arg) {\n" + + " case when when when when.when && when.when(null) -> when.when;\n" + + " case null -> true;\n" + + " default -> false;\n" + + " };\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " System.out.println(when(new when()));\n" + + " }\n" + + "}" + }, + "true"); + } + public void testIssue1466_01() { + this.runConformTest( + new String[] { + "X.java", + """ + public class X { + + private static String foo(Integer i) { + return switch (i) { + case null -> "null"; + case Integer value when value > 0 -> value.toString(); + default -> i.toString(); + }; + } + + public static void main(String[] args) { + System.out.println(foo(0)); + } + } + + """, + }, + "0"); + } + public void testIssue1466_02() { + this.runConformTest( + new String[] { + "X.java", + """ + public class X { + public static void main(String[] args) { + constantLabelMustAppearBeforePatternInteger(-1); + constantLabelMustAppearBeforePatternInteger(0); + constantLabelMustAppearBeforePatternInteger(42); + constantLabelMustAppearBeforePatternInteger(-99); + constantLabelMustAppearBeforePatternInteger(Integer.valueOf(123)); + constantLabelMustAppearBeforePatternInteger(null); + } + static String constantLabelMustAppearBeforePatternInteger(Integer i) { + switch (i) { + case null -> System.out.println("value unavailable: " + i); + case -1, 1 -> System.out.println("absolute value 1: " + i); + case Integer value when value > 0 -> System.out.println("positive integer: " + i); + default -> System.out.println("other integer: " + i); + } + return i == null ? "null" : i.toString(); + } + } + + """, + }, + "absolute value 1: -1\n" + + "other integer: 0\n" + + "positive integer: 42\n" + + "other integer: -99\n" + + "positive integer: 123\n" + + "value unavailable: null" +); + } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java index b971f434db..72d147bc6f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java @@ -234,6 +234,7 @@ public static Test suite() { ArrayList since_21 = new ArrayList(); since_21.add(SwitchPatternTest.class); since_21.add(RecordPatternTest.class); +// since_21.add(UnnammedPatternsAndVarsTest.class); Enable after implementation. since_21.add(NullAnnotationTests18.class); // Build final test suite diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java index 0c9d879e59..baac48baea 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java @@ -27,7 +27,6 @@ * strategy is to keep this one updated and when the time comes, move this over * to the other bundle after synch-up of tests from both. * @author jay - * */ public class TextBlockTest extends AbstractRegressionTest { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java index 36982eee3c..6ac0148c4d 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java @@ -4396,6 +4396,26 @@ public void testGHIssue1063() { " at X.main(X.java:7)\n", null); } + +// https://github.com/eclipse-jdt/eclipse.jdt.core/pull/1495 +public void testGHissue1495() { + this.runConformTest( + new String[] { + "X.java", + "import java.io.*;\n" + + "interface I extends Closeable {}\n" + + "public class X {\n" + + " public static void main(String[] args) {\n" + + " try (I i = i()) {\n" + + " return;\n" + + " } finally {\n" + + " return;\n" + + " }" + + " }" + + " public static I i() { return null; }\n" + + "}\n" + }); +} public static Class testClass() { return TryWithResourcesStatementTest.class; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UnnammedPatternsAndVarsTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UnnammedPatternsAndVarsTest.java new file mode 100644 index 0000000000..47d10629c6 --- /dev/null +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UnnammedPatternsAndVarsTest.java @@ -0,0 +1,226 @@ +/******************************************************************************* + * Copyright (c) 2023 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 + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.compiler.regression; + +import java.util.Map; + +import org.eclipse.jdt.internal.compiler.batch.FileSystem; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; +import org.eclipse.jdt.internal.compiler.env.INameEnvironment; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; + +import junit.framework.Test; + +public class UnnammedPatternsAndVarsTest extends AbstractRegressionTest9 { + + private static final JavacTestOptions JAVAC_OPTIONS = new JavacTestOptions("-source 21 --enable-preview -Xlint:-preview"); + static { +// TESTS_NUMBERS = new int [] { 1 }; +// TESTS_RANGE = new int[] { 1, -1 }; +// TESTS_NAMES = new String[] { "test005" }; + } + private String extraLibPath; + public static Class testClass() { + return UnnammedPatternsAndVarsTest.class; + } + public static Test suite() { + return buildMinimalComplianceTestSuite(testClass(), F_21); + } + public UnnammedPatternsAndVarsTest(String testName){ + super(testName); + } + // Enables the tests to run individually + protected Map getCompilerOptions(boolean preview) { + Map defaultOptions = super.getCompilerOptions(); + if (preview) { + if (this.complianceLevel >= ClassFileConstants.getLatestJDKLevel()) { + defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED); + } else { + defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_21); + defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_21); + defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_21); + } + } + return defaultOptions; + } + + protected Map getCompilerOptions() { + return getCompilerOptions(true); + } + protected String[] getDefaultClassPaths() { + String[] libs = DefaultJavaRuntimeEnvironment.getDefaultClassPaths(); + if (this.extraLibPath != null) { + String[] l = new String[libs.length + 1]; + System.arraycopy(libs, 0, l, 0, libs.length); + l[libs.length] = this.extraLibPath; + return l; + } + return libs; + } + @Override + protected INameEnvironment getNameEnvironment(final String[] testFiles, String[] classPaths, Map options) { + this.classpaths = classPaths == null ? getDefaultClassPaths() : classPaths; + INameEnvironment[] classLibs = getClassLibs(false, options); + for (INameEnvironment nameEnvironment : classLibs) { + ((FileSystem) nameEnvironment).scanForModules(createParser()); + } + return new InMemoryNameEnvironment9(testFiles, this.moduleMap, classLibs); + } + @Override + protected void runConformTest(String[] testFiles, String expectedOutput) { + runConformTest(testFiles, expectedOutput, getCompilerOptions(true)); + } + @Override + protected void runConformTest(String[] testFiles, String expectedOutput, Map customOptions) { + if(!isJRE21Plus) + return; + runConformTest(testFiles, expectedOutput, customOptions, new String[] {"--enable-preview"}, JAVAC_OPTIONS); + } + protected void runConformTest( + String[] testFiles, + String expectedOutputString, + String[] classLibraries, + boolean shouldFlushOutputDirectory, + String[] vmArguments) { + runTest( + // test directory preparation + shouldFlushOutputDirectory /* should flush output directory */, + testFiles /* test files */, + // compiler options + classLibraries /* class libraries */, + null /* no custom options */, + false /* do not perform statements recovery */, + null /* no custom requestor */, + // compiler results + false /* expecting no compiler errors */, + null /* do not check compiler log */, + // runtime options + false /* do not force execution */, + vmArguments /* vm arguments */, + // runtime results + expectedOutputString /* expected output string */, + null /* do not check error string */, + // javac options + JavacTestOptions.DEFAULT /* default javac test options */); + } + protected void runNegativeTest( + String[] testFiles, + String expectedCompilerLog, + String javacLog, + String[] classLibraries, + boolean shouldFlushOutputDirectory, + Map customOptions) { + Runner runner = new Runner(); + runner.testFiles = testFiles; + runner.expectedCompilerLog = expectedCompilerLog; + runner.javacTestOptions = JAVAC_OPTIONS; + runner.customOptions = customOptions; + runner.expectedJavacOutputString = javacLog; + runner.runNegativeTest(); + } + public void _test001() { + runConformTest(new String[] { + "X.java", + "public class X {\n"+ + " public static int foo() {\n"+ + " int _ = 1;\n"+ + " return 0;\n"+ + " }\n"+ + " public static void main(String[] args) {\n"+ + " System.out.println(X.foo());\n"+ + " }\n"+ + "}" + }, + "0"); + } + // Test that pattern variables are allowed for the nested patterns (not just the outermost record pattern) + public void _test002() { + runConformTest(new String[] { + "X.java", + "@SuppressWarnings(\"preview\")\n" + + "public class X {\n"+ + " public static int foo() {\n"+ + " int _ = bar();\n"+ + " return 0;\n"+ + " }\n"+ + " public static int bar() {\n"+ + " return 0;\n"+ + " }\n"+ + " public static void main(String[] args) {\n"+ + " System.out.println(X.foo());\n"+ + " }\n"+ + "}" + }, + "0"); + } + public void _test003() { + runNegativeTest(new String[] { + "X.java", + "@SuppressWarnings(\"preview\")\n" + + "public class X {\n" + + " public static int foo() {\n"+ + " int _;\n"+ // Error should be thrown - uninitialized + " return 0;\n"+ + " }\n"+ + " public static void main(String[] args) {\n"+ + " System.out.println(X.foo());\n"+ + " }\n"+ + "}" + }, + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " int _;\\n" + + " ^\n" + + "local variable _ should be initialized\n" + + "----------\n"); + } + public void _test004() { + runNegativeTest(new String[] { + "X.java", + "@SuppressWarnings(\"preview\")\n" + + "public class X {\n" + + " public static int foo() {\n"+ + " int _ = 0;\n"+ // Error should be thrown - uninitialized + " return _;\n"+ + " }\n"+ + " public static void main(String[] args) {\n"+ + " System.out.println(X.foo());\n"+ + " }\n"+ + "}" + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " int _;\\n" + + " ^\n" + + "_ can only be used in declarations\n" + + "----------\n"); + } + public void _test005() { + runNegativeTest(new String[] { + "X.java", + "@SuppressWarnings(\"preview\")\n" + + "public class X {\n" + + " public int _;\n"+ // Error should be thrown - Field not allowed + " public static void main(String[] args) {\n"+ + " System.out.println(0);\n"+ + " }\n"+ + "}" + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " int _;\\n" + + " ^\n" + + "_ can only be used in declarations\n" + + "----------\n"); + } +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/util/JrtUtilTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/util/JrtUtilTest.java index 5ba67a3e1a..875904285e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/util/JrtUtilTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/util/JrtUtilTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022 Andrey Loskutov, and others. + * Copyright (c) 2022, 2023 Andrey Loskutov, and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -60,14 +60,14 @@ public void testGetReleaseVersion() { @Test public void testGetNewJrtFileSystem() throws Exception { int majorVersionSegment = getMajorVersionSegment(this.jdkRelease); - Object jrtSystem = JRTUtil.getJrtSystem(this.image); + Object jrtSystem = JRTUtil.getJrtSystem(this.image, null); Object jrtSystem2 = JRTUtil.getJrtSystem(this.image, String.valueOf(majorVersionSegment)); assertSame(jrtSystem, jrtSystem2); jrtSystem2 = JRTUtil.getJrtSystem(this.image, String.valueOf(majorVersionSegment-2)); assertNotSame(jrtSystem, jrtSystem2); - Object jrtSystem3 = JRTUtil.getJrtSystem(this.image); + Object jrtSystem3 = JRTUtil.getJrtSystem(this.image, null); assertSame(jrtSystem, jrtSystem3); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java index 16f9c71bbb..0dfa63eb26 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java @@ -399,7 +399,6 @@ public void acceptAST(String sourceFilePath, CompilationUnit ast) { /** * @deprecated - * @throws IOException */ public void testBug415066_001() throws IOException { File rootDir = new File(System.getProperty("java.io.tmpdir")); @@ -488,7 +487,6 @@ public void acceptAST(String sourceFilePath, CompilationUnit ast) { /** * Negative test case * @deprecated - * @throws IOException */ public void testBug415066_002() throws IOException { File rootDir = new File(System.getProperty("java.io.tmpdir")); @@ -1959,4 +1957,4 @@ public void testBug568629() throws JavaModelException { } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java index 3ef37988bf..fa061d69e9 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java @@ -653,7 +653,6 @@ public static List buildTestsList(Class evaluationTestClass, int inheritedDepth, * * Note that this lis maybe reduced using some mechanisms detailed in {@link #buildTestsList(Class)} method. * - * @param evaluationTestClass * @return a {@link Test test suite} */ public static Test buildTestSuite(Class evaluationTestClass) { @@ -667,8 +666,6 @@ public static Test buildTestSuite(Class evaluationTestClass) { * * Note that this lis maybe reduced using some mechanisms detailed in {@link #buildTestsList(Class)} method. * - * @param evaluationTestClass - * @param suiteName * @return a test suite ({@link Test}) */ public static Test buildTestSuite(Class evaluationTestClass, String suiteName) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/AbstractReader.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/AbstractReader.java index 3a2a2188a4..9e824aee6f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/AbstractReader.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/AbstractReader.java @@ -34,7 +34,6 @@ public AbstractReader(String name) { abstract protected void readerLoop(); /** * Start the thread that reads events. - * */ public void start() { this.readerThread = new Thread( diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VirtualMachine.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VirtualMachine.java index 2ebdd8acbe..89a99a4b27 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VirtualMachine.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VirtualMachine.java @@ -21,7 +21,7 @@ class J9VirtualMachine extends LocalVirtualMachine { private Process proxyProcess; private AbstractReader proxyConsoleReader; - private String proxyOutputFile; + private final String proxyOutputFile; /** * Creates a new J9VirtualMachine from the Processes that runs this VM * and its J9 Proxy and with the given info. diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/NullConsoleReader.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/NullConsoleReader.java index 6f934ec928..1fa412088a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/NullConsoleReader.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/NullConsoleReader.java @@ -21,7 +21,7 @@ */ public class NullConsoleReader extends AbstractReader { - private InputStream input; + private final InputStream input; /* * Creates a new console reader that will read from the given input stream. */ diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/ProxyConsoleReader.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/ProxyConsoleReader.java index 7411aca78d..e57f0b26f0 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/ProxyConsoleReader.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/ProxyConsoleReader.java @@ -20,7 +20,7 @@ * redirects it to a file or to the stdout if "con" is the name of the file. */ class ProxyConsoleReader extends AbstractReader { - private InputStream input; + private final InputStream input; private OutputStream output; /* * Creates a new proxy console reader that will read from the given input stream diff --git a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java index c682c68856..26dcd87bf9 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java +++ b/jdt-patch/e430/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java @@ -1533,8 +1533,6 @@ public static void zipFiles(File[] files, String zipPath) throws IOException { * Returns the compilation errors / warnings for the given CompilationResult. * * @param compilationResult the compilation result - * @param showCategory - * @param showWarningToken * @return String the problem log */ public static String getProblemLog(CompilationResult compilationResult, boolean showCategory, boolean showWarningToken) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionElementNotifier.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionElementNotifier.java index 87636feec3..3461ed9577 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionElementNotifier.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionElementNotifier.java @@ -42,7 +42,7 @@ public class CompletionElementNotifier extends SourceElementNotifier { - private ASTNode assistNode; + private final ASTNode assistNode; public CompletionElementNotifier( CompletionUnitStructureRequestor requestor, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java index 5ee2237866..d8c5d47cac 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java @@ -22,6 +22,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.codeassist; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -865,7 +867,6 @@ public void acceptPotentiallyCompatibleMethods(MethodBinding[] methods) {/* igno * all elements found matches the expected type, the completion proposals will not contains the calculated expected type * relevance. This is done to keep the overloaded method suggestions always on top in this mode as a fix for * https://bugs.eclipse.org/bugs/show_bug.cgi?id=575149 - * */ private boolean strictMatchForExtepectedType = false; @@ -1902,7 +1903,7 @@ private void buildContext( buildTokenLocationContext(context, scope, astNode, astNodeParent); if(DEBUG) { - System.out.println(context.toString()); + trace(context.toString()); } this.requestor.acceptContext(context); } @@ -2122,12 +2123,8 @@ private boolean complete( public void complete(ICompilationUnit sourceUnit, int completionPosition, int pos, ITypeRoot root) { if(DEBUG) { - System.out.print("COMPLETION IN "); //$NON-NLS-1$ - System.out.print(sourceUnit.getFileName()); - System.out.print(" AT POSITION "); //$NON-NLS-1$ - System.out.println(completionPosition); - System.out.println("COMPLETION - Source :"); //$NON-NLS-1$ - System.out.println(sourceUnit.getContents()); + trace("COMPLETION IN " + new String(sourceUnit.getFileName()) + " AT POSITION " + completionPosition); //$NON-NLS-1$//$NON-NLS-2$ + trace("COMPLETION - Source :" + new String(sourceUnit.getContents())); //$NON-NLS-1$ } if (this.monitor != null) this.monitor.beginTask(Messages.engine_completing, IProgressMonitor.UNKNOWN); this.requestor.beginReporting(); @@ -2148,8 +2145,8 @@ public void complete(ICompilationUnit sourceUnit, int completionPosition, int po // boolean completionNodeFound = false; if (parsedUnit != null) { if(DEBUG) { - System.out.println("COMPLETION - Diet AST :"); //$NON-NLS-1$ - System.out.println(parsedUnit.toString()); + trace("COMPLETION - Diet AST :"); //$NON-NLS-1$ + trace(parsedUnit.toString()); } if (parsedUnit.isModuleInfo()) { @@ -2235,11 +2232,9 @@ public void complete(ICompilationUnit sourceUnit, int completionPosition, int po if (e.astNode != null) { // if null then we found a problem in the completion node if(DEBUG) { - System.out.print("COMPLETION - Completion node : "); //$NON-NLS-1$ - System.out.println(e.astNode.toString()); + trace("COMPLETION - Completion node : " + e.astNode.toString()); //$NON-NLS-1$ if(this.parser.assistNodeParent != null) { - System.out.print("COMPLETION - Parent Node : "); //$NON-NLS-1$ - System.out.println(this.parser.assistNodeParent); + trace("COMPLETION - Parent Node : " + this.parser.assistNodeParent); //$NON-NLS-1$ } } this.lookupEnvironment.unitBeingCompleted = parsedUnit; // better resilient to further error reporting @@ -2343,8 +2338,8 @@ public void complete(ICompilationUnit sourceUnit, int completionPosition, int po this.unitScope.throwDeferredException(); parseBlockStatements(parsedUnit, this.actualCompletionPosition); if(DEBUG) { - System.out.println("COMPLETION - AST :"); //$NON-NLS-1$ - System.out.println(parsedUnit.toString()); + trace("COMPLETION - AST :"); //$NON-NLS-1$ + trace(parsedUnit.toString()); } parsedUnit.resolve(); } @@ -2353,11 +2348,9 @@ public void complete(ICompilationUnit sourceUnit, int completionPosition, int po if (e.astNode != null) { // if null then we found a problem in the completion node if(DEBUG) { - System.out.print("COMPLETION - Completion node : "); //$NON-NLS-1$ - System.out.println(e.astNode.toString()); + trace("COMPLETION - Completion node : " + e.astNode.toString()); //$NON-NLS-1$ if(this.parser.assistNodeParent != null) { - System.out.print("COMPLETION - Parent Node : "); //$NON-NLS-1$ - System.out.println(this.parser.assistNodeParent); + trace("COMPLETION - Parent Node : " + this.parser.assistNodeParent); //$NON-NLS-1$ } } this.lookupEnvironment.unitBeingCompleted = parsedUnit; // better resilient to further error reporting @@ -2407,8 +2400,7 @@ public void complete(ICompilationUnit sourceUnit, int completionPosition, int po */ } catch (IndexOutOfBoundsException | InvalidCursorLocation | AbortCompilation | CompletionNodeFound e){ // internal failure - bugs 5618 if(DEBUG) { - System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$ - e.printStackTrace(System.out); + trace("Exception caught by CompletionEngine:", e); //$NON-NLS-1$ } } finally { if(!contextAccepted) { @@ -2440,11 +2432,9 @@ private boolean completeJavadocTagInModuleInfo(CompilationUnitDeclaration parsed if (e.astNode != null) { // if null then we found a problem in the completion node if(DEBUG) { - System.out.print("COMPLETION - Completion node : "); //$NON-NLS-1$ - System.out.println(e.astNode.toString()); + trace("COMPLETION - Completion node : " + e.astNode.toString()); //$NON-NLS-1$ if(this.parser.assistNodeParent != null) { - System.out.print("COMPLETION - Parent Node : "); //$NON-NLS-1$ - System.out.println(this.parser.assistNodeParent); + trace("COMPLETION - Parent Node : " + this.parser.assistNodeParent); //$NON-NLS-1$ } } this.lookupEnvironment.unitBeingCompleted = parsedUnit; // better resilient to further error reporting @@ -2605,8 +2595,8 @@ public void complete(IType type, char[] snippet, int position, char[][] localVar typeDeclaration.fields = newFields; if(DEBUG) { - System.out.println("SNIPPET COMPLETION AST :"); //$NON-NLS-1$ - System.out.println(compilationUnit.toString()); + trace("SNIPPET COMPLETION AST :"); //$NON-NLS-1$ + trace(compilationUnit.toString()); } if (compilationUnit.types != null) { @@ -2649,8 +2639,7 @@ public void complete(IType type, char[] snippet, int position, char[][] localVar } } catch (IndexOutOfBoundsException | InvalidCursorLocation | AbortCompilation | CompletionNodeFound e){ // internal failure - bugs 5618 (added with fix of 99629) if(DEBUG) { - System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$ - e.printStackTrace(System.out); + trace("Exception caught by CompletionEngine:", e); //$NON-NLS-1$ } } catch(JavaModelException e) { // Do nothing @@ -12012,8 +12001,7 @@ public void acceptSearchMatch(SearchMatch match) { ); } catch (CoreException e) { if(DEBUG) { - System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$ - e.printStackTrace(System.out); + trace("Exception caught by CompletionEngine:", e); //$NON-NLS-1$ } } @@ -12990,8 +12978,9 @@ public void acceptSearchMatch(SearchMatch match) throws CoreException { acceptTypes(scope); } } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + trace("", e); //$NON-NLS-1$ + } } if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) { checkCancel(); @@ -13758,7 +13747,6 @@ protected boolean hasPossibleAnnotationTarget(TypeBinding typeBinding, Scope sco } /** * Returns completion string inserted inside a specified inline tag. - * @param completionName * @return char[] Completion text inclunding specified inline tag */ private char[] inlineTagCompletion(char[] completionName, char[] inlineTag) { @@ -14004,15 +13992,13 @@ private Initializer parseSnippeInitializer(char[] snippet, int position, char[][ } protected void printDebug(CategorizedProblem error) { if(CompletionEngine.DEBUG) { - System.out.print("COMPLETION - completionFailure("); //$NON-NLS-1$ - System.out.print(error); - System.out.println(")"); //$NON-NLS-1$ + trace("COMPLETION - completionFailure(" + error + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } protected void printDebug(CompletionProposal proposal){ StringBuffer buffer = new StringBuffer(); printDebug(proposal, 0, buffer); - System.out.println(buffer.toString()); + trace(buffer.toString()); } private void printDebug(CompletionProposal proposal, int tab, StringBuffer buffer){ diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionRequestorWrapper.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionRequestorWrapper.java index 99190f6855..641bfd9887 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionRequestorWrapper.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionRequestorWrapper.java @@ -28,7 +28,7 @@ public class CompletionRequestorWrapper extends CompletionRequestor { private static boolean DECODE_SIGNATURE = false; - private org.eclipse.jdt.core.ICompletionRequestor requestor; + private final org.eclipse.jdt.core.ICompletionRequestor requestor; public CompletionRequestorWrapper(org.eclipse.jdt.core.ICompletionRequestor requestor) { this.requestor = requestor; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionUnitStructureRequestor.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionUnitStructureRequestor.java index 25d3f9eed2..caee8b2e3b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionUnitStructureRequestor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionUnitStructureRequestor.java @@ -62,11 +62,11 @@ @SuppressWarnings({"rawtypes"}) public class CompletionUnitStructureRequestor extends CompilationUnitStructureRequestor { - private ASTNode assistNode; + private final ASTNode assistNode; - private Map bindingCache; - private Map elementCache; - private Map elementWithProblemCache; + private final Map bindingCache; + private final Map elementCache; + private final Map elementWithProblemCache; public CompletionUnitStructureRequestor( ICompilationUnit unit, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java index d98a1ece40..548ff0efad 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java @@ -69,13 +69,13 @@ public class InternalCompletionProposal extends CompletionProposal { /** * Kind of completion request. */ - private int completionKind; + private final int completionKind; /** * Offset in original buffer where ICodeAssist.codeComplete() was * requested. */ - private int completionLocation; + private final int completionLocation; /** * Start position (inclusive) of source range in original buffer @@ -135,7 +135,6 @@ public class InternalCompletionProposal extends CompletionProposal { * in the context. * * Defaults to null if not set. - * */ private char[][] declarationTypeVariables = null; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java index a05cb7ffeb..e316021f81 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java @@ -79,18 +79,18 @@ public ASTNode get(Binding binding) { } }; - private InternalCompletionContext completionContext; + private final InternalCompletionContext completionContext; // static data - private ITypeRoot typeRoot; - private CompilationUnitDeclaration compilationUnitDeclaration; - private LookupEnvironment lookupEnvironment; - private Scope assistScope; - private ASTNode assistNode; - private ASTNode assistNodeParent; - private WorkingCopyOwner owner; - - private CompletionParser parser; + private final ITypeRoot typeRoot; + private final CompilationUnitDeclaration compilationUnitDeclaration; + private final LookupEnvironment lookupEnvironment; + private final Scope assistScope; + private final ASTNode assistNode; + private final ASTNode assistNodeParent; + private final WorkingCopyOwner owner; + + private final CompletionParser parser; // computed data private boolean hasComputedVisibleElementBindings; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/MissingTypesGuesser.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/MissingTypesGuesser.java index f16b915641..e2bf7d336f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/MissingTypesGuesser.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/MissingTypesGuesser.java @@ -45,7 +45,7 @@ public void accept( } private static class ResolutionCleaner extends ASTVisitor { - private HashtableOfObjectToInt bitsMap = new HashtableOfObjectToInt(); + private final HashtableOfObjectToInt bitsMap = new HashtableOfObjectToInt(); private boolean firstCall = true; public ResolutionCleaner(){ @@ -167,8 +167,8 @@ public boolean visit(ParameterizedQualifiedTypeReference parameterizedQualifiedT } - private CompletionEngine.CompletionProblemFactory problemFactory ; - private SearchableEnvironment nameEnvironment; + private final CompletionEngine.CompletionProblemFactory problemFactory ; + private final SearchableEnvironment nameEnvironment; private HashMap substituedTypes; private HashMap originalTypes; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java index 30618b0348..eb32cf2b4f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java @@ -162,7 +162,7 @@ public AcceptedType(int modifiers, char[] packageName, char[] simpleTypeName, St } } - private ImportReference[] importReferences; + private final ImportReference[] importReferences; private boolean importCachesNodeInitialized = false; private ImportReference[] onDemandImportsNodeCache; @@ -170,8 +170,8 @@ public AcceptedType(int modifiers, char[] packageName, char[] simpleTypeName, St private char[][][] importsNodeCache; private int importsNodeCacheCount; - private HashtableOfObject onDemandFound = new HashtableOfObject(); - private ObjectVector notImportedFound = new ObjectVector(); + private final HashtableOfObject onDemandFound = new HashtableOfObject(); + private final ObjectVector notImportedFound = new ObjectVector(); public SelectionTypeNameMatchRequestorWrapper(TypeNameMatchRequestor requestor, IJavaSearchScope scope, ImportReference[] importReferences) { super(requestor, scope); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ThrownExceptionFinder.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ThrownExceptionFinder.java index 5847fba02d..0f4d1e66cf 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ThrownExceptionFinder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ThrownExceptionFinder.java @@ -44,9 +44,7 @@ public class ThrownExceptionFinder extends ASTVisitor { * Finds the thrown exceptions minus the ones that are already caught in previous catch blocks. * Exception is already caught even if its super type is being caught. Also computes, separately, * a list comprising of (a)those exceptions that have been caught already and (b)those exceptions that are thrown - * by the method and whose super type has been caught already. - * @param tryStatement - * @param scope + * by the method and whose super type has been caught already. */ public void processThrownExceptions(TryStatement tryStatement, BlockScope scope) { this.thrownExceptions = new SimpleSet(); @@ -107,10 +105,10 @@ public ReferenceBinding[] getAlreadyCaughtExceptions() { this.caughtExceptions.asArray(allCaughtExceptions); return allCaughtExceptions; } - + /** * Returns all the thrown exceptions minus the ones that are already caught in previous catch blocks - * (of the same try), found by the call to + * (of the same try), found by the call to * {@link ThrownExceptionFinder#processThrownExceptions(TryStatement, BlockScope)}. * @return Returns an array of thrown exceptions that are still not caught in any catch block. */ @@ -119,9 +117,9 @@ public ReferenceBinding[] getThrownUncaughtExceptions() { this.thrownExceptions.asArray(result); return result; } - + /** - * Returns all exceptions that are discouraged to use because (a) they are already caught in some inner try-catch, + * Returns all exceptions that are discouraged to use because (a) they are already caught in some inner try-catch, * or (b) their super exception has already been caught. * @return all discouraged exceptions */ @@ -174,7 +172,7 @@ public boolean visit(TryStatement tryStatement, BlockScope scope) { } return false; } - + private void removeCaughtExceptions(TryStatement tryStatement, boolean recordUncheckedCaughtExceptions) { Argument[] catchArguments = tryStatement.catchArguments; int length = catchArguments == null ? 0 : catchArguments.length; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/UnresolvedReferenceNameFinder.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/UnresolvedReferenceNameFinder.java index 2b181fa55c..948a5787e1 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/UnresolvedReferenceNameFinder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/UnresolvedReferenceNameFinder.java @@ -45,9 +45,9 @@ public static interface UnresolvedReferenceNameRequestor { private UnresolvedReferenceNameRequestor requestor; - private CompletionEngine completionEngine; - private CompletionParser parser; - private CompletionScanner completionScanner; + private final CompletionEngine completionEngine; + private final CompletionParser parser; + private final CompletionScanner completionScanner; private int parentsPtr; private ASTNode[] parents; @@ -56,7 +56,7 @@ public static interface UnresolvedReferenceNameRequestor { private char[][] potentialVariableNames; private int[] potentialVariableNameStarts; - private SimpleSetOfCharArray acceptedNames = new SimpleSetOfCharArray(); + private final SimpleSetOfCharArray acceptedNames = new SimpleSetOfCharArray(); public UnresolvedReferenceNameFinder(CompletionEngine completionEngine) { this.completionEngine = completionEngine; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionJavadoc.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionJavadoc.java index 6b9b99872f..bb5aafdc65 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionJavadoc.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionJavadoc.java @@ -37,8 +37,6 @@ public Expression getCompletionNode() { /** * Resolve selected node if not null and throw exception to let clients know * that it has been found. - * - * @throws CompletionNodeFound */ private void internalResolve(Scope scope) { if (this.completionNode != null) { @@ -161,8 +159,6 @@ public StringBuffer print(int indent, StringBuffer output) { /** * Resolve completion node if not null and throw exception to let clients know * that it has been found. - * - * @throws CompletionNodeFound */ @Override public void resolve(ClassScope scope) { @@ -173,8 +169,6 @@ public void resolve(ClassScope scope) { /** * Resolve completion node if not null and throw exception to let clients know * that it has been found. - * - * @throws CompletionNodeFound */ @Override public void resolve(CompilationUnitScope scope) { @@ -184,8 +178,6 @@ public void resolve(CompilationUnitScope scope) { /** * Resolve completion node if not null and throw exception to let clients know * that it has been found. - * - * @throws CompletionNodeFound */ @Override public void resolve(MethodScope scope) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionJavadocParser.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionJavadocParser.java index 8a82459d97..3f1fb22031 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionJavadocParser.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionJavadocParser.java @@ -22,6 +22,7 @@ import org.eclipse.jdt.internal.compiler.ast.*; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.parser.JavadocParser; +import org.eclipse.jdt.internal.compiler.parser.Scanner; import org.eclipse.jdt.internal.compiler.parser.ScannerHelper; import org.eclipse.jdt.internal.compiler.parser.TerminalTokens; @@ -581,7 +582,7 @@ protected Object parseArguments(Object receiver, boolean verifySpaceOrEndComment } // Something wrong happened => Invalid input - throw new InvalidInputException(); + throw Scanner.invalidInput(); } finally { // we have to make sure that this is reset to the previous value even if an exception occurs this.scanner.tokenizeWhiteSpace = tokenWhiteSpace; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNode.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNode.java index a83862855c..25f82af5a3 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNode.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNode.java @@ -12,10 +12,9 @@ * Gayan Perera - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.codeassist.complete; - /** * Marker interface for all completion nodes */ public interface CompletionNode { - // marker interface + // Nothing to declare } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeDetector.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeDetector.java index 3d963a1d72..696b89bff4 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeDetector.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeDetector.java @@ -25,7 +25,7 @@ public class CompletionNodeDetector extends ASTVisitor { static class FindAny extends GenericAstVisitor { - private ASTNode searchFor; + private final ASTNode searchFor; boolean found; public FindAny(ASTNode searchFor) { @@ -49,10 +49,10 @@ public static boolean findAny(CompilationUnitDeclaration unit, ASTNode searchFor @SuppressWarnings("serial") static class StopTraversal extends RuntimeException { /* no details */} - private ASTNode searchedNode; + private final ASTNode searchedNode; private ASTNode parent; private Expression outerExpression; - private Stack interestingEnclosings = new Stack<>(); + private final Stack interestingEnclosings = new Stack<>(); private ASTNode enclosingNode; private boolean result; private ASTNode blockedNode; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword1.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword1.java index 34c7849f18..d59ca2c286 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword1.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword1.java @@ -18,7 +18,7 @@ import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; public class CompletionOnKeyword1 extends SingleTypeReference implements CompletionOnKeyword { - private char[][] possibleKeywords; + private final char[][] possibleKeywords; public CompletionOnKeyword1(char[] token, long pos, char[] possibleKeyword) { this(token, pos, new char[][]{possibleKeyword}); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword2.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword2.java index 4a983baab4..32fcd6cc3c 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword2.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword2.java @@ -17,8 +17,8 @@ import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; public class CompletionOnKeyword2 extends ImportReference implements CompletionOnKeyword { - private char[] token; - private char[][] possibleKeywords; + private final char[] token; + private final char[][] possibleKeywords; public CompletionOnKeyword2(char[] token, long pos, char[][] possibleKeywords) { super(new char[][]{token}, new long[]{pos}, false, ClassFileConstants.AccDefault); this.token = token; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword3.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword3.java index 6924bb6a4e..42b606b1a5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword3.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword3.java @@ -18,8 +18,8 @@ import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; public class CompletionOnKeyword3 extends SingleNameReference implements CompletionOnKeyword { - private char[][] possibleKeywords; - private boolean tryOrCatch; + private final char[][] possibleKeywords; + private final boolean tryOrCatch; public CompletionOnKeyword3(char[] token, long pos, char[] possibleKeyword) { this(token, pos, new char[][]{possibleKeyword}, false); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeywordModule2.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeywordModule2.java index c5522ee6da..8eef66325d 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeywordModule2.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeywordModule2.java @@ -17,8 +17,8 @@ import org.eclipse.jdt.internal.compiler.ast.ModuleReference; public class CompletionOnKeywordModule2 extends ModuleReference implements CompletionOnKeyword { - private char[] token; - private char[][] possibleKeywords; + private final char[] token; + private final char[][] possibleKeywords; public CompletionOnKeywordModule2(char[] token, long pos, char[][] possibleKeywords) { super(new char[][] {token}, new long[] {pos}); // dummy diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeywordModuleDeclaration.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeywordModuleDeclaration.java index 9c867b6d94..81bf130d36 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeywordModuleDeclaration.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeywordModuleDeclaration.java @@ -7,10 +7,10 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation - * + * *******************************************************************************/ package org.eclipse.jdt.internal.codeassist.complete; @@ -18,8 +18,8 @@ public class CompletionOnKeywordModuleDeclaration extends ModuleDeclaration implements CompletionOnKeyword { - private char[] token; - private char[][] possibleKeywords; + private final char[] token; + private final char[][] possibleKeywords; public CompletionOnKeywordModuleDeclaration(char[] token, long pos, char[][] possibleKeywords) { super(null, new char[][]{token}, new long[]{pos}); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeywordModuleInfo.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeywordModuleInfo.java index ddb343acf6..cb0068da14 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeywordModuleInfo.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeywordModuleInfo.java @@ -18,14 +18,14 @@ import org.eclipse.jdt.internal.compiler.ast.ImportReference; /** - * + * * This class is independent of its parent class and is in fact a dummy ExportsStatement. Used to hook * into the existing module declaration type and is used as a placeholder for keyword completion. This can * be any module keyword completion and not necessarily related to exports statement. */ public class CompletionOnKeywordModuleInfo extends ExportsStatement implements CompletionOnKeyword { - private char[] token; - private char[][] possibleKeywords; + private final char[] token; + private final char[][] possibleKeywords; public CompletionOnKeywordModuleInfo(char[] token, long pos, char[][] possibleKeywords) { super(new ImportReference(new char[][] {token}, new long[] {pos}, false, 0), null); // dummy diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnParameterizedQualifiedTypeReference.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnParameterizedQualifiedTypeReference.java index 52397359f9..e4e1973ccf 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnParameterizedQualifiedTypeReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnParameterizedQualifiedTypeReference.java @@ -44,21 +44,10 @@ public class CompletionOnParameterizedQualifiedTypeReference extends Parameteriz private int kind = K_TYPE; public char[] completionIdentifier; - /** - * @param tokens - * @param typeArguments - * @param positions - */ public CompletionOnParameterizedQualifiedTypeReference(char[][] tokens, TypeReference[][] typeArguments, char[] completionIdentifier, long[] positions) { this(tokens, typeArguments, completionIdentifier, positions, K_TYPE); } - /** - * @param tokens - * @param typeArguments - * @param positions - * @param kind - */ public CompletionOnParameterizedQualifiedTypeReference(char[][] tokens, TypeReference[][] typeArguments, char[] completionIdentifier, long[] positions, int kind) { super(tokens, typeArguments, 0, positions); this.completionIdentifier = completionIdentifier; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java index 5587d0bba2..aba235a3b4 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java @@ -74,7 +74,6 @@ protected boolean isAtAssistIdentifier() { /* * Truncate the current identifier if it is containing the cursor location. Since completion is performed * on an identifier prefix. - * */ @Override public char[] getCurrentIdentifierSource() { @@ -364,7 +363,7 @@ protected int getNextToken0() throws InvalidInputException { { int test; if ((test = getNextChar('\n', '\r')) == 0) { - throw new InvalidInputException(INVALID_CHARACTER_CONSTANT); + throw invalidCharacter(); } if (test > 0) { // relocate if finding another quote fairly close: thus unicode '/u000D' will be fully consumed @@ -378,7 +377,7 @@ protected int getNextToken0() throws InvalidInputException { break; } } - throw new InvalidInputException(INVALID_CHARACTER_CONSTANT); + throw invalidCharacter(); } } if (getNextChar('\'')) { @@ -393,7 +392,7 @@ protected int getNextToken0() throws InvalidInputException { break; } } - throw new InvalidInputException(INVALID_CHARACTER_CONSTANT); + throw invalidCharacter(); } if (getNextChar('\\')) { if (this.unicodeAsBackSlash) { @@ -418,7 +417,7 @@ protected int getNextToken0() throws InvalidInputException { && (this.source[this.currentPosition] == 'u'); } catch(IndexOutOfBoundsException e) { this.currentPosition--; - throw new InvalidInputException(INVALID_CHARACTER_CONSTANT); + throw invalidCharacter(); } if (checkIfUnicode) { getNextUnicodeChar(); @@ -441,7 +440,7 @@ protected int getNextToken0() throws InvalidInputException { break; } } - throw new InvalidInputException(INVALID_CHARACTER_CONSTANT); + throw invalidCharacter(); case '"' : boolean isTextBlock = scanForTextBlockBeginning(); if (isTextBlock) { @@ -492,7 +491,7 @@ protected int getNextToken0() throws InvalidInputException { break; } if (this.currentCharacter == '\"') { - throw new InvalidInputException(INVALID_CHAR_IN_STRING); + throw invalidCharInString(); } } } else { @@ -503,7 +502,7 @@ protected int getNextToken0() throws InvalidInputException { return TokenNameStringLiteral; } } - throw new InvalidInputException(INVALID_CHAR_IN_STRING); + throw invalidCharInString(); } if (this.currentCharacter == '\\') { if (this.unicodeAsBackSlash) { @@ -551,7 +550,7 @@ protected int getNextToken0() throws InvalidInputException { // complete inside a string literal return TokenNameStringLiteral; } - throw new InvalidInputException(UNTERMINATED_STRING); + throw unterminatedString(); } catch (InvalidInputException e) { if (e.getMessage().equals(INVALID_ESCAPE)) { // relocate if finding another quote fairly close: thus unicode '/u000D' will be fully consumed @@ -592,7 +591,7 @@ protected int getNextToken0() throws InvalidInputException { || c3 < 0 || (c4 = ScannerHelper.getHexadecimalValue(this.source[this.currentPosition++])) > 15 || c4 < 0) { - throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + throw invalidUnicodeEscape(); } else { this.currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4); } @@ -625,7 +624,7 @@ protected int getNextToken0() throws InvalidInputException { || c3 < 0 || (c4 = ScannerHelper.getHexadecimalValue(this.source[this.currentPosition++])) > 15 || c4 < 0) { - throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + throw invalidUnicodeEscape(); } else { this.currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4); } @@ -664,7 +663,7 @@ protected int getNextToken0() throws InvalidInputException { || (c4 = ScannerHelper.getHexadecimalValue(this.source[index++])) > 15 || c4 < 0) { this.currentPosition = index; - throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + throw invalidUnicodeEscape(); } else { unicodeChar = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4); } @@ -809,7 +808,7 @@ protected int getNextToken0() throws InvalidInputException { } } catch (IndexOutOfBoundsException e) { this.currentPosition--; - throw new InvalidInputException(UNTERMINATED_COMMENT); + throw unterminatedComment(); } break; } @@ -821,7 +820,7 @@ protected int getNextToken0() throws InvalidInputException { if (atEnd()) return TokenNameEOF; //the atEnd may not be if source is only some part of a real (external) stream - throw new InvalidInputException("Ctrl-Z"); //$NON-NLS-1$ + throw invalidEof(); default : char c = this.currentCharacter; @@ -837,21 +836,21 @@ protected int getNextToken0() throws InvalidInputException { boolean isJavaIdStart; if (c >= HIGH_SURROGATE_MIN_VALUE && c <= HIGH_SURROGATE_MAX_VALUE) { if (this.complianceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + throw invalidUnicodeEscape(); } // Unicode 4 detection char low = (char) getNextChar(); if (low < LOW_SURROGATE_MIN_VALUE || low > LOW_SURROGATE_MAX_VALUE) { // illegal low surrogate - throw new InvalidInputException(INVALID_LOW_SURROGATE); + throw invalidLowSurrogate(); } isJavaIdStart = ScannerHelper.isJavaIdentifierStart(this.complianceLevel, c, low); } else if (c >= LOW_SURROGATE_MIN_VALUE && c <= LOW_SURROGATE_MAX_VALUE) { if (this.complianceLevel < ClassFileConstants.JDK1_5) { - throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + throw invalidUnicodeEscape(); } - throw new InvalidInputException(INVALID_HIGH_SURROGATE); + throw invalidHighSurrogate(); } else { // optimized case already checked isJavaIdStart = Character.isJavaIdentifierStart(c); @@ -1001,7 +1000,7 @@ protected int scanForTextBlock() throws InvalidInputException { if (lastQuotePos > 0) this.currentPosition = lastQuotePos; this.currentPosition = (lastQuotePos > 0) ? lastQuotePos : this.startPosition + this.rawStart; - throw new InvalidInputException(UNTERMINATED_TEXT_BLOCK); + throw unterminatedTextBlock(); } catch (IndexOutOfBoundsException e) { this.currentPosition = (lastQuotePos > 0) ? lastQuotePos : this.startPosition + this.rawStart; if(this.startPosition <= this.cursorLocation @@ -1009,7 +1008,7 @@ protected int scanForTextBlock() throws InvalidInputException { // complete inside a string literal return TokenNameStringLiteral; } - throw new InvalidInputException(UNTERMINATED_TEXT_BLOCK); + throw unterminatedTextBlock(); } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistAnnotation.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistAnnotation.java index 34ce4e27ec..e4ef4b97be 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistAnnotation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistAnnotation.java @@ -22,7 +22,7 @@ @SuppressWarnings("rawtypes") public class AssistAnnotation extends Annotation { - private Map infoCache; + private final Map infoCache; public AssistAnnotation(JavaElement parent, String name, Map infoCache) { super(parent, name); this.infoCache = infoCache; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistCompilationUnit.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistCompilationUnit.java index bdaa79b17a..d8900246af 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistCompilationUnit.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistCompilationUnit.java @@ -28,8 +28,8 @@ @SuppressWarnings("rawtypes") public class AssistCompilationUnit extends CompilationUnit { - private Map infoCache; - private Map bindingCache; + private final Map infoCache; + private final Map bindingCache; public AssistCompilationUnit(ICompilationUnit compilationUnit, WorkingCopyOwner owner, Map bindingCache, Map infoCache) { super((PackageFragment)compilationUnit.getParent(), compilationUnit.getElementName(), owner); this.bindingCache = bindingCache; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistImportContainer.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistImportContainer.java index 74c6e8726b..77ad37086f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistImportContainer.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistImportContainer.java @@ -23,7 +23,7 @@ @SuppressWarnings("rawtypes") public class AssistImportContainer extends ImportContainer { - private Map infoCache; + private final Map infoCache; public AssistImportContainer(CompilationUnit parent, Map infoCache) { super(parent); this.infoCache = infoCache; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistImportDeclaration.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistImportDeclaration.java index 6f3f2506a8..d03dba300d 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistImportDeclaration.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistImportDeclaration.java @@ -22,7 +22,7 @@ @SuppressWarnings("rawtypes") public class AssistImportDeclaration extends ImportDeclaration { - private Map infoCache; + private final Map infoCache; public AssistImportDeclaration(ImportContainer parent, String name, boolean isOnDemand, Map infoCache) { super(parent, name, isOnDemand); this.infoCache = infoCache; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistInitializer.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistInitializer.java index 880c40be6f..2e9e94c1c4 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistInitializer.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistInitializer.java @@ -23,8 +23,8 @@ @SuppressWarnings("rawtypes") public class AssistInitializer extends Initializer { - private Map bindingCache; - private Map infoCache; + private final Map bindingCache; + private final Map infoCache; public AssistInitializer(JavaElement parent, int count, Map bindingCache, Map infoCache) { super(parent, count); this.bindingCache = bindingCache; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistPackageDeclaration.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistPackageDeclaration.java index 5235ab3a5b..1710eb5bb3 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistPackageDeclaration.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistPackageDeclaration.java @@ -23,7 +23,7 @@ @SuppressWarnings("rawtypes") public class AssistPackageDeclaration extends PackageDeclaration { - private Map infoCache; + private final Map infoCache; public AssistPackageDeclaration(CompilationUnit parent, String name, Map infoCache) { super(parent, name); this.infoCache = infoCache; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java index 9ec0ac8682..1751ea7a78 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java @@ -18,7 +18,6 @@ /* * Parser extension for code assist task - * */ import java.util.HashSet; @@ -197,7 +196,6 @@ public Object becomeSimpleParser() { } /** * Restore the parser as an assist parser - * @param parserState */ public void restoreAssistParser(Object parserState) { //Do nothing diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistSourceField.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistSourceField.java index 3d9371267f..6bc52442fc 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistSourceField.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistSourceField.java @@ -25,8 +25,8 @@ @SuppressWarnings("rawtypes") public class AssistSourceField extends ResolvedSourceField { - private Map bindingCache; - private Map infoCache; + private final Map bindingCache; + private final Map infoCache; private String uniqueKey; private boolean isResolved; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistSourceMethod.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistSourceMethod.java index 695525ab79..89e22cf9c3 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistSourceMethod.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistSourceMethod.java @@ -26,8 +26,8 @@ @SuppressWarnings("rawtypes") public class AssistSourceMethod extends ResolvedSourceMethod { - private Map bindingCache; - private Map infoCache; + private final Map bindingCache; + private final Map infoCache; private String uniqueKey; private boolean isResolved; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistSourceType.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistSourceType.java index 3418e9e556..2f4157b96a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistSourceType.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistSourceType.java @@ -29,8 +29,8 @@ @SuppressWarnings("rawtypes") public class AssistSourceType extends ResolvedSourceType { - private Map bindingCache; - private Map infoCache; + private final Map bindingCache; + private final Map infoCache; private String uniqueKey; private boolean isResolved; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistTypeParameter.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistTypeParameter.java index b0a196960c..a92d08fbdd 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistTypeParameter.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistTypeParameter.java @@ -22,7 +22,7 @@ @SuppressWarnings("rawtypes") public class AssistTypeParameter extends TypeParameter { - private Map infoCache; + private final Map infoCache; public AssistTypeParameter(JavaElement parent, String name, Map infoCache) { super(parent, name); this.infoCache = infoCache; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadoc.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadoc.java index 8f38859824..a369fb7e96 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadoc.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadoc.java @@ -72,8 +72,6 @@ public StringBuffer print(int indent, StringBuffer output) { /** * Resolve selected node if not null and throw exception to let clients know * that it has been found. - * - * @throws SelectionNodeFound */ private void internalResolve(Scope scope) { if (this.selectedNode != null) { @@ -125,8 +123,6 @@ private void internalResolve(Scope scope) { /** * Resolve selected node if not null and throw exception to let clients know * that it has been found. - * - * @throws SelectionNodeFound */ @Override public void resolve(ClassScope scope) { @@ -136,8 +132,6 @@ public void resolve(ClassScope scope) { /** * Resolve selected node if not null and throw exception to let clients know * that it has been found. - * - * @throws SelectionNodeFound */ @Override public void resolve(MethodScope scope) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnExplicitConstructorCall.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnExplicitConstructorCall.java index 4413f63f9c..1820501f89 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnExplicitConstructorCall.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnExplicitConstructorCall.java @@ -29,7 +29,6 @@ * * } * } - * */ import org.eclipse.jdt.internal.compiler.ast.*; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldReference.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldReference.java index 4e713fba65..ccfb59f8d5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldReference.java @@ -29,7 +29,6 @@ * * } * } - * */ import org.eclipse.jdt.internal.compiler.ast.FieldReference; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnImportReference.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnImportReference.java index d2e1217928..285f20df89 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnImportReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnImportReference.java @@ -29,7 +29,6 @@ * void foo() { * } * } - * */ import org.eclipse.jdt.internal.compiler.ast.ImportReference; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnMessageSend.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnMessageSend.java index a0d3b462fa..af36d4e67e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnMessageSend.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnMessageSend.java @@ -29,7 +29,6 @@ * * } * } - * */ import org.eclipse.jdt.internal.compiler.ast.MessageSend; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageReference.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageReference.java index ef874f0f3a..53bfeca6ea 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageReference.java @@ -29,7 +29,6 @@ * void foo() { * } * } - * */ import org.eclipse.jdt.internal.compiler.ast.ImportReference; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageVisibilityReference.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageVisibilityReference.java index a3fd664ad6..db03de1bc8 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageVisibilityReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageVisibilityReference.java @@ -29,7 +29,6 @@ * module myModule { * ---> * } - * */ public class SelectionOnPackageVisibilityReference extends ImportReference { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java index d1ed320c4f..2332cfd213 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java @@ -31,7 +31,6 @@ * * } * } - * */ import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java index c6dd955ec9..1a3f66d72c 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java @@ -31,7 +31,6 @@ * * } * } - * */ import org.eclipse.jdt.core.compiler.CharOperation; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedSuperReference.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedSuperReference.java index 59003a59d8..be07c41ddb 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedSuperReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedSuperReference.java @@ -33,7 +33,6 @@ * } * } * } - * */ import org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java index 998b39392a..2669d6998a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java @@ -22,7 +22,6 @@ * class X extends java.lang.[start]Object[end] * * ---> class X extends - * */ import org.eclipse.jdt.core.compiler.CharOperation; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java index aa772a936e..b6eb937ecd 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java @@ -29,7 +29,6 @@ * * } * } - * */ import org.eclipse.jdt.internal.compiler.ast.SingleNameReference; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java index adca5ede29..db5db8e694 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java @@ -22,7 +22,6 @@ * class X extends [start]Object[end] * * ---> class X extends - * */ import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference; import org.eclipse.jdt.internal.compiler.lookup.Binding; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSuperReference.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSuperReference.java index 4e835aa07c..7b3ae9c922 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSuperReference.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSuperReference.java @@ -33,7 +33,6 @@ * } * } * } - * */ import org.eclipse.jdt.internal.compiler.ast.SuperReference; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java index 9ddd123710..a0f2cbe7be 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java @@ -386,6 +386,12 @@ protected void classInstanceCreation(boolean hasClassBody) { this.isOrphanCompletionNode = true; } else { super.classInstanceCreation(hasClassBody); + if (this.assistNode != null) { + QualifiedAllocationExpression alloc = (QualifiedAllocationExpression) this.expressionStack[this.expressionPtr]; + if (this.assistNode.sourceStart >= alloc.sourceStart && this.assistNode.sourceEnd <= alloc.sourceEnd) + this.selectionNodeFoundLevel = 1; // continue to parse until containing block statement is reduced, so as to + // ensure the type declaration makes it to the astStack (possibly as a subexpression or as an expression statement) + } } } @Override @@ -1852,9 +1858,25 @@ public CompilationUnitDeclaration parse(ICompilationUnit sourceUnit, Compilation @Override protected boolean restartRecovery() { - return requireExtendedRecovery() || this.selectionNodeFoundLevel > 0 ? - false : - super.restartRecovery(); + if (requireExtendedRecovery() || this.selectionNodeFoundLevel > 0) + return false; + boolean deferRestartOnLocalType = false; + for (int i = 0; i <= this.elementPtr; i++) { + switch (this.elementKindStack[i]) { + case K_INSIDE_STATEMENT_SWITCH: + case K_INSIDE_EXPRESSION_SWITCH: + case K_INSIDE_IF: + case K_INSIDE_WHILE: + deferRestartOnLocalType = true; + break; + case K_TYPE_DELIMITER: + if (deferRestartOnLocalType) + return false; + break; + } + } + + return super.restartRecovery(); } @Override diff --git a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionScanner.java b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionScanner.java index 2dda5ffc6e..466d78a429 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionScanner.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionScanner.java @@ -28,7 +28,6 @@ public class SelectionScanner extends Scanner { /* * Truncate the current identifier if it is containing the cursor location. Since completion is performed * on an identifier prefix. - * */ public SelectionScanner(long sourceLevel, boolean previewEnabled) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java index ecf50d2c45..1d0fd41dce 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java @@ -967,7 +967,7 @@ public static CompilationUnit parseCompilationUnit( */ int apiLevel; - private boolean previewEnabled; + private final boolean previewEnabled; /** * Tag bit value. This represents internal state of the tree. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java index 153ebaec72..865c9072fb 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java @@ -463,8 +463,6 @@ private void checkAndSetMalformed(ASTNode spannedNode, ASTNode spanningNode) { } /** * Internal access method to SwitchCase#setExpression() for avoiding deprecated warnings - * @param switchCase - * @param exp * @deprecated */ private static void internalSetExpression(SwitchCase switchCase, Expression exp) { @@ -473,8 +471,6 @@ private static void internalSetExpression(SwitchCase switchCase, Expression exp) /** * Internal access method to SingleVariableDeclaration#setExtraDimensions() for avoiding deprecated warnings * - * @param node - * @param dimensions * @deprecated */ private static void internalSetExtraDimensions(SingleVariableDeclaration node, int dimensions) { @@ -483,8 +479,6 @@ private static void internalSetExtraDimensions(SingleVariableDeclaration node, i /** * Internal access method to VariableDeclarationFragment#setExtraDimensions() for avoiding deprecated warnings * - * @param node - * @param dimensions * @deprecated */ private static void internalSetExtraDimensions(VariableDeclarationFragment node, int dimensions) { @@ -493,8 +487,6 @@ private static void internalSetExtraDimensions(VariableDeclarationFragment node, /** * Internal access method to MethodDeclaration#setExtraDimension() for avoiding deprecated warnings * - * @param node - * @param dimensions * @deprecated */ private static void internalSetExtraDimensions(MethodDeclaration node, int dimensions) { @@ -503,17 +495,12 @@ private static void internalSetExtraDimensions(MethodDeclaration node, int dimen /** * Internal access method to MethodDeclaration#thrownExceptions() for avoiding deprecated warnings * - * @param node * @deprecated */ private static List internalThownExceptions(MethodDeclaration node) { return node.thrownExceptions(); } - /** - * @param compilationUnit - * @param comments - */ void buildCommentsTable(CompilationUnit compilationUnit, int[][] comments) { // Build comment table this.commentsTable = new Comment[comments.length]; @@ -5927,9 +5914,6 @@ protected void setModifiers(AnnotationTypeMemberDeclaration annotationTypeMember this.setModifiers(annotationTypeMemberDecl, annotationTypeMemberDeclaration.annotations, annotationTypeMemberDeclaration.sourceStart); } - /** - * @param bodyDeclaration - */ protected void setModifiers(BodyDeclaration bodyDeclaration, org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations, int modifiersEnd) { setModifiers(bodyDeclaration.modifiers(), annotations, modifiersEnd); } @@ -6035,10 +6019,6 @@ protected void setModifiers(EnumConstantDeclaration enumConstantDeclaration, org } } - /** - * @param fieldDeclaration - * @param fieldDecl - */ protected void setModifiers(FieldDeclaration fieldDeclaration, org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDecl) { switch(this.ast.apiLevel) { case AST.JLS2_INTERNAL : @@ -6053,10 +6033,6 @@ protected void setModifiers(FieldDeclaration fieldDeclaration, org.eclipse.jdt.i } } - /** - * @param initializer - * @param oldInitializer - */ protected void setModifiers(Initializer initializer, org.eclipse.jdt.internal.compiler.ast.Initializer oldInitializer) { switch(this.ast.apiLevel) { case AST.JLS2_INTERNAL: @@ -6070,10 +6046,6 @@ protected void setModifiers(Initializer initializer, org.eclipse.jdt.internal.co this.setModifiers(initializer, oldInitializer.annotations, oldInitializer.bodyStart); } } - /** - * @param methodDecl - * @param methodDeclaration - */ protected void setModifiers(MethodDeclaration methodDecl, AbstractMethodDeclaration methodDeclaration) { switch(this.ast.apiLevel) { case AST.JLS2_INTERNAL : @@ -6099,10 +6071,6 @@ protected void setAnnotations(ModuleDeclaration moduleDecl, org.eclipse.jdt.inte moduleDecl.annotations().add(ie); } } - /** - * @param variableDecl - * @param argument - */ protected void setModifiers(SingleVariableDeclaration variableDecl, Argument argument) { switch(this.ast.apiLevel) { case AST.JLS2_INTERNAL : @@ -6261,7 +6229,6 @@ protected void setModifiers(SingleVariableDeclaration variableDecl, LocalDeclara } /** - * @param variableDecl * @param component * * TODO: just plain copy of sM(SVD, Argument) - need to cut the flab here. @@ -6340,10 +6307,6 @@ protected void setModifiers(SingleVariableDeclaration variableDecl, RecordCompon } } } - /** - * @param typeDecl - * @param typeDeclaration - */ protected void setModifiers(TypeDeclaration typeDecl, org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) { switch(this.ast.apiLevel) { case AST.JLS2_INTERNAL : @@ -6361,10 +6324,6 @@ protected void setModifiers(TypeDeclaration typeDecl, org.eclipse.jdt.internal.c } } - /** - * @param variableDeclarationExpression - * @param localDeclaration - */ protected void setModifiers(VariableDeclarationExpression variableDeclarationExpression, LocalDeclaration localDeclaration) { switch(this.ast.apiLevel) { case AST.JLS2_INTERNAL : @@ -6442,10 +6401,6 @@ protected void setModifiers(VariableDeclarationExpression variableDeclarationExp } } - /** - * @param variableDeclarationStatement - * @param localDeclaration - */ protected void setModifiers(VariableDeclarationStatement variableDeclarationStatement, LocalDeclaration localDeclaration) { switch(this.ast.apiLevel) { case AST.JLS2_INTERNAL : @@ -6692,8 +6647,6 @@ protected void setTypeForField(FieldDeclaration fieldDeclaration, Type type, int /** extracts the subArrayType for a given declaration for AST levels less * @param arrayType parent type - * @param remainingDimensions - * @param dimensionsToRemove * @return an ArrayType */ private ArrayType extractSubArrayType(ArrayType arrayType, int remainingDimensions, int dimensionsToRemove) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java index 64bbd5aefb..00704b3dff 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2022 IBM Corporation and others. + * Copyright (c) 2000, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -55,7 +55,7 @@ public class ASTMatcher { * Indicates whether doc tags should be matched. * @since 3.0 */ - private boolean matchDocTags; + private final boolean matchDocTags; /** * Creates a new AST matcher instance. @@ -1976,15 +1976,19 @@ public boolean match(ParenthesizedExpression node, Object other) { * different node type or is null * @since 3.26 */ - @SuppressWarnings("deprecation") + @SuppressWarnings("deprecation") // GROOVY add public boolean match(PatternInstanceofExpression node, Object other) { if (!(other instanceof PatternInstanceofExpression)) { return false; } PatternInstanceofExpression o = (PatternInstanceofExpression) other; - return - safeSubtreeMatch(node.getLeftOperand(), o.getLeftOperand()) - && safeSubtreeMatch(node.getRightOperand(), o.getRightOperand()); + AST ast = node.getAST(); + if (ast.apiLevel() <= 20) { + return safeSubtreeMatch(node.getLeftOperand(), o.getLeftOperand()) + && safeSubtreeMatch(node.getRightOperand(), o.getRightOperand()); + } + return safeSubtreeMatch(node.getLeftOperand(), o.getLeftOperand()) + && safeSubtreeMatch(node.getPattern(), o.getPattern()); } /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java index fc44454369..d3f6d043b5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java @@ -78,10 +78,10 @@ class ASTRecoveryPropagator extends DefaultASTVisitor { this.endingTokens.put(VariableDeclarationStatement.class, new int[]{TerminalTokens.TokenNameSEMICOLON}); } - private CategorizedProblem[] problems; - private boolean[] usedOrIrrelevantProblems; + private final CategorizedProblem[] problems; + private final boolean[] usedOrIrrelevantProblems; - private RecoveryScannerData data; + private final RecoveryScannerData data; private int blockDepth = 0; private int lastEnd; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTSyntaxErrorPropagator.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTSyntaxErrorPropagator.java index 126df88eca..4285c8ea20 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTSyntaxErrorPropagator.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTSyntaxErrorPropagator.java @@ -22,7 +22,7 @@ */ class ASTSyntaxErrorPropagator extends ASTVisitor { - private CategorizedProblem[] problems; + private final CategorizedProblem[] problems; ASTSyntaxErrorPropagator(CategorizedProblem[] problems) { // visit Javadoc.tags() as well diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTVisitor.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTVisitor.java index efe03fe829..078d2fd0ff 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTVisitor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTVisitor.java @@ -110,7 +110,7 @@ public abstract class ASTVisitor { * Indicates whether doc tags should be visited by default. * @since 3.0 */ - private boolean visitDocTags; + private final boolean visitDocTags; /** * Creates a new AST visitor instance. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AbstractTextElement.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AbstractTextElement.java index a761ad3b9d..406363acf4 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AbstractTextElement.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AbstractTextElement.java @@ -33,7 +33,6 @@ public abstract class AbstractTextElement extends ASTNode implements IDocElement /** * The "text" structural property of this node type (type: {@link String}). - * */ public static final SimplePropertyDescriptor internalTextPropertyFactory(Class nodeClass) { return new SimplePropertyDescriptor(nodeClass, "text", String.class, MANDATORY); //$NON-NLS-1$ diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AnnotationBinding.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AnnotationBinding.java index c3de8d8231..b91008cafb 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AnnotationBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AnnotationBinding.java @@ -31,8 +31,8 @@ */ class AnnotationBinding implements IAnnotationBinding { static final AnnotationBinding[] NoAnnotations = new AnnotationBinding[0]; - private org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding binding; - private BindingResolver bindingResolver; + private final org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding binding; + private final BindingResolver bindingResolver; private String key; AnnotationBinding(org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding annotation, BindingResolver resolver) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AnonymousClassDeclaration.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AnonymousClassDeclaration.java index e8204ff6a5..50ee7e4126 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AnonymousClassDeclaration.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AnonymousClassDeclaration.java @@ -75,7 +75,7 @@ public static List propertyDescriptors(int apiLevel) { * The body declarations (element type: {@link BodyDeclaration}). * Defaults to none. */ - private ASTNode.NodeList bodyDeclarations = + private final ASTNode.NodeList bodyDeclarations = new ASTNode.NodeList(BODY_DECLARATIONS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayCreation.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayCreation.java index 6cfde67889..363cfbb583 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayCreation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayCreation.java @@ -104,7 +104,7 @@ public static List propertyDescriptors(int apiLevel) { * The list of dimension expressions (element type: * {@link Expression}). Defaults to an empty list. */ - private ASTNode.NodeList dimensions = + private final ASTNode.NodeList dimensions = new ASTNode.NodeList(DIMENSIONS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayInitializer.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayInitializer.java index 7ed33b4104..9066d0c17e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayInitializer.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayInitializer.java @@ -71,7 +71,7 @@ public static List propertyDescriptors(int apiLevel) { * The list of expressions (element type: * {@link Expression}). Defaults to an empty list. */ - private ASTNode.NodeList expressions = + private final ASTNode.NodeList expressions = new ASTNode.NodeList(EXPRESSIONS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Assignment.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Assignment.java index f901e1783e..b19bc64cbc 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Assignment.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Assignment.java @@ -56,7 +56,7 @@ public static class Operator { /** * The name of the operator */ - private String op; + private final String op; /** * Creates a new assignment operator with the given name. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingComparator.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingComparator.java index 58ea6657e4..20d50ebc23 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingComparator.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingComparator.java @@ -36,8 +36,6 @@ @SuppressWarnings({"rawtypes", "unchecked"}) class BindingComparator { /** - * @param bindings - * @param otherBindings * @return true if both parameters are equals, false otherwise */ static boolean isEqual(TypeVariableBinding[] bindings, TypeVariableBinding[] otherBindings) { @@ -63,8 +61,6 @@ static boolean isEqual(TypeVariableBinding[] bindings, TypeVariableBinding[] oth } /** - * @param declaringElement - * @param declaringElement2 * @return true if both parameters are equals, false otherwise */ static boolean isEqual(Binding declaringElement, Binding declaringElement2, HashSet visitedTypes) { @@ -144,7 +140,7 @@ static boolean isEqual(org.eclipse.jdt.internal.compiler.lookup.ModuleBinding mo return moduleBinding2 == null; if (moduleBinding2 == null) return false; - return CharOperation.equals(moduleBinding.moduleName, moduleBinding2.moduleName); + return CharOperation.equals(moduleBinding.moduleName, moduleBinding2.moduleName); } static boolean isEqual(VariableBinding variableBinding, VariableBinding variableBinding2) { @@ -163,16 +159,12 @@ && isEqual(fieldBinding.type, fieldBinding2.type, visitedTypes) } /** - * @param bindings - * @param otherBindings * @return true if both parameters are equals, false otherwise */ static boolean isEqual(org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] bindings, org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] otherBindings) { return isEqual(bindings, otherBindings, new HashSet()); } /** - * @param bindings - * @param otherBindings * @return true if both parameters are equals, false otherwise */ static boolean isEqual(org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] bindings, org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] otherBindings, HashSet visitedTypes) { @@ -320,8 +312,6 @@ && isEqual(referenceBinding.typeVariables(), referenceBinding2.typeVariables(), } } /** - * @param typeBinding - * @param typeBinding2 * @return true if both parameters are equals, false otherwise */ static boolean isEqual(org.eclipse.jdt.internal.compiler.lookup.TypeBinding typeBinding, org.eclipse.jdt.internal.compiler.lookup.TypeBinding typeBinding2) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingResolver.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingResolver.java index 043b8b5465..0457605974 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingResolver.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingResolver.java @@ -165,7 +165,6 @@ IMemberValuePairBinding getMemberValuePairBinding(ElementValuePair valuePair) { * * @param moduleBinding the old module binding * @return the new module binding - * */ IModuleBinding getModuleBinding(org.eclipse.jdt.internal.compiler.lookup.ModuleBinding moduleBinding) { return null; @@ -313,7 +312,6 @@ LookupEnvironment lookupEnvironment() { * The default implementation of this method does nothing. * Subclasses may reimplement. *

    - * @param astNode */ void recordScope(ASTNode astNode, BlockScope blockScope) { // default implementation: do nothing diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Block.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Block.java index 378c130354..95f7ba7d00 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Block.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Block.java @@ -70,7 +70,7 @@ public static List propertyDescriptors(int apiLevel) { * The list of statements (element type: {@link Statement}). * Defaults to an empty list. */ - private ASTNode.NodeList statements = + private final ASTNode.NodeList statements = new ASTNode.NodeList(STATEMENTS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ClassInstanceCreation.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ClassInstanceCreation.java index 8d27af0053..d35acc64c2 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ClassInstanceCreation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ClassInstanceCreation.java @@ -169,7 +169,7 @@ public static List propertyDescriptors(int apiLevel) { * The list of argument expressions (element type: * {@link Expression}). Defaults to an empty list. */ - private ASTNode.NodeList arguments = + private final ASTNode.NodeList arguments = new ASTNode.NodeList(ARGUMENTS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnit.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnit.java index aa65c8c62d..bb3889846a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnit.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnit.java @@ -169,7 +169,7 @@ public static List propertyDescriptors(int apiLevel) { * The list of import declarations in textual order order; * initially none (elementType: ImportDeclaration). */ - private ASTNode.NodeList imports = + private final ASTNode.NodeList imports = new ASTNode.NodeList(IMPORTS_PROPERTY); /** @@ -227,7 +227,7 @@ public static List propertyDescriptors(int apiLevel) { * The list of type declarations in textual order order; * initially none (elementType: AbstractTypeDeclaration) */ - private ASTNode.NodeList types = + private final ASTNode.NodeList types = new ASTNode.NodeList(TYPES_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java index d822141fbc..1ae39c1b86 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java @@ -121,7 +121,7 @@ public void add(int i) { boolean hasCompilationAborted; CategorizedProblem abortProblem; - private IProgressMonitor monitor; + private final IProgressMonitor monitor; /** * Set to true if the receiver was initialized using a java project name environment diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ConstructorInvocation.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ConstructorInvocation.java index e131337e4a..57b9e49c2b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ConstructorInvocation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ConstructorInvocation.java @@ -105,7 +105,7 @@ public static List propertyDescriptors(int apiLevel) { * The list of argument expressions (element type: * {@link Expression}). Defaults to an empty list. */ - private ASTNode.NodeList arguments = + private final ASTNode.NodeList arguments = new ASTNode.NodeList(ARGUMENTS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultASTVisitor.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultASTVisitor.java index 9f53c761d8..d741476019 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultASTVisitor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultASTVisitor.java @@ -11,19 +11,11 @@ * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.core.dom; -/** - */ class DefaultASTVisitor extends ASTVisitor { - /** - * - */ public DefaultASTVisitor() { super(); } - /** - * - */ public DefaultASTVisitor(boolean visitDocTags) { super(visitDocTags); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java index cee7440580..ed8adeb5f4 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java @@ -152,7 +152,7 @@ static class BindingTables { /** * Compilation unit scope */ - private CompilationUnitScope scope; + private final CompilationUnitScope scope; /** * The working copy owner that defines the context in which this resolver is creating the bindings. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultCommentMapper.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultCommentMapper.java index 806d1ca420..530ed561b7 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultCommentMapper.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultCommentMapper.java @@ -188,7 +188,6 @@ public int getExtendedLength(ASTNode node) { /** * Return index of first leading comment of a given node. * - * @param node * @return index of first leading comment or -1 if node has no leading comment */ int firstLeadingCommentIndex(ASTNode node) { @@ -205,7 +204,6 @@ int firstLeadingCommentIndex(ASTNode node) { /** * Return index of last trailing comment of a given node. * - * @param node * @return index of last trailing comment or -1 if node has no trailing comment */ int lastTrailingCommentIndex(ASTNode node) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultValuePairBinding.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultValuePairBinding.java index 5a5ea0c267..af8b951874 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultValuePairBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultValuePairBinding.java @@ -21,7 +21,7 @@ */ class DefaultValuePairBinding extends MemberValuePairBinding { - private org.eclipse.jdt.internal.compiler.lookup.MethodBinding method; + private final org.eclipse.jdt.internal.compiler.lookup.MethodBinding method; DefaultValuePairBinding(org.eclipse.jdt.internal.compiler.lookup.MethodBinding binding, BindingResolver resolver) { super(null, resolver); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Dimension.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Dimension.java index d829829634..230f12f12e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Dimension.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Dimension.java @@ -26,7 +26,7 @@ *
  • extra dimension in the following node types: * {@link SingleVariableDeclaration}, {@link VariableDeclarationFragment}, {@link MethodDeclaration}
  • * - * + * *
      * Dimension:
      * 	{ Annotation } []
    @@ -75,7 +75,7 @@ public static List propertyDescriptors(int apiLevel) {
     	 * The list of annotations for this dimension (element type: {@link Annotation}).
     	 * Defaults to an empty list.
     	 */
    -	private ASTNode.NodeList annotations = new ASTNode.NodeList(ANNOTATIONS_PROPERTY);
    +	private final ASTNode.NodeList annotations = new ASTNode.NodeList(ANNOTATIONS_PROPERTY);
     
     	/**
     	 * Creates a new dimension node (supported only in level JLS8 or above).
    diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DocCommentParser.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DocCommentParser.java
    index c7bab8a826..4b22c26a4f 100644
    --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DocCommentParser.java
    +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DocCommentParser.java
    @@ -35,7 +35,7 @@
     class DocCommentParser extends AbstractCommentParser {
     
     	private Javadoc docComment;
    -	private AST ast;
    +	private final AST ast;
     
     	DocCommentParser(AST ast, Scanner scanner, boolean check) {
     		super(null);
    @@ -155,7 +155,7 @@ protected Object createArgumentReference(char[] name, int dim, boolean isVarargs
     			return argument;
     		}
     		catch (ClassCastException ex) {
    -				throw new InvalidInputException();
    +				throw Scanner.invalidInput();
     		}
     	}
     
    @@ -182,7 +182,7 @@ protected Object createFieldReference(Object receiver) throws InvalidInputExcept
     			return fieldRef;
     		}
     		catch (ClassCastException ex) {
    -				throw new InvalidInputException();
    +				throw Scanner.invalidInput();
     		}
     	}
     
    @@ -219,7 +219,7 @@ protected Object createMethodReference(Object receiver, List arguments) throws I
     			return methodRef;
     		}
     		catch (ClassCastException ex) {
    -				throw new InvalidInputException();
    +				throw Scanner.invalidInput();
     		}
     	}
     
    diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EnumConstantDeclaration.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EnumConstantDeclaration.java
    index 563617d2d2..6e44f164f4 100644
    --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EnumConstantDeclaration.java
    +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EnumConstantDeclaration.java
    @@ -117,7 +117,7 @@ public static List propertyDescriptors(int apiLevel) {
     	 * The list of argument expressions (element type:
     	 * {@link Expression}). Defaults to an empty list.
     	 */
    -	private ASTNode.NodeList arguments =
    +	private final ASTNode.NodeList arguments =
     		new ASTNode.NodeList(ARGUMENTS_PROPERTY);
     
     	/**
    diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EnumDeclaration.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EnumDeclaration.java
    index aff2b84c73..6d2ed9d9a6 100644
    --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EnumDeclaration.java
    +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EnumDeclaration.java
    @@ -120,7 +120,7 @@ public static List propertyDescriptors(int apiLevel) {
     	 * The superinterface types (element type: {@link Type}).
     	 * Defaults to an empty list.
     	 */
    -	private ASTNode.NodeList superInterfaceTypes =
    +	private final ASTNode.NodeList superInterfaceTypes =
     		new ASTNode.NodeList(SUPER_INTERFACE_TYPES_PROPERTY);
     
     	/**
    @@ -128,7 +128,7 @@ public static List propertyDescriptors(int apiLevel) {
     	 * (element type: {@link EnumConstantDeclaration}).
     	 * Defaults to an empty list.
     	 */
    -	private ASTNode.NodeList enumConstants =
    +	private final ASTNode.NodeList enumConstants =
     		new ASTNode.NodeList(ENUM_CONSTANTS_PROPERTY);
     
     	/**
    diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/FieldDeclaration.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/FieldDeclaration.java
    index a9de22677f..6d89384011 100644
    --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/FieldDeclaration.java
    +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/FieldDeclaration.java
    @@ -141,7 +141,7 @@ public static List propertyDescriptors(int apiLevel) {
     	 * The list of variable declaration fragments (element type:
     	 * {@link VariableDeclarationFragment}).  Defaults to an empty list.
     	 */
    -	private ASTNode.NodeList variableDeclarationFragments =
    +	private final ASTNode.NodeList variableDeclarationFragments =
     		new ASTNode.NodeList(FRAGMENTS_PROPERTY);
     
     	/**
    diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ForStatement.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ForStatement.java
    index cfc5826145..ef50d5684f 100644
    --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ForStatement.java
    +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ForStatement.java
    @@ -111,7 +111,7 @@ public static List propertyDescriptors(int apiLevel) {
     	 * The list of initializer expressions (element type:
     	 * {@link Expression}). Defaults to an empty list.
     	 */
    -	private ASTNode.NodeList initializers =
    +	private final ASTNode.NodeList initializers =
     		new ASTNode.NodeList(INITIALIZERS_PROPERTY);
     
     	/**
    @@ -123,7 +123,7 @@ public static List propertyDescriptors(int apiLevel) {
     	 * The list of update expressions (element type:
     	 * {@link Expression}). Defaults to an empty list.
     	 */
    -	private ASTNode.NodeList updaters =
    +	private final ASTNode.NodeList updaters =
     		new ASTNode.NodeList(UPDATERS_PROPERTY);
     
     	/**
    diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java
    index 295dfa0d33..6ebc4a5c8f 100644
    --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java
    +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java
    @@ -239,7 +239,6 @@ public void setExpression(Expression expression) {
     
     	/**
     	 * Sets the pattern of this switch case.
    -	 * @param pattern
     	 * @noreference This method is not intended to be referenced by clients.
     	 * @exception UnsupportedOperationException if this operation is used not for JLS18
     	 * @exception UnsupportedOperationException if this operation is used without previewEnabled
    diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InfixExpression.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InfixExpression.java
    index a336b63143..c32c108779 100644
    --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InfixExpression.java
    +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InfixExpression.java
    @@ -62,7 +62,7 @@ public static class Operator {
     		/**
     		 * The token for the operator.
     		 */
    -		private String token;
    +		private final String token;
     
     		/**
     		 * Creates a new infix operator with the given token.
    diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InternalASTRewrite.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InternalASTRewrite.java
    index ec5eec4509..34c95e73bc 100644
    --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InternalASTRewrite.java
    +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InternalASTRewrite.java
    @@ -42,7 +42,7 @@
     class InternalASTRewrite extends NodeEventHandler {
     
     	/** root node for the rewrite: Only nodes under this root are accepted */
    -	private CompilationUnit root;
    +	private final CompilationUnit root;
     
     	protected final RewriteEventStore eventStore;
     	protected final NodeInfoStore nodeStore;
    diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IntersectionType.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IntersectionType.java
    index 5d45767cda..14aa6f8dc3 100644
    --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IntersectionType.java
    +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IntersectionType.java
    @@ -69,12 +69,12 @@ public static List propertyDescriptors(int apiLevel) {
     	/**
     	 * The list of types (element type: {@link Type}).  Defaults to an empty list.
     	 */
    -	private ASTNode.NodeList types = new ASTNode.NodeList(TYPES_PROPERTY);
    +	private final ASTNode.NodeList types = new ASTNode.NodeList(TYPES_PROPERTY);
     
     	/**
     	 * Creates a new unparented node for an intersection type owned by the given AST.
     	 * By default, it has no types.

    - * + * * N.B. This constructor is package-private. *

    * diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/JavaDocRegion.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/JavaDocRegion.java index 80c1e895b5..53e78f3548 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/JavaDocRegion.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/JavaDocRegion.java @@ -94,7 +94,7 @@ public class JavaDocRegion extends AbstractTagElement{ /** * The tags list; empty for none; */ - private ASTNode.NodeList tags = new ASTNode.NodeList(TAGS_PROPERTY); + private final ASTNode.NodeList tags = new ASTNode.NodeList(TAGS_PROPERTY); /** * The property dummyRegion @@ -231,7 +231,6 @@ public boolean isDummyRegion() { /** * Sets the value of dummyRegion property. - * @param dummyRegion * @exception UnsupportedOperationException if this operation is used below JLS18 */ public void setDummyRegion(boolean dummyRegion) { @@ -253,7 +252,6 @@ public boolean isValidSnippet() { /** * Sets the value of validSnippet property. - * @param validSnippet * @exception UnsupportedOperationException if this operation is used below JLS18 */ public void setValidSnippet(boolean validSnippet) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Javadoc.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Javadoc.java index 1c56d89d47..6b7f9ac59a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Javadoc.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Javadoc.java @@ -117,7 +117,7 @@ public static List propertyDescriptors(int apiLevel) { * Defaults to an empty list. * @since 3.0 */ - private ASTNode.NodeList tags = + private final ASTNode.NodeList tags = new ASTNode.NodeList(TAGS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/LambdaExpression.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/LambdaExpression.java index 67774f36ed..8810129886 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/LambdaExpression.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/LambdaExpression.java @@ -24,14 +24,14 @@ * ( [ Identifier { , Identifier } ] ) -> Body * ( [ FormalParameter { , FormalParameter } ] ) -> Body *
    - * - *

    + * + *

    * The first two forms use {@link VariableDeclarationFragment} for the parameter or parameters, * while the third form uses {@link SingleVariableDeclaration}.

    *

    The Body can be either a {@link Block} or an {@link Expression}.

    * * @since 3.10 - * @noinstantiate This class is not intended to be instantiated by clients + * @noinstantiate This class is not intended to be instantiated by clients */ @SuppressWarnings({"rawtypes", "unchecked"}) public class LambdaExpression extends Expression { @@ -55,7 +55,7 @@ public class LambdaExpression extends Expression { */ public static final ChildListPropertyDescriptor PARAMETERS_PROPERTY = new ChildListPropertyDescriptor(LambdaExpression.class, "parameters", VariableDeclaration.class, CYCLE_RISK); //$NON-NLS-1$ - + /** * The "body" structural property of this node type (child type: {@link ASTNode}, * must be either a {@link Block} or an {@link Expression}). @@ -69,7 +69,7 @@ public class LambdaExpression extends Expression { * or null if uninitialized. */ private static final List PROPERTY_DESCRIPTORS_8_0; - + static { List propertyList = new ArrayList(4); createPropertyList(LambdaExpression.class, propertyList); @@ -78,7 +78,7 @@ public class LambdaExpression extends Expression { addProperty(BODY_PROPERTY, propertyList); PROPERTY_DESCRIPTORS_8_0 = reapPropertyList(propertyList); } - + /** * Returns a list of structural property descriptors for this node type. * Clients must not modify the result. @@ -93,7 +93,7 @@ public static List propertyDescriptors(int apiLevel) { /** * Indicates whether parentheses are present or not. - * Defaults to true. + * Defaults to true. */ private boolean hasParentheses = true; @@ -102,7 +102,7 @@ public static List propertyDescriptors(int apiLevel) { * (element type: {@link VariableDeclaration}). * Defaults to an empty list. */ - private ASTNode.NodeList parameters = + private final ASTNode.NodeList parameters = new ASTNode.NodeList(PARAMETERS_PROPERTY); /** @@ -208,7 +208,7 @@ void accept0(ASTVisitor visitor) { * just a single {@link VariableDeclarationFragment}. * ASTRewrite may ignore this property if necessary. *

    - * + * * @return true if this lambda expression has parentheses around * its parameters and false otherwise */ @@ -250,7 +250,7 @@ public List parameters() { /** * Returns the body of this lambda expression. - * + * * @return the lambda expression body, which can be either a {@link Block} or an {@link Expression} */ public ASTNode getBody() { @@ -315,4 +315,4 @@ int treeSize() { + this.parameters.listSize() + (this.body == null ? 0 : getBody().treeSize()); } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MemberValuePairBinding.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MemberValuePairBinding.java index bcfcae2849..18e5736fa3 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MemberValuePairBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MemberValuePairBinding.java @@ -31,7 +31,7 @@ class MemberValuePairBinding implements IMemberValuePairBinding { private static final Object NoValue = new Object(); private static final Object[] EmptyArray = new Object[0]; - private ElementValuePair internalPair; + private final ElementValuePair internalPair; protected Object value = null; protected BindingResolver bindingResolver; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Message.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Message.java index fa002da3fe..df77a22c80 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Message.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Message.java @@ -25,12 +25,12 @@ public class Message { /** * The message. */ - private String message; + private final String message; /** * The character index into the original source string, or -1 if none. */ - private int startPosition; + private final int startPosition; /** * The length in characters of the original source file indicating diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodBinding.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodBinding.java index f807e6d314..1bc18dfb8a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodBinding.java @@ -532,8 +532,8 @@ public String toString() { */ static class LambdaMethod extends MethodBinding { - private MethodBinding implementation; - private IBinding declaringMember; + private final MethodBinding implementation; + private final IBinding declaringMember; private IVariableBinding[] syntheticOuterLocalVariables; public LambdaMethod(DefaultBindingResolver resolver, @@ -620,4 +620,4 @@ public boolean isSyntheticRecordMethod() { public String[] getParameterNames() { return CharOperation.toStrings(this.binding.parameterNames); } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodDeclaration.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodDeclaration.java index 739eb3ced7..366d15c559 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodDeclaration.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodDeclaration.java @@ -343,7 +343,7 @@ public static List propertyDescriptors(int apiLevel) { * (element type: {@link SingleVariableDeclaration}). * Defaults to an empty list. */ - private ASTNode.NodeList parameters = + private final ASTNode.NodeList parameters = new ASTNode.NodeList(PARAMETERS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodInvocation.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodInvocation.java index f2e812be06..e5053805cf 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodInvocation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodInvocation.java @@ -134,7 +134,7 @@ public static List propertyDescriptors(int apiLevel) { * The list of argument expressions (element type: * {@link Expression}). Defaults to an empty list. */ - private ASTNode.NodeList arguments = + private final ASTNode.NodeList arguments = new ASTNode.NodeList(ARGUMENTS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodRef.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodRef.java index d5fd31d913..830c6d2d8e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodRef.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodRef.java @@ -100,7 +100,7 @@ public static List propertyDescriptors(int apiLevel) { * (element type: {@link MethodRefParameter}). * Defaults to an empty list. */ - private ASTNode.NodeList parameters = + private final ASTNode.NodeList parameters = new ASTNode.NodeList(PARAMETERS_PROPERTY); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Modifier.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Modifier.java index 29dc14afbb..110db75477 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Modifier.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Modifier.java @@ -187,12 +187,12 @@ public static ModifierKeyword toKeyword(String keyword) { /** * The flag value for the modifier. */ - private int flagValue; + private final int flagValue; /** * The keyword modifier string. */ - private String keyword; + private final String keyword; /** * Creates a new modifier with the given keyword. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleBinding.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleBinding.java index f302f6ec50..d9596898ca 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleBinding.java @@ -30,11 +30,11 @@ class ModuleBinding implements IModuleBinding { protected static final ITypeBinding[] NO_TYPE_BINDINGS = new ITypeBinding[0]; - private String name = null; + private final String name = null; private volatile String key; private boolean isOpen = false; - private org.eclipse.jdt.internal.compiler.lookup.ModuleBinding binding; + private final org.eclipse.jdt.internal.compiler.lookup.ModuleBinding binding; protected BindingResolver resolver; private IAnnotationBinding[] annotations; @@ -86,7 +86,7 @@ private IAnnotationBinding[] resolveAnnotationBindings(org.eclipse.jdt.internal. @Override public String getName() { if (this.name == null) { - char[] tmp = this.binding.moduleName; + char[] tmp = this.binding.moduleName; return tmp != null && tmp.length != 0 ? new String(tmp) : Util.EMPTY_STRING; } return this.name; @@ -113,7 +113,7 @@ public boolean isSynthetic() { // TODO Auto-generated method stub // TODO Java 9 no reference seen in jvms draft - only in sotm // check on version change and after compiler ast implements isSynthetic return this.binding.isSynthetic(); - + return false; } @@ -238,4 +238,4 @@ public ITypeBinding[] getImplementations(ITypeBinding service) { public String toString() { return this.binding.toString(); } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleDeclaration.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleDeclaration.java index eace44eeda..5827b95824 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleDeclaration.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleDeclaration.java @@ -104,9 +104,8 @@ public static List propertyDescriptors(int apiLevel) { /** * The annotations (element type: {@link Annotation}). * Defaults to an empty list. - * */ - private ASTNode.NodeList annotations = new ASTNode.NodeList(ANNOTATIONS_PROPERTY); + private final ASTNode.NodeList annotations = new ASTNode.NodeList(ANNOTATIONS_PROPERTY); /** * open versus normal; defaults to normal module. @@ -123,7 +122,7 @@ public static List propertyDescriptors(int apiLevel) { * The list of statements (element type: {@link ModuleDirective}). * Defaults to an empty list. */ - private ASTNode.NodeList moduleStatements = new ASTNode.NodeList(MODULE_DIRECTIVES_PROPERTY); + private final ASTNode.NodeList moduleStatements = new ASTNode.NodeList(MODULE_DIRECTIVES_PROPERTY); ModuleDeclaration(AST ast) { super(ast); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleModifier.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleModifier.java index 427140e441..3d7eb9dc78 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleModifier.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleModifier.java @@ -109,12 +109,12 @@ public static ModuleModifierKeyword toKeyword(String keyword) { /** * The flag value for the module modifier. */ - private int flagValue; + private final int flagValue; /** * The keyword module modifier string. */ - private String keyword; + private final String keyword; /** * Creates a new module modifier with the given keyword. @@ -345,4 +345,4 @@ final boolean subtreeMatch0(ASTMatcher matcher, Object other) { int treeSize() { return memSize(); } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleQualifiedName.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleQualifiedName.java index fbea5c0134..f990051715 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleQualifiedName.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ModuleQualifiedName.java @@ -31,7 +31,6 @@ * * @noinstantiate This class is not intended to be instantiated by clients. * @since 3.24 - * */ @SuppressWarnings("rawtypes") public class ModuleQualifiedName extends Name { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NameEnvironmentWithProgress.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NameEnvironmentWithProgress.java index 9b0e9a2042..af6e816b8e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NameEnvironmentWithProgress.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NameEnvironmentWithProgress.java @@ -15,6 +15,8 @@ *******************************************************************************/ package org.eclipse.jdt.core.dom; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.jdt.core.compiler.CharOperation; @@ -31,7 +33,7 @@ */ class NameEnvironmentWithProgress extends FileSystem implements INameEnvironmentWithProgress { IProgressMonitor monitor; - + public NameEnvironmentWithProgress(Classpath[] paths, String[] initialFileNames, IProgressMonitor monitor) { super(paths, initialFileNames, false); setMonitor(monitor); @@ -39,7 +41,7 @@ public NameEnvironmentWithProgress(Classpath[] paths, String[] initialFileNames, private void checkCanceled() { if (this.monitor != null && this.monitor.isCanceled()) { if (NameLookup.VERBOSE) { - System.out.println(Thread.currentThread() + " CANCELLING LOOKUP "); //$NON-NLS-1$ + trace(Thread.currentThread() + " CANCELLING LOOKUP "); //$NON-NLS-1$ } throw new AbortCompilation(true/*silent*/, new OperationCanceledException()); } @@ -90,7 +92,7 @@ public boolean isPackage(char[][] compoundName, char[] packageName) { checkCanceled(); return super.isPackage(compoundName, packageName); } - + @Override public void setMonitor(IProgressMonitor monitor) { this.monitor = monitor; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NodeFinder.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NodeFinder.java index 9c165b069d..9ec41326e8 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NodeFinder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NodeFinder.java @@ -34,8 +34,8 @@ public final class NodeFinder { * This class defines the actual visitor that finds the node. */ private static class NodeFinderVisitor extends ASTVisitor { - private int fStart; - private int fEnd; + private final int fStart; + private final int fEnd; private ASTNode fCoveringNode; private ASTNode fCoveredNode; @@ -181,8 +181,8 @@ public static ASTNode perform(ASTNode root, int start, int length, ITypeRoot sou } return finder.getCoveringNode(); } - private ASTNode fCoveringNode; - private ASTNode fCoveredNode; + private final ASTNode fCoveringNode; + private final ASTNode fCoveredNode; /** * Instantiate a new node finder using the given root node, the given start and the given length. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NormalAnnotation.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NormalAnnotation.java index 4efea1700f..76ccd0bb09 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NormalAnnotation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NormalAnnotation.java @@ -72,7 +72,7 @@ public static List propertyDescriptors(int apiLevel) { * The list of member value pairs (element type: * {@link MemberValuePair}). Defaults to an empty list. */ - private ASTNode.NodeList values = + private final ASTNode.NodeList values = new ASTNode.NodeList(VALUES_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PackageBinding.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PackageBinding.java index b2be5bc640..346ff52fb5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PackageBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PackageBinding.java @@ -48,9 +48,9 @@ class PackageBinding implements IPackageBinding { private static final String UNNAMED = Util.EMPTY_STRING; private static final char PACKAGE_NAME_SEPARATOR = '.'; - private org.eclipse.jdt.internal.compiler.lookup.PackageBinding binding; + private final org.eclipse.jdt.internal.compiler.lookup.PackageBinding binding; private String name; - private BindingResolver resolver; + private final BindingResolver resolver; private String[] components; PackageBinding(org.eclipse.jdt.internal.compiler.lookup.PackageBinding binding, BindingResolver resolver) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ParameterizedType.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ParameterizedType.java index 8bcddb717c..3595442caa 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ParameterizedType.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ParameterizedType.java @@ -89,7 +89,7 @@ public static List propertyDescriptors(int apiLevel) { * The type arguments (element type: {@link Type}). * Defaults to an empty list. */ - private ASTNode.NodeList typeArguments = + private final ASTNode.NodeList typeArguments = new ASTNode.NodeList(TYPE_ARGUMENTS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PostfixExpression.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PostfixExpression.java index d13ea21f4e..9a6135aefe 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PostfixExpression.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PostfixExpression.java @@ -46,7 +46,7 @@ public static class Operator { /** * The token for the operator. */ - private String token; + private final String token; /** * Creates a new postfix operator with the given token. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrefixExpression.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrefixExpression.java index 5293330e41..dda545fb2b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrefixExpression.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrefixExpression.java @@ -50,7 +50,7 @@ public static class Operator { /** * The token for the operator. */ - private String token; + private final String token; /** * Creates a new prefix operator with the given token. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrimitiveType.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrimitiveType.java index 6450bf5c34..0b9b13cb29 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrimitiveType.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrimitiveType.java @@ -64,7 +64,7 @@ public static class Code { /** * The name of the type. */ - private String name; + private final String name; /** * Creates a new primitive type code with the given name. @@ -165,7 +165,7 @@ public static PrimitiveType.Code toCode(String token) { */ public static final ChildListPropertyDescriptor ANNOTATIONS_PROPERTY = internalAnnotationsPropertyFactory(PrimitiveType.class); - + /** * The "primitiveTypeCode" structural property of this node type (type: {@link PrimitiveType.Code}). * @since 3.0 @@ -191,7 +191,7 @@ public static PrimitiveType.Code toCode(String token) { createPropertyList(PrimitiveType.class, propertyList); addProperty(PRIMITIVE_TYPE_CODE_PROPERTY, propertyList); PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); - + propertyList = new ArrayList(3); createPropertyList(PrimitiveType.class, propertyList); addProperty(ANNOTATIONS_PROPERTY, propertyList); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ProvidesDirective.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ProvidesDirective.java index 8cd255189c..3152cc36b6 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ProvidesDirective.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ProvidesDirective.java @@ -23,7 +23,7 @@ * * * @since 3.14 - * + * * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. */ @@ -82,7 +82,7 @@ public static List propertyDescriptors(int apiLevel) { * (element type: {@link Name}). * Defaults to an empty list. */ - private ASTNode.NodeList implementations = + private final ASTNode.NodeList implementations = new ASTNode.NodeList(IMPLEMENTATIONS_PROPERTY); /** @@ -223,4 +223,4 @@ int treeSize() { + (this.name == null ? 0 : getName().treeSize()) + this.implementations.listSize(); } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecordDeclaration.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecordDeclaration.java index 25a0dfeef6..c7a8d08c73 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecordDeclaration.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecordDeclaration.java @@ -99,7 +99,6 @@ public class RecordDeclaration extends AbstractTypeDeclaration { private int restrictedIdentifierStartPosition = -1; /** - * @param restrictedIdentifierStartPosition * @since 3.26 */ public void setRestrictedIdentifierStartPosition(int restrictedIdentifierStartPosition) { @@ -161,7 +160,7 @@ public static List propertyDescriptors(int apiLevel) { * The type parameters (element type: {@link TypeParameter}). * defaults to an empty list */ - private ASTNode.NodeList typeParameters = new ASTNode.NodeList(TYPE_PARAMETERS_PROPERTY); + private final ASTNode.NodeList typeParameters = new ASTNode.NodeList(TYPE_PARAMETERS_PROPERTY); /** @@ -169,14 +168,14 @@ public static List propertyDescriptors(int apiLevel) { * defaults to an empty list * (see constructor). */ - private ASTNode.NodeList superInterfaceTypes = new ASTNode.NodeList(SUPER_INTERFACE_TYPES_PROPERTY); + private final ASTNode.NodeList superInterfaceTypes = new ASTNode.NodeList(SUPER_INTERFACE_TYPES_PROPERTY); /** * The parameters (element type: {@link SingleVariableDeclaration}). * defaults to an empty list * (see constructor). */ - private ASTNode.NodeList recordComponents = new ASTNode.NodeList(RECORD_COMPONENTS_PROPERTY); + private final ASTNode.NodeList recordComponents = new ASTNode.NodeList(RECORD_COMPONENTS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecordPattern.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecordPattern.java index 669556bc45..f46468bb25 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecordPattern.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecordPattern.java @@ -80,7 +80,7 @@ int getNodeType0() { * (element type: {@link Pattern}). * Defaults to an empty list. */ - private ASTNode.NodeList patterns = + private final ASTNode.NodeList patterns = new ASTNode.NodeList(PATTERNS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredPackageBinding.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredPackageBinding.java index 2a0859c803..11c80140e4 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredPackageBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredPackageBinding.java @@ -28,8 +28,8 @@ class RecoveredPackageBinding implements IPackageBinding { private static final String UNNAMED = Util.EMPTY_STRING; private static final char PACKAGE_NAME_SEPARATOR = '.'; - private PackageBinding binding; - private BindingResolver resolver; + private final PackageBinding binding; + private final BindingResolver resolver; private String name = null; private String[] components = null; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java index 11b472f62a..29acce24e4 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java @@ -37,7 +37,7 @@ class RecoveredTypeBinding implements ITypeBinding { private VariableDeclaration variableDeclaration; private Type currentType; - private BindingResolver resolver; + private final BindingResolver resolver; private int dimensions; private RecoveredTypeBinding innerTypeBinding; private ITypeBinding[] typeArguments; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredVariableBinding.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredVariableBinding.java index fb5a689bf0..2997f84307 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredVariableBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredVariableBinding.java @@ -20,8 +20,8 @@ */ class RecoveredVariableBinding implements IVariableBinding { - private VariableDeclaration variableDeclaration; - private BindingResolver resolver; + private final VariableDeclaration variableDeclaration; + private final BindingResolver resolver; RecoveredVariableBinding(BindingResolver resolver, VariableDeclaration variableDeclaration) { this.resolver = resolver; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RequiresDirective.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RequiresDirective.java index a0bc690c1c..433ed7f402 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RequiresDirective.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RequiresDirective.java @@ -75,7 +75,7 @@ public static List propertyDescriptors(int apiLevel) { * The extended modifiers (element type: {@link ModuleModifier}). * defaults to an empty list */ - private ASTNode.NodeList modifiers = new ASTNode.NodeList(MODIFIERS_PROPERTY); + private final ASTNode.NodeList modifiers = new ASTNode.NodeList(MODIFIERS_PROPERTY); /** * The referenced module name; lazily initialized; defaults to a unspecified, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperConstructorInvocation.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperConstructorInvocation.java index 6c11ef7ad0..165ccb5c06 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperConstructorInvocation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperConstructorInvocation.java @@ -120,7 +120,7 @@ public static List propertyDescriptors(int apiLevel) { * The list of argument expressions (element type: * {@link Expression}). Defaults to an empty list. */ - private ASTNode.NodeList arguments = + private final ASTNode.NodeList arguments = new ASTNode.NodeList(ARGUMENTS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperMethodInvocation.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperMethodInvocation.java index 432382bf5f..d773f43290 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperMethodInvocation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperMethodInvocation.java @@ -135,7 +135,7 @@ public static List propertyDescriptors(int apiLevel) { * The list of argument expressions (element type: * {@link Expression}). Defaults to an empty list. */ - private ASTNode.NodeList arguments = + private final ASTNode.NodeList arguments = new ASTNode.NodeList(ARGUMENTS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchExpression.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchExpression.java index dca6c0d8a2..3e11380c62 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchExpression.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchExpression.java @@ -89,7 +89,7 @@ public static List propertyDescriptors(int apiLevel) { * (element type: {@link Statement}). * Defaults to an empty list. */ - private ASTNode.NodeList statements = + private final ASTNode.NodeList statements = new ASTNode.NodeList(STATEMENTS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchStatement.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchStatement.java index f248dd428c..930e6b1aa2 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchStatement.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchStatement.java @@ -90,7 +90,7 @@ public static List propertyDescriptors(int apiLevel) { * (element type: {@link Statement}). * Defaults to an empty list. */ - private ASTNode.NodeList statements = + private final ASTNode.NodeList statements = new ASTNode.NodeList(STATEMENTS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TagElement.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TagElement.java index 5b83577b9a..ff31425373 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TagElement.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TagElement.java @@ -308,7 +308,7 @@ final SimplePropertyDescriptor internalTagNamePropertyFactory() { * The list of doc elements (element type: {@link TagProperty}). * Defaults to an empty list. */ - private ASTNode.NodeList tagProperties = + private final ASTNode.NodeList tagProperties = new ASTNode.NodeList(TAG_PROPERTIES_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TagProperty.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TagProperty.java index fd7b913ae7..b0697e5461 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TagProperty.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TagProperty.java @@ -240,7 +240,6 @@ public ASTNode getNodeValue() { /** * Sets the name of this tag property. * - * @param name * @exception UnsupportedOperationException if this operation is used below JLS18 */ public void setName(String name) { @@ -252,7 +251,6 @@ public void setName(String name) { /** * Sets the string value of this tag property. - * @param value * @exception UnsupportedOperationException if this operation is used below JLS18 */ public void setStringValue(String value) { @@ -264,7 +262,6 @@ public void setStringValue(String value) { /** * Sets the node value of this tag property. - * @param value * @exception UnsupportedOperationException if this operation is used below JLS18 */ public void setNodeValue(ASTNode value) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TryStatement.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TryStatement.java index a21679da5d..de1e9a39d7 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TryStatement.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TryStatement.java @@ -30,9 +30,9 @@ *

    * Not all node arrangements will represent legal Java constructs. In particular, * at least one resource, catch clause, or finally block must be present.

    - * + * *

    A resource is either a {@link VariableDeclarationExpression} or (since JLS9) a {@link Name}.

    - * + * * @since 2.0 * @noinstantiate This class is not intended to be instantiated by clients. * @noextend This class is not intended to be subclassed by clients. @@ -40,7 +40,7 @@ @SuppressWarnings({"rawtypes", "unchecked"}) public class TryStatement extends Statement { - + /** * The "resources" structural property of this node type (element type: {@link VariableDeclarationExpression}) (added in JLS4 API). * @deprecated In the JLS9 API, this property is replaced by {@link #RESOURCES2_PROPERTY}. @@ -83,7 +83,7 @@ public class TryStatement extends Statement { * or null if uninitialized. */ private static final List PROPERTY_DESCRIPTORS; - + /** * A list of property descriptors (element type: * {@link StructuralPropertyDescriptor}), @@ -167,7 +167,7 @@ public static List propertyDescriptors(int apiLevel) { * The catch clauses (element type: {@link CatchClause}). * Defaults to an empty list. */ - private ASTNode.NodeList catchClauses = + private final ASTNode.NodeList catchClauses = new ASTNode.NodeList(CATCH_CLAUSES_PROPERTY); /** @@ -360,7 +360,7 @@ public void setFinally(Block block) { /** * Returns the live ordered list of resources for this try statement (added in JLS4 API). - * + * *

    A resource is either a {@link VariableDeclarationExpression} or (since JLS9) a {@link Name}.

    * * @return the live list of resources (element type: {@link Expression}). diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java index b11bc305a5..7b53aed953 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java @@ -1323,7 +1323,7 @@ public IAnnotationBinding[] getTypeAnnotations() { static class LocalTypeBinding extends TypeBinding { - private IBinding declaringMember; + private final IBinding declaringMember; public LocalTypeBinding(BindingResolver resolver, org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclaration.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclaration.java index f259aee6ab..16cfe22b0e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclaration.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclaration.java @@ -252,7 +252,6 @@ public static List propertyDescriptors(int apiLevel) { * The superinterface names (element type: {@link Name}). * JLS2 only; defaults to an empty list. Not used in JLS3. * (see constructor). - * */ private ASTNode.NodeList superInterfaceNames = null; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeParameter.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeParameter.java index 19b450d1ef..e11897d449 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeParameter.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeParameter.java @@ -19,7 +19,7 @@ /** * Type parameter declaration node (added in JLS3 API). - * + * *
      * TypeParameter:
      *    { ExtendedModifier } Identifier [ extends Type { & Type } ]
    @@ -37,7 +37,7 @@ public class TypeParameter extends ASTNode {
     	 */
     	public static final ChildListPropertyDescriptor MODIFIERS_PROPERTY =
     			new ChildListPropertyDescriptor(TypeParameter.class, "modifiers", IExtendedModifier.class, CYCLE_RISK); //$NON-NLS-1$
    -	
    +
     	/**
     	 * The "name" structural property of this node type (child type: {@link SimpleName}).
     	 */
    @@ -70,7 +70,7 @@ public class TypeParameter extends ASTNode {
     		addProperty(NAME_PROPERTY, propertyList);
     		addProperty(TYPE_BOUNDS_PROPERTY, propertyList);
     		PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
    -		
    +
     		propertyList = new ArrayList(4);
     		createPropertyList(TypeParameter.class, propertyList);
     		addProperty(MODIFIERS_PROPERTY, propertyList);
    @@ -110,7 +110,7 @@ public static List propertyDescriptors(int apiLevel) {
     	 * The type bounds (element type: {@link Type}).
     	 * Defaults to an empty list.
     	 */
    -	private ASTNode.NodeList typeBounds =
    +	private final ASTNode.NodeList typeBounds =
     		new ASTNode.NodeList(TYPE_BOUNDS_PROPERTY);
     
     	/**
    @@ -119,7 +119,7 @@ public static List propertyDescriptors(int apiLevel) {
     	 * (see constructor).
     	 */
     	private ASTNode.NodeList modifiers = null;
    -	
    +
     	/**
     	 * Creates a new unparented node for a parameterized type owned by the
     	 * given AST. By default, an unspecified, but legal, type variable name,
    @@ -275,7 +275,7 @@ public void setName(SimpleName typeName) {
     	public List typeBounds() {
     		return this.typeBounds;
     	}
    -	
    +
     	/**
     	 * Returns the live ordered list of modifiers for this TypeParameter node (added in JLS8 API).
     	 *
    diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/UnionType.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/UnionType.java
    index 77de29cce8..15f0fef038 100644
    --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/UnionType.java
    +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/UnionType.java
    @@ -69,12 +69,12 @@ public static List propertyDescriptors(int apiLevel) {
     	/**
     	 * The list of types (element type: {@link Type}).  Defaults to an empty list.
     	 */
    -	private ASTNode.NodeList types = new ASTNode.NodeList(TYPES_PROPERTY);
    +	private final ASTNode.NodeList types = new ASTNode.NodeList(TYPES_PROPERTY);
     
     	/**
     	 * Creates a new unparented node for an union type owned by the given AST.
     	 * By default, it has no types.

    - * + * * N.B. This constructor is package-private. *

    * diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableBinding.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableBinding.java index 8924a4fde6..ab276164e9 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableBinding.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableBinding.java @@ -41,11 +41,11 @@ class VariableBinding implements IVariableBinding { private static final int VALID_MODIFIERS = Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL | Modifier.TRANSIENT | Modifier.VOLATILE; - private org.eclipse.jdt.internal.compiler.lookup.VariableBinding binding; + private final org.eclipse.jdt.internal.compiler.lookup.VariableBinding binding; private ITypeBinding declaringClass; private String key; private String name; - private BindingResolver resolver; + private final BindingResolver resolver; private ITypeBinding type; private IAnnotationBinding[] annotations; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationExpression.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationExpression.java index 78da7f4e6d..a303c92ade 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationExpression.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationExpression.java @@ -144,7 +144,7 @@ public static List propertyDescriptors(int apiLevel) { * The list of variable declaration fragments (element type: * {@link VariableDeclarationFragment}). Defaults to an empty list. */ - private ASTNode.NodeList variableDeclarationFragments = + private final ASTNode.NodeList variableDeclarationFragments = new ASTNode.NodeList(FRAGMENTS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationStatement.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationStatement.java index 808bceb25d..f4e64a4bc8 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationStatement.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationStatement.java @@ -147,7 +147,7 @@ public static List propertyDescriptors(int apiLevel) { * The list of variable variable declaration fragments (element type: * {@link VariableDeclarationFragment}). Defaults to an empty list. */ - private ASTNode.NodeList variableDeclarationFragments = + private final ASTNode.NodeList variableDeclarationFragments = new ASTNode.NodeList(FRAGMENTS_PROPERTY); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ListRewrite.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ListRewrite.java index 852f58b435..86e7a3c32f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ListRewrite.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/ListRewrite.java @@ -40,9 +40,9 @@ @SuppressWarnings({"rawtypes", "unchecked"}) public final class ListRewrite { - private ASTNode parent; - private ChildListPropertyDescriptor childListProperty; - private ASTRewrite rewriter; + private final ASTNode parent; + private final ChildListPropertyDescriptor childListProperty; + private final ASTRewrite rewriter; /* package*/ ListRewrite(ASTRewrite rewriter, ASTNode parent, ChildListPropertyDescriptor childProperty) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/TargetSourceRangeComputer.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/TargetSourceRangeComputer.java index 991bf9b338..abac91b795 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/TargetSourceRangeComputer.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/rewrite/TargetSourceRangeComputer.java @@ -51,13 +51,13 @@ public static final class SourceRange { * 0-based character index, or -1 * if no source position information is known. */ - private int startPosition; + private final int startPosition; /** * (possibly 0) length, or 0 * if no source position information is known. */ - private int length; + private final int length; /** * Creates a new source range. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/SourceRangeVerifier.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/SourceRangeVerifier.java index 148d3f744a..17398e8e19 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/SourceRangeVerifier.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/SourceRangeVerifier.java @@ -40,7 +40,6 @@ public class SourceRangeVerifier extends ASTVisitor { * nodes never overlap. *

    * - * @param node * @return null if everything is OK; a list of errors otherwise */ public String process(ASTNode node) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java index 3509864d2c..56c8473caf 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java @@ -35,6 +35,7 @@ import org.eclipse.jdt.internal.compiler.parser.ScannerHelper; import org.eclipse.jdt.internal.compiler.parser.TerminalTokens; import org.eclipse.jdt.internal.compiler.util.Util; +import org.eclipse.jdt.internal.core.JavaModelManager; import org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFormatter.BlockContext; import org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFormatter.NodeMarker; import org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFormatter.Prefix; @@ -160,7 +161,7 @@ public final class ASTRewriteAnalyzer extends ASTVisitor { Map options; - private RecoveryScannerData recoveryScannerData; + private final RecoveryScannerData recoveryScannerData; /** * Constructor for ASTRewriteAnalyzer. @@ -1104,8 +1105,8 @@ class ParagraphListRewriter extends ListRewriter { public final static int DEFAULT_SPACING= 1; - private int initialIndent; - private int separatorLines; + private final int initialIndent; + private final int separatorLines; public ParagraphListRewriter(int initialIndent, int separator) { this.initialIndent= initialIndent; @@ -2109,7 +2110,9 @@ private int getPreviousTokenEndOffset(ASTNode node, int token) { try { offset = getScanner().getPreviousTokenEndOffset(token, offset); } catch (CoreException e1) { - e1.printStackTrace(); + if (JavaModelManager.VERBOSE) { + JavaModelManager.trace("", e1); //$NON-NLS-1$ + } } } return offset; @@ -2141,7 +2144,9 @@ public boolean visit(Dimension node) { delEnd = getScanner().getNextStartOffset(delStart, false); doTextRemove(delStart, delEnd - delStart, null); /* remove spaces after the annotation */ } catch (CoreException e) { - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } } } else if (oldAnnotationSize == 0 && newAnnotationSize > 0) { /* inserting first annotation */ if (ScannerHelper.isWhitespace(this.content[node.getStartPosition() - 1])) { @@ -4658,7 +4663,7 @@ public boolean visit(YieldStatement node) { } try { - int offset= node.isImplicit() ? node.getStartPosition() : getScanner().getTokenEndOffset(TerminalTokens.TokenNamebreak, node.getStartPosition()); + int offset= node.isImplicit() ? node.getStartPosition() : getScanner().getTokenEndOffset(TerminalTokens.TokenNameSEMICOLON, node.getStartPosition()); if ((node.getAST().apiLevel() >= JLS14_INTERNAL)) { rewriteNode(node, YieldStatement.EXPRESSION_PROPERTY, offset, ASTRewriteFormatter.SPACE); // space between yield and label } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java index 564a603eb2..4bed38386d 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFlattener.java @@ -105,7 +105,7 @@ public static String asString(ASTNode node, RewriteEventStore store) { } protected StringBuffer result; - private RewriteEventStore store; + private final RewriteEventStore store; public ASTRewriteFlattener(RewriteEventStore store) { this.store= store; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFormatter.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFormatter.java index 5da51b2c1b..d4f2dc3cc9 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFormatter.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteFormatter.java @@ -52,7 +52,7 @@ public static class NodeMarker extends Position { private class ExtendedFlattener extends ASTRewriteFlattener { - private ArrayList positions; + private final ArrayList positions; public ExtendedFlattener(RewriteEventStore store) { super(store); @@ -247,7 +247,6 @@ public TextEdit formatString(int kind, String string, int offset, int length, in * Creates edits that describe how to format the given string. Returns null if the code could not be formatted for the given kind. * @param node Node describing the type of the string * @param str The unformatted string - * @param indentationLevel * @return Returns the edit representing the result of the formatter * @throws IllegalArgumentException If the offset and length are not inside the string, a * IllegalArgumentException is thrown. @@ -455,7 +454,7 @@ public static interface BlockContext { } public static class ConstPrefix implements Prefix { - private String prefix; + private final String prefix; public ConstPrefix(String prefix) { this.prefix= prefix; @@ -468,10 +467,10 @@ public String getPrefix(int indent) { } private class FormattingPrefix implements Prefix { - private int kind; - private String string; - private int start; - private int length; + private final int kind; + private final String string; + private final int start; + private final int length; public FormattingPrefix(String string, String sub, int kind) { this.start= string.indexOf(sub); @@ -493,8 +492,8 @@ public String getPrefix(int indent) { } private class BlockFormattingPrefix implements BlockContext { - private String prefix; - private int start; + private final String prefix; + private final int start; public BlockFormattingPrefix(String prefix, int start) { this.start= start; @@ -516,9 +515,9 @@ public String[] getPrefixAndSuffix(int indent, ASTNode node, RewriteEventStore e } private class BlockFormattingPrefixSuffix implements BlockContext { - private String prefix; - private String suffix; - private int start; + private final String prefix; + private final String suffix; + private final int start; public BlockFormattingPrefixSuffix(String prefix, String suffix, int start) { this.start= start; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/LineInformation.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/LineInformation.java index 5211074456..85d56537af 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/LineInformation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/LineInformation.java @@ -18,9 +18,6 @@ import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; -/** - * - */ public abstract class LineInformation { public static LineInformation create(final IDocument doc) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ListRewriteEvent.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ListRewriteEvent.java index 9ea5b06078..2d8758bc12 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ListRewriteEvent.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ListRewriteEvent.java @@ -18,9 +18,6 @@ import org.eclipse.jdt.core.dom.ASTNode; -/** - * - */ @SuppressWarnings({"rawtypes", "unchecked"}) public class ListRewriteEvent extends RewriteEvent { @@ -29,7 +26,7 @@ public class ListRewriteEvent extends RewriteEvent { public final static int BOTH= NEW | OLD; /** original list of 'ASTNode' */ - private List originalNodes; + private final List originalNodes; /** list of type 'RewriteEvent' */ private List listEntries; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/NodeInfoStore.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/NodeInfoStore.java index 63493fcc91..78f1835ae2 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/NodeInfoStore.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/NodeInfoStore.java @@ -30,12 +30,9 @@ import org.eclipse.jdt.internal.core.dom.rewrite.RewriteEventStore.CopySourceInfo; -/** - * - */ @SuppressWarnings({"rawtypes", "unchecked"}) public final class NodeInfoStore { - private AST ast; + private final AST ast; private Map placeholderNodes; private Set collapsedNodes; @@ -159,9 +156,6 @@ public String toString() { } } - /** - * - */ public void clear() { this.placeholderNodes= null; this.collapsedNodes= null; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/NodeRewriteEvent.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/NodeRewriteEvent.java index 6b31f9fb2e..c49265dad3 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/NodeRewriteEvent.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/NodeRewriteEvent.java @@ -15,12 +15,9 @@ -/** - * - */ public class NodeRewriteEvent extends RewriteEvent { - private Object originalValue; + private final Object originalValue; private Object newValue; public NodeRewriteEvent(Object originalValue, Object newValue) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/RewriteEvent.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/RewriteEvent.java index 813a2bcb98..e5b7fdd37b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/RewriteEvent.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/RewriteEvent.java @@ -14,9 +14,6 @@ package org.eclipse.jdt.internal.core.dom.rewrite; -/** - * - */ public abstract class RewriteEvent { /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/RewriteEventStore.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/RewriteEventStore.java index e4ef31864e..4d0236aabd 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/RewriteEventStore.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/RewriteEventStore.java @@ -248,7 +248,7 @@ public String toString() { */ private class ParentIterator implements Iterator { - private Iterator eventIter; + private final Iterator eventIter; private Iterator sourceNodeIter; private Iterator rangeNodeIter; private Iterator trackedNodeIter; @@ -477,8 +477,6 @@ public PropertyLocation getPropertyLocation(Object value, int kind) { /** * Kind is either ORIGINAL, NEW, or BOTH - * @param value - * @param kind * @return Returns the event with the given value of null. */ public RewriteEvent findEvent(Object value, int kind) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/TrackedNodePosition.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/TrackedNodePosition.java index 656da6c033..0bc20e3117 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/TrackedNodePosition.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/TrackedNodePosition.java @@ -20,9 +20,6 @@ import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; import org.eclipse.jface.text.IRegion; -/** - * - */ public class TrackedNodePosition implements ITrackedNodePosition { private final TextEditGroup group; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/imports/OnDemandComputer.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/imports/OnDemandComputer.java index 396c85b837..e510a3bcdd 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/imports/OnDemandComputer.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/imports/OnDemandComputer.java @@ -20,8 +20,8 @@ import java.util.Set; class OnDemandComputer { - private int typeOnDemandThreshold; - private int staticOnDemandThreshold; + private final int typeOnDemandThreshold; + private final int staticOnDemandThreshold; OnDemandComputer(int typeOnDemandThreshold, int staticOnDemandThreshold) { this.typeOnDemandThreshold = typeOnDemandThreshold; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/util/DOMASTUtil.java b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/util/DOMASTUtil.java index 000cf31b09..421069b9ed 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/util/DOMASTUtil.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/util/DOMASTUtil.java @@ -212,7 +212,6 @@ public static void checkASTLevel(int level) { * Calculates the JavaCore Option value string corresponding to the input ast level. * AST Level 4 is used for Java versions 1.4 to 1.7 and is converted to compliance level 7 * if input ast level is out of boundary, latest compliance will be returned - * @param astLevel * @return JavaCore Option value string corresponding to the ast level */ public static String getCompliance(int astLevel) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEnvironment.java b/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEnvironment.java index ea376d5d17..4b5252854e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEnvironment.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEnvironment.java @@ -20,6 +20,7 @@ import org.eclipse.jdt.internal.compiler.env.IBinaryType; import org.eclipse.jdt.internal.compiler.env.INameEnvironment; import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; +import org.eclipse.jdt.internal.core.JavaModelManager; /** * An environment that wraps the client's name environment. @@ -63,7 +64,10 @@ public NameEnvironmentAnswer findType(char[][] compoundTypeName) { try { binary = new ClassFileReader(classFile.getBytes(), null); } catch (ClassFormatException e) { - e.printStackTrace(); // Should never happen since we compiled this type + if (JavaModelManager.VERBOSE) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } + // Should never happen since we compiled this type return null; } return new NameEnvironmentAnswer(binary, null /*no access restriction*/); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEvaluator.java b/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEvaluator.java index 850d1811f8..5596ff9563 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEvaluator.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEvaluator.java @@ -27,6 +27,7 @@ import org.eclipse.jdt.internal.compiler.env.IBinaryType; import org.eclipse.jdt.internal.compiler.env.INameEnvironment; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; +import org.eclipse.jdt.internal.core.JavaModelManager; /** * A code snippet evaluator compiles and returns class file for a code snippet. @@ -150,7 +151,10 @@ Compiler getCompiler(ICompilerRequestor compilerRequestor) { try { binaryType = new ClassFileReader(globalClassFiles[i].getBytes(), null); } catch (ClassFormatException e) { - e.printStackTrace(); // Should never happen since we compiled this type + if (JavaModelManager.VERBOSE) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } + // Should never happen since we compiled this type } compiler.lookupEnvironment.cacheBinaryType(binaryType, null /*no access restriction*/); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java b/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java index 920630b2c9..f21f18d34a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java @@ -53,7 +53,6 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl /** * Dump the suitable return bytecode for a return statement - * */ @Override public void generateReturnBytecode(CodeStream codeStream) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java b/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java index 12401511f9..9ac0883dd8 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java @@ -36,6 +36,7 @@ import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; import org.eclipse.jdt.internal.compiler.util.SuffixConstants; +import org.eclipse.jdt.internal.core.JavaModelManager; import org.eclipse.jdt.internal.core.SearchableEnvironment; import org.eclipse.jdt.internal.core.util.Util; @@ -105,7 +106,7 @@ public GlobalVariable[] allVariables() { * * @param owner * the owner of working copies that take precedence over their original compilation units - * + * * @param monitor * the progress monitor used to report progress */ @@ -192,7 +193,10 @@ public char[] getModuleName() { try { binary = new ClassFileReader(classFile.getBytes(), null); } catch (ClassFormatException e) { - e.printStackTrace(); // Should never happen since we compiled this type + if (JavaModelManager.VERBOSE) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } + // Should never happen since we compiled this type } engine.lookupEnvironment.cacheBinaryType(binary, null /*no access restriction*/); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesEvaluator.java b/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesEvaluator.java index 5997987142..fadc5b6c3b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesEvaluator.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesEvaluator.java @@ -24,6 +24,7 @@ import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; import org.eclipse.jdt.internal.compiler.env.IBinaryType; import org.eclipse.jdt.internal.compiler.env.INameEnvironment; +import org.eclipse.jdt.internal.core.JavaModelManager; /** * A variables evaluator compiles the global variables of an evaluation context and returns @@ -167,7 +168,10 @@ Compiler getCompiler(ICompilerRequestor compilerRequestor) { try { binary = new ClassFileReader(classFile.getBytes(), null); } catch (ClassFormatException e) { - e.printStackTrace(); // Should never happen since we compiled this type + if (JavaModelManager.VERBOSE) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } + // Should never happen since we compiled this type } compiler.lookupEnvironment.cacheBinaryType(binary, null /*no access restriction*/); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java index d8a5b3b551..f5ae7e982e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java @@ -6001,7 +6001,7 @@ public static int getIndentStyle(String value) { * @return the settings according to the Java conventions * @since 3.0 */ - public static Map getJavaConventionsSettings() { + public static Map getJavaConventionsSettings() { return DefaultCodeFormatterOptions.getJavaConventionsSettings().getMap(); } /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java index 88d857a454..acc77d653b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java @@ -22,6 +22,7 @@ import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameCOMMENT_LINE; import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameNotAToken; import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameStringLiteral; +import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameTextBlock; import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameWHITESPACE; import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNamepackage; @@ -127,7 +128,7 @@ public class CommentsPreparator extends ASTVisitor { private int noFormatOpenTagStartIndex = -1; private int formatCodeOpenTagEndIndex = -1; private int lastFormatCodeClosingTagIndex = -1; - private ArrayList commonAttributeAnnotations = new ArrayList(); + private final ArrayList commonAttributeAnnotations = new ArrayList(); private DefaultCodeFormatter preTagCodeFormatter; private DefaultCodeFormatter snippetCodeFormatter; @@ -358,7 +359,7 @@ private List findStringLiteralsInLine(int lastTokenIndex) { Token token = this.tm.get(i); if (this.tm.countLineBreaksBetween(token, previous) > 0) break; - if (token.tokenType == TokenNameStringLiteral) + if (token.tokenType == TokenNameStringLiteral || token.tokenType == TokenNameTextBlock) stringLiterals.add(token); previous = token; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java index 98db506c8e..7e72d559e1 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java @@ -102,7 +102,7 @@ public class DefaultCodeFormatter extends CodeFormatter { private List formatRegions; private ASTNode astRoot; - private List tokens = new ArrayList<>(); + private final List tokens = new ArrayList<>(); private TokenManager tokenManager; public DefaultCodeFormatter() { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java index f3b609ce77..c1befdcdd5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java @@ -148,7 +148,7 @@ public class SpacePreparator extends ASTVisitor { } TokenManager tm; - private DefaultCodeFormatterOptions options; + private final DefaultCodeFormatterOptions options; public SpacePreparator(TokenManager tokenManager, DefaultCodeFormatterOptions options) { this.tm = tokenManager; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/TextEditsBuilder.java b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/TextEditsBuilder.java index b822e7729e..cf5c7e8375 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/TextEditsBuilder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/TextEditsBuilder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2018 Mateusz Matela and others. + * Copyright (c) 2014, 2023 Mateusz Matela and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -136,7 +136,7 @@ protected boolean token(Token token, int index) { } } - if (token.tokenType == TokenNameStringLiteral) + if (token.tokenType == TokenNameStringLiteral || token.tokenType == TokenNameTextBlock) this.stringLiteralsInLine.add(token); if (getNext() == null) { @@ -553,4 +553,4 @@ public List getEdits() { public void setAlignChar(int alignChar) { this.alignChar = alignChar; } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/TokenManager.java b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/TokenManager.java index 28d06331da..9ceeb2c574 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/TokenManager.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/TokenManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2022 Mateusz Matela and others. + * Copyright (c) 2014, 2023 Mateusz Matela and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -18,6 +18,7 @@ import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameNotAToken; import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameStringLiteral; import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameTextBlock; +import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameIdentifier; import java.util.ArrayList; import java.util.HashMap; @@ -32,6 +33,7 @@ import org.eclipse.jdt.core.dom.StringLiteral; import org.eclipse.jdt.core.dom.TypeDeclaration; import org.eclipse.jdt.core.dom.InfixExpression.Operator; +import org.eclipse.jdt.internal.compiler.parser.TerminalTokens; import org.eclipse.jdt.internal.formatter.Token.WrapMode; import org.eclipse.jdt.internal.formatter.linewrap.CommentWrapExecutor; @@ -52,7 +54,7 @@ public class TokenManager implements Iterable { final CommentWrapExecutor commentWrapper; private HashMap tokenIndexToNLSAlign; - private List formatOffTagPairs = new ArrayList<>(); + private final List formatOffTagPairs = new ArrayList<>(); private int headerEndIndex = 0; public TokenManager(List tokens, String source, DefaultCodeFormatterOptions options) { @@ -167,7 +169,12 @@ public int findIndex(int positionInSource, int tokenType, boolean forward) { index--; if (forward && get(index).originalEnd < positionInSource) index++; - while (tokenType >= 0 && get(index).tokenType != tokenType) { + Token t; + while (tokenType >= 0 && (t = get(index)).tokenType != tokenType) { + if (TerminalTokens.isRestrictedKeyword(tokenType) && t.tokenType == TokenNameIdentifier) { + if (tokenType == TerminalTokens.getRestrictedKeyword(toString(t))) + break; + } index += forward ? 1 : -1; } return index; @@ -243,7 +250,7 @@ public int countLineBreaksBetween(String text, int startPosition, int endPositio return result; } - private TokenTraverser positionInLineCounter = new TokenTraverser() { + private final TokenTraverser positionInLineCounter = new TokenTraverser() { private boolean isNLSTagInLine = false; @Override @@ -253,7 +260,7 @@ protected boolean token(Token traversed, int index) { return false; } if (traversed.hasNLSTag()) { - assert traversed.tokenType == TokenNameStringLiteral; + assert traversed.tokenType == TokenNameStringLiteral || traversed.tokenType == TokenNameTextBlock; this.isNLSTagInLine = true; } if (traversed.getAlign() > 0) diff --git a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapExecutor.java b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapExecutor.java index b347880f56..28df674e70 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapExecutor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapExecutor.java @@ -229,7 +229,7 @@ private boolean isActiveTopPriorityWrap(int index, WrapPolicy wrapPolicy) { private class WrapsApplier extends TokenTraverser { private final TokenManager tm2 = WrapExecutor.this.tm; - private ArrayDeque stack = new ArrayDeque<>(); + private final ArrayDeque stack = new ArrayDeque<>(); private int initialIndent; private int currentIndent; private int fixedIndentDelta; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java index 7aea8e8705..b337b2c15a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2022 Mateusz Matela and others. + * Copyright (c) 2014, 2023 Mateusz Matela and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -40,6 +40,7 @@ import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNamenew; import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameRestrictedIdentifierpermits; import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNamesuper; +import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameTextBlock; import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNamethis; import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNamethrows; import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameto; @@ -239,10 +240,10 @@ public int getIdentifierIndex(TokenManager tm) { * temporary values used when calling {@link #handleWrap(int)} to avoid ArrayList initialization and long lists of * parameters */ - private List wrapIndexes = new ArrayList<>(); + private final List wrapIndexes = new ArrayList<>(); /** Indexes for wraps that shouldn't happen but should be indented if cannot be removed */ - private List secondaryWrapIndexes = new ArrayList<>(); - private List wrapPenalties = new ArrayList<>(); + private final List secondaryWrapIndexes = new ArrayList<>(); + private final List wrapPenalties = new ArrayList<>(); private int wrapParentIndex = -1; private int wrapGroupEnd = -1; @@ -1566,7 +1567,7 @@ private void wrapComments() { if (token.getLineBreaksBefore() > 0 || token.getLineBreaksAfter() > 0) isNLSTagInLine = false; if (token.hasNLSTag()) { - assert token.tokenType == TokenNameStringLiteral; + assert token.tokenType == TokenNameStringLiteral || token.tokenType == TokenNameTextBlock; isNLSTagInLine = true; } List structure = token.getInternalStructure(); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/BindingKey.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/BindingKey.java index b8f3cb7774..5707a7cf18 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/BindingKey.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/BindingKey.java @@ -28,7 +28,7 @@ */ public final class BindingKey { - private String key; + private final String key; /** * Creates a new binding key. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/BufferChangedEvent.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/BufferChangedEvent.java index 17b11c2ed4..e6144611a7 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/BufferChangedEvent.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/BufferChangedEvent.java @@ -48,17 +48,17 @@ public class BufferChangedEvent extends EventObject { /** * The length of text that has been modified in the buffer. */ - private int length; + private final int length; /** * The offset into the buffer where the modification took place. */ - private int offset; + private final int offset; /** * The text that was modified. */ - private String text; + private final String text; private static final long serialVersionUID = 655379473891745999L; // backward compatible diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ElementChangedEvent.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ElementChangedEvent.java index 86f6ba29c3..f0790310c6 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ElementChangedEvent.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ElementChangedEvent.java @@ -95,7 +95,7 @@ public class ElementChangedEvent extends EventObject { * - PRE_AUTO_BUILD * - POST_RECONCILE */ - private int type; + private final int type; /** * Creates an new element changed event (based on a IJavaElementDelta). diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeAssist.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeAssist.java index a9c25caf0d..17b354736f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeAssist.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeAssist.java @@ -257,7 +257,6 @@ void codeComplete(int offset, CompletionRequestor requestor, WorkingCopyOwner ow *
  • The range specified is not within this element's * source range (INDEX_OUT_OF_BOUNDS) * - * */ IJavaElement[] codeSelect(int offset, int length) throws JavaModelException; /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IField.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IField.java index 93caca0f80..19b8cafbe8 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IField.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IField.java @@ -94,7 +94,6 @@ public interface IField extends IMember, IAnnotatable { * Returns whether this field represents a record component. * * @return whether this field represents a record component. - * @throws JavaModelException * @since 3.26 */ boolean isRecordComponent() throws JavaModelException; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java index 3b7e74c03d..6def10a572 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java @@ -638,7 +638,6 @@ IPackageFragmentRoot findPackageFragmentRoot(IPath path) * @return the {@link IModuleDescription} this project owns. * @exception JavaModelException if this element does not exist or if an * exception occurs while accessing its corresponding resource - * @throws JavaModelException * @since 3.20 */ IModuleDescription getOwnModuleDescription() throws JavaModelException; @@ -1150,7 +1149,6 @@ void setRawClasspath(IClasspathEntry[] entries, IClasspathEntry[] referencedEntr * {@link #setRawClasspath(IClasspathEntry[], IClasspathEntry[], IPath, IProgressMonitor)} * If the client has not stored any referenced entries for this project, an empty array is returned. * - * @throws JavaModelException * @return an array of referenced classpath entries stored for this java project or an empty array if none * stored earlier. * @since 3.6 @@ -1248,7 +1246,6 @@ void setRawClasspath(IClasspathEntry[] entries, IPath outputLocation, IProgressM * @param path * IPath * @return the classpath entry or null. - * @throws JavaModelException * @since 3.14 */ IClasspathEntry getClasspathEntryFor(IPath path) throws JavaModelException; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IMethod.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IMethod.java index d0f7804856..c28b0eac69 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IMethod.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IMethod.java @@ -111,7 +111,7 @@ public interface IMethod extends IMember, IAnnotatable { *

    For binary types, associated source is used to retrieve the {@link ILocalVariable#getNameRange() name range}, * {@link ILocalVariable#getSourceRange() source range} and the {@link ILocalVariable#getFlags() flags}.

    *

    These local variables can be used to retrieve the {@link ILocalVariable#getAnnotations() parameter annotations}.

    - * + * * @return the parameters of this method * @throws JavaModelException if this element does not exist or if an * exception occurs while accessing its corresponding resource. @@ -263,6 +263,31 @@ public interface IMethod extends IMember, IAnnotatable { */ boolean isMainMethod() throws JavaModelException; +/** + * Returns whether this method is a main method candidate. + * It is a main method if: + *
      + *
    • its name is equal to "main"
    • + *
    • its return type is void
    • + *
    • it is static and public
    • + *
    • it defines one parameter whose type's simple name is String[]
    • + *
    + * Starting with Java 21 there is "preview feature" that allows instance main methods. + * It is a main method according to this JEP if: + *
      + *
    • its name is equal to "main"
    • + *
    • its return type is void
    • + *
    • it is non-private
    • + *
    • it defines one parameter whose type's simple name is String[] or no parameter at all
    • + *
    + * + * @exception JavaModelException if this element does not exist or if an + * exception occurs while accessing its corresponding resource. + * @since 3.36 + * @return true if this method is a main method, false otherwise + */ +boolean isMainMethodCandidate() throws JavaModelException; + /** * Returns whether this method represents a lambda expression. * diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IModularClassFile.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IModularClassFile.java index d67fe823ba..0156e8e67c 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IModularClassFile.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IModularClassFile.java @@ -24,7 +24,6 @@ public interface IModularClassFile extends IClassFile { * Returns the module description contained in this type root. * An error-free {@link IModularClassFile} should always have a module. * - * @throws JavaModelException * @return the module description contained in the type root. */ @Override diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IModuleDescription.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IModuleDescription.java index bf5eed5c96..a364029b88 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IModuleDescription.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IModuleDescription.java @@ -36,21 +36,19 @@ public interface IModuleDescription extends IMember, IAnnotatable { * @since 3.14 */ String[] getRequiredModuleNames() throws JavaModelException; - + /** * Get provided service names for this module. * * @return a non-null array of provided service names - * @throws JavaModelException * @since 3.18 */ String[] getProvidedServiceNames() throws JavaModelException; - + /** * Get used service names for this module. * * @return a non-null array of used service names - * @throws JavaModelException * @since 3.18 */ String[] getUsedServiceNames() throws JavaModelException; @@ -60,7 +58,6 @@ public interface IModuleDescription extends IMember, IAnnotatable { * * @param targetModule filter the result to include only packages exported to the given module, unless {@code null}. * @return a non-null array of exported package names - * @throws JavaModelException * @since 3.18 */ String[] getExportedPackageNames(IModuleDescription targetModule) throws JavaModelException; @@ -70,13 +67,12 @@ public interface IModuleDescription extends IMember, IAnnotatable { * * @param targetModule filter the result to include only packages opened to the given module, unless {@code null}. * @return a non-null array of opened package names - * @throws JavaModelException * @since 3.18 */ String[] getOpenedPackageNames(IModuleDescription targetModule) throws JavaModelException; /** - * + * * @return true if automatic module, else false * @since 3.14 */ diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ITypeRoot.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ITypeRoot.java index 1556b177bf..e1c77781b2 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ITypeRoot.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ITypeRoot.java @@ -41,7 +41,6 @@ public interface ITypeRoot extends IJavaElement, IParent, IOpenable, ISourceRefe * in this type root. *

    Only subtype {@link IModularClassFile} promises to return non-null.

    * - * @throws JavaModelException * @since 3.14 * @return the module description contained in the type root or null. */ diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java index 983bf40675..7d50caa241 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java @@ -114,6 +114,8 @@ package org.eclipse.jdt.core; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -3878,8 +3880,7 @@ private static ClasspathContainerInitializer computeClasspathContainerInitialize } catch(CoreException e) { // executable extension could not be created: ignore this initializer if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { - verbose_failed_to_instanciate_container_initializer(containerID, configurationElement); - e.printStackTrace(); + verbose_failed_to_instanciate_container_initializer(containerID, configurationElement, e); } } } @@ -3889,16 +3890,16 @@ private static ClasspathContainerInitializer computeClasspathContainerInitialize return null; } - private static void verbose_failed_to_instanciate_container_initializer(String containerID, IConfigurationElement configurationElement) { - Util.verbose( + private static void verbose_failed_to_instanciate_container_initializer(String containerID, IConfigurationElement configurationElement, CoreException e) { + trace( "CPContainer INIT - failed to instanciate initializer\n" + //$NON-NLS-1$ " container ID: " + containerID + '\n' + //$NON-NLS-1$ " class: " + configurationElement.getAttribute("class"), //$NON-NLS-1$ //$NON-NLS-2$ - System.err); + e); } private static void verbose_found_container_initializer(String containerID, IConfigurationElement configurationElement) { - Util.verbose( + trace( "CPContainer INIT - found initializer\n" + //$NON-NLS-1$ " container ID: " + containerID + '\n' + //$NON-NLS-1$ " class: " + configurationElement.getAttribute("class")); //$NON-NLS-1$ //$NON-NLS-2$ @@ -3959,7 +3960,7 @@ public static IPath getClasspathVariable(final String variableName) { ok = true; } catch (RuntimeException | Error e) { if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) - e.printStackTrace(); + trace("", new Exception(e)); //$NON-NLS-1$ throw e; } finally { if (!ok) JavaModelManager.getJavaModelManager().variablePut(variableName, null); // flush cache @@ -3972,36 +3973,34 @@ public static IPath getClasspathVariable(final String variableName) { } private static void verbose_no_variable_initializer_found(String variableName) { - Util.verbose( + trace( "CPVariable INIT - no initializer found\n" + //$NON-NLS-1$ " variable: " + variableName); //$NON-NLS-1$ } private static void verbose_variable_value_after_initialization(String variableName, IPath variablePath) { - Util.verbose( + trace( "CPVariable INIT - after initialization\n" + //$NON-NLS-1$ " variable: " + variableName +'\n' + //$NON-NLS-1$ " variable path: " + variablePath); //$NON-NLS-1$ } private static void verbose_triggering_variable_initialization(String variableName, ClasspathVariableInitializer initializer) { - Util.verbose( + trace( "CPVariable INIT - triggering initialization\n" + //$NON-NLS-1$ " variable: " + variableName + '\n' + //$NON-NLS-1$ " initializer: " + initializer); //$NON-NLS-1$ } private static void verbose_triggering_variable_initialization_invocation_trace() { - Util.verbose( + trace( "CPVariable INIT - triggering initialization\n" + //$NON-NLS-1$ - " invocation trace:"); //$NON-NLS-1$ - new Exception("").printStackTrace(System.out); //$NON-NLS-1$ + " invocation trace:", new Exception("")); //$NON-NLS-1$ //$NON-NLS-2$ } /** * Returns deprecation message of a given classpath variable. * - * @param variableName * @return A string if the classpath variable is deprecated, null otherwise. * @since 3.3 */ @@ -4088,8 +4087,7 @@ public static ClasspathVariableInitializer getClasspathVariableInitializer(Strin } catch(CoreException e){ // executable extension could not be created: ignore this initializer if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { - verbose_failed_to_instanciate_variable_initializer(variable, configElement); - e.printStackTrace(); + verbose_failed_to_instanciate_variable_initializer(variable, configElement, e); } } } @@ -4098,16 +4096,16 @@ public static ClasspathVariableInitializer getClasspathVariableInitializer(Strin return null; } - private static void verbose_failed_to_instanciate_variable_initializer(String variable, IConfigurationElement configElement) { - Util.verbose( + private static void verbose_failed_to_instanciate_variable_initializer(String variable, IConfigurationElement configElement, CoreException e) { + trace( "CPContainer INIT - failed to instanciate initializer\n" + //$NON-NLS-1$ " variable: " + variable + '\n' + //$NON-NLS-1$ " class: " + configElement.getAttribute("class"), //$NON-NLS-1$ //$NON-NLS-2$ - System.err); + e); } private static void verbose_found_variable_initializer(String variable, IConfigurationElement configElement) { - Util.verbose( + trace( "CPVariable INIT - found initializer\n" + //$NON-NLS-1$ " variable: " + variable + '\n' + //$NON-NLS-1$ " class: " + configElement.getAttribute("class")); //$NON-NLS-1$ //$NON-NLS-2$ @@ -4251,7 +4249,9 @@ public static IResource[] getGeneratedResources(IRegion region, boolean includes outputLocation = entryOutputLocation; } } catch (JavaModelException e) { - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + trace("", e); //$NON-NLS-1$ + } } if (outputLocation == null) continue; IContainer container = (IContainer) project.getWorkspace().getRoot().findMember(outputLocation); @@ -4710,16 +4710,18 @@ public static void initializeAfterLoad(IProgressMonitor monitor) throws CoreExce String newVersionNumber = Byte.toString(State.VERSION); if (!newVersionNumber.equals(versionNumber)) { // build state version number has changed: touch every projects to force a rebuild - if (JavaBuilder.DEBUG) - System.out.println("Build state version number has changed"); //$NON-NLS-1$ + if (JavaBuilder.DEBUG) { + trace("Build state version number has changed"); //$NON-NLS-1$ + } IWorkspaceRunnable runnable = new IWorkspaceRunnable() { @Override public void run(IProgressMonitor progressMonitor2) throws CoreException { for (int i = 0, length = projects.length; i < length; i++) { IJavaProject project = projects[i]; try { - if (JavaBuilder.DEBUG) - System.out.println("Touching " + project.getElementName()); //$NON-NLS-1$ + if (JavaBuilder.DEBUG) { + trace("Touching " + project.getElementName()); //$NON-NLS-1$ + } new ClasspathValidation((JavaProject) project).validate(); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=287164 project.getProject().touch(progressMonitor2); } catch (CoreException e) { @@ -4781,7 +4783,6 @@ public void acceptType( /** * Returns whether a given classpath variable is read-only or not. * - * @param variableName * @return true if the classpath variable is read-only, * false otherwise. * @since 3.3 @@ -5881,7 +5882,6 @@ public static void removePreProcessingResourceChangedListener(IResourceChangeLis * * @param monitor a progress monitor, or null if progress * reporting and cancellation are not desired - * @throws CoreException * @since 3.13 */ public static void rebuildIndex(IProgressMonitor monitor) throws CoreException { @@ -6016,7 +6016,6 @@ public static void run(IWorkspaceRunnable action, ISchedulingRule rule, IProgres * @param affectedProjects - the set of projects for which this container is being bound * @param respectiveContainers - the set of respective containers for the affected projects * @param monitor a monitor to report progress - * @throws JavaModelException * @see ClasspathContainerInitializer * @see #getClasspathContainer(IPath, IJavaProject) * @see IClasspathContainer @@ -6054,7 +6053,6 @@ public static void setClasspathContainer(IPath containerPath, IJavaProject[] aff * * @param variableName the name of the classpath variable * @param path the path - * @throws JavaModelException * @see #getClasspathVariable(String) * * @deprecated Use {@link #setClasspathVariable(String, IPath, IProgressMonitor)} instead @@ -6083,7 +6081,6 @@ public static void setClasspathVariable(String variableName, IPath path) * @param variableName the name of the classpath variable * @param path the path * @param monitor a monitor to report progress - * @throws JavaModelException * @see #getClasspathVariable(String) */ public static void setClasspathVariable( @@ -6122,7 +6119,6 @@ public static void setClasspathVariable( * @param paths an array of path updates for the modified classpath variables (null * meaning that the corresponding value will be removed * @param monitor a monitor to report progress - * @throws JavaModelException * @see #getClasspathVariable(String) * @since 2.0 */ @@ -6311,7 +6307,6 @@ public static int compareJavaVersions(String first, String second) { * @param project * the project whose referenced modules to be computed * @return an array of String containing module names - * @throws CoreException * @since 3.14 */ public static String[] getReferencedModules(IJavaProject project) throws CoreException { @@ -6329,7 +6324,6 @@ public static String[] getReferencedModules(IJavaProject project) throws CoreExc * * @return the IModuleDescription representing this java element as an automatic module, * never null. - * @throws JavaModelException * @throws IllegalArgumentException if the provided element is neither IPackageFragmentRoot * nor IJavaProject * @since 3.14 @@ -6379,7 +6373,6 @@ public static List defaultRootModules(Iterable all * @param classFileAttributes map of attribute names and values to be used during class file generation * @return the compiled byte code * - * @throws JavaModelException * @throws IllegalArgumentException if the map of classFileAttributes contains an unsupported key. * @since 3.14 */ @@ -6478,7 +6471,6 @@ public void stop(BundleContext context) throws Exception { * Registers the JavaModelManager as a resource changed listener and save participant. * Starts the background indexing, and restore saved classpath variable values. *

    - * @throws Exception * @see org.eclipse.core.runtime.Plugin#start(BundleContext) */ @Override diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/SourceRange.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/SourceRange.java index c8883edaa4..320935fd47 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/SourceRange.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/SourceRange.java @@ -37,8 +37,8 @@ public static boolean isAvailable(ISourceRange range) { // see https://bugs.ecli return range != null && range.getOffset() != -1; } - private int offset; - private int length; + private final int offset; + private final int length; /** * Instantiate a new source range using the given offset and the given length. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ToolFactory.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ToolFactory.java index 78e8b3739c..8e45e49e88 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ToolFactory.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ToolFactory.java @@ -358,7 +358,7 @@ public static IClassFileReader createDefaultClassFileReader(String zipFileName, ZipFile zipFile = null; try { if (JavaModelManager.ZIP_ACCESS_VERBOSE) { - System.out.println("(" + Thread.currentThread() + ") [ToolFactory.createDefaultClassFileReader()] Creating ZipFile on " + zipFileName); //$NON-NLS-1$ //$NON-NLS-2$ + JavaModelManager.trace("(" + Thread.currentThread() + ") [ToolFactory.createDefaultClassFileReader()] Creating ZipFile on " + zipFileName); //$NON-NLS-1$ //$NON-NLS-2$ } zipFile = new ZipFile(zipFileName); ZipEntry zipEntry = zipFile.getEntry(zipEntryName); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/ReconcileContext.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/ReconcileContext.java index 33fef4cd56..d76c27b820 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/ReconcileContext.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/ReconcileContext.java @@ -52,8 +52,8 @@ @SuppressWarnings({"rawtypes"}) public class ReconcileContext { - private ReconcileWorkingCopyOperation operation; - private CompilationUnit workingCopy; + private final ReconcileWorkingCopyOperation operation; + private final CompilationUnit workingCopy; /** * Creates a reconcile context for the given reconcile operation. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/provisional/JavaModelAccess.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/provisional/JavaModelAccess.java index 0bdc298098..207fe2a9ab 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/provisional/JavaModelAccess.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/core/provisional/JavaModelAccess.java @@ -23,7 +23,7 @@ /** * Provisional API for use by JDT/UI or JDT/Debug, which may possibly be removed in a future version. - * See Bug 522391. + * See Bug 522391. */ public class JavaModelAccess { /** @@ -38,17 +38,16 @@ public static String[] getRequiredModules(IModuleDescription module) throws Java } /** - * Returns the IModuleDescription that the given java element contains + * Returns the IModuleDescription that the given java element contains * when regarded as an automatic module. The element must be an IPackageFragmentRoot * or an IJavaProject. - * + * *

    The returned module descriptor has a name (getElementName()) following * the specification of java.lang.module.ModuleFinder.of(Path...), but it * contains no other useful information.

    - * + * * @return the IModuleDescription representing this java element as an automatic module, * never null. - * @throws JavaModelException * @throws IllegalArgumentException if the provided element is neither IPackageFragmentRoot * nor IJavaProject * @since 3.14 @@ -67,7 +66,7 @@ public static IModuleDescription getAutomaticModuleDescription(IJavaElement elem /** * Answer whether the given module is a system module. *

    This provisional API may likely be changed into a direct method {@code IModuleDescription.isSystemModule()}.

    - * + * * @param module the module being queried about * @return {@code true} iff the module is defined in the system library (also known as JRE). * @since 3.18 diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/IDocumentElementRequestor.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/IDocumentElementRequestor.java index 1c12f0b3e0..ee9e7da3db 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/IDocumentElementRequestor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/IDocumentElementRequestor.java @@ -97,7 +97,6 @@ void acceptInitializer( * of the parse action, so as to allow computation of normalized ranges. * * A line separator might corresponds to several characters in the source, - * */ void acceptLineSeparatorPositions(int[] positions); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java index a8b17e6f17..aa3968b73f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java @@ -191,7 +191,6 @@ public static class FieldInfo { * the parse action, so as to allow computation of normalized ranges. * * A line separator might corresponds to several characters in the source, - * */ void acceptLineSeparatorPositions(int[] positions); @@ -243,4 +242,12 @@ default void enterModule(ModuleInfo info) { default void exitModule(int declarationEnd) { // do nothing } + + default void enterCompactConstructor(MethodInfo methodInfo) { + // do nothing + } + + default void exitCompactConstructor(int declarationEnd) { + // do nothing + } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java index 83381b4290..0ae22e7fcb 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java @@ -255,8 +255,8 @@ protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDecl this.visitIfNeeded(methodDeclaration); return; } - if ((methodDeclaration.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.IsImplicit) != 0) - return; + + final boolean isImplicit = (methodDeclaration.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.IsImplicit) != 0; if (methodDeclaration.isDefaultConstructor()) { if (this.reportReferenceInfo) { @@ -329,7 +329,11 @@ protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDecl methodInfo.declaringTypeModifiers = declaringType.modifiers; methodInfo.extraFlags = ExtraFlags.getExtraFlags(declaringType); methodInfo.node = methodDeclaration; - this.requestor.enterConstructor(methodInfo); + if(isImplicit) { + this.requestor.enterCompactConstructor(methodInfo); + } else { + this.requestor.enterConstructor(methodInfo); + } } if (this.reportReferenceInfo) { ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration; @@ -354,7 +358,11 @@ protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDecl } this.visitIfNeeded(methodDeclaration); if (isInRange){ - this.requestor.exitConstructor(methodDeclaration.declarationSourceEnd); + if(isImplicit) { + this.requestor.exitCompactConstructor(methodDeclaration.declarationSourceEnd); + } else { + this.requestor.exitConstructor(methodDeclaration.declarationSourceEnd); + } } return; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java index da5057dd31..8dd483f170 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java @@ -27,7 +27,6 @@ * | not take advantage of remote field constant inlining. * | Given the intended purpose of the conversion is to resolve references, this is not * | a problem. - * */ import org.codehaus.jdt.groovy.integration.LanguageSupportFactory; @@ -73,7 +72,7 @@ static class AnonymousMemberFound extends RuntimeException { public static final int LOCAL_TYPE = 0x20; public static final int NONE = 0; - private int flags; + private final int flags; private CompilationUnitDeclaration unit; private Parser parser; private ICompilationUnit cu; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/TypeConverter.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/TypeConverter.java index 2b1951fe26..f6073fdad5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/TypeConverter.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/TypeConverter.java @@ -41,7 +41,7 @@ public abstract class TypeConverter { protected ProblemReporter problemReporter; protected boolean has1_5Compliance; protected boolean has14_Compliance; - private char memberTypeSeparator; + private final char memberTypeSeparator; protected TypeConverter(ProblemReporter problemReporter, char memberTypeSeparator) { this.problemReporter = problemReporter; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/AbstractModule.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/AbstractModule.java index b95f900110..515072ed0d 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/AbstractModule.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/AbstractModule.java @@ -28,15 +28,15 @@ import org.eclipse.jdt.internal.compiler.env.IModule.IService; public interface AbstractModule extends IModuleDescription { - + /** * Handle for an automatic module. * *

    Note, that by definition this is mostly a fake, only {@link #getElementName()} provides a useful value.

    */ static class AutoModule extends NamedMember implements AbstractModule { - - private boolean nameFromManifest; + + private final boolean nameFromManifest; public AutoModule(JavaElement parent, String name, boolean nameFromManifest) { super(parent, name); @@ -75,7 +75,7 @@ public void toStringContent(StringBuffer buffer, String lineDelimiter) throws Ja buffer.append(this.name); } } - + // "forward declaration" for a method from JavaElement: abstract Object getElementInfo() throws JavaModelException; @@ -123,7 +123,7 @@ default IPackageExport[] getExportedPackages() throws JavaModelException { default IService[] getProvidedServices() throws JavaModelException { return getModuleInfo().provides(); } - @Override + @Override default String[] getProvidedServiceNames() throws JavaModelException { ArrayList results = new ArrayList<>(); IService[] services = getProvidedServices(); @@ -131,12 +131,12 @@ default String[] getProvidedServiceNames() throws JavaModelException { results.add(new String(service.name())); } return results.toArray(new String[0]); - + } default char[][] getUsedServices() throws JavaModelException { return getModuleInfo().uses(); } - @Override + @Override default String[] getUsedServiceNames() throws JavaModelException { ArrayList results = new ArrayList<>(); char[][] services = getUsedServices(); @@ -144,7 +144,7 @@ default String[] getUsedServiceNames() throws JavaModelException { char[] service = services[i]; results.add(new String(service)); } - return results.toArray(new String[0]); + return results.toArray(new String[0]); } default IPackageExport[] getOpenedPackages() throws JavaModelException { return getModuleInfo().opens(); @@ -160,8 +160,9 @@ default String toString(String lineDelimiter) { try { toStringContent(buffer, lineDelimiter); } catch (JavaModelException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } } return buffer.toString(); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java index 16183556d7..f11348094f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java @@ -655,6 +655,11 @@ public boolean isConstructor() throws JavaModelException { public boolean isMainMethod() throws JavaModelException { return this.isMainMethod(this); } + +@Override +public boolean isMainMethodCandidate() throws JavaModelException { + return this.isMainMethodCandidate(this); +} /* * @see IMethod#isLambdaMethod() */ diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryModule.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryModule.java index 02053a1b07..bb319ebbe6 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryModule.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryModule.java @@ -136,9 +136,10 @@ public String toString(String lineDelimiter) { try { toStringContent(buffer, lineDelimiter); } catch (JavaModelException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } } return buffer.toString(); } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java index 07ed1f29de..90c0e7ba88 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java @@ -140,8 +140,8 @@ public void codeComplete( engine.complete(this, snippet, position, localVariableTypeNames, localVariableNames, localVariableModifiers, isStatic); } if (NameLookup.VERBOSE) { - System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ - System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + JavaModelManager.trace(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + JavaModelManager.trace(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryTypeConverter.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryTypeConverter.java index 191e06280e..6274f75bfd 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryTypeConverter.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryTypeConverter.java @@ -48,8 +48,8 @@ */ public class BinaryTypeConverter extends TypeConverter { - private CompilationResult compilationResult; - private HashSetOfCharArrayArray typeNames; + private final CompilationResult compilationResult; + private final HashSetOfCharArrayArray typeNames; public BinaryTypeConverter(ProblemReporter problemReporter, CompilationResult compilationResult, HashSetOfCharArrayArray typeNames) { super(problemReporter, Signature.C_DOLLAR); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferCache.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferCache.java index 043f930dd9..2af2df7854 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferCache.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferCache.java @@ -24,7 +24,7 @@ */ public class BufferCache extends OverflowingLRUCache { - private ThreadLocal> buffersToClose = new ThreadLocal<>(); + private final ThreadLocal> buffersToClose = new ThreadLocal<>(); /** * Constructs a new buffer cache of the given size. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferManager.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferManager.java index 99c4a7993b..589bf62db2 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferManager.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferManager.java @@ -34,7 +34,7 @@ public class BufferManager { * LRU cache of buffers. The key and value for an entry * in the table is the identical buffer. */ - private BufferCache openBuffers = new BufferCache<>(60); + private final BufferCache openBuffers = new BufferCache<>(60); /** * @deprecated diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java index 77043eb3da..19c7c68c87 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java @@ -216,7 +216,7 @@ public IBinaryType getBinaryTypeInfo() throws JavaModelException { } catch (ClassFormatException cfe) { //the structure remains unknown if (JavaCore.getPlugin().isDebugging()) { - cfe.printStackTrace(System.err); + JavaModelManager.trace("", cfe); //$NON-NLS-1$ } return null; } catch (IOException ioe) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathAttribute.java index 3b7fed047a..0f58cdc4cf 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathAttribute.java @@ -18,8 +18,8 @@ public class ClasspathAttribute implements IClasspathAttribute { - private String name; - private String value; + private final String name; + private final String value; public ClasspathAttribute(String name, String value) { this.name = name; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathChange.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathChange.java index da4c355431..f1b6c4543d 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathChange.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathChange.java @@ -15,6 +15,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; @@ -290,7 +292,7 @@ public int generateDelta(JavaElementDelta delta, boolean addClasspathChange) { deltaProcessor.projectCachesToReset.add(this.project); } catch (JavaModelException e) { if (DeltaProcessor.VERBOSE) { - e.printStackTrace(); + trace("", e); //$NON-NLS-1$ } // project no longer exist return result; @@ -459,8 +461,9 @@ public int generateDelta(JavaElementDelta delta, boolean addClasspathChange) { delta.removed(frag); } } catch (JavaModelException e) { - if (DeltaProcessor.VERBOSE) - e.printStackTrace(); + if (DeltaProcessor.VERBOSE) { + trace("", e); //$NON-NLS-1$ + } } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java index f868e62670..a9831e4d40 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java @@ -22,6 +22,7 @@ import static org.eclipse.jdt.internal.compiler.util.Util.UTF_8; import static org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsCharArray; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; import java.io.File; import java.io.IOException; @@ -161,16 +162,16 @@ public AssertionFailedException(String message) { /** * Patterns allowing to include/exclude portions of the resource tree denoted by this entry path. */ - private IPath[] inclusionPatterns; + private final IPath[] inclusionPatterns; private volatile char[][] fullInclusionPatternChars; - private IPath[] exclusionPatterns; + private final IPath[] exclusionPatterns; private volatile char[][] fullExclusionPatternChars; private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$ public final static ClasspathEntry[] NO_ENTRIES = new ClasspathEntry[0]; private final static IPath[] NO_PATHS = new IPath[0]; private final static IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - private boolean combineAccessRules; + private final boolean combineAccessRules; private String rootID; private AccessRuleSet accessRuleSet; @@ -983,14 +984,14 @@ private static void resolvedChainedLibraries(IPath jarPath, HashSet visited, Arr String calledFileName = (String) calledFilesIterator.next(); if (!directoryPath.isValidPath(calledFileName)) { if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { - Util.verbose("Invalid Class-Path entry " + calledFileName + " in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ + trace("Invalid Class-Path entry " + calledFileName + " in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ } } else { IPath calledJar = directoryPath.append(new Path(calledFileName)); // Ignore if segment count is Zero (https://bugs.eclipse.org/bugs/show_bug.cgi?id=308150) if (calledJar.segmentCount() == 0) { if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { - Util.verbose("Invalid Class-Path entry " + calledFileName + " in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ + trace("Invalid Class-Path entry " + calledFileName + " in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ } continue; } @@ -1042,20 +1043,19 @@ private static List getCalledFileNames(IPath jarPath) { calledFileNames = analyzer.getCalledFileNames(); if (!success || analyzer.getClasspathSectionsCount() == 1 && calledFileNames == null) { if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { - Util.verbose("Invalid Class-Path header in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ + trace("Invalid Class-Path header in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ } return null; } else if (analyzer.getClasspathSectionsCount() > 1) { if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { - Util.verbose("Multiple Class-Path headers in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ + trace("Multiple Class-Path headers in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ } return null; } } catch (CoreException | IOException e) { // not a zip file if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { - Util.verbose("Could not read Class-Path header in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ - e.printStackTrace(); + trace("Could not read Class-Path header in manifest of jar file: " + jarPath.toOSString(), e); //$NON-NLS-1$ } } return calledFileNames; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathValidation.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathValidation.java index 14a914f846..68b52be5d2 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathValidation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathValidation.java @@ -27,7 +27,7 @@ */ public class ClasspathValidation { - private JavaProject project; + private final JavaProject project; public ClasspathValidation(JavaProject project) { this.project = project; @@ -64,9 +64,9 @@ public void validate() { if (!status.isOK()) this.project.createClasspathProblemMarker(status); - // update overlapping output problem markers + // update overlapping output problem markers this.project.flushClasspathProblemMarkers(false/*cycle*/, false/*format*/, true/*overlapping*/); - + // update resolved classpath problems this.project.flushClasspathProblemMarkers(false/*cycle*/, false/*format*/, false/*overlapping*/); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java index 89a781c4aa..8cfb0cae53 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java @@ -502,8 +502,9 @@ public void destroy() { try { discardWorkingCopy(); } catch (JavaModelException e) { - if (JavaModelManager.VERBOSE) - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } } } @@ -1466,8 +1467,9 @@ public char[] getModuleName() { if (module != null) return module.getElementName().toCharArray(); } catch (JavaModelException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } } return null; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java index 7a72ca616b..a575806349 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java @@ -313,8 +313,8 @@ public static CompilationUnitDeclaration process( problems.put(IJavaModelMarker.TASK_MARKER, categorizedProblems); } if (NameLookup.VERBOSE) { - System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ - System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + JavaModelManager.trace(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + JavaModelManager.trace(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ } } } catch (OperationCanceledException e) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java index 630106781a..d3f2cca135 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java @@ -83,13 +83,13 @@ public class CompilationUnitStructureRequestor extends ReferenceInfoAdapter impl /* * A table from a handle (with occurenceCount == 1) to the current occurence count for this handle */ - private HashMap occurenceCounts; + private final HashMap occurenceCounts; /* * A table to store the occurrence count of anonymous types. The key will be the handle to the * enclosing type of the anonymous. */ - private HashMap localOccurrenceCounts; + private final HashMap localOccurrenceCounts; /** * Stack of parent scope info objects. The info on the @@ -179,7 +179,6 @@ public void acceptImport(int declarationStart, int declarationEnd, int nameSourc * of the parse action, so as to allow computation of normalized ranges. * * A line separator might corresponds to several characters in the source, - * */ @Override public void acceptLineSeparatorPositions(int[] positions) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyElementsOperation.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyElementsOperation.java index 0f254f1ef6..aed0719d27 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyElementsOperation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyElementsOperation.java @@ -60,13 +60,12 @@ * *
  • This operation only copies elements contained within compilation units. * - * */ @SuppressWarnings({"rawtypes", "unchecked"}) public class CopyElementsOperation extends MultiOperation implements SuffixConstants { - private Map sources = new HashMap(); + private final Map sources = new HashMap(); /** * When executed, this operation will copy the given elements to the * given containers. The elements and destination containers must be in diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java index 7e7d0ef250..3082296d81 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java @@ -78,7 +78,6 @@ *
  • This operation only copies compilation units and package fragments. * It does not copy package fragment roots - a platform operation must be used for that. * - * */ @SuppressWarnings({"rawtypes", "unchecked"}) public class CopyResourceElementsOperation extends MultiOperation implements SuffixConstants { @@ -293,7 +292,6 @@ private IResource getResource(IJavaElement element) { *
  • one rooted in the destination project *
  • When a CU is being overwritten, the delta on the destination will be of type F_CONTENT * If the operation is rooted in a single project, the delta is rooted in that project - * */ protected void prepareDeltas(IJavaElement sourceElement, IJavaElement destinationElement, boolean isMove, boolean overWriteCU) { if (Util.isExcluded(sourceElement) || Util.isExcluded(destinationElement)) return; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java index d4d092cb1b..421d6ec2f7 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java @@ -41,7 +41,6 @@ * element in the compilation unit via the methods #createAfter * and #createBefore. By default, the new element is positioned * as the last child of its parent element. - * */ public abstract class CreateElementInCUOperation extends JavaModelOperation { /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessingState.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessingState.java index 121a1ef847..1004a3823c 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessingState.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessingState.java @@ -79,7 +79,7 @@ public class DeltaProcessingState implements IResourceChangeListener { /* * The delta processor for the current thread. */ - private ThreadLocal deltaProcessors = new ThreadLocal<>(); + private final ThreadLocal deltaProcessors = new ThreadLocal<>(); public void doNotUse() { // reset the delta processor of the current thread to avoid to keep it in memory @@ -113,7 +113,7 @@ public void doNotUse() { public boolean rootsAreStale = true; /* Threads that are currently running initializeRoots() */ - private Set initializingThreads = Collections.synchronizedSet(new HashSet<>()); + private final Set initializingThreads = Collections.synchronizedSet(new HashSet<>()); /* A table from file system absoulte path (String) to timestamp (Long) */ public Hashtable externalTimeStamps; @@ -126,13 +126,13 @@ public void doNotUse() { private Map classpathChanges = new LinkedHashMap<>(); /* A table from JavaProject to ClasspathValidation */ - private Map classpathValidations = new LinkedHashMap<>(); + private final Map classpathValidations = new LinkedHashMap<>(); /* A table from JavaProject to ProjectReferenceChange */ private Set projectReferenceChanges = new LinkedHashSet<>(); /* A table from JavaProject to ExternalFolderChange */ - private Map externalFolderChanges = new LinkedHashMap<>(); + private final Map externalFolderChanges = new LinkedHashMap<>(); /** * Workaround for bug 15168 circular errors not reported @@ -373,7 +373,9 @@ private RootInfos getRootInfos(boolean usePreviousSession) { try { propertyString = Util.getSourceAttachmentProperty(path); } catch (JavaModelException e) { - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } } IPath sourceAttachmentPath; if (propertyString != null) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java index 598230a0be..1cc931ee6b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java @@ -16,6 +16,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.File; import java.net.URL; import java.util.*; @@ -229,7 +231,7 @@ public static long getTimeStamp(File file) { /* * The global state of delta processing. */ - private DeltaProcessingState state; + private final DeltaProcessingState state; /* * The Java model manager @@ -636,7 +638,7 @@ private void readRawClasspath(JavaProject javaProject) { perProjectInfo.readAndCacheClasspath(javaProject); } catch (JavaModelException e) { if (VERBOSE) { - e.printStackTrace(); + trace("", e); //$NON-NLS-1$ } } } @@ -899,8 +901,9 @@ public void run(IProgressMonitor progressMonitor) throws CoreException { IProject project = projectsToTouch[i]; // touch to force a build of this project - if (JavaBuilder.DEBUG) - System.out.println("Touching project " + project.getName() + " due to external jar file change"); //$NON-NLS-1$ //$NON-NLS-2$ + if (JavaBuilder.DEBUG) { + trace("Touching project " + project.getName() + " due to external jar file change"); //$NON-NLS-1$ //$NON-NLS-2$ + } project.touch(progressMonitor); } } @@ -1083,7 +1086,7 @@ private boolean createExternalArchiveDelta(Set refreshedElements, if (status == EXTERNAL_JAR_ADDED){ PackageFragmentRoot root = (PackageFragmentRoot) javaProject.getPackageFragmentRoot(entryPath.toString()); if (VERBOSE){ - System.out.println("- External JAR ADDED, affecting root: "+root.getElementName()); //$NON-NLS-1$ + trace("- External JAR ADDED, affecting root: "+root.getElementName()); //$NON-NLS-1$ } elementAdded(root, null, null); deltaContainsModifiedJar = true; @@ -1092,7 +1095,7 @@ private boolean createExternalArchiveDelta(Set refreshedElements, } else if (status == EXTERNAL_JAR_CHANGED) { PackageFragmentRoot root = (PackageFragmentRoot) javaProject.getPackageFragmentRoot(entryPath.toString()); if (VERBOSE){ - System.out.println("- External JAR CHANGED, affecting root: "+root.getElementName()); //$NON-NLS-1$ + trace("- External JAR CHANGED, affecting root: "+root.getElementName()); //$NON-NLS-1$ } // TODO(sxenos): this is causing each change event for an external jar file to be fired twice. // We need to preserve the clearing of cached information in the jar but defer the actual firing of @@ -1103,7 +1106,7 @@ private boolean createExternalArchiveDelta(Set refreshedElements, } else if (status == EXTERNAL_JAR_REMOVED) { PackageFragmentRoot root = (PackageFragmentRoot) javaProject.getPackageFragmentRoot(entryPath.toString()); if (VERBOSE){ - System.out.println("- External JAR REMOVED, affecting root: "+root.getElementName()); //$NON-NLS-1$ + trace("- External JAR REMOVED, affecting root: "+root.getElementName()); //$NON-NLS-1$ } elementRemoved(root, null, null); deltaContainsModifiedJar = true; @@ -1513,7 +1516,7 @@ public void fire(IJavaElementDelta customDelta, int eventType) { if (!this.isFiring) return; if (DEBUG) { - System.out.println("-----------------------------------------------------------------------------------------------------------------------");//$NON-NLS-1$ + trace("-----------------------------------------------------------------------------------------------------------------------");//$NON-NLS-1$ } IJavaElementDelta deltaToNotify; @@ -1565,8 +1568,8 @@ private void firePostChangeDelta( // post change deltas if (DEBUG){ - System.out.println("FIRING POST_CHANGE Delta ["+Thread.currentThread()+"]:"); //$NON-NLS-1$//$NON-NLS-2$ - System.out.println(deltaToNotify == null ? "" : deltaToNotify.toString()); //$NON-NLS-1$ + trace("FIRING POST_CHANGE Delta ["+Thread.currentThread()+"]:"); //$NON-NLS-1$//$NON-NLS-2$ + trace(deltaToNotify == null ? "" : deltaToNotify.toString()); //$NON-NLS-1$ } if (deltaToNotify != null) { // flush now so as to keep listener reactions to post their own deltas for subsequent iteration @@ -1586,8 +1589,8 @@ private void fireReconcileDelta( IJavaElementDelta deltaToNotify = mergeDeltas(this.reconcileDeltas.values()); if (DEBUG){ - System.out.println("FIRING POST_RECONCILE Delta ["+Thread.currentThread()+"]:"); //$NON-NLS-1$//$NON-NLS-2$ - System.out.println(deltaToNotify == null ? "" : deltaToNotify.toString()); //$NON-NLS-1$ + trace("FIRING POST_RECONCILE Delta ["+Thread.currentThread()+"]:"); //$NON-NLS-1$//$NON-NLS-2$ + trace(deltaToNotify == null ? "" : deltaToNotify.toString()); //$NON-NLS-1$ } if (deltaToNotify != null) { // flush now so as to keep listener reactions to post their own deltas for subsequent iteration @@ -1697,7 +1700,7 @@ private IJavaElementDelta mergeDeltas(Collection deltas) { if (deltas.size() == 1) return deltas.iterator().next(); if (VERBOSE) { - System.out.println("MERGING " + deltas.size() + " DELTAS ["+Thread.currentThread()+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + trace("MERGING " + deltas.size() + " DELTAS ["+Thread.currentThread()+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } Iterator iterator = deltas.iterator(); @@ -1706,7 +1709,7 @@ private IJavaElementDelta mergeDeltas(Collection deltas) { while (iterator.hasNext()) { JavaElementDelta delta = (JavaElementDelta)iterator.next(); if (VERBOSE) { - System.out.println(delta.toString()); + trace(delta.toString()); } IJavaElement element = delta.getElement(); if (this.manager.javaModel.equals(element)) { @@ -1761,7 +1764,7 @@ public void run() throws Exception { } }); if (VERBOSE) { - System.out.println(" -> " + (System.currentTimeMillis()-start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" -> " + (System.currentTimeMillis()-start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -1947,7 +1950,7 @@ private IJavaElementDelta processResourceDelta(IResourceDelta changes) { model.open(null); } catch (JavaModelException e) { if (VERBOSE) { - e.printStackTrace(); + trace("", e); //$NON-NLS-1$ } return null; } @@ -2619,8 +2622,9 @@ public boolean updateCurrentDeltaAndIndex(IResourceDelta delta, int elementType, if (deltaRes.getType() == IResource.PROJECT){ // reset the corresponding project built state, since cannot reuse if added back - if (JavaBuilder.DEBUG) - System.out.println("Clearing last state for removed project : " + deltaRes); //$NON-NLS-1$ + if (JavaBuilder.DEBUG) { + trace("Clearing last state for removed project : " + deltaRes); //$NON-NLS-1$ + } this.manager.setLastBuiltState((IProject)deltaRes, null /*no state*/); // clean up previous session containers (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=89850) @@ -2697,8 +2701,9 @@ public boolean updateCurrentDeltaAndIndex(IResourceDelta delta, int elementType, this.manager.indexManager.discardJobs(element.getElementName()); this.manager.indexManager.removeIndexFamily(res.getFullPath()); // reset the corresponding project built state, since cannot reuse if added back - if (JavaBuilder.DEBUG) - System.out.println("Clearing last state for project loosing Java nature: " + res); //$NON-NLS-1$ + if (JavaBuilder.DEBUG) { + trace("Clearing last state for project loosing Java nature: " + res); //$NON-NLS-1$ + } this.manager.setLastBuiltState(res, null /*no state*/); } return false; // when a project's nature is added/removed don't process children diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DocumentAdapter.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DocumentAdapter.java index a0a286c8a8..adb2519736 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DocumentAdapter.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DocumentAdapter.java @@ -22,7 +22,7 @@ */ public class DocumentAdapter extends Document { - private IBuffer buffer; + private final IBuffer buffer; public DocumentAdapter(IBuffer buffer) { super(buffer.getContents()); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFolderChange.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFolderChange.java index 626b8e6260..bbcb6b897e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFolderChange.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ExternalFolderChange.java @@ -26,8 +26,8 @@ @SuppressWarnings("rawtypes") public class ExternalFolderChange { - private JavaProject project; - private IClasspathEntry[] oldResolvedClasspath; + private final JavaProject project; + private final IClasspathEntry[] oldResolvedClasspath; public ExternalFolderChange(JavaProject project, IClasspathEntry[] oldResolvedClasspath) { this.project = project; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportContainer.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportContainer.java index 554744ccb1..7d73c49f90 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportContainer.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportContainer.java @@ -92,8 +92,6 @@ public ISourceRange getSourceRange() throws JavaModelException { SourceRange range= new SourceRange(firstRange.getOffset(), lastRange.getOffset() + lastRange.getLength() - firstRange.getOffset()); return range; } -/** - */ @Override public String readableName() { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportDeclaration.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportDeclaration.java index 64ebd1985f..d52c0cad46 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportDeclaration.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportDeclaration.java @@ -105,8 +105,6 @@ public JavaElement getPrimaryElement(boolean checkOwner) { public boolean isOnDemand() { return this.isOnDemand; } -/** - */ @Override public String readableName() { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Initializer.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Initializer.java index 87aa535b61..e75b464f74 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Initializer.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Initializer.java @@ -68,8 +68,6 @@ protected char getHandleMementoDelimiter() { public int hashCode() { return Util.combineHashCodes(this.getParent().hashCode(), this.occurrenceCount); } -/** - */ @Override public String readableName() { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarEntryFile.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarEntryFile.java index b13d2713c8..0f036340ba 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarEntryFile.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarEntryFile.java @@ -67,7 +67,7 @@ public InputStream getContents() throws CoreException { try { zipFile = getZipFile(); if (JavaModelManager.ZIP_ACCESS_VERBOSE) { - System.out.println("(" + Thread.currentThread() + ") [JarEntryFile.getContents()] Creating ZipFile on " +zipFile.getName()); //$NON-NLS-1$ //$NON-NLS-2$ + JavaModelManager.trace("(" + Thread.currentThread() + ") [JarEntryFile.getContents()] Creating ZipFile on " +zipFile.getName()); //$NON-NLS-1$ //$NON-NLS-2$ } String entryName = getEntryName(); ZipEntry zipEntry = zipFile.getEntry(entryName); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaCorePreferenceModifyListener.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaCorePreferenceModifyListener.java index 08f82c31e7..34c682e2fb 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaCorePreferenceModifyListener.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaCorePreferenceModifyListener.java @@ -67,7 +67,6 @@ void cleanJavaCore(Preferences preferences) { * Returns whether a java project referenced in property key * is still longer accessible or not. * - * @param propertyName * @return true if a project is referenced in given key and this project * is still accessible, false otherwise. */ diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java index 0c8ad07755..e10887d5c6 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java @@ -140,7 +140,6 @@ public abstract class JavaElement extends PlatformObject implements IJavaElement * * @exception IllegalArgumentException if the type is not one of the valid * Java element type constants - * */ protected JavaElement(JavaElement parent) throws IllegalArgumentException { this.setParent(parent); @@ -605,8 +604,6 @@ protected Object openWhenClosed(Object info, boolean forceAdd, IProgressMonitor } return info; } - /** - */ public String readableName() { return getElementName(); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java index 73551b4e9f..6b73a07fb4 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java @@ -410,7 +410,7 @@ static private boolean isExternalFile(IPath path) { return true; } if (JavaModelManager.ZIP_ACCESS_VERBOSE) { - System.out.println("(" + Thread.currentThread() + ") [JavaModel.isExternalFile(...)] Checking existence of " + path.toString()); //$NON-NLS-1$ //$NON-NLS-2$ + JavaModelManager.trace("(" + Thread.currentThread() + ") [JavaModel.isExternalFile(...)] Checking existence of " + path.toString()); //$NON-NLS-1$ //$NON-NLS-2$ } boolean isFile = path.toFile().isFile(); if (isFile) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelCache.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelCache.java index 361c1ef9d8..202630c87e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelCache.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelCache.java @@ -218,7 +218,7 @@ protected Object peekAtInfo(IJavaElement element) { */ protected void putInfo(IJavaElement element, Object info) { if (DEBUG_CACHE_INSERTIONS) { - System.out.println(Thread.currentThread() + " cache putInfo (" + getElementType(element) + " " + element.toString() + ", " + info + ")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ + JavaModelManager.trace(Thread.currentThread() + " cache putInfo (" + getElementType(element) + " " + element.toString() + ", " + info + ")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ } switch (element.getElementType()) { case IJavaElement.JAVA_MODEL: @@ -275,7 +275,7 @@ public static String getElementType(IJavaElement element) { protected void removeInfo(JavaElement element) { if (DEBUG_CACHE_INSERTIONS) { String elementToString = element.toString(); - System.out.println(Thread.currentThread() + " cache removeInfo " + getElementType(element) + " " + elementToString); //$NON-NLS-1$//$NON-NLS-2$ + JavaModelManager.trace(Thread.currentThread() + " cache removeInfo " + getElementType(element) + " " + elementToString); //$NON-NLS-1$//$NON-NLS-2$ } switch (element.getElementType()) { case IJavaElement.JAVA_MODEL: diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java index 069088ab4b..c575d8e5c0 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java @@ -163,6 +163,7 @@ import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; import org.eclipse.osgi.service.debug.DebugOptions; import org.eclipse.osgi.service.debug.DebugOptionsListener; +import org.eclipse.osgi.service.debug.DebugTrace; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; import org.osgi.service.prefs.BackingStoreException; @@ -202,7 +203,7 @@ public boolean isValid() { * Define a zip cache object. */ static class ZipCache { - private Map map; + private final Map map; Object owner; ZipCache(Object owner) { @@ -217,7 +218,7 @@ public void flush() { ZipFile zipFile = iterator.next(); try { if (JavaModelManager.ZIP_ACCESS_VERBOSE) { - System.out.println("(" + currentThread + ") [ZipCache[" + this.owner //$NON-NLS-1$//$NON-NLS-2$ + trace("(" + currentThread + ") [ZipCache[" + this.owner //$NON-NLS-1$//$NON-NLS-2$ + "].flush()] Closing ZipFile on " + zipFile.getName()); //$NON-NLS-1$ } zipFile.close(); @@ -237,12 +238,14 @@ public void setCache(IPath path, ZipFile zipFile) { if (old != null) { if (JavaModelManager.ZIP_ACCESS_VERBOSE) { Thread currentThread = Thread.currentThread(); - System.out.println("(" + currentThread + ") [ZipCache[" + this.owner //$NON-NLS-1$//$NON-NLS-2$ + trace("(" + currentThread + ") [ZipCache[" + this.owner //$NON-NLS-1$//$NON-NLS-2$ + "].setCache()] leaked ZipFile on " + old.getName() + " for path: " + path); //$NON-NLS-1$ //$NON-NLS-2$ } } } catch (IOException e) { - e.printStackTrace(); + if (VERBOSE) { + trace("", e); //$NON-NLS-1$ + } } } } @@ -259,14 +262,14 @@ public void setCache(IPath path, ZipFile zipFile) { public HashMap deprecatedVariables = new HashMap<>(5); public HashSet readOnlyVariables = new HashSet<>(5); public HashMap previousSessionVariables = new HashMap<>(5); - private ThreadLocal> variableInitializationInProgress = new ThreadLocal<>(); + private final ThreadLocal> variableInitializationInProgress = new ThreadLocal<>(); /** * Classpath containers pool */ public HashMap> containers = new HashMap<>(5); public HashMap> previousSessionContainers = new HashMap<>(5); - private ThreadLocal>> containerInitializationInProgress = new ThreadLocal<>(); + private final ThreadLocal>> containerInitializationInProgress = new ThreadLocal<>(); ThreadLocal>> containersBeingInitialized = new ThreadLocal<>(); public static final int NO_BATCH_INITIALIZATION = 0; @@ -282,7 +285,7 @@ public void setCache(IPath path, ZipFile zipFile) { /* * A HashSet that contains the IJavaProject whose classpath is being resolved. */ - private ThreadLocal> classpathsBeingResolved = new ThreadLocal<>(); + private final ThreadLocal> classpathsBeingResolved = new ThreadLocal<>(); /* * The unique workspace scope @@ -420,6 +423,8 @@ public void setCache(IPath path, ZipFile zipFile) { static final Object[][] NO_PARTICIPANTS = new Object[0][]; + private static DebugTrace DEBUG_TRACE; + public static class CompilationParticipants { static final int MAX_SOURCE_LEVEL = JavaCore.getAllVersions().size() - 1; // All except VERSION_CLDC_1_1 @@ -594,7 +599,7 @@ public int compare(Object a, Object b) { /* whether an AbortCompilationUnit should be thrown when the source of a compilation unit cannot be retrieved */ public ThreadLocal abortOnMissingSource = new ThreadLocal<>(); - private ExternalFoldersManager externalFoldersManager = ExternalFoldersManager.getExternalFoldersManager(); + private final ExternalFoldersManager externalFoldersManager = ExternalFoldersManager.getExternalFoldersManager(); /** * Returns whether the given full path (for a package) conflicts with the output location @@ -818,7 +823,7 @@ private void verbose_missbehaving_container( final IClasspathContainer container, final IClasspathEntry[] newEntries, final IClasspathEntry[] oldEntries) { - Util.verbose( + trace( "CPContainer SET - missbehaving container\n" + //$NON-NLS-1$ " container path: " + containerPath + '\n' + //$NON-NLS-1$ " projects: {" +//$NON-NLS-1$ @@ -881,7 +886,7 @@ public String displayString(Object o) { } void verbose_missbehaving_container(IJavaProject project, IPath containerPath, IClasspathEntry[] classpathEntries) { - Util.verbose( + trace( "CPContainer GET - missbehaving container (returning null classpath entry)\n" + //$NON-NLS-1$ " project: " + project.getElementName() + '\n' + //$NON-NLS-1$ " container path: " + containerPath + '\n' + //$NON-NLS-1$ @@ -905,7 +910,7 @@ public String displayString(Object o) { } void verbose_missbehaving_container_null_entries(IJavaProject project, IPath containerPath) { - Util.verbose( + trace( "CPContainer GET - missbehaving container (returning null as classpath entries)\n" + //$NON-NLS-1$ " project: " + project.getElementName() + '\n' + //$NON-NLS-1$ " container path: " + containerPath + '\n' + //$NON-NLS-1$ @@ -1100,7 +1105,7 @@ public static ICompilationUnit createCompilationUnitFrom(IFile file, IJavaProjec pkg = root.getPackageFragment(CharOperation.NO_STRINGS); if (VERBOSE){ - System.out.println("WARNING : creating unit element outside classpath ("+ Thread.currentThread()+"): " + file.getFullPath()); //$NON-NLS-1$//$NON-NLS-2$ + trace("WARNING : creating unit element outside classpath ("+ Thread.currentThread()+"): " + file.getFullPath()); //$NON-NLS-1$//$NON-NLS-2$ } } return pkg.getCompilationUnit(file.getName()); @@ -1215,7 +1220,7 @@ public static IJavaElement determineIfOnClasspath(IResource resource, IJavaProje /* * Temporary cache of newly opened elements */ - private ThreadLocal> temporaryCache = new ThreadLocal<>(); + private final ThreadLocal> temporaryCache = new ThreadLocal<>(); /** * Set of elements which are out of sync with their buffers. @@ -1405,12 +1410,12 @@ public synchronized ClasspathChange resetResolvedClasspath() { private ClasspathChange setClasspath(IClasspathEntry[] newRawClasspath, IClasspathEntry[] referencedEntries, IPath newOutputLocation, IJavaModelStatus newRawClasspathStatus, IClasspathEntry[] newResolvedClasspath, Map newRootPathToRawEntries, Map newRootPathToResolvedEntries, IJavaModelStatus newUnresolvedEntryStatus, boolean addClasspathChange) { if (DEBUG_CLASSPATH) { - System.out.println("Setting resolved classpath for " + this.project.getFullPath()); //$NON-NLS-1$ + trace("Setting resolved classpath for " + this.project.getFullPath()); //$NON-NLS-1$ if (newResolvedClasspath == null) { - System.out.println("New classpath = null"); //$NON-NLS-1$ + trace("New classpath = null"); //$NON-NLS-1$ } else { for (IClasspathEntry next : newResolvedClasspath) { - System.out.println(" " + next); //$NON-NLS-1$ + trace(" " + next); //$NON-NLS-1$ } } } @@ -1465,7 +1470,6 @@ public synchronized void setJrtPackageRoots(IPath jrtPath, ObjectVector roots) { * Reads the classpath and caches the entries. Returns a two-dimensional array, where the number of elements in the row is fixed to 2. * The first element is an array of raw classpath entries and the second element is an array of referenced entries that may have been stored * by the client earlier. See {@link IJavaProject#getReferencedClasspathEntries()} for more details. - * */ public synchronized IClasspathEntry[][] readAndCacheClasspath(JavaProject javaProject) { // read file entries and update status @@ -1657,7 +1661,7 @@ public String toString() { * A cache of opened zip files per thread. * (for a given thread, the object value is a HashMap from IPath to java.io.ZipFile) */ - private ThreadLocal zipFiles = new ThreadLocal<>(); + private final ThreadLocal zipFiles = new ThreadLocal<>(); private UserLibraryManager userLibraryManager; @@ -1863,7 +1867,7 @@ public void addNonChainingJar(IPath path) { public void addInvalidArchive(IPath path, ArchiveValidity reason) { if (DEBUG_INVALID_ARCHIVES) { - System.out.println("JAR cache: adding " + reason + " " + path); //$NON-NLS-1$//$NON-NLS-2$ + trace("JAR cache: adding " + reason + " " + path); //$NON-NLS-1$//$NON-NLS-2$ } synchronized (this.invalidArchives) { this.invalidArchives.put(path, new InvalidArchiveInfo(System.currentTimeMillis() + INVALID_ARCHIVE_TTL_MILLISECONDS, reason)); @@ -1901,13 +1905,13 @@ public void closeZipFile(ZipFile zipFile) { if (zipFile == null) return; if (this.zipFiles.get() != null) { if (JavaModelManager.ZIP_ACCESS_VERBOSE) { - System.out.println("(" + Thread.currentThread() + ") [JavaModelManager.closeZipFile(ZipFile)] NOT closed ZipFile (cache exist!) on " +zipFile.getName()); //$NON-NLS-1$ //$NON-NLS-2$ + trace("(" + Thread.currentThread() + ") [JavaModelManager.closeZipFile(ZipFile)] NOT closed ZipFile (cache exist!) on " +zipFile.getName()); //$NON-NLS-1$ //$NON-NLS-2$ } return; // zip file will be closed by call to flushZipFiles } try { if (JavaModelManager.ZIP_ACCESS_VERBOSE) { - System.out.println("(" + Thread.currentThread() + ") [JavaModelManager.closeZipFile(ZipFile)] Closing ZipFile on " +zipFile.getName()); //$NON-NLS-1$ //$NON-NLS-2$ + trace("(" + Thread.currentThread() + ") [JavaModelManager.closeZipFile(ZipFile)] Closing ZipFile on " +zipFile.getName()); //$NON-NLS-1$ //$NON-NLS-2$ } zipFile.close(); } catch (IOException e) { @@ -1921,8 +1925,11 @@ public static void registerDebugOptionsListener(BundleContext context) { Hashtable properties = new Hashtable<>(2); properties.put(DebugOptions.LISTENER_SYMBOLICNAME, JavaCore.PLUGIN_ID); DEBUG_REGISTRATION = context.registerService(DebugOptionsListener.class, new DebugOptionsListener() { + + @Override public void optionsChanged(DebugOptions options) { + DEBUG_TRACE = options.newDebugTrace(JavaCore.PLUGIN_ID, JavaModelManager.class); boolean debug = options.getBooleanOption(DEBUG, false); BufferManager.VERBOSE = debug && options.getBooleanOption(BUFFER_MANAGER_DEBUG, false); JavaBuilder.DEBUG = debug && options.getBooleanOption(BUILDER_DEBUG, false); @@ -2091,7 +2098,7 @@ public void flushZipFiles(Object owner) { ZipCache zipCache = this.zipFiles.get(); if (zipCache == null) { if (JavaModelManager.ZIP_ACCESS_VERBOSE) { - System.out.println("(" + Thread.currentThread() + ") [JavaModelManager.flushZipFiles(String)] NOT found cache for " + owner); //$NON-NLS-1$ //$NON-NLS-2$ + trace("(" + Thread.currentThread() + ") [JavaModelManager.flushZipFiles(String)] NOT found cache for " + owner); //$NON-NLS-1$ //$NON-NLS-2$ } return; } @@ -2102,7 +2109,7 @@ public void flushZipFiles(Object owner) { zipCache.flush(); } else { if (JavaModelManager.ZIP_ACCESS_VERBOSE) { - System.out.println("(" + Thread.currentThread() //$NON-NLS-1$ + trace("(" + Thread.currentThread() //$NON-NLS-1$ + ") [JavaModelManager.flushZipFiles(String)] NOT closed cache, wrong owner, expected: " //$NON-NLS-1$ + zipCache.owner + ", got: " + owner); //$NON-NLS-1$ } @@ -2317,8 +2324,9 @@ public final static JavaModelManager getJavaModelManager() { */ public Object getLastBuiltState(IProject project, IProgressMonitor monitor) { if (!JavaProject.hasJavaNature(project)) { - if (JavaBuilder.DEBUG) - System.out.println(project + " is not a Java project"); //$NON-NLS-1$ + if (JavaBuilder.DEBUG) { + trace(project + " is not a Java project"); //$NON-NLS-1$ + } return null; // should never be requested on non-Java projects } PerProjectInfo info = getPerProjectInfo(project, true/*create if missing*/); @@ -2634,8 +2642,7 @@ private void verbose_reentering_project_container_access( IPath containerPath, I } } buffer.append(" }"); //$NON-NLS-1$ - Util.verbose(buffer.toString()); - new Exception("").printStackTrace(System.out); //$NON-NLS-1$ + trace(buffer.toString(), new Exception("")); //$NON-NLS-1$ } /** @@ -2652,11 +2659,10 @@ public IPath getPreviousSessionVariable(String variableName) { } private void verbose_reentering_variable_access(String variableName, IPath previousPath) { - Util.verbose( + trace( "CPVariable INIT - reentering access to variable during its initialization, will see previous value\n" + //$NON-NLS-1$ " variable: "+ variableName + '\n' + //$NON-NLS-1$ - " previous value: " + previousPath); //$NON-NLS-1$ - new Exception("").printStackTrace(System.out); //$NON-NLS-1$ + " previous value: " + previousPath, new Exception("")); //$NON-NLS-1$ //$NON-NLS-2$ } /** @@ -2960,7 +2966,7 @@ public ZipFile getZipFile(IPath path, boolean checkInvalidArchiveCache) throws C try { if (ZIP_ACCESS_VERBOSE) { - System.out.println("(" + Thread.currentThread() + ") [JavaModelManager.getZipFile(IPath)] Creating ZipFile on " + localFile ); //$NON-NLS-1$ //$NON-NLS-2$ + trace("(" + Thread.currentThread() + ") [JavaModelManager.getZipFile(IPath)] Creating ZipFile on " + localFile ); //$NON-NLS-1$ //$NON-NLS-2$ } if (throwIoExceptionsInGetZipFile) { throw new IOException(); @@ -3181,7 +3187,7 @@ private void initKnownContainers(Map").printStackTrace(System.out); //$NON-NLS-1$ + " invocation trace:", new Exception("")); //$NON-NLS-1$ //$NON-NLS-2$ } /** @@ -3403,7 +3409,7 @@ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { SubMonitor subMonitor = SubMonitor.convert(monitor, projectsToTouch.length); for (IProject iProject : projectsToTouch) { if (JavaBuilder.DEBUG) { - System.out.println("Touching project " + iProject.getName()); //$NON-NLS-1$ + trace("Touching project " + iProject.getName()); //$NON-NLS-1$ } if (iProject.isAccessible()) { iProject.touch(subMonitor.split(1)); @@ -3452,7 +3458,7 @@ public ArchiveValidity getArchiveValidity(IPath path) { } if (invalidArchiveInfo == null) { if (DEBUG_INVALID_ARCHIVES) { - System.out.println("JAR cache: UNKNOWN validity for " + path); //$NON-NLS-1$ + trace("JAR cache: UNKNOWN validity for " + path); //$NON-NLS-1$ } return null; } @@ -3473,7 +3479,7 @@ public ArchiveValidity getArchiveValidity(IPath path) { return ArchiveValidity.INVALID; } if (DEBUG_INVALID_ARCHIVES) { - System.out.println("JAR cache: " + invalidArchiveInfo.reason + " " + path); //$NON-NLS-1$ //$NON-NLS-2$ + trace("JAR cache: " + invalidArchiveInfo.reason + " " + path); //$NON-NLS-1$ //$NON-NLS-2$ } return invalidArchiveInfo.reason; } @@ -3483,14 +3489,14 @@ public void removeFromInvalidArchiveCache(IPath path) { InvalidArchiveInfo entry = this.invalidArchives.get(path); if (entry != null && entry.reason == ArchiveValidity.VALID) { if (DEBUG_INVALID_ARCHIVES) { - System.out.println("JAR cache: keep VALID " + path); //$NON-NLS-1$ + trace("JAR cache: keep VALID " + path); //$NON-NLS-1$ } return; // do not remove the VALID information } // If it transitioned to being valid then force an update to project caches. if (this.invalidArchives.remove(path) != null) { if (DEBUG_INVALID_ARCHIVES) { - System.out.println("JAR cache: removed INVALID " + path); //$NON-NLS-1$ + trace("JAR cache: removed INVALID " + path); //$NON-NLS-1$ } try { // Bug 455042: Force an update of the JavaProjectElementInfo project caches. @@ -4173,7 +4179,7 @@ protected Object readState(IProject project) throws CoreException { Object result = readStateTimed(project); if (JavaBuilder.DEBUG) { long stopTime = System.currentTimeMillis(); - System.out.println("readState took " + (stopTime - startTime) + "ms:" + project.getName()); //$NON-NLS-1$ //$NON-NLS-2$ + trace("readState took " + (stopTime - startTime) + "ms:" + project.getName()); //$NON-NLS-1$ //$NON-NLS-2$ } return result; } @@ -4190,17 +4196,21 @@ private Object readStateTimed(IProject project) throws CoreException { throw new IOException(Messages.build_wrongFileFormat); if (in.readBoolean()) return JavaBuilder.readState(project, in); - if (JavaBuilder.DEBUG) - System.out.println("Saved state thinks last build failed for " + project.getName()); //$NON-NLS-1$ + if (JavaBuilder.DEBUG) { + trace("Saved state thinks last build failed for " + project.getName()); //$NON-NLS-1$ + } } catch (Exception e) { - e.printStackTrace(); + if (JavaBuilder.DEBUG) { + trace("", e); //$NON-NLS-1$ + } throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR, "Error reading last build state for project "+ project.getName(), e)); //$NON-NLS-1$ } } else if (JavaBuilder.DEBUG) { - if (file == null) - System.out.println("Project does not exist: " + project); //$NON-NLS-1$ - else - System.out.println("Build state file " + file.getPath() + " does not exist"); //$NON-NLS-1$ //$NON-NLS-2$ + if (file == null) { + trace("Project does not exist: " + project); //$NON-NLS-1$ + } else { + trace("Build state file " + file.getPath() + " does not exist"); //$NON-NLS-1$ //$NON-NLS-2$ + } } return null; } @@ -4288,7 +4298,7 @@ public synchronized Object removeInfoAndChildren(JavaElement element) throws Jav try { if (JavaModelCache.VERBOSE) { String elementType = JavaModelCache.getElementType(element); - System.out.println(Thread.currentThread() + " CLOSING "+ elementType + " " + element.toStringWithAncestors()); //$NON-NLS-1$//$NON-NLS-2$ + trace(Thread.currentThread() + " CLOSING "+ elementType + " " + element.toStringWithAncestors()); //$NON-NLS-1$//$NON-NLS-2$ wasVerbose = true; JavaModelCache.VERBOSE = false; } @@ -4298,7 +4308,7 @@ public synchronized Object removeInfoAndChildren(JavaElement element) throws Jav } this.cache.removeInfo(element); if (wasVerbose) { - System.out.println(this.cache.toStringFillingRation("-> ")); //$NON-NLS-1$ + trace(this.cache.toStringFillingRation("-> ")); //$NON-NLS-1$ } } finally { JavaModelCache.VERBOSE = wasVerbose; @@ -4400,7 +4410,7 @@ private void saveState(PerProjectInfo info, ISaveContext context) throws CoreExc saveBuiltState(info); if (JavaBuilder.DEBUG) { long stopTime = System.currentTimeMillis(); - System.out.println("saveState took " + (stopTime - startTime) + "ms:" + info.project.getName()); //$NON-NLS-1$ //$NON-NLS-2$ + trace("saveState took " + (stopTime - startTime) + "ms:" + info.project.getName()); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -4409,8 +4419,9 @@ private void saveState(PerProjectInfo info, ISaveContext context) throws CoreExc * Saves the built state for the project. */ private void saveBuiltState(PerProjectInfo info) throws CoreException { - if (JavaBuilder.DEBUG) - System.out.println(Messages.bind(Messages.build_saveStateProgress, info.project.getName())); + if (JavaBuilder.DEBUG) { + trace(Messages.bind(Messages.build_saveStateProgress, info.project.getName())); + } File file = getSerializationFile(info.project); if (file == null) return; long t = System.currentTimeMillis(); @@ -4437,7 +4448,7 @@ private void saveBuiltState(PerProjectInfo info) throws CoreException { } if (JavaBuilder.DEBUG) { t = System.currentTimeMillis() - t; - System.out.println(Messages.bind(Messages.build_saveStateComplete, String.valueOf(t))); + trace(Messages.bind(Messages.build_saveStateComplete, String.valueOf(t))); } } @@ -4722,7 +4733,19 @@ private void traceVariableAndContainers(String action, long start) { String pattern = "{0} {1} bytes in variablesAndContainers.dat in {2}ms"; //$NON-NLS-1$ String message = MessageFormat.format(pattern, new Object[]{action, length, delta}); - System.out.println(message); + trace(message); + } + + public static void trace(String msg) { + DEBUG_TRACE.trace(null, msg); + } + + public static void trace(String msg, Exception e) { + DEBUG_TRACE.trace(null, msg, e); + } + + public static void traceDumpStack() { + DEBUG_TRACE.traceDumpStack(null); } /** @@ -4734,7 +4757,7 @@ public void saving(ISaveContext context) throws CoreException { savingTimed(context); if (JavaBuilder.DEBUG) { long stopTime = System.currentTimeMillis(); - System.out.println("saving took " + (stopTime - startTime) + "ms:" + this.perProjectInfos.values().size()); //$NON-NLS-1$ //$NON-NLS-2$ + trace("saving took " + (stopTime - startTime) + "ms:" + this.perProjectInfos.values().size()); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -4841,7 +4864,7 @@ public void secondaryTypeAdding(String path, char[] typeName, char[] packageName buffer.append(new String(typeName)); buffer.append(']'); buffer.append(')'); - Util.verbose(buffer.toString()); + trace(buffer.toString()); } IWorkspaceRoot wRoot = ResourcesPlugin.getWorkspace().getRoot(); IResource resource = wRoot.findMember(path); @@ -4875,7 +4898,7 @@ public void secondaryTypeAdding(String path, char[] typeName, char[] packageName packageTypes.put(typeString, type); } if (VERBOSE) { - Util.verbose(" - indexing cache:"); //$NON-NLS-1$ + trace(" - indexing cache:"); //$NON-NLS-1$ dumpIndexingSecondaryTypes(indexedSecondaryTypes); } } @@ -4892,7 +4915,7 @@ private void dumpIndexingSecondaryTypes(Map>> entry = entries.next(); IFile file = entry.getKey(); - Util.verbose(" + "+file.getFullPath()+':'+ entry.getValue()); //$NON-NLS-1$ + trace(" + "+file.getFullPath()+':'+ entry.getValue()); //$NON-NLS-1$ } } } @@ -4903,7 +4926,7 @@ private static void dumpSecondaryTypes(Map> secondary while (entries.hasNext()) { Entry> entry = entries.next(); String packName = entry.getKey(); - Util.verbose(" + " + packName + ':' + entry.getValue()); //$NON-NLS-1$ + trace(" + " + packName + ':' + entry.getValue()); //$NON-NLS-1$ } } } @@ -4933,7 +4956,7 @@ public Map> secondaryTypes(IJavaProject project, bool if (VERBOSE) { StringBuilder buffer = new StringBuilder("JavaModelManager.secondaryTypes("); //$NON-NLS-1$ buffer.append(project.getElementName()).append(',').append(waitForIndexes).append(')'); - Util.verbose(buffer.toString()); + trace(buffer.toString()); } // Return cache if not empty and there's no new secondary types created during indexing @@ -5010,8 +5033,8 @@ private static Map> secondaryTypesMerging(PerProjectI return secondaryTypes; } if (VERBOSE) { - Util.verbose("JavaModelManager.getSecondaryTypesMerged()"); //$NON-NLS-1$ - Util.verbose(" - current cache to merge:"); //$NON-NLS-1$ + trace("JavaModelManager.getSecondaryTypesMerged()"); //$NON-NLS-1$ + trace(" - current cache to merge:"); //$NON-NLS-1$ dumpSecondaryTypes(secondaryTypes); } Map>> indexedSecondaryTypes = cache.indexingSecondaryCache(); @@ -5050,7 +5073,7 @@ private static Map> secondaryTypesMerging(PerProjectI } } if (VERBOSE) { - Util.verbose(" - secondary types cache merged:"); //$NON-NLS-1$ + trace(" - secondary types cache merged:"); //$NON-NLS-1$ dumpSecondaryTypes(secondaryTypes); } projectInfo.secondaryTypes.indexingDone(); @@ -5069,7 +5092,7 @@ private static Map> secondaryTypesSearching(IJavaProj buffer.append(','); buffer.append(waitForIndexes); buffer.append(')'); - Util.verbose(buffer.toString()); + trace(buffer.toString()); } final Hashtable> secondaryTypesSearch = new Hashtable<>(3); @@ -5126,7 +5149,7 @@ public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, stCache = projectInfo.secondaryTypes.doneSearching(secondaryTypes); if (VERBOSE || BasicSearchEngine.VERBOSE) { - Util.verbose(" -> secondary paths stored in cache: "); //$NON-NLS-1$ + trace(" -> secondary paths stored in cache: "); //$NON-NLS-1$ dumpSecondaryTypes(secondaryTypes); } } @@ -5147,7 +5170,7 @@ public void secondaryTypesRemoving(IFile file, boolean cleanIndexCache) { StringBuilder buffer = new StringBuilder("JavaModelManager.removeFromSecondaryTypesCache("); //$NON-NLS-1$ buffer.append(file.getName()); buffer.append(')'); - Util.verbose(buffer.toString()); + trace(buffer.toString()); } if (file != null) { PerProjectInfo projectInfo = getPerProjectInfo(file.getProject(), false); @@ -5161,7 +5184,7 @@ public void secondaryTypesRemoving(IFile file, boolean cleanIndexCache) { return; } if (VERBOSE) { - Util.verbose("-> remove file from cache of project: "+file.getProject().getName()); //$NON-NLS-1$ + trace("-> remove file from cache of project: "+file.getProject().getName()); //$NON-NLS-1$ } // Clean current cache @@ -5192,7 +5215,7 @@ private static void secondaryTypesRemoving(Map> secon if (VERBOSE) { StringBuilder buffer = new StringBuilder("JavaModelManager.removeSecondaryTypesFromMap("); //$NON-NLS-1$ buffer.append(',').append(file.getFullPath()).append(')'); - Util.verbose(buffer.toString()); + trace(buffer.toString()); dumpSecondaryTypes(secondaryTypesMap); } Set>> packageEntries = secondaryTypesMap.entrySet(); @@ -5234,7 +5257,7 @@ private static void secondaryTypesRemoving(Map> secon } } if (VERBOSE) { - Util.verbose(" - new secondary types map:"); //$NON-NLS-1$ + trace(" - new secondary types map:"); //$NON-NLS-1$ dumpSecondaryTypes(secondaryTypesMap); } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelOperation.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelOperation.java index b9c1115193..61dd755541 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelOperation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelOperation.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; @@ -634,16 +636,16 @@ protected JavaModelOperation popOperation() { */ protected void postAction(IPostAction action, int insertionMode) { if (POST_ACTION_VERBOSE) { - System.out.print("(" + Thread.currentThread() + ") [JavaModelOperation.postAction(IPostAction, int)] Posting action " + action.getID()); //$NON-NLS-1$ //$NON-NLS-2$ + trace("(" + Thread.currentThread() + ") [JavaModelOperation.postAction(IPostAction, int)] Posting action " + action.getID()); //$NON-NLS-1$ //$NON-NLS-2$ switch(insertionMode) { case REMOVEALL_APPEND: - System.out.println(" (REMOVEALL_APPEND)"); //$NON-NLS-1$ + trace(" (REMOVEALL_APPEND)"); //$NON-NLS-1$ break; case KEEP_EXISTING: - System.out.println(" (KEEP_EXISTING)"); //$NON-NLS-1$ + trace(" (KEEP_EXISTING)"); //$NON-NLS-1$ break; case APPEND: - System.out.println(" (APPEND)"); //$NON-NLS-1$ + trace(" (APPEND)"); //$NON-NLS-1$ break; } } @@ -700,7 +702,7 @@ protected void pushOperation(JavaModelOperation operation) { */ protected void removeAllPostAction(String actionID) { if (POST_ACTION_VERBOSE) { - System.out.println("(" + Thread.currentThread() + ") [JavaModelOperation.removeAllPostAction(String)] Removing actions " + actionID); //$NON-NLS-1$ //$NON-NLS-2$ + trace("(" + Thread.currentThread() + ") [JavaModelOperation.removeAllPostAction(String)] Removing actions " + actionID); //$NON-NLS-1$ //$NON-NLS-2$ } JavaModelOperation topLevelOp = (JavaModelOperation)getCurrentOperationStack().get(0); @@ -828,7 +830,7 @@ protected void runPostActions() throws JavaModelException { while (this.actionsStart <= this.actionsEnd) { IPostAction postAction = this.actions[this.actionsStart++]; if (POST_ACTION_VERBOSE) { - System.out.println("(" + Thread.currentThread() + ") [JavaModelOperation.runPostActions()] Running action " + postAction.getID()); //$NON-NLS-1$ //$NON-NLS-2$ + trace("(" + Thread.currentThread() + ") [JavaModelOperation.runPostActions()] Running action " + postAction.getID()); //$NON-NLS-1$ //$NON-NLS-2$ } postAction.run(); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java index 4fa6e6f282..59aca34b99 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java @@ -17,6 +17,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.*; import java.net.URI; import java.nio.charset.StandardCharsets; @@ -425,7 +427,6 @@ public static boolean hasJavaNature(IProject project) { * Detect cycles in the classpath of the workspace's projects * and create markers if necessary. * @param preferredClasspaths Map - * @throws JavaModelException */ public static void validateCycles(Map preferredClasspaths) throws JavaModelException { //long start = System.currentTimeMillis(); @@ -450,7 +451,6 @@ public static void validateCycles(Map preferredClasspaths) throws JavaModelExcep } } } - //System.out.println("updateAllCycleMarkers: " + (System.currentTimeMillis() - start) + " ms"); for (int i = 0; i < length; i++){ JavaProject project = projects[i]; @@ -585,7 +585,6 @@ public void close() throws JavaModelException { /** * Internal computation of an expanded classpath. It will eliminate duplicates, and produce copies * of exported or restricted classpath entries to avoid possible side-effects ever after. - * @param excludeTestCode */ private void computeExpandedClasspath( ClasspathEntry referringEntry, @@ -704,7 +703,6 @@ public void computePackageFragmentRoots( * @param rootIDs HashSet * @param referringEntry the CP entry (project) referring to this entry, or null if initial project * @param retrieveExportedRoots boolean - * @throws JavaModelException */ public void computePackageFragmentRoots( IClasspathEntry resolvedEntry, @@ -728,7 +726,6 @@ public void computePackageFragmentRoots( * @param filterModuleRoots if true, roots corresponding to modules will be filtered if applicable: * if a limit-modules attribute exists, this is used, otherwise system modules will be filtered * according to the rules of root modules per JEP 261. - * @throws JavaModelException */ public void computePackageFragmentRoots( IClasspathEntry resolvedEntry, @@ -1040,7 +1037,6 @@ public IPackageFragmentRoot[] computePackageFragmentRoots( * if a limit-modules attribute exists, this is used, otherwise system modules will be filtered * according to the rules of root modules per JEP 261. * @return IPackageFragmentRoot[] - * @throws JavaModelException */ public IPackageFragmentRoot[] computePackageFragmentRoots( IClasspathEntry[] resolvedClasspath, @@ -1089,7 +1085,6 @@ public void computePackageFragmentRoots( * @param filterModuleRoots if true, roots corresponding to modules will be filtered if applicable: * if a limit-modules attribute exists, this is used, otherwise system modules will be filtered * according to the rules of root modules per JEP 261. - * @throws JavaModelException */ public void computePackageFragmentRoots( IClasspathEntry[] resolvedClasspath, @@ -1296,7 +1291,7 @@ public void createClasspathProblemMarker(IJavaModelStatus status) { } catch (CoreException e) { // could not create marker: cannot do much if (JavaModelManager.VERBOSE) { - e.printStackTrace(); + trace("", e); //$NON-NLS-1$ } } } @@ -1313,7 +1308,6 @@ protected Object createElementInfo() { * Reads and decode an XML classpath string. Returns a two-dimensional array, where the number of elements in the row is fixed to 2. * The first element is an array of raw classpath entries and the second element is an array of referenced entries that may have been stored * by the client earlier. See {@link IJavaProject#getReferencedClasspathEntries()} for more details. - * */ public IClasspathEntry[][] decodeClasspath(String xmlClasspath, Map unknownElements) throws IOException, ClasspathEntry.AssertionFailedException { @@ -1835,7 +1829,7 @@ protected void flushClasspathProblemMarkers(boolean flushCycleMarkers, boolean f } catch (CoreException e) { // could not flush markers: not much we can do if (JavaModelManager.VERBOSE) { - e.printStackTrace(); + trace("", e); //$NON-NLS-1$ } } } @@ -2046,7 +2040,6 @@ public int getElementType() { * where all classpath variable entries have been resolved and substituted with their final target entries. * All project exports have been appended to project entries. * @return IClasspathEntry[] - * @throws JavaModelException */ public IClasspathEntry[] getExpandedClasspath() throws JavaModelException { return getExpandedClasspath(false); @@ -2618,11 +2611,10 @@ public IClasspathEntry[] getResolvedClasspath(boolean ignoreUnresolvedEntry) thr } private void verbose_reentering_classpath_resolution() { - Util.verbose( + trace( "CPResolution: reentering raw classpath resolution, will use empty classpath instead" + //$NON-NLS-1$ " project: " + getElementName() + '\n' + //$NON-NLS-1$ - " invocation stack trace:"); //$NON-NLS-1$ - new Exception("").printStackTrace(System.out); //$NON-NLS-1$ + " invocation stack trace:", new Exception("")); //$NON-NLS-1$ //$NON-NLS-2$ } /** @@ -2642,7 +2634,6 @@ public IResource resource(PackageFragmentRoot root) { * @param key String * @see JavaProject#setSharedProperty(String, String) * @return String - * @throws CoreException */ public String getSharedProperty(String key) throws CoreException { @@ -3512,7 +3503,6 @@ public String rootID(){ * @param newClasspath IClasspathEntry[] * @param newOutputLocation IPath * @return boolean Return whether the .classpath file was modified. - * @throws JavaModelException */ public boolean writeFileEntries(IClasspathEntry[] newClasspath, IClasspathEntry[] referencedEntries, IPath newOutputLocation) throws JavaModelException { @@ -3759,7 +3749,6 @@ public void setRawClasspath( * @param key String * @param value String * @see JavaProject#getSharedProperty(String key) - * @throws CoreException */ public void setSharedProperty(String key, String value) throws CoreException { @@ -3788,7 +3777,7 @@ public void setSharedProperty(String key, String value) throws CoreException { /** internal structure for detected build path cycles. */ static class CycleInfo { - private List pathToCycle; + private final List pathToCycle; public final List cycle; public CycleInfo(List pathToCycle, List cycle) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocContents.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocContents.java index 5a744d7a1c..010e1b3de1 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocContents.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocContents.java @@ -29,7 +29,7 @@ public class JavadocContents { private static final int[] UNKNOWN_FORMAT = new int[0]; private BinaryType type; - private char[] content; + private final char[] content; private int childrenStart; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/LambdaMethod.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/LambdaMethod.java index a71d8af007..516cbc5c0c 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/LambdaMethod.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/LambdaMethod.java @@ -24,12 +24,12 @@ public class LambdaMethod extends SourceMethod { - private int sourceStart; // cached for ease of use in hashcode/equals. - private String [] parameterNameStrings; - private String returnTypeString; + private final int sourceStart; // cached for ease of use in hashcode/equals. + private final String [] parameterNameStrings; + private final String returnTypeString; SourceMethodElementInfo elementInfo; - private String key; - + private final String key; + LambdaMethod(JavaElement parent, String name, String key, int sourceStart, String [] parameterTypes, String [] parameterNames, String returnType, SourceMethodElementInfo elementInfo) { super(parent, name, parameterTypes); this.sourceStart = sourceStart; @@ -38,7 +38,7 @@ public class LambdaMethod extends SourceMethod { this.elementInfo = elementInfo; this.key = key; } - + /** * @see IMethod */ @@ -60,12 +60,12 @@ public String getSignature() throws JavaModelException { public boolean isLambdaMethod() { return true; } - + @Override protected void closing(Object info) { // nothing to do. } - + @Override public boolean equals(Object o) { if (!(o instanceof LambdaMethod)) return false; @@ -77,7 +77,7 @@ public boolean equals(Object o) { public Object getElementInfo(IProgressMonitor monitor) throws JavaModelException { return this.elementInfo; } - + public void getHandleMemento(StringBuffer buff, boolean serializeParent) { if (serializeParent) { ((LambdaExpression) getParent()).getHandleMemento(buff, true, false); @@ -108,27 +108,27 @@ public void getHandleMemento(StringBuffer buff) { // lambda method and lambda expression cannot share the same memento - add a trailing discriminator. appendEscapedDelimiter(buff, getHandleMementoDelimiter()); } - + @Override protected char getHandleMementoDelimiter() { return JavaElement.JEM_LAMBDA_METHOD; } - + @Override public String getKey() { return this.key; } - + @Override public int hashCode() { return Util.combineHashCodes(super.hashCode(), this.sourceStart); } - + @Override public boolean isResolved() { return true; // we maintain enough information so as not to need another layer of abstraction. } - + @Override public JavaElement resolved(Binding binding) { return this; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/LocalVariable.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/LocalVariable.java index da97fad414..ecf4cf6268 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/LocalVariable.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/LocalVariable.java @@ -47,8 +47,8 @@ public class LocalVariable extends SourceRefElement implements ILocalVariable { public int nameStart, nameEnd; String typeSignature; public IAnnotation[] annotations; - private int flags; - private boolean isParameter; + private final int flags; + private final boolean isParameter; public IAnnotation[][] annotationsOnDimensions; public LocalVariable( diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java index cabbdd210b..495f48add2 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.Map; import org.eclipse.jdt.core.*; import org.eclipse.jdt.core.compiler.CharOperation; @@ -22,6 +23,7 @@ import org.eclipse.jdt.core.compiler.ITerminalSymbols; import org.eclipse.jdt.core.compiler.InvalidInputException; import org.eclipse.jdt.internal.compiler.impl.Constant; +import org.eclipse.jdt.internal.compiler.impl.JavaFeature; import org.eclipse.jdt.internal.compiler.lookup.TypeIds; import org.eclipse.jdt.internal.core.util.MementoTokenizer; @@ -394,20 +396,47 @@ public boolean isBinary() { } protected boolean isMainMethod(IMethod method) throws JavaModelException { if ("main".equals(method.getElementName()) && Signature.SIG_VOID.equals(method.getReturnType())) { //$NON-NLS-1$ - int flags= method.getFlags(); + int flags = method.getFlags(); IType declaringType = null; if (Flags.isStatic(flags) && (Flags.isPublic(flags) || ((declaringType = getDeclaringType()) != null && declaringType.isInterface()))) { - String[] paramTypes= method.getParameterTypes(); + String[] paramTypes = method.getParameterTypes(); if (paramTypes.length == 1) { - String typeSignature= Signature.toString(paramTypes[0]); - return "String[]".equals(Signature.getSimpleName(typeSignature)); //$NON-NLS-1$ + return isStringArrayParameter(paramTypes[0]); } } } return false; } + +protected boolean isMainMethodCandidate(IMethod method) throws JavaModelException { + Map options = method.getJavaProject().getOptions(true); + if (JavaFeature.UNNAMMED_CLASSES_AND_INSTANCE_MAIN_METHODS.isSupported( + options.get(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM), + JavaCore.ENABLED.equals(options.get(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES)))) { + if ("main".equals(method.getElementName()) && Signature.SIG_VOID.equals(method.getReturnType())) { //$NON-NLS-1$ + int flags = method.getFlags(); + if (!Flags.isPrivate(flags)) { + String[] paramTypes = method.getParameterTypes(); + if (paramTypes.length == 1) { + return isStringArrayParameter(paramTypes[0]); + } else if (paramTypes.length == 0) { + return true; + } + } + } + return false; + } else { + return isMainMethod(method); + } +} + +private boolean isStringArrayParameter(String paramType) { + String typeSignature = Signature.toString(paramType); + return "String[]".equals(Signature.getSimpleName(typeSignature)); //$NON-NLS-1$ +} + /** * @see IJavaElement */ @@ -415,8 +444,6 @@ protected boolean isMainMethod(IMethod method) throws JavaModelException { public boolean isReadOnly() { return getClassFile() != null; } -/** - */ @Override public String readableName() { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModularClassFile.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModularClassFile.java index b292f11ced..aae9730d76 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModularClassFile.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModularClassFile.java @@ -145,7 +145,7 @@ public IBinaryModule getBinaryModuleInfo() throws JavaModelException { } catch (ClassFormatException cfe) { //the structure remains unknown if (JavaCore.getPlugin().isDebugging()) { - cfe.printStackTrace(System.err); + JavaModelManager.trace("", cfe); //$NON-NLS-1$ } return null; } catch (IOException ioe) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModulePathContainer.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModulePathContainer.java index b503fe229d..2d5d805e99 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModulePathContainer.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModulePathContainer.java @@ -28,7 +28,7 @@ public class ModulePathContainer implements IClasspathContainer{ - private IJavaProject project; + private final IJavaProject project; public ModulePathContainer(IJavaProject project) { this.project = project; @@ -64,19 +64,19 @@ public IClasspathEntry[] getClasspathEntries() { @Override public String getDescription() { - // + // return "Module path"; //$NON-NLS-1$ } @Override public int getKind() { - // + // return K_APPLICATION; } @Override public IPath getPath() { - // + // return new Path(JavaCore.MODULE_PATH_CONTAINER_ID); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModulePathContainerInitializer.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModulePathContainerInitializer.java index 10f293fbbf..92b7d8fd0f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModulePathContainerInitializer.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModulePathContainerInitializer.java @@ -19,7 +19,6 @@ import org.eclipse.jdt.core.IClasspathContainer; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.internal.core.util.Util; public class ModulePathContainerInitializer extends ClasspathContainerInitializer { @@ -41,7 +40,7 @@ private boolean isModulePathContainer(IPath path) { return path != null && JavaCore.MODULE_PATH_CONTAINER_ID.equals(path.segment(0)); } private void verbose_not_a_module_project(IJavaProject project, IPath containerPath) { - Util.verbose( + JavaModelManager.trace( "Module path INIT - FAILED (not a module project)\n" + //$NON-NLS-1$ " project: " + project.getElementName() + '\n' + //$NON-NLS-1$ " container path: " + containerPath); //$NON-NLS-1$ diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleSourcePathManager.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleSourcePathManager.java index 5256cc798b..a892c2a530 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleSourcePathManager.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleSourcePathManager.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -26,7 +28,7 @@ public class ModuleSourcePathManager { - private Map knownModules = new HashMap(11); + private final Map knownModules = new HashMap(11); private IModulePathEntry getModuleRoot0(String name) { return this.knownModules.get(name); @@ -37,8 +39,9 @@ public IModulePathEntry getModuleRoot(String name) { try { seekModule(name.toCharArray(),false, new JavaElementRequestor()); } catch (JavaModelException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + trace("", e); //$NON-NLS-1$ + } } } root = this.knownModules.get(name); @@ -94,15 +97,19 @@ public IModule getModule(char[] name) { if (root != null) try { return root.getModule(); - } catch (Exception e1) { - // + } catch (Exception e) { + if (JavaModelManager.VERBOSE) { + trace("", e); //$NON-NLS-1$ + } return null; } JavaElementRequestor requestor = new JavaElementRequestor(); try { seekModule(name, false, requestor); } catch (JavaModelException e) { - // + if (JavaModelManager.VERBOSE) { + trace("", e); //$NON-NLS-1$ + } } IModuleDescription[] modules = requestor.getModules(); if (modules.length > 0) { @@ -110,24 +117,12 @@ public IModule getModule(char[] name) { try { return (IModule) ((JavaElement) module).getElementInfo(); } catch (JavaModelException e) { - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + trace("", e); //$NON-NLS-1$ + } } } - return null; + return null; } -// public IModuleDeclaration[] getModules() { -// if (this.knownModules.size() == 0) { -// return new IModuleDeclaration[0]; -// } -// List modules = new ArrayList(); -// for (IModulePathEntry val : this.knownModules.values()) { -// try { -// modules.add(val.getModule()); -// } catch (Exception e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// return modules.toArray(new IModuleDeclaration[modules.size()]); -// } + } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleUpdater.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleUpdater.java index 836c64b2a3..cab3e3e8b3 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleUpdater.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModuleUpdater.java @@ -43,9 +43,9 @@ */ public class ModuleUpdater { - private JavaProject javaProoject; + private final JavaProject javaProoject; - private Map moduleUpdates = new HashMap<>(); + private final Map moduleUpdates = new HashMap<>(); public ModuleUpdater(JavaProject javaProject) { this.javaProoject = javaProject; @@ -55,7 +55,6 @@ public ModuleUpdater(JavaProject javaProject) { * Detects any ADD_EXPORTS or ADD_READS classpath attributes, parses the value, * and collects the resulting module updates. * @param entry a classpath entry of the current project. - * @throws JavaModelException */ public void computeModuleUpdates(IClasspathEntry entry) throws JavaModelException { for (IClasspathAttribute attribute : entry.getExtraAttributes()) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java index afc1f72cd2..9d8ba04943 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.File; import java.util.*; import java.util.function.Function; @@ -65,7 +67,6 @@ * package. The other set of methods all begin with seek*. These methods * do comprehensive searches of the IJavaProject returning hits * in real time through an IJavaElementRequestor. - * */ @SuppressWarnings({"rawtypes", "unchecked"}) public class NameLookup implements SuffixConstants { @@ -238,7 +239,7 @@ public boolean isCanceled() { public long timeSpentInIsPackageWithModuleContext; public long timeSpentInSeekTypesInType; - private JavaProject rootProject; + private final JavaProject rootProject; public NameLookup( JavaProject rootProject, IPackageFragmentRoot[] packageFragmentRoots, @@ -248,10 +249,10 @@ public NameLookup( this.rootProject = rootProject; long start = -1; if (VERBOSE) { - Util.verbose(" BUILDING NameLoopkup"); //$NON-NLS-1$ - Util.verbose(" -> pkg roots size: " + (packageFragmentRoots == null ? 0 : packageFragmentRoots.length)); //$NON-NLS-1$ - Util.verbose(" -> pkgs size: " + (packageFragments == null ? 0 : packageFragments.size())); //$NON-NLS-1$ - Util.verbose(" -> working copy size: " + (workingCopies == null ? 0 : workingCopies.length)); //$NON-NLS-1$ + trace(" BUILDING NameLoopkup"); //$NON-NLS-1$ + trace(" -> pkg roots size: " + (packageFragmentRoots == null ? 0 : packageFragmentRoots.length)); //$NON-NLS-1$ + trace(" -> pkgs size: " + (packageFragments == null ? 0 : packageFragments.size())); //$NON-NLS-1$ + trace(" -> working copy size: " + (workingCopies == null ? 0 : workingCopies.length)); //$NON-NLS-1$ start = System.currentTimeMillis(); } this.rootToModule = new HashMap<>(); @@ -361,7 +362,7 @@ public NameLookup( this.rootToResolvedEntries = rootToResolvedEntries; if (VERBOSE) { - Util.verbose(" -> spent: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" -> spent: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -716,11 +717,11 @@ private IType findSecondaryType(String packageName, String typeName, IJavaProjec IType type = types.get(typeName); if (type != null) { if (JavaModelManager.VERBOSE) { - Util.verbose("NameLookup FIND SECONDARY TYPES:"); //$NON-NLS-1$ - Util.verbose(" -> pkg name: " + packageName); //$NON-NLS-1$ - Util.verbose(" -> type name: " + typeName); //$NON-NLS-1$ - Util.verbose(" -> project: "+project.getElementName()); //$NON-NLS-1$ - Util.verbose(" -> type: " + type.getElementName()); //$NON-NLS-1$ + trace("NameLookup FIND SECONDARY TYPES:"); //$NON-NLS-1$ + trace(" -> pkg name: " + packageName); //$NON-NLS-1$ + trace(" -> type name: " + typeName); //$NON-NLS-1$ + trace(" -> project: "+project.getElementName()); //$NON-NLS-1$ + trace(" -> type: " + type.getElementName()); //$NON-NLS-1$ } return type; } @@ -1776,14 +1777,14 @@ public void printTimeSpent() { if(!NameLookup.VERBOSE) return; - Util.verbose(" TIME SPENT NameLoopkup"); //$NON-NLS-1$ - Util.verbose(" -> seekTypesInSourcePackage..................." + this.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" -> seekTypesInBinaryPackage..................." + this.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" -> seekTypesInType............................" + this.timeSpentInSeekTypesInType + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" -> seekModule................................." + this.timeSpentInSeekModule + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" -> seekModuleAwarePartialPackageFragments....." + this.timeSpentInSeekModuleAwarePartialPackageFragments + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" -> seekPackageFragments......................." + this.timeSpentInSeekPackageFragments + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" -> seekPackageFragmentsWithModuleContext......" + this.timeSpentInSeekPackageFragmentsWithModuleContext + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" -> isPackage(pkg,moduleCtx)..................." + this.timeSpentInIsPackageWithModuleContext + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" TIME SPENT NameLoopkup"); //$NON-NLS-1$ + trace(" -> seekTypesInSourcePackage..................." + this.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" -> seekTypesInBinaryPackage..................." + this.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" -> seekTypesInType............................" + this.timeSpentInSeekTypesInType + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" -> seekModule................................." + this.timeSpentInSeekModule + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" -> seekModuleAwarePartialPackageFragments....." + this.timeSpentInSeekModuleAwarePartialPackageFragments + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" -> seekPackageFragments......................." + this.timeSpentInSeekPackageFragments + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" -> seekPackageFragmentsWithModuleContext......" + this.timeSpentInSeekPackageFragmentsWithModuleContext + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" -> isPackage(pkg,moduleCtx)..................." + this.timeSpentInIsPackageWithModuleContext + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NamedMember.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NamedMember.java index cee115127f..118df9f36d 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NamedMember.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NamedMember.java @@ -327,8 +327,8 @@ public void acceptModule(char[] moduleName, char[] uniqueKey, int start, int end engine.selectType(typeName.toCharArray(), (IType) this); if (NameLookup.VERBOSE) { - System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ - System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + JavaModelManager.trace(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + JavaModelManager.trace(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ } return requestor.answers; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Openable.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Openable.java index 62a2fc64dd..210b95b6ca 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Openable.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Openable.java @@ -241,7 +241,7 @@ protected void generateInfos(Object info, HashMap newElements, IProgressMonitor default: element = "element"; //$NON-NLS-1$ } - System.out.println(Thread.currentThread() +" OPENING " + element + " " + this.toStringWithAncestors()); //$NON-NLS-1$//$NON-NLS-2$ + JavaModelManager.trace(Thread.currentThread() +" OPENING " + element + " " + this.toStringWithAncestors()); //$NON-NLS-1$//$NON-NLS-2$ } // open its ancestors if needed @@ -274,7 +274,7 @@ protected void generateInfos(Object info, HashMap newElements, IProgressMonitor JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().remove(this); if (JavaModelCache.VERBOSE) { - System.out.println(JavaModelManager.getJavaModelManager().cacheToString("-> ")); //$NON-NLS-1$ + JavaModelManager.trace(JavaModelManager.getJavaModelManager().cacheToString("-> ")); //$NON-NLS-1$ } } protected boolean ignoreErrorStatus(IStatus status) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OverflowingLRUCache.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OverflowingLRUCache.java index e710c4ae8e..1b5af4a42b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OverflowingLRUCache.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OverflowingLRUCache.java @@ -107,7 +107,6 @@ public OverflowingLRUCache clone() { * *

    NOTE: this triggers an external remove from the cache * by closing the object. - * */ protected abstract boolean close(LRUCacheEntry entry); /** diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java index cf33e61a3a..02ecae3705 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java @@ -67,7 +67,7 @@ public class PackageFragment extends Openable implements IPackageFragment, Suffi public String[] names; - private boolean isValidPackageName; + private final boolean isValidPackageName; protected PackageFragment(PackageFragmentRoot root, String[] names) { super(root); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java index 713c58ee5e..e09259ff1a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java @@ -28,8 +28,6 @@ class PackageFragmentInfo extends OpenableElementInfo { public PackageFragmentInfo() { this.nonJavaResources = null; } -/** - */ boolean containsJavaResources() { return this.children.length != 0; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java index 1705f4b8e2..d2c40c8b30 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java @@ -341,7 +341,6 @@ protected int determineKind(IResource underlyingResource) throws JavaModelExcept * Compares two objects for equality; * for PackageFragmentRoots, equality is having the * same parent, same resources, and occurrence count. - * */ @Override public boolean equals(Object o) { @@ -892,7 +891,6 @@ protected void verifyAttachSource(IPath sourcePath) throws JavaModelException { * to directly under the root. It is the responsibility of such package fragment roots to * provide the custom behavior. * - * @param classname * @return the relative path for the class file within the archive */ public String getClassFilePath(String classname) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ProjectEntry.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ProjectEntry.java index 7b0447e365..0f89698807 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ProjectEntry.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ProjectEntry.java @@ -26,7 +26,6 @@ /** * Represents a project - * */ public class ProjectEntry implements IModulePathEntry { @@ -38,9 +37,9 @@ static boolean representsProject(IModulePathEntry entry, IJavaProject otherProje } JavaProject project; - + public ProjectEntry(JavaProject project) { - // + // this.project = project; } @Override diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ReconcileWorkingCopyOperation.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ReconcileWorkingCopyOperation.java index 99fd941eea..35a35318bb 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ReconcileWorkingCopyOperation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ReconcileWorkingCopyOperation.java @@ -125,9 +125,6 @@ protected void executeOperation() throws JavaModelException { /** * Report working copy problems to a given requestor. - * - * @param workingCopy - * @param problemRequestor */ private void reportProblems(CompilationUnit workingCopy, IProblemRequestor problemRequestor) { try { @@ -138,7 +135,7 @@ private void reportProblems(CompilationUnit workingCopy, IProblemRequestor probl for (int i = 0, length = categorizedProblems.length; i < length; i++) { CategorizedProblem problem = categorizedProblems[i]; if (JavaModelManager.VERBOSE){ - System.out.println("PROBLEM FOUND while reconciling : " + problem.getMessage());//$NON-NLS-1$ + JavaModelManager.trace("PROBLEM FOUND while reconciling : " + problem.getMessage());//$NON-NLS-1$ } if (this.progressMonitor != null && this.progressMonitor.isCanceled()) break; problemRequestor.acceptProblem(problem); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Region.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Region.java index 62596fdfb6..ab1b4aeabc 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Region.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Region.java @@ -90,7 +90,7 @@ public void removeChild(IJavaElement currentElement) { } } - private Node root = new Node(); + private final Node root = new Node(); @Override public void add(IJavaElement element) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryField.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryField.java index 04277a9606..5a55f3e388 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryField.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryField.java @@ -20,7 +20,7 @@ */ public class ResolvedBinaryField extends BinaryField { - private String uniqueKey; + private final String uniqueKey; /* * See class comments. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryMethod.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryMethod.java index 0040b540f7..fb0f8fddb2 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryMethod.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryMethod.java @@ -22,7 +22,7 @@ */ public class ResolvedBinaryMethod extends BinaryMethod { - private String uniqueKey; + private final String uniqueKey; /** * The parameter type signatures are expected to be dot-based. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryType.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryType.java index 65b4bc8048..033b7f667a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryType.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedBinaryType.java @@ -22,7 +22,7 @@ */ public class ResolvedBinaryType extends BinaryType { - private String uniqueKey; + private final String uniqueKey; /* * See class comments. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedLambdaExpression.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedLambdaExpression.java index bbb7a46ebf..d2db871a47 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedLambdaExpression.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedLambdaExpression.java @@ -17,7 +17,7 @@ public class ResolvedLambdaExpression extends LambdaExpression { - private String uniqueKey; + private final String uniqueKey; LambdaExpression unresolved; public ResolvedLambdaExpression(JavaElement parent, LambdaExpression unresolved, String uniqueKey) { @@ -63,4 +63,4 @@ protected void toStringInfo(int tab, StringBuffer buffer, Object info, boolean s public JavaElement unresolved() { return this.unresolved; } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedSourceField.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedSourceField.java index ba85abf27d..4dbb5f7f2a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedSourceField.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedSourceField.java @@ -19,7 +19,7 @@ */ public class ResolvedSourceField extends SourceField { - private String uniqueKey; + private final String uniqueKey; /* * See class comments. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedSourceMethod.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedSourceMethod.java index dc4a544613..2f58e0a3e0 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedSourceMethod.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedSourceMethod.java @@ -19,7 +19,7 @@ */ public class ResolvedSourceMethod extends SourceMethod { - private String uniqueKey; + private final String uniqueKey; /* * See class comments. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedSourceType.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedSourceType.java index 4262a56d02..343fb0e2a6 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedSourceType.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ResolvedSourceType.java @@ -21,7 +21,7 @@ */ public class ResolvedSourceType extends SourceType { - private String uniqueKey; + private final String uniqueKey; /* * See class comments. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java index ef3538834d..cd6ba2fb84 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java @@ -80,7 +80,7 @@ public class SearchableEnvironment protected boolean checkAccessRestrictions; // moduleName -> IPackageFragmentRoot[](lazily populated) private Map knownModuleLocations; // null indicates: not using JPMS - private boolean excludeTestCode; + private final boolean excludeTestCode; private ModuleUpdater moduleUpdater; private Map rootToModule; @@ -1298,9 +1298,9 @@ public void printTimeSpent() { if(!NameLookup.VERBOSE) return; - Util.verbose(" TIME SPENT SearchableEnvironment"); //$NON-NLS-1$ - Util.verbose(" -> getModulesDeclaringPackage..." + this.timeSpentInGetModulesDeclaringPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" -> findTypes...................." + this.timeSpentInFindTypes + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + JavaModelManager.trace(" TIME SPENT SearchableEnvironment"); //$NON-NLS-1$ + JavaModelManager.trace(" -> getModulesDeclaringPackage..." + this.timeSpentInGetModulesDeclaringPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + JavaModelManager.trace(" -> findTypes...................." + this.timeSpentInFindTypes + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ this.nameLookup.printTimeSpent(); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java index 5bcd3d76e3..f1e8e94590 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -110,9 +112,7 @@ private void acceptBinaryMethod( addElement(method); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept method("); //$NON-NLS-1$ - System.out.print(method.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept method(" + method.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } else { ISourceRange range = method.getSourceRange(); @@ -128,17 +128,13 @@ private void acceptBinaryMethod( } addElement(method); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept method("); //$NON-NLS-1$ - System.out.print(method.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept method(" + method.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } else { // no range was actually found, but a method was originally given -> default constructor addElement(type); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept type("); //$NON-NLS-1$ - System.out.print(type.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept type(" + type.toString()+ ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -227,9 +223,7 @@ public void acceptType(char[] packageName, char[] typeName, int modifiers, boole if (type != null) { addElement(type); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept type("); //$NON-NLS-1$ - System.out.print(type.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept type(" + type.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -250,9 +244,7 @@ public void acceptType(IType type) { addElement(type); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept type("); //$NON-NLS-1$ - System.out.print(type.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept type(" + type.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } /** @@ -290,9 +282,7 @@ public void acceptField(char[] declaringTypePackageName, char[] declaringTypeNam && field.getElementName().equals(new String(name))) { addElement(fields[i]); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept field("); //$NON-NLS-1$ - System.out.print(field.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept field(" + field.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } return; // only one method is possible } @@ -325,9 +315,7 @@ public void acceptField(char[] declaringTypePackageName, char[] declaringTypeNam } addElement(field); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept field("); //$NON-NLS-1$ - System.out.print(field.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept field(" + field.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -364,9 +352,7 @@ public void acceptLocalField(FieldBinding fieldBinding) { } addElement(field); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept field("); //$NON-NLS-1$ - System.out.print(field.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept field(" + field.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -397,18 +383,14 @@ public void acceptLocalMethod(MethodBinding methodBinding) { } addElement(res); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept method("); //$NON-NLS-1$ - System.out.print(res.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept method(" + res.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } else if(methodBinding.selector == TypeConstants.INIT && res.getElementType() == IJavaElement.TYPE) { // it's a default constructor res = ((JavaElement)res).resolved(methodBinding.declaringClass); addElement(res); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept type("); //$NON-NLS-1$ - System.out.print(res.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept type(" + res.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -425,9 +407,7 @@ public void acceptLocalType(TypeBinding typeBinding) { res = ((JavaElement)res).resolved(typeBinding); addElement(res); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept type("); //$NON-NLS-1$ - System.out.print(res.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept type(" + res.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -446,9 +426,7 @@ public void acceptLocalTypeParameter(TypeVariableBinding typeVariableBinding) { if (typeParameter.exists()) { addElement(typeParameter); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept type parameter("); //$NON-NLS-1$ - System.out.print(typeParameter.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept type parameter(" + typeParameter.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -463,9 +441,7 @@ public void acceptLocalMethodTypeParameter(TypeVariableBinding typeVariableBindi if (typeParameter.exists()) { addElement(typeParameter); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept type parameter("); //$NON-NLS-1$ - System.out.print(typeParameter.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept type parameter(" + typeParameter.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -507,9 +483,7 @@ public void acceptLocalVariable(LocalVariableBinding binding, org.eclipse.jdt.in if (localVar != null) { addElement(localVar); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept local variable("); //$NON-NLS-1$ - System.out.print(localVar.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept local variable(" + localVar.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -610,9 +584,7 @@ public void acceptPackage(char[] packageName) { for (int i = 0, length = pkgs.length; i < length; i++) { addElement(pkgs[i]); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept package("); //$NON-NLS-1$ - System.out.print(pkgs[i].toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept package(" + pkgs[i].toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -696,9 +668,7 @@ protected void acceptSourceMethod( // no match was actually found, but a method was originally given -> default accessor addElement(comp); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept field("); //$NON-NLS-1$ - System.out.print(comp.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept field(" + comp.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -710,9 +680,7 @@ protected void acceptSourceMethod( // no match was actually found, but a method was originally given -> default constructor addElement(type); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept type("); //$NON-NLS-1$ - System.out.print(type.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept type(" + type.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } return; @@ -721,9 +689,7 @@ protected void acceptSourceMethod( // if there is only one match, we've got it if (this.elementIndex == 0) { if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept method("); //$NON-NLS-1$ - System.out.print(this.elements[0].toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept method(" + this.elements[0].toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } return; } @@ -753,9 +719,7 @@ protected void acceptSourceMethod( if (match) { addElement(method); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept method("); //$NON-NLS-1$ - System.out.print(method.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept method(" + method.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -773,9 +737,7 @@ protected void acceptMethodDeclaration(IType type, char[] selector, int start, i && methods[i].getElementName().equals(name)) { addElement(methods[i]); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept method("); //$NON-NLS-1$ - System.out.print(this.elements[0].toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept method(" + this.elements[0].toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } return; // only one method is possible } @@ -787,9 +749,7 @@ protected void acceptMethodDeclaration(IType type, char[] selector, int start, i // no match was actually found addElement(type); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept type("); //$NON-NLS-1$ - System.out.print(type.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept type(" + type.toString()+ ")"); //$NON-NLS-1$ //$NON-NLS-2$ } return; } @@ -810,16 +770,12 @@ public void acceptTypeParameter(char[] declaringTypePackageName, char[] declarin if(typeParameter == null) { addElement(type); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept type("); //$NON-NLS-1$ - System.out.print(type.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept type(" + type.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } else { addElement(typeParameter); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept type parameter("); //$NON-NLS-1$ - System.out.print(typeParameter.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept type parameter(" + typeParameter.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -854,25 +810,19 @@ public void acceptMethodTypeParameter(char[] declaringTypePackageName, char[] de if(method == null) { addElement(type); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept type("); //$NON-NLS-1$ - System.out.print(type.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept type(" + type.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } else { ITypeParameter typeParameter = method.getTypeParameter(new String(typeParameterName)); if(typeParameter == null) { addElement(method); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept method("); //$NON-NLS-1$ - System.out.print(method.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept method(" + method.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } else { addElement(typeParameter); if(SelectionEngine.DEBUG){ - System.out.print("SELECTION - accept method type parameter("); //$NON-NLS-1$ - System.out.print(typeParameter.toString()); - System.out.println(")"); //$NON-NLS-1$ + trace("SELECTION - accept method type parameter(" + typeParameter.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetContainerOperation.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetContainerOperation.java index 9ca100b09e..c51d6bad74 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetContainerOperation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetContainerOperation.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -23,7 +25,6 @@ import org.eclipse.jdt.core.IJavaModelStatusConstants; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.core.util.Util; public class SetContainerOperation extends ChangeClasspathOperation { @@ -150,22 +151,21 @@ protected void executeOperation() throws JavaModelException { } private void verbose_failure(CoreException e) { - Util.verbose( + trace( "CPContainer SET - FAILED DUE TO EXCEPTION\n" + //$NON-NLS-1$ " container path: " + this.containerPath, //$NON-NLS-1$ - System.err); - e.printStackTrace(); + e); } private void verbose_update_project(JavaProject affectedProject) { - Util.verbose( + trace( "CPContainer SET - updating affected project due to setting container\n" + //$NON-NLS-1$ " project: " + affectedProject.getElementName() + '\n' + //$NON-NLS-1$ " container path: " + this.containerPath); //$NON-NLS-1$ } private void verbose_set_container() { - Util.verbose( + trace( "CPContainer SET - setting container\n" + //$NON-NLS-1$ " container path: " + this.containerPath + '\n' + //$NON-NLS-1$ " projects: {" +//$NON-NLS-1$ @@ -205,10 +205,9 @@ public String displayString(Object o) { } private void verbose_set_container_invocation_trace() { - Util.verbose( + trace( "CPContainer SET - setting container\n" + //$NON-NLS-1$ - " invocation stack trace:"); //$NON-NLS-1$ - new Exception("").printStackTrace(System.out); //$NON-NLS-1$ + " invocation stack trace:", new Exception("")); //$NON-NLS-1$ //$NON-NLS-2$ } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetVariablesOperation.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetVariablesOperation.java index c860a3142e..11e80f3ba6 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetVariablesOperation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetVariablesOperation.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.util.HashMap; import java.util.Iterator; @@ -24,7 +26,6 @@ import org.eclipse.jdt.core.IJavaModel; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.core.util.Util; @SuppressWarnings({"rawtypes", "unchecked"}) public class SetVariablesOperation extends ChangeClasspathOperation { @@ -158,8 +159,7 @@ protected void executeOperation() throws JavaModelException { } } catch (CoreException e) { if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE){ - verbose_failure(dbgVariableNames); - e.printStackTrace(); + verbose_failure(dbgVariableNames, e); } if (e instanceof JavaModelException) { throw (JavaModelException)e; @@ -173,23 +173,22 @@ protected void executeOperation() throws JavaModelException { } } - private void verbose_failure(String[] dbgVariableNames) { - Util.verbose( + private void verbose_failure(String[] dbgVariableNames, CoreException e) { + trace( "CPVariable SET - FAILED DUE TO EXCEPTION\n" + //$NON-NLS-1$ - " variables: " + org.eclipse.jdt.internal.compiler.util.Util.toString(dbgVariableNames), //$NON-NLS-1$ - System.err); + " variables: " + org.eclipse.jdt.internal.compiler.util.Util.toString(dbgVariableNames), e); //$NON-NLS-1$ } private void verbose_update_project(String[] dbgVariableNames, JavaProject affectedProject) { - Util.verbose( + trace( "CPVariable SET - updating affected project due to setting variables\n" + //$NON-NLS-1$ " project: " + affectedProject.getElementName() + '\n' + //$NON-NLS-1$ " variables: " + org.eclipse.jdt.internal.compiler.util.Util.toString(dbgVariableNames)); //$NON-NLS-1$ } private void verbose_set_variables() { - Util.verbose( + trace( "CPVariable SET - setting variables\n" + //$NON-NLS-1$ " variables: " + org.eclipse.jdt.internal.compiler.util.Util.toString(this.variableNames) + '\n' +//$NON-NLS-1$ " values: " + org.eclipse.jdt.internal.compiler.util.Util.toString(this.variablePaths)); //$NON-NLS-1$ diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SortElementsOperation.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SortElementsOperation.java index 9cb2d7f872..9b343bb1c5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SortElementsOperation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SortElementsOperation.java @@ -67,9 +67,6 @@ public class SortElementsOperation extends JavaModelOperation { * Constructor for SortElementsOperation. * * @param level the AST API level; one of the AST LEVEL constants - * @param elements - * @param positions - * @param comparator */ public SortElementsOperation(int level, IJavaElement[] elements, int[] positions, Comparator comparator) { super(elements); @@ -122,7 +119,6 @@ protected void executeOperation() throws JavaModelException { /** * Calculates the required text edits to sort the unit - * @param group * @return the edit or null if no sorting is required */ public TextEdit calculateEdit(org.eclipse.jdt.core.dom.CompilationUnit unit, TextEditGroup group) throws JavaModelException { @@ -151,8 +147,6 @@ public TextEdit calculateEdit(org.eclipse.jdt.core.dom.CompilationUnit unit, Tex /** * Method processElement. - * @param unit - * @param source */ private String processElement(ICompilationUnit unit, char[] source) { Document document = new Document(new String(source)); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java index f0af66dcd9..575ac61e69 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java @@ -16,6 +16,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.attribute.BasicFileAttributes; @@ -549,7 +551,7 @@ private synchronized void computeAllRootPaths(IJavaElement typeOrModule) { final HashSet tempRoots = new HashSet(); long time = 0; if (VERBOSE) { - System.out.println("compute all root paths for " + root.getElementName()); //$NON-NLS-1$ + trace("compute all root paths for " + root.getElementName()); //$NON-NLS-1$ time = System.currentTimeMillis(); } final HashSet firstLevelPackageNames = new HashSet(); @@ -570,7 +572,7 @@ private synchronized void computeAllRootPaths(IJavaElement typeOrModule) { } catch (IOException e) { // We are not reading any specific file, so, move on for now if (VERBOSE) { - e.printStackTrace(); + trace("", e); //$NON-NLS-1$ } } } else if (root.isArchive()) { @@ -710,11 +712,11 @@ public int compare(Object o1, Object o2) { } this.areRootPathsComputed = true; if (VERBOSE) { - System.out.println("Spent " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ - System.out.println("Found " + size + " root paths"); //$NON-NLS-1$ //$NON-NLS-2$ + trace("Spent " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + trace("Found " + size + " root paths"); //$NON-NLS-1$ //$NON-NLS-2$ int i = 0; for (Iterator iterator = this.rootPaths.iterator(); iterator.hasNext();) { - System.out.println("root[" + i + "]=" + ((String) iterator.next()));//$NON-NLS-1$ //$NON-NLS-2$ + trace("root[" + i + "]=" + ((String) iterator.next()));//$NON-NLS-1$ //$NON-NLS-2$ i++; } } @@ -754,8 +756,9 @@ private void computeRootPath(IContainer container, HashSet firstLevelPackageName } } } catch (CoreException e) { - // ignore - e.printStackTrace(); + if (VERBOSE) { + trace("", e); //$NON-NLS-1$ + } } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethod.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethod.java index 6fa21e07b1..da62b923b2 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethod.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethod.java @@ -242,6 +242,12 @@ public boolean isConstructor() throws JavaModelException { public boolean isMainMethod() throws JavaModelException { return this.isMainMethod(this); } + +@Override +public boolean isMainMethodCandidate() throws JavaModelException { + return this.isMainMethodCandidate(this); +} + /** * @see IMethod#isLambdaMethod() */ @@ -266,8 +272,6 @@ public boolean isSimilar(IMethod method) { null); } -/** - */ @Override public String readableName() { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceModule.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceModule.java index 2d87051293..28bd424184 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceModule.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceModule.java @@ -47,8 +47,9 @@ public String toString(String lineDelimiter) { try { toStringContent(buffer, lineDelimiter); } catch (JavaModelException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } } return buffer.toString(); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java index 5a8c898365..86607c9e17 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java @@ -142,8 +142,8 @@ public void codeComplete( engine.complete(this, snippet, position, localVariableTypeNames, localVariableNames, localVariableModifiers, isStatic); } if (NameLookup.VERBOSE) { - System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ - System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + JavaModelManager.trace(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + JavaModelManager.trace(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ } } /** @@ -357,7 +357,6 @@ public String getFullyQualifiedParameterizedName() throws JavaModelException { } /* * For source types, the occurrence count is the one computed in the context of the immediately enclosing type. - * */ @Override protected String getOccurrenceCountSignature() { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeVector.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeVector.java index fe63810bc0..8e2783a9fd 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeVector.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeVector.java @@ -26,7 +26,7 @@ public final class TypeVector { int maxSize; IType[] elements; /** - * {@link HashMap} that contains the same elements as the {@link #elements}. Used to speed up {@link #contains} + * {@link HashMap} that contains the same elements as the {@link #elements}. Used to speed up {@link #contains} * for large lists. It is lazily constructed the first time it is needed for vectors larger than * {@link #MIN_ELEMENTS_FOR_HASHSET}. Set to null if not constructed yet. The keys and values are the same */ @@ -79,14 +79,11 @@ public boolean contains(IType element) { return this.elementSet.containsKey(element); } - for (int i = this.size; --i >= 0;) + for (int i = this.size; --i >= 0;) if (element.equals(this.elements[i])) return true; return false; } -/** - * - */ private void constructElementSetIfNecessary() { if (this.elementSet == null && this.size >= MIN_ELEMENTS_FOR_HASHSET) { this.elementSet = new HashMap<>(); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibrary.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibrary.java index b645401640..6ca685b00c 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibrary.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibrary.java @@ -53,8 +53,8 @@ public class UserLibrary { private static final String TAG_ARCHIVE= "archive"; //$NON-NLS-1$ private static final String TAG_SYSTEMLIBRARY= "systemlibrary"; //$NON-NLS-1$ - private boolean isSystemLibrary; - private IClasspathEntry[] entries; + private final boolean isSystemLibrary; + private final IClasspathEntry[] entries; public UserLibrary(IClasspathEntry[] entries, boolean isSystemLibrary) { Assert.isNotNull(entries); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryClasspathContainer.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryClasspathContainer.java index 65eea09ce0..b795f0deb3 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryClasspathContainer.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryClasspathContainer.java @@ -18,14 +18,10 @@ import org.eclipse.jdt.core.IClasspathContainer; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.internal.core.util.Util; -/** - * - */ public class UserLibraryClasspathContainer implements IClasspathContainer { - private String name; + private final String name; public UserLibraryClasspathContainer(String name) { this.name = name; @@ -68,7 +64,7 @@ private UserLibrary getUserLibrary() { } private void verbose_no_user_library_found(String userLibraryName) { - Util.verbose( + JavaModelManager.trace( "UserLibrary INIT - FAILED (no user library found)\n" + //$NON-NLS-1$ " userLibraryName: " + userLibraryName); //$NON-NLS-1$ } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryClasspathContainerInitializer.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryClasspathContainerInitializer.java index 42cee87e91..95127b66d6 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryClasspathContainerInitializer.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryClasspathContainerInitializer.java @@ -19,11 +19,7 @@ import org.eclipse.jdt.core.IClasspathContainer; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.internal.core.util.Util; -/** - * - */ public class UserLibraryClasspathContainerInitializer extends ClasspathContainerInitializer { @Override @@ -84,14 +80,14 @@ public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject pr } private void verbose_no_user_library_found(IJavaProject project, String userLibraryName) { - Util.verbose( + JavaModelManager.trace( "UserLibrary INIT - FAILED (no user library found)\n" + //$NON-NLS-1$ " project: " + project.getElementName() + '\n' + //$NON-NLS-1$ " userLibraryName: " + userLibraryName); //$NON-NLS-1$ } private void verbose_not_a_user_library(IJavaProject project, IPath containerPath) { - Util.verbose( + JavaModelManager.trace( "UserLibrary INIT - FAILED (not a user library)\n" + //$NON-NLS-1$ " project: " + project.getElementName() + '\n' + //$NON-NLS-1$ " container path: " + containerPath); //$NON-NLS-1$ diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryManager.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryManager.java index 969b6de974..2e8c316a22 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryManager.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryManager.java @@ -31,9 +31,6 @@ import org.eclipse.jdt.internal.core.util.Util; import org.osgi.service.prefs.BackingStoreException; -/** - * - */ @SuppressWarnings({"rawtypes", "unchecked"}) public class UserLibraryManager { @@ -153,7 +150,7 @@ public void updateUserLibrary(String libName, String encodedUserLibrary) { } catch (IOException | ClasspathEntry.AssertionFailedException ase) { Util.log(ase, "Exception while decoding user library '"+ libName +"'."); //$NON-NLS-1$ //$NON-NLS-2$ } - + } public void removeUserLibrary(String libName) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/VerboseElementCache.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/VerboseElementCache.java index fa9ddb66e4..29a808bd57 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/VerboseElementCache.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/VerboseElementCache.java @@ -22,7 +22,7 @@ public class VerboseElementCache extends ElementCache { private K beingAdded; - private String name; + private final String name; public VerboseElementCache(int size, String name) { super(size); @@ -36,10 +36,10 @@ protected boolean makeSpace(int space) { boolean result = super.makeSpace(space); String newFillingRatio = toStringFillingRation(this.name); if (!fillingRatio.equals(newFillingRatio)) { - System.out.println(Thread.currentThread() + " " + new Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$ - System.out.println(Thread.currentThread() + " MADE SPACE FOR " + fillingRatio + " (NOW " + NumberFormat.getInstance().format(fillingRatio()) + "% full)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - System.out.println(Thread.currentThread() + " WHILE OPENING "+ ((JavaElement) this.beingAdded).toStringWithAncestors()); //$NON-NLS-1$ - System.out.println(); + JavaModelManager.trace(Thread.currentThread() + " " + new Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$ + JavaModelManager.trace(Thread.currentThread() + " MADE SPACE FOR " + fillingRatio + " (NOW " + NumberFormat.getInstance().format(fillingRatio()) + "% full)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + JavaModelManager.trace(Thread.currentThread() + " WHILE OPENING "+ ((JavaElement) this.beingAdded).toStringWithAncestors()); //$NON-NLS-1$ + JavaModelManager.trace(""); //$NON-NLS-1$ } return result; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java index f9455cf4f4..a92deb7bac 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java @@ -36,6 +36,8 @@ import org.eclipse.jdt.internal.core.util.Messages; import org.eclipse.jdt.internal.core.util.Util; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.*; import java.util.*; @@ -85,7 +87,7 @@ public abstract class AbstractImageBuilder implements ICompilerRequestor, ICompi public final static Integer P_HIGH = Integer.valueOf(IMarker.PRIORITY_HIGH); public final static Integer P_NORMAL = Integer.valueOf(IMarker.PRIORITY_NORMAL); public final static Integer P_LOW = Integer.valueOf(IMarker.PRIORITY_LOW); -private CompilationGroup compilationGroup; +private final CompilationGroup compilationGroup; protected AbstractImageBuilder(JavaBuilder javaBuilder, boolean buildStarting, State newState, CompilationGroup compilationGroup) { // local copies @@ -355,9 +357,11 @@ protected void compile(SourceFile[] units) { // GROOVY end if (this.compiledAllAtOnce) { // do them all now - if (JavaBuilder.DEBUG) - for (int i = 0; i < unitsLength; i++) - System.out.println("About to compile " + units[i].typeLocator()); //$NON-NLS-1$ + if (JavaBuilder.DEBUG) { + for (int i = 0; i < unitsLength; i++) { + trace("About to compile " + units[i].typeLocator()); //$NON-NLS-1$ + } + } compile(units, null, true); } else { SourceFile[] remainingUnits = new SourceFile[unitsLength]; // copy of units, removing units when about to compile @@ -373,8 +377,9 @@ protected void compile(SourceFile[] units) { // already been compiled when it was referenced by another unit. SourceFile unit = remainingUnits[remainingIndex]; if (unit != null && (compilingFirstGroup || this.workQueue.isWaiting(unit))) { - if (JavaBuilder.DEBUG) - System.out.println("About to compile #" + remainingIndex + " : "+ unit.typeLocator()); //$NON-NLS-1$ //$NON-NLS-2$ + if (JavaBuilder.DEBUG) { + trace("About to compile #" + remainingIndex + " : "+ unit.typeLocator()); //$NON-NLS-1$ //$NON-NLS-2$ + } toCompile[count++] = unit; } remainingUnits[remainingIndex++] = null; @@ -754,8 +759,9 @@ protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] prob break; } if (buildPathProblemMessage != null) { - if (JavaBuilder.DEBUG) - System.out.println(buildPathProblemMessage); + if (JavaBuilder.DEBUG) { + trace(buildPathProblemMessage); + } boolean isInvalidClasspathError = JavaCore.ERROR.equals(this.javaBuilder.javaProject.getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true)); // insert extra classpath problem, and make it the only problem for this project (optional) if (isInvalidClasspathError && JavaCore.ABORT.equals(this.javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true))) { @@ -801,7 +807,7 @@ protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] prob } catch (CoreException e) { // marker retrieval failed, cannot do much if (JavaModelManager.VERBOSE) { - e.printStackTrace(); + trace("", e); //$NON-NLS-1$ } } IResource tempRes = pkg.resource(); @@ -931,15 +937,18 @@ protected void writeClassFileContents(ClassFile classFile, IFile file, String qu InputStream input = new ByteArrayInputStream(classFile.getBytes()); if (file.exists()) { // Deal with shared output folders... last one wins... no collision cases detected - if (JavaBuilder.DEBUG) - System.out.println("Writing changed class file " + file.getName());//$NON-NLS-1$ - if (!file.isDerived()) + if (JavaBuilder.DEBUG) { + trace("Writing changed class file " + file.getName());//$NON-NLS-1$ + } + if (!file.isDerived()) { file.setDerived(true, null); + } file.setContents(input, true, false, null); } else { // Default implementation just writes out the bytes for the new class file... - if (JavaBuilder.DEBUG) - System.out.println("Writing new class file " + file.getName());//$NON-NLS-1$ + if (JavaBuilder.DEBUG) { + trace("Writing new class file " + file.getName());//$NON-NLS-1$ + } file.create(input, IResource.FORCE | IResource.DERIVED, null); } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/BuildNotifier.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/BuildNotifier.java index 98692623ce..e9e36d0c79 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/BuildNotifier.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/BuildNotifier.java @@ -46,9 +46,9 @@ public class BuildNotifier { .getInteger("org.eclipse.jdt.MillisecondsBeforeCancelAutoBuild", 1000); //$NON-NLS-1$ private static final int millisecondsBeforeInterruptAutoBuild = Integer .getInteger("org.eclipse.jdt.MillisecondsBeforeInterruptAutoBuild", 3000); //$NON-NLS-1$ -private BooleanSupplier interruptSupplier; -private long startTimeNanos; -private int buildKind; +private final BooleanSupplier interruptSupplier; +private final long startTimeNanos; +private final int buildKind; public static void resetProblemCounters() { NewErrorCount = 0; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java index 81a6e08bea..31c9070fcd 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.builder; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.IOException; import java.util.HashSet; import java.util.Set; @@ -34,6 +36,7 @@ import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable; import org.eclipse.jdt.internal.compiler.util.SuffixConstants; +import org.eclipse.jdt.internal.core.JavaModelManager; import org.eclipse.jdt.internal.core.util.Util; @@ -84,15 +87,18 @@ IModule initializeModule() { ClassFileReader cfr = Util.newClassFileReader(m); return cfr.getModuleDeclaration(); } catch (ClassFormatException | IOException e) { - // TODO Java 9 Auto-generated catch block - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + trace("", e); //$NON-NLS-1$ + } } } } } } } catch (CoreException e1) { - e1.printStackTrace(); + if (JavaModelManager.VERBOSE) { + trace("", e1); //$NON-NLS-1$ + } } return null; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java index c2eb8621af..ce7ee0278d 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java @@ -16,6 +16,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.builder; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -50,6 +52,7 @@ import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; import org.eclipse.jdt.internal.compiler.util.SimpleSet; import org.eclipse.jdt.internal.compiler.util.SuffixConstants; +import org.eclipse.jdt.internal.core.JavaModelManager; import org.eclipse.jdt.internal.core.util.Util; @SuppressWarnings("rawtypes") @@ -133,7 +136,9 @@ IModule initializeModule() { try { classfile = ClassFileReader.read(file, releasePath); } catch (Exception e) { - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + trace("", e); //$NON-NLS-1$ + } // move on to the default } if (classfile == null) { @@ -210,8 +215,8 @@ public void cleanup() { if (this.zipFile != null) { try { this.zipFile.close(); - if (org.eclipse.jdt.internal.core.JavaModelManager.ZIP_ACCESS_VERBOSE) { - System.out.println("(" + Thread.currentThread() + ") [ClasspathJar.cleanup()] Closed ZipFile on " + this.zipFilename); //$NON-NLS-1$ //$NON-NLS-2$ + if (JavaModelManager.ZIP_ACCESS_VERBOSE) { + trace("(" + Thread.currentThread() + ") [ClasspathJar.cleanup()] Closed ZipFile on " + this.zipFilename); //$NON-NLS-1$ //$NON-NLS-2$ } } catch(IOException e) { // ignore it JavaCore.getPlugin().getLog().log(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, "Error closing " + this.zipFile.getName(), e)); //$NON-NLS-1$ @@ -221,8 +226,8 @@ public void cleanup() { if (this.annotationZipFile != null) { try { this.annotationZipFile.close(); - if (org.eclipse.jdt.internal.core.JavaModelManager.ZIP_ACCESS_VERBOSE) { - System.out.println("(" + Thread.currentThread() + ") [ClasspathJar.cleanup()] Closed Annotation ZipFile on " + this.zipFilename); //$NON-NLS-1$ //$NON-NLS-2$ + if (JavaModelManager.ZIP_ACCESS_VERBOSE) { + trace("(" + Thread.currentThread() + ") [ClasspathJar.cleanup()] Closed Annotation ZipFile on " + this.zipFilename); //$NON-NLS-1$ //$NON-NLS-2$ } } catch(IOException e) { // ignore it JavaCore.getPlugin().getLog().log(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, "Error closing " + this.annotationZipFile.getName(), e)); //$NON-NLS-1$ @@ -230,10 +235,10 @@ public void cleanup() { this.annotationZipFile = null; } } else { - if (this.zipFile != null && org.eclipse.jdt.internal.core.JavaModelManager.ZIP_ACCESS_VERBOSE) { + if (this.zipFile != null && JavaModelManager.ZIP_ACCESS_VERBOSE) { try { this.zipFile.size(); - System.out.println("(" + Thread.currentThread() + ") [ClasspathJar.cleanup()] ZipFile NOT closed on " + this.zipFilename); //$NON-NLS-1$ //$NON-NLS-2$ + trace("(" + Thread.currentThread() + ") [ClasspathJar.cleanup()] ZipFile NOT closed on " + this.zipFilename); //$NON-NLS-1$ //$NON-NLS-2$ } catch (IllegalStateException e) { // OK: the file was already closed } @@ -332,8 +337,8 @@ public boolean hasCompilationUnit(String pkgName, String moduleName) { private boolean scanContent() { try { if (this.zipFile == null) { - if (org.eclipse.jdt.internal.core.JavaModelManager.ZIP_ACCESS_VERBOSE) { - System.out.println("(" + Thread.currentThread() + ") [ClasspathJar.isPackage(String)] Creating ZipFile on " + this.zipFilename); //$NON-NLS-1$ //$NON-NLS-2$ + if (JavaModelManager.ZIP_ACCESS_VERBOSE) { + trace("(" + Thread.currentThread() + ") [ClasspathJar.isPackage(String)] Creating ZipFile on " + this.zipFilename); //$NON-NLS-1$ //$NON-NLS-2$ } this.zipFile = new ZipFile(this.zipFilename); this.closeZipFileAtEnd = true; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/CompilationParticipantResult.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/CompilationParticipantResult.java index 8b2bb23e44..c57c19b478 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/CompilationParticipantResult.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/CompilationParticipantResult.java @@ -27,7 +27,7 @@ public class CompilationParticipantResult extends BuildContext { protected IFile[] deletedFiles; // previously generated source files that should be deleted protected CategorizedProblem[] problems; // new problems to report against this compilationUnit protected String[] dependencies; // fully-qualified type names of any new dependencies, each name is of the form 'p1.p2.A.B' - private boolean isTestCode; + private final boolean isTestCode; protected CompilationParticipantResult(SourceFile sourceFile, boolean isTestCode) { this.sourceFile = sourceFile; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java index 68fe0fa59f..76a228bc17 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.builder; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import org.eclipse.core.resources.*; import org.eclipse.core.runtime.*; @@ -170,9 +172,10 @@ protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) thro this.currentProject = getProject(); if (this.currentProject == null || !this.currentProject.isAccessible()) return new IProject[0]; - if (DEBUG) - System.out.println("\nJavaBuilder: Starting build of " + this.currentProject.getName() //$NON-NLS-1$ + if (DEBUG) { + trace("\nJavaBuilder: Starting build of " + this.currentProject.getName() //$NON-NLS-1$ + " @ " + new Date(System.currentTimeMillis())); //$NON-NLS-1$ + } this.notifier = new BuildNotifier(monitor,kind, kind == IncrementalProjectBuilder.AUTO_BUILD ? this::isInterrupted : ()->false); this.notifier.begin(); @@ -183,46 +186,53 @@ protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) thro if (isWorthBuilding()) { if (kind == FULL_BUILD) { - if (DEBUG) - System.out.println("JavaBuilder: Performing full build as requested"); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Performing full build as requested"); //$NON-NLS-1$ + } buildAll(); } else { if ((this.lastState = getLastState(this.currentProject)) == null) { - if (DEBUG) - System.out.println("JavaBuilder: Performing full build since last saved state was not found"); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Performing full build since last saved state was not found"); //$NON-NLS-1$ + } buildAll(); } else if (hasClasspathChanged()) { // if the output location changes, do not delete the binary files from old location // the user may be trying something - if (DEBUG) - System.out.println("JavaBuilder: Performing full build since classpath has changed"); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Performing full build since classpath has changed"); //$NON-NLS-1$ + } buildAll(); } else if (this.nameEnvironment.sourceLocations.length > 0 || this.testNameEnvironment.sourceLocations.length > 0) { // if there is no source to compile & no classpath changes then we are done SimpleLookupTable deltas = findDeltas(); if (deltas == null) { - if (DEBUG) - System.out.println("JavaBuilder: Performing full build since deltas are missing after incremental request"); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Performing full build since deltas are missing after incremental request"); //$NON-NLS-1$ + } buildAll(); } else if (deltas.elementSize > 0) { if (hasJdtCoreSettingsChange(deltas) && !DISABLE_AUTO_BUILDING_ON_SETTINGS_CHANGE) { - if (DEBUG) - System.out.println("JavaBuilder: Performing full build since project settings have changed"); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Performing full build since project settings have changed"); //$NON-NLS-1$ + } buildAll(); } else { buildDeltas(deltas); } } else if (DEBUG) { - System.out.println("JavaBuilder: Nothing to build since deltas were empty"); //$NON-NLS-1$ + trace("JavaBuilder: Nothing to build since deltas were empty"); //$NON-NLS-1$ } } else { if (hasStructuralDelta()) { // double check that a jar file didn't get replaced in a binary project - if (DEBUG) - System.out.println("JavaBuilder: Performing full build since there are structural deltas"); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Performing full build since there are structural deltas"); //$NON-NLS-1$ + } buildAll(); } else { - if (DEBUG) - System.out.println("JavaBuilder: Nothing to build since there are no source folders and no deltas"); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Nothing to build since there are no source folders and no deltas"); //$NON-NLS-1$ + } this.lastState.tagAsNoopBuild(); } } @@ -237,8 +247,9 @@ protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) thro createInconsistentBuildMarker(e.coreException); } catch (MissingSourceFileException e) { // do not log this exception since its thrown to handle aborted compiles because of missing source files - if (DEBUG) - System.out.println(Messages.bind(Messages.build_missingSourceFile, e.missingSourceFile)); + if (DEBUG) { + trace(Messages.bind(Messages.build_missingSourceFile, e.missingSourceFile)); + } removeProblemsAndTasksFor(this.currentProject); // make this the only problem for this project Map attributes = new HashMap<>(); @@ -256,17 +267,19 @@ protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) thro cleanup(); } IProject[] requiredProjects = getRequiredProjects(true); - if (DEBUG) - System.out.println("JavaBuilder: Finished build of " + this.currentProject.getName() //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Finished build of " + this.currentProject.getName() //$NON-NLS-1$ + " @ " + new Date(System.currentTimeMillis()) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ + } return requiredProjects; } private void buildAll() { this.notifier.checkCancel(); this.notifier.subTask(Messages.bind(Messages.build_preparingBuild, this.currentProject.getName())); - if (DEBUG && this.lastState != null) - System.out.println("JavaBuilder: Clearing last state : " + this.lastState); //$NON-NLS-1$ + if (DEBUG && this.lastState != null) { + trace("JavaBuilder: Clearing last state : " + this.lastState); //$NON-NLS-1$ + } clearLastState(); BatchImageBuilder imageBuilder = new BatchImageBuilder(this, true, CompilationGroup.MAIN); BatchImageBuilder testImageBuilder = new BatchImageBuilder(imageBuilder, true, CompilationGroup.TEST); @@ -283,15 +296,17 @@ private void buildAll() { private void buildDeltas(SimpleLookupTable deltas) { this.notifier.checkCancel(); this.notifier.subTask(Messages.bind(Messages.build_preparingBuild, this.currentProject.getName())); - if (DEBUG && this.lastState != null) - System.out.println("JavaBuilder: Clearing last state : " + this.lastState); //$NON-NLS-1$ + if (DEBUG && this.lastState != null) { + trace("JavaBuilder: Clearing last state : " + this.lastState); //$NON-NLS-1$ + } clearLastState(); // clear the previously built state so if the build fails, a full build will occur next time IncrementalImageBuilder imageBuilder = new IncrementalImageBuilder(this); if (imageBuilder.build(deltas)) { recordNewState(imageBuilder.newState); } else { - if (DEBUG) - System.out.println("JavaBuilder: Performing full build since incremental build failed"); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Performing full build since incremental build failed"); //$NON-NLS-1$ + } buildAll(); } } @@ -301,17 +316,19 @@ protected void clean(IProgressMonitor monitor) throws CoreException { this.currentProject = getProject(); if (this.currentProject == null || !this.currentProject.isAccessible()) return; - if (DEBUG) - System.out.println("\nJavaBuilder: Cleaning " + this.currentProject.getName() //$NON-NLS-1$ + if (DEBUG) { + trace("\nJavaBuilder: Cleaning " + this.currentProject.getName() //$NON-NLS-1$ + " @ " + new Date(System.currentTimeMillis())); //$NON-NLS-1$ + } this.notifier = new BuildNotifier(monitor,CLEAN_BUILD, ()->false); this.notifier.begin(); try { this.notifier.checkCancel(); initializeBuilder(CLEAN_BUILD, true); - if (DEBUG) - System.out.println("JavaBuilder: Clearing last state as part of clean : " + this.lastState); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Clearing last state as part of clean : " + this.lastState); //$NON-NLS-1$ + } clearLastState(); removeProblemsAndTasksFor(this.currentProject); new BatchImageBuilder(this, false, CompilationGroup.MAIN).cleanOutputFolders(false); @@ -323,9 +340,10 @@ protected void clean(IProgressMonitor monitor) throws CoreException { this.notifier.done(); cleanup(); } - if (DEBUG) - System.out.println("JavaBuilder: Finished cleaning " + this.currentProject.getName() //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Finished cleaning " + this.currentProject.getName() //$NON-NLS-1$ + " @ " + new Date(System.currentTimeMillis())); //$NON-NLS-1$ + } } private void createInconsistentBuildMarker(CoreException coreException) throws CoreException { @@ -395,13 +413,15 @@ private SimpleLookupTable findDeltas() { SimpleLookupTable deltas = new SimpleLookupTable(3); if (delta != null) { if (delta.getKind() != IResourceDelta.NO_CHANGE) { - if (DEBUG) - System.out.println("JavaBuilder: Found source delta for: " + this.currentProject.getName()); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Found source delta for: " + this.currentProject.getName()); //$NON-NLS-1$ + } deltas.put(this.currentProject, delta); } } else { - if (DEBUG) - System.out.println("JavaBuilder: Missing delta for: " + this.currentProject.getName()); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Missing delta for: " + this.currentProject.getName()); //$NON-NLS-1$ + } this.notifier.subTask(""); //$NON-NLS-1$ return null; } @@ -430,13 +450,15 @@ private SimpleLookupTable findDeltas() { delta = getDelta(p); if (delta != null) { if (delta.getKind() != IResourceDelta.NO_CHANGE) { - if (DEBUG) - System.out.println("JavaBuilder: Found binary delta for: " + p.getName()); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Found binary delta for: " + p.getName()); //$NON-NLS-1$ + } deltas.put(p, delta); } } else { - if (DEBUG) - System.out.println("JavaBuilder: Missing delta for: " + p.getName()); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Missing delta for: " + p.getName()); //$NON-NLS-1$ + } this.notifier.subTask(""); //$NON-NLS-1$ return null; } @@ -536,7 +558,7 @@ private boolean hasClasspathChanged(CompilationGroup compilationGroup) { } catch (CoreException ignore) { // skip it } if (DEBUG) { - System.out.println("JavaBuilder: New location: " + newSourceLocations[n] + "\n!= old location: " + oldSourceLocations[o]); //$NON-NLS-1$ //$NON-NLS-2$ + trace("JavaBuilder: New location: " + newSourceLocations[n] + "\n!= old location: " + oldSourceLocations[o]); //$NON-NLS-1$ //$NON-NLS-2$ printLocations(newSourceLocations, oldSourceLocations); } return true; @@ -550,7 +572,7 @@ private boolean hasClasspathChanged(CompilationGroup compilationGroup) { } catch (CoreException ignore) { // skip it } if (DEBUG) { - System.out.println("JavaBuilder: Added non-empty source folder"); //$NON-NLS-1$ + trace("JavaBuilder: Added non-empty source folder"); //$NON-NLS-1$ printLocations(newSourceLocations, oldSourceLocations); } return true; @@ -561,7 +583,7 @@ private boolean hasClasspathChanged(CompilationGroup compilationGroup) { continue; } if (DEBUG) { - System.out.println("JavaBuilder: Removed non-empty source folder"); //$NON-NLS-1$ + trace("JavaBuilder: Removed non-empty source folder"); //$NON-NLS-1$ printLocations(newSourceLocations, oldSourceLocations); } return true; @@ -574,14 +596,14 @@ private boolean hasClasspathChanged(CompilationGroup compilationGroup) { for (n = o = 0; n < newLength && o < oldLength; n++, o++) { if (newBinaryLocations[n].equals(oldBinaryLocations[o])) continue; if (DEBUG) { - System.out.println("JavaBuilder: New test location: " + newBinaryLocations[n] + "\n!= old test location: " + oldBinaryLocations[o]); //$NON-NLS-1$ //$NON-NLS-2$ + trace("JavaBuilder: New test location: " + newBinaryLocations[n] + "\n!= old test location: " + oldBinaryLocations[o]); //$NON-NLS-1$ //$NON-NLS-2$ printLocations(newBinaryLocations, oldBinaryLocations); } return true; } if (n < newLength || o < oldLength) { if (DEBUG) { - System.out.println("JavaBuilder: Number of test binary folders/jar files has changed:"); //$NON-NLS-1$ + trace("JavaBuilder: Number of test binary folders/jar files has changed:"); //$NON-NLS-1$ printLocations(newBinaryLocations, oldBinaryLocations); } return true; @@ -695,15 +717,17 @@ private boolean isWorthBuilding() throws CoreException { boolean abortBuilds = JavaCore.ABORT.equals(this.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true)); if (!abortBuilds) { - if (DEBUG) - System.out.println("JavaBuilder: Ignoring invalid classpath"); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Ignoring invalid classpath"); //$NON-NLS-1$ + } return true; } // Abort build only if there are classpath errors if (isClasspathBroken(this.javaProject, true)) { - if (DEBUG) - System.out.println("JavaBuilder: Aborted build because project has classpath errors (incomplete or involved in cycle)"); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Aborted build because project has classpath errors (incomplete or involved in cycle)"); //$NON-NLS-1$ + } removeProblemsAndTasksFor(this.currentProject); // remove all compilation problems @@ -729,20 +753,23 @@ private boolean isWorthBuilding() throws CoreException { // The prereq project has no build state: if this prereq project has a 'warning' cycle marker then allow build (see bug id 23357) JavaProject prereq = (JavaProject) JavaCore.create(p); if (prereq.hasCycleMarker() && JavaCore.WARNING.equals(this.javaProject.getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true))) { - if (DEBUG) - System.out.println("JavaBuilder: Continued to build even though prereq project " + p.getName() //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Continued to build even though prereq project " + p.getName() //$NON-NLS-1$ + " was not built since its part of a cycle"); //$NON-NLS-1$ + } continue; } if (!hasJavaBuilder(p)) { - if (DEBUG) - System.out.println("JavaBuilder: Continued to build even though prereq project " + p.getName() //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Continued to build even though prereq project " + p.getName() //$NON-NLS-1$ + " is not built by JavaBuilder"); //$NON-NLS-1$ + } continue; } - if (DEBUG) - System.out.println("JavaBuilder: Aborted build because prereq project " + p.getName() //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Aborted build because prereq project " + p.getName() //$NON-NLS-1$ + " was not built"); //$NON-NLS-1$ + } removeProblemsAndTasksFor(this.currentProject); // make this the only problem for this project @@ -776,9 +803,10 @@ void mustPropagateStructuralChanges() { if (participantPath != currentPath) { IProject project = this.workspaceRoot.getProject(participantPath.segment(0)); if (hasBeenBuilt(project)) { - if (DEBUG) - System.out.println("JavaBuilder: Requesting another build iteration since cycle participant " + project.getName() //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Requesting another build iteration since cycle participant " + project.getName() //$NON-NLS-1$ + " has not yet seen some structural changes"); //$NON-NLS-1$ + } toRebuild.add(project); } } @@ -789,12 +817,14 @@ void mustPropagateStructuralChanges() { } private void printLocations(ClasspathLocation[] newLocations, ClasspathLocation[] oldLocations) { - System.out.println("JavaBuilder: New locations:"); //$NON-NLS-1$ - for (int i = 0, length = newLocations.length; i < length; i++) - System.out.println(" " + newLocations[i].debugPathString()); //$NON-NLS-1$ - System.out.println("JavaBuilder: Old locations:"); //$NON-NLS-1$ - for (int i = 0, length = oldLocations.length; i < length; i++) - System.out.println(" " + oldLocations[i].debugPathString()); //$NON-NLS-1$ + trace("JavaBuilder: New locations:"); //$NON-NLS-1$ + for (int i = 0, length = newLocations.length; i < length; i++) { + trace(" " + newLocations[i].debugPathString()); //$NON-NLS-1$ + } + trace("JavaBuilder: Old locations:"); //$NON-NLS-1$ + for (int i = 0, length = oldLocations.length; i < length; i++) { + trace(" " + oldLocations[i].debugPathString()); //$NON-NLS-1$ + } } private void recordNewState(State state) { @@ -805,8 +835,9 @@ private void recordNewState(State state) { state.recordStructuralDependency(prereqProject, getLastState(prereqProject)); } - if (DEBUG) - System.out.println("JavaBuilder: Recording new state : " + state); //$NON-NLS-1$ + if (DEBUG) { + trace("JavaBuilder: Recording new state : " + state); //$NON-NLS-1$ + } // state.dump(); JavaModelManager.getJavaModelManager().setLastBuiltState(this.currentProject, state); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ModulePathEntry.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ModulePathEntry.java index f3332ed0b8..13f192ced3 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ModulePathEntry.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ModulePathEntry.java @@ -30,7 +30,7 @@ */ public class ModulePathEntry implements IModulePathEntry { - private IPath path; + private final IPath path; /*private*/ ClasspathLocation[] locations; IModule module; boolean isAutomaticModule; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java index 2540c33bfe..f63661e10b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java @@ -52,7 +52,7 @@ public class NameEnvironment implements IModuleAwareNameEnvironment, SuffixConst SimpleSet initialTypeNames; // assumed that each name is of the form "a/b/ClassName", or, if a module is given: "my.mod:a/b/ClassName" SimpleLookupTable additionalUnits; -private CompilationGroup compilationGroup; +private final CompilationGroup compilationGroup; /** Tasks resulting from add-reads or add-exports classpath attributes. */ ModuleUpdater moduleUpdater; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/State.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/State.java index 45bafca372..90f51571f8 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/State.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/State.java @@ -18,6 +18,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.builder; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -279,19 +281,22 @@ void removeQualifiedTypeName(String qualifiedTypeNameToRemove) { static State read(IProject project, DataInputStream input) throws IOException, CoreException { CompressedReader in = new CompressedReader(input); - if (JavaBuilder.DEBUG) - System.out.println("About to read state " + project.getName()); //$NON-NLS-1$ + if (JavaBuilder.DEBUG) { + trace("About to read state " + project.getName()); //$NON-NLS-1$ + } if (VERSION != in.readByte()) { - if (JavaBuilder.DEBUG) - System.out.println("Found non-compatible state version... answered null for " + project.getName()); //$NON-NLS-1$ + if (JavaBuilder.DEBUG) { + trace("Found non-compatible state version... answered null for " + project.getName()); //$NON-NLS-1$ + } return null; } State newState = new State(); newState.javaProjectName = in.readStringUsingDictionary(); if (!project.getName().equals(newState.javaProjectName)) { - if (JavaBuilder.DEBUG) - System.out.println("Project's name does not match... answered null"); //$NON-NLS-1$ + if (JavaBuilder.DEBUG) { + trace("Project's name does not match... answered null"); //$NON-NLS-1$ + } return null; } newState.buildNumber = in.readInt(); @@ -370,8 +375,9 @@ static State read(IProject project, DataInputStream input) throws IOException, C } newState.references.put(typeLocator, collection); } - if (JavaBuilder.DEBUG) - System.out.println("Successfully read state for " + newState.javaProjectName); //$NON-NLS-1$ + if (JavaBuilder.DEBUG) { + trace("Successfully read state for " + newState.javaProjectName); //$NON-NLS-1$ + } return newState; } @@ -579,8 +585,9 @@ void write(DataOutputStream output) throws IOException { out.writeLong(((Long) valueTable[i]).longValue()); } } - if (JavaBuilder.DEBUG && length != 0) - System.out.println("structuralBuildNumbers table is inconsistent"); //$NON-NLS-1$ + if (JavaBuilder.DEBUG && length != 0) { + trace("structuralBuildNumbers table is inconsistent"); //$NON-NLS-1$ + } } /* @@ -597,8 +604,9 @@ void write(DataOutputStream output) throws IOException { internedTypeLocators.put(key, Integer.valueOf(internedTypeLocators.elementSize)); } } - if (JavaBuilder.DEBUG && length != 0) - System.out.println("references table is inconsistent"); //$NON-NLS-1$ + if (JavaBuilder.DEBUG && length != 0) { + trace("references table is inconsistent"); //$NON-NLS-1$ + } } /* @@ -619,8 +627,9 @@ void write(DataOutputStream output) throws IOException { out.writeIntInRange(index.intValue(), internedTypeLocators.elementSize); } } - if (JavaBuilder.DEBUG && length != 0) - System.out.println("typeLocators table is inconsistent"); //$NON-NLS-1$ + if (JavaBuilder.DEBUG && length != 0) { + trace("typeLocators table is inconsistent"); //$NON-NLS-1$ + } } /* @@ -741,8 +750,9 @@ void write(DataOutputStream output) throws IOException { out.writeIntInRange(index.intValue(), internedRootNames.elementSize); } } - if (JavaBuilder.DEBUG && length != 0) - System.out.println("references table is inconsistent"); //$NON-NLS-1$ + if (JavaBuilder.DEBUG && length != 0) { + trace("references table is inconsistent"); //$NON-NLS-1$ + } } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/WorkQueue.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/WorkQueue.java index a392b0f1c1..c35796559e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/WorkQueue.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/WorkQueue.java @@ -19,8 +19,8 @@ public class WorkQueue { -private Set needsCompileList; -private Set compiledList; +private final Set needsCompileList; +private final Set compiledList; public WorkQueue() { this.needsCompileList = new HashSet<>(); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/RequestorWrapper.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/RequestorWrapper.java index 1c4487c304..5cd2dc22f9 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/RequestorWrapper.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/RequestorWrapper.java @@ -23,6 +23,7 @@ import org.eclipse.jdt.core.compiler.CategorizedProblem; import org.eclipse.jdt.core.eval.ICodeSnippetRequestor; import org.eclipse.jdt.internal.compiler.ClassFile; +import org.eclipse.jdt.internal.core.JavaModelManager; import org.eclipse.jdt.internal.core.builder.JavaBuilder; import org.eclipse.jdt.internal.eval.IRequestor; @@ -72,7 +73,9 @@ public void acceptProblem(CategorizedProblem problem, char[] fragmentSource, int IMarker marker = ResourcesPlugin.getWorkspace().getRoot().createMarker(IJavaModelMarker.TRANSIENT_PROBLEM, attributes); this.requestor.acceptProblem(marker, new String(fragmentSource), fragmentKind); } catch (CoreException e) { - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } } } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/BindingMap.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/BindingMap.java index ff335f36d9..5b46c3c73c 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/BindingMap.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/BindingMap.java @@ -33,9 +33,9 @@ * exhaustive search.) */ public class BindingMap { - private Map identityMap = new IdentityHashMap<>(); + private final Map identityMap = new IdentityHashMap<>(); private Object[] mapIdToValue = new Object[0]; - private Set bindingsWithoutAnId = new HashSet<>(); + private final Set bindingsWithoutAnId = new HashSet<>(); public void put(TypeBinding key, V value) { this.identityMap.put(key, value); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java index a0578b84d1..e21e3a9862 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java @@ -34,13 +34,13 @@ import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants; public class HierarchyBinaryType implements IBinaryType { - private int modifiers; - private char[] sourceName; + private final int modifiers; + private final char[] sourceName; private char[] name; private char[] enclosingTypeName; private char[] superclass; private char[][] superInterfaces = NoInterface; - private char[][] typeParameterSignatures; + private final char[][] typeParameterSignatures; private char[] genericSignature; public HierarchyBinaryType(int modifiers, char[] qualification, char[] sourceName, char[] enclosingTypeName, char[][] typeParameterSignatures, char typeSuffix){ diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBuilder.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBuilder.java index f89f38066b..a237a4ca10 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBuilder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBuilder.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.hierarchy; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.util.HashMap; import java.util.Map; @@ -151,22 +153,21 @@ public void connect( if (typeHandle == null) return; if (TypeHierarchy.DEBUG) { - System.out.println( + trace( "Connecting: " + ((JavaElement) typeHandle).toStringWithAncestors()); //$NON-NLS-1$ - System.out.println( + trace( " to superclass: " //$NON-NLS-1$ + (superclassHandle == null ? "" //$NON-NLS-1$ : ((JavaElement) superclassHandle).toStringWithAncestors())); - System.out.print(" and superinterfaces:"); //$NON-NLS-1$ + trace(" and superinterfaces:"); //$NON-NLS-1$ if (superinterfaceHandles == null || superinterfaceHandles.length == 0) { - System.out.println(" "); //$NON-NLS-1$ + trace(" "); //$NON-NLS-1$ } else { - System.out.println(); + trace(""); //$NON-NLS-1$ for (int i = 0, length = superinterfaceHandles.length; i < length; i++) { if (superinterfaceHandles[i] == null) continue; - System.out.println( - " " + ((JavaElement) superinterfaceHandles[i]).toStringWithAncestors()); //$NON-NLS-1$ + trace(" " + ((JavaElement) superinterfaceHandles[i]).toStringWithAncestors()); //$NON-NLS-1$ } } } @@ -304,7 +305,7 @@ protected IBinaryType createInfoFromClassFile(Openable handle, IResource file) { info = Util.newClassFileReader(file); } catch (org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException | java.io.IOException | CoreException e) { if (TypeHierarchy.DEBUG) { - e.printStackTrace(); + trace("", e); //$NON-NLS-1$ } return null; } @@ -321,7 +322,7 @@ protected IBinaryType createInfoFromClassFileInJar(Openable classFile) { info = BinaryTypeFactory.create(cf, null); } catch (JavaModelException | ClassFormatException e) { if (TypeHierarchy.DEBUG) { - e.printStackTrace(); + trace("", e); //$NON-NLS-1$ } return null; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java index 5ab226928c..83a634ab65 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java @@ -79,7 +79,7 @@ public class HierarchyResolver implements ITypeRequestor { private CompilerOptions options; HierarchyBuilder builder; private ReferenceBinding[] typeBindings; - private BindingMap bindingMap = new BindingMap<>(); + private final BindingMap bindingMap = new BindingMap<>(); private int typeIndex; private IGenericType[] typeModels; @@ -109,8 +109,6 @@ public HierarchyResolver(LookupEnvironment lookupEnvironment, HierarchyBuilder b /** * Add an additional binary type - * @param binaryType - * @param packageBinding */ @Override public void accept(IBinaryType binaryType, PackageBinding packageBinding, AccessRestriction accessRestriction) { @@ -137,7 +135,6 @@ private void sanitizeBinaryType(IGenericType binaryType) { /** * Add an additional compilation unit. - * @param sourceUnit */ @Override public void accept(ICompilationUnit sourceUnit, AccessRestriction accessRestriction) { @@ -169,8 +166,6 @@ private Parser basicParser() { /** * Add additional source types - * @param sourceTypes - * @param packageBinding */ @Override public void accept(ISourceType[] sourceTypes, PackageBinding packageBinding, AccessRestriction accessRestriction) { @@ -625,7 +620,6 @@ private void reset(){ * Resolve the supertypes for the supplied source type. * Inform the requestor of the resolved supertypes using: * connect(ISourceType suppliedType, IGenericType superclass, IGenericType[] superinterfaces) - * @param suppliedType */ public void resolve(IGenericType suppliedType) { try { @@ -687,9 +681,6 @@ public void resolve(IGenericType suppliedType) { * Also inform the requestor of the supertypes of each * additional requested super type which is also a source type * instead of a binary type. - * @param openables - * @param localTypes - * @param monitor */ public void resolve(Openable[] openables, HashSet localTypes, IProgressMonitor monitor) { SubMonitor subMonitor = SubMonitor.convert(monitor, 3); @@ -913,8 +904,9 @@ public void resolve(Openable[] openables, HashSet localTypes, IProgressMonitor m } catch (ClassCastException e){ // work-around for 1GF5W1S - can happen in case duplicates are fed to the hierarchy with binaries hiding sources } catch (AbortCompilation e) { // ignore this exception for now since it typically means we cannot find java.lang.Object - if (TypeHierarchy.DEBUG) - e.printStackTrace(); + if (TypeHierarchy.DEBUG) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } } finally { reset(); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java index f76803abde..731ee90840 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java @@ -473,12 +473,6 @@ public void acceptPath(String path, boolean containsLocalTypes) { * hierarchy. * The match locator is not used here to narrow down the results, the type hierarchy * resolver is rather used to compute the whole hierarchy at once. - * @param type - * @param scope - * @param binariesFromIndexMatches - * @param pathRequestor - * @param waitingPolicy - * @param monitor */ public static void searchAllPossibleSubTypes( IType type, @@ -596,7 +590,7 @@ public boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, job.finished(); if (JobManager.VERBOSE) { long wallClockTime = System.currentTimeMillis() - startTime; - Util.verbose("-> execution time: " + wallClockTime + "ms - " + IndexBasedHierarchyBuilder.class.getSimpleName());//$NON-NLS-1$//$NON-NLS-2$ + JavaModelManager.trace("-> execution time: " + wallClockTime + "ms - " + IndexBasedHierarchyBuilder.class.getSimpleName());//$NON-NLS-1$//$NON-NLS-2$ } } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java index 47de70dbc8..3c14944edb 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.hierarchy; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -54,6 +56,7 @@ import org.eclipse.jdt.internal.core.ClassFile; import org.eclipse.jdt.internal.core.CompilationUnit; import org.eclipse.jdt.internal.core.JavaElement; +import org.eclipse.jdt.internal.core.JavaModelManager; import org.eclipse.jdt.internal.core.JavaModelStatus; import org.eclipse.jdt.internal.core.JavaProject; import org.eclipse.jdt.internal.core.Openable; @@ -375,12 +378,12 @@ public void fireChange() { return; } if (DEBUG) { - System.out.println("FIRING hierarchy change ["+Thread.currentThread()+"]"); //$NON-NLS-1$ //$NON-NLS-2$ + trace("FIRING hierarchy change ["+Thread.currentThread()+"]"); //$NON-NLS-1$ //$NON-NLS-2$ if (this.focusType != null) { - System.out.println(" for hierarchy focused on " + ((JavaElement)this.focusType).toStringWithAncestors()); //$NON-NLS-1$ + trace(" for hierarchy focused on " + ((JavaElement)this.focusType).toStringWithAncestors()); //$NON-NLS-1$ } } - + for (int i= 0; i < listeners.size(); i++) { final ITypeHierarchyChangedListener listener= listeners.get(i); SafeRunner.run(new ISafeRunnable() { @@ -448,8 +451,6 @@ private IType[] getAllSubtypesForType(IType type) { subTypes.toArray(subClasses); return subClasses; } -/** - */ private void getAllSubtypesForType0(IType type, ArrayList subs) { IType[] subTypes = getSubtypesForType(type); if (subTypes.length != 0) { @@ -1041,7 +1042,7 @@ private boolean isAffectedByPackageFragmentRoot(IJavaElementDelta delta, IJavaEl protected boolean isAffectedByOpenable(IJavaElementDelta delta, IJavaElement element, int eventType) { if (element instanceof CompilationUnit) { CompilationUnit cu = (CompilationUnit)element; - ICompilationUnit focusCU = + ICompilationUnit focusCU = this.focusType != null ? this.focusType.getCompilationUnit() : null; if (focusCU != null && focusCU.getOwner() != cu.getOwner()) return false; @@ -1056,8 +1057,9 @@ protected boolean isAffectedByOpenable(IJavaElementDelta delta, IJavaElement ele try { collector.addChange(cu, delta); } catch (JavaModelException e) { - if (DEBUG) - e.printStackTrace(); + if (DEBUG) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } } if (cu.isWorkingCopy() && eventType == ElementChangedEvent.POST_RECONCILE) { // changes to working copies are batched @@ -1307,12 +1309,12 @@ public synchronized void refresh(IProgressMonitor monitor) throws JavaModelExcep if (DEBUG) { start = System.currentTimeMillis(); if (this.computeSubtypes) { - System.out.println("CREATING TYPE HIERARCHY [" + Thread.currentThread() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ + trace("CREATING TYPE HIERARCHY [" + Thread.currentThread() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ } else { - System.out.println("CREATING SUPER TYPE HIERARCHY [" + Thread.currentThread() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ + trace("CREATING SUPER TYPE HIERARCHY [" + Thread.currentThread() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ } if (this.focusType != null) { - System.out.println(" on type " + ((JavaElement)this.focusType).toStringWithAncestors()); //$NON-NLS-1$ + trace(" on type " + ((JavaElement)this.focusType).toStringWithAncestors()); //$NON-NLS-1$ } } @@ -1323,11 +1325,11 @@ public synchronized void refresh(IProgressMonitor monitor) throws JavaModelExcep if (DEBUG) { if (this.computeSubtypes) { - System.out.println("CREATED TYPE HIERARCHY in " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + trace("CREATED TYPE HIERARCHY in " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ } else { - System.out.println("CREATED SUPER TYPE HIERARCHY in " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + trace("CREATED SUPER TYPE HIERARCHY in " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ } - System.out.println(this.toString()); + trace(this.toString()); } } catch (JavaModelException e) { throw e; @@ -1509,7 +1511,7 @@ boolean subtypesIncludeSupertypeOf(IType type) { superclassName = type.getSuperclassName(); } catch (JavaModelException e) { if (DEBUG) { - e.printStackTrace(); + trace("", e); //$NON-NLS-1$ } return false; } @@ -1525,8 +1527,9 @@ boolean subtypesIncludeSupertypeOf(IType type) { try { interfaceNames = type.getSuperInterfaceNames(); } catch (JavaModelException e) { - if (DEBUG) - e.printStackTrace(); + if (DEBUG) { + trace("", e); //$NON-NLS-1$ + } return false; } for (int i = 0, length = interfaceNames.length; i < length; i++) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMBuilder.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMBuilder.java index 3f36e00dd2..c1be6653d8 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMBuilder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMBuilder.java @@ -190,9 +190,6 @@ public IDOMField createField(char[] sourceCode) { this.fNode.normalize(this); return (IDOMField)this.fNode; } -/** - * - */ public IDOMField[] createFields(char[] sourceCode) { initializeBuild(sourceCode, false, false, false); this.fFields= new ArrayList(); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMethod.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMethod.java index c9e972d823..0697c8714f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMethod.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMethod.java @@ -732,8 +732,6 @@ public void setReturnType(String name) throws IllegalArgumentException { protected void setReturnTypeAltered(boolean typeAltered) { setMask(MASK_RETURN_TYPE_ALTERED, typeAltered); } -/** - */ @Override protected void setSourceRangeEnd(int end) { super.setSourceRangeEnd(end); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMNode.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMNode.java index 5950a77cce..dd26b5c959 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMNode.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMNode.java @@ -281,7 +281,6 @@ public void addChild(IDOMNode child) throws IllegalArgumentException, DOMExcepti * using the original document and indicies as a form for the current * attribute values of this node. If this node not fragmented, the * contents can be obtained from the document. - * */ protected void appendContents(CharArrayBuffer buffer) { if (isFragmented()) { @@ -296,7 +295,6 @@ protected void appendContents(CharArrayBuffer buffer) { * *

    This algorithm used minimizes String generation by merging * adjacent unfragmented children into one substring operation. - * */ protected void appendContentsOfChildren(CharArrayBuffer buffer) { DOMNode child= this.fFirstChild; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java index d7f85b6c26..d668f8e48e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java @@ -93,8 +93,6 @@ protected void enterAbstractMethod(MethodInfo methodInfo) { // type parameters not supported by JDOM } -/** - */ @Override public void enterConstructor(MethodInfo methodInfo) { /* see 1FVIIQZ */ @@ -105,8 +103,6 @@ public void enterConstructor(MethodInfo methodInfo) { enterAbstractMethod(methodInfo); } -/** - */ @Override public void enterField(FieldInfo fieldInfo) { @@ -121,9 +117,6 @@ public void enterField(FieldInfo fieldInfo) { addChild(this.fNode); this.fStack.push(this.fNode); } -/** - - */ @Override public void enterInitializer(int declarationSourceStart, int modifiers) { int[] sourceRange = {declarationSourceStart, -1}; @@ -131,14 +124,10 @@ public void enterInitializer(int declarationSourceStart, int modifiers) { addChild(this.fNode); this.fStack.push(this.fNode); } -/** - */ @Override public void enterMethod(MethodInfo methodInfo) { enterAbstractMethod(methodInfo); } -/** - */ @Override public void enterType(TypeInfo typeInfo) { if (this.fBuildingType) { @@ -162,14 +151,10 @@ public void enterType(TypeInfo typeInfo) { public void exitConstructor(int declarationEnd) { exitMember(declarationEnd); } -/** - */ @Override public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd) { exitMember(declarationEnd); } -/** - */ @Override public void exitInitializer(int declarationEnd) { exitMember(declarationEnd); @@ -185,8 +170,6 @@ protected void exitMember(int declarationEnd) { m.setSourceRangeEnd(declarationEnd); this.fNode = m; } -/** - */ @Override public void exitMethod(int declarationEnd, Expression defaultValue) { exitMember(declarationEnd); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ASTNodeFinder.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ASTNodeFinder.java index 5c9e7bfc33..d987fc2afa 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ASTNodeFinder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ASTNodeFinder.java @@ -31,7 +31,7 @@ * Finds an ASTNode given an IJavaElement in a CompilationUnitDeclaration */ public class ASTNodeFinder { - private CompilationUnitDeclaration unit; + private final CompilationUnitDeclaration unit; public ASTNodeFinder(CompilationUnitDeclaration unit) { this.unit = unit; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Annotation.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Annotation.java index 46bc001f25..987a3d1bb9 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Annotation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Annotation.java @@ -27,19 +27,14 @@ public class Annotation extends ClassFileStruct implements IAnnotation { private static final IAnnotationComponent[] NO_ENTRIES = new IAnnotationComponent[0]; - private int typeIndex; + private final int typeIndex; private char[] typeName; - private int componentsNumber; + private final int componentsNumber; private IAnnotationComponent[] components; private int readOffset; /** * Constructor for Annotation. - * - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public Annotation( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnnotationComponent.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnnotationComponent.java index f0ae8a8696..5aec652474 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnnotationComponent.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnnotationComponent.java @@ -25,9 +25,9 @@ */ public class AnnotationComponent extends ClassFileStruct implements IAnnotationComponent { - private int componentNameIndex; + private final int componentNameIndex; private char[] componentName; - private IAnnotationComponentValue componentValue; + private final IAnnotationComponentValue componentValue; private int readOffset; public AnnotationComponent( diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnnotationComponentValue.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnnotationComponentValue.java index 89d744eae9..7d179156a1 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnnotationComponentValue.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnnotationComponentValue.java @@ -38,7 +38,7 @@ public class AnnotationComponentValue extends ClassFileStruct implements IAnnota private char[] enumConstantName; private int readOffset; - private int tag; + private final int tag; private int valuesNumber; public AnnotationComponentValue( diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnnotationDefaultAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnnotationDefaultAttribute.java index 11a10c109a..9dbb4f16be 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnnotationDefaultAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnnotationDefaultAttribute.java @@ -27,14 +27,10 @@ public class AnnotationDefaultAttribute extends ClassFileAttribute implements IAnnotationDefaultAttribute { - private IAnnotationComponentValue memberValue; + private final IAnnotationComponentValue memberValue; /** * Constructor for AnnotationDefaultAttribute. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public AnnotationDefaultAttribute( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java index 9ec9edb4f5..b79e2771b0 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java @@ -65,7 +65,7 @@ public class BindingKeyResolver extends BindingKeyParser { private static final class SyntheticLocalVariableBinding extends LocalVariableBinding { private final MethodBinding enclosingMethod; - private int paramPosition; + private final int paramPosition; private char[] key; SyntheticLocalVariableBinding(char[] name, TypeBinding type, MethodBinding enclosingMethod, int paramPosition) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BootstrapMethodsAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BootstrapMethodsAttribute.java index 6c60e6040e..477a482c84 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BootstrapMethodsAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BootstrapMethodsAttribute.java @@ -25,14 +25,10 @@ public class BootstrapMethodsAttribute extends ClassFileAttribute implements IBo private static final IBootstrapMethodsEntry[] NO_ENTRIES = new IBootstrapMethodsEntry[0]; private IBootstrapMethodsEntry[] entries; - private int numberOfBootstrapMethods; + private final int numberOfBootstrapMethods; /** * Constructor for BootstrapMethodsAttribute. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public BootstrapMethodsAttribute( byte[] classFileBytes, @@ -47,7 +43,7 @@ public BootstrapMethodsAttribute( BootstrapMethodsEntry entry; for (int i = 0; i < length; i++) { this.entries[i] = entry = new BootstrapMethodsEntry(classFileBytes, constantPool, offset + readOffset); - readOffset += 4 + 2 * entry.getBootstrapArguments().length; + readOffset += 4 + 2 * entry.getBootstrapArguments().length; } } else { this.entries = NO_ENTRIES; @@ -61,7 +57,7 @@ public BootstrapMethodsAttribute( public IBootstrapMethodsEntry[] getBootstrapMethods() { return this.entries; } - + @Override public int getBootstrapMethodsLength() { return this.numberOfBootstrapMethods; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BootstrapMethodsEntry.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BootstrapMethodsEntry.java index abce7e7862..fe6cff118c 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BootstrapMethodsEntry.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BootstrapMethodsEntry.java @@ -24,8 +24,8 @@ public class BootstrapMethodsEntry extends ClassFileStruct implements IBootstrapMethodsEntry { - private int bootstrapMethodReference; - private int[] bootstrapArguments; + private final int bootstrapMethodReference; + private final int[] bootstrapArguments; public BootstrapMethodsEntry(byte classFileBytes[], IConstantPool constantPool, int offset) throws ClassFormatException { this.bootstrapMethodReference = u2At(classFileBytes, 0, offset); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileAttribute.java index 908f28562d..1939ed9d93 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileAttribute.java @@ -24,9 +24,9 @@ */ public class ClassFileAttribute extends ClassFileStruct implements IClassFileAttribute { public static final IClassFileAttribute[] NO_ATTRIBUTES = new IClassFileAttribute[0]; - private long attributeLength; - private int attributeNameIndex; - private char[] attributeName; + private final long attributeLength; + private final int attributeNameIndex; + private final char[] attributeName; public ClassFileAttribute(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException { this.attributeNameIndex = u2At(classFileBytes, 0, offset); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileReader.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileReader.java index 1e4092af0e..2e3c0c4996 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileReader.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileReader.java @@ -34,6 +34,7 @@ import org.eclipse.jdt.core.util.IRecordAttribute; import org.eclipse.jdt.core.util.ISourceAttribute; import org.eclipse.jdt.internal.compiler.util.Util; +import org.eclipse.jdt.internal.core.JavaModelManager; public class ClassFileReader extends ClassFileStruct implements IClassFileReader { private static final IFieldInfo[] NO_FIELD_INFOS = new IFieldInfo[0]; @@ -337,7 +338,9 @@ public ClassFileReader(byte[] classFileBytes, int decodingFlags) throws ClassFor } catch(ClassFormatException e) { throw e; } catch (Exception e) { - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } throw new ClassFormatException(ClassFormatException.ERROR_TRUNCATED_INPUT); } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CodeAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CodeAttribute.java index e6a980c085..f3deb4f3dd 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CodeAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CodeAttribute.java @@ -34,18 +34,18 @@ public class CodeAttribute extends ClassFileAttribute implements ICodeAttribute { private static final IExceptionTableEntry[] NO_EXCEPTION_TABLE = new IExceptionTableEntry[0]; private IClassFileAttribute[] attributes; - private int attributesCount; + private final int attributesCount; private byte[] bytecodes; - private byte[] classFileBytes; - private long codeLength; - private int codeOffset; - private IConstantPool constantPool; + private final byte[] classFileBytes; + private final long codeLength; + private final int codeOffset; + private final IConstantPool constantPool; private IExceptionTableEntry[] exceptionTableEntries; - private int exceptionTableLength; + private final int exceptionTableLength; private ILineNumberAttribute lineNumberAttribute; private ILocalVariableAttribute localVariableAttribute; - private int maxLocals; - private int maxStack; + private final int maxLocals; + private final int maxStack; CodeAttribute(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException { super(classFileBytes, constantPool, offset); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java index 899faeb1c3..83512efcff 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java @@ -37,10 +37,6 @@ public class CommentRecorderParser extends Parser { int commentPtr = -1; // no comment test with commentPtr value -1 protected final static int CommentIncrement = 100; - /** - * @param problemReporter - * @param optimizeStringLiterals - */ public CommentRecorderParser(ProblemReporter problemReporter, boolean optimizeStringLiterals) { super(problemReporter, optimizeStringLiterals); } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ComponentInfo.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ComponentInfo.java index 756d34971f..a38f8024c8 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ComponentInfo.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ComponentInfo.java @@ -24,13 +24,13 @@ * Default implementation of IComponentInfo. */ public class ComponentInfo extends ClassFileStruct implements IComponentInfo { - private int attributeBytes; + private final int attributeBytes; private IClassFileAttribute[] attributes; - private int attributesCount; - private char[] descriptor; - private int descriptorIndex; - private char[] name; - private int nameIndex; + private final int attributesCount; + private final char[] descriptor; + private final int descriptorIndex; + private final char[] name; + private final int nameIndex; /** * @param classFileBytes byte[] @@ -136,4 +136,4 @@ public int getNameIndex() { public int sizeInBytes() { return this.attributeBytes; } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantPool.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantPool.java index 6e8a244acf..65ca208070 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantPool.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantPool.java @@ -22,9 +22,9 @@ */ public class ConstantPool extends ClassFileStruct implements IConstantPool { - private int constantPoolCount; - private int[] constantPoolOffset; - private byte[] classFileBytes; + private final int constantPoolCount; + private final int[] constantPoolOffset; + private final byte[] classFileBytes; ConstantPool(byte[] reference, int[] constantPoolOffset) { this.constantPoolCount = constantPoolOffset.length; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantValueAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantValueAttribute.java index ba83a203b8..b8034c21b9 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantValueAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantValueAttribute.java @@ -25,8 +25,8 @@ public class ConstantValueAttribute extends ClassFileAttribute implements IConstantValueAttribute { - private int constantValueIndex; - private IConstantPoolEntry constantPoolEntry; + private final int constantValueIndex; + private final IConstantPoolEntry constantPoolEntry; ConstantValueAttribute(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DOMFinder.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DOMFinder.java index 28253e4e90..250860f4e0 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DOMFinder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DOMFinder.java @@ -56,9 +56,9 @@ public class DOMFinder extends ASTVisitor { public ASTNode foundNode = null; public IBinding foundBinding = null; - private CompilationUnit ast; - private SourceRefElement element; - private boolean resolveBinding; + private final CompilationUnit ast; + private final SourceRefElement element; + private final boolean resolveBinding; private int rangeStart = -1, rangeLength = 0; public DOMFinder(CompilationUnit ast, SourceRefElement element, boolean resolveBinding) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DefaultBytecodeVisitor.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DefaultBytecodeVisitor.java index f8ff04aca9..9516889a9d 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DefaultBytecodeVisitor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DefaultBytecodeVisitor.java @@ -41,15 +41,15 @@ public class DefaultBytecodeVisitor implements IBytecodeVisitor { private static final int T_INT = 10; private static final int T_LONG = 11; - private StringBuffer buffer; - private String lineSeparator; - private int tabNumber; - private int digitNumberForPC; + private final StringBuffer buffer; + private final String lineSeparator; + private final int tabNumber; + private final int digitNumberForPC; private ILocalVariableTableEntry[] localVariableTableEntries; - private int localVariableAttributeLength; - private int mode; - private char[][] parameterNames; - private boolean isStatic; + private final int localVariableAttributeLength; + private final int mode; + private final char[][] parameterNames; + private final boolean isStatic; private int[] argumentSizes; public DefaultBytecodeVisitor(ICodeAttribute codeAttribute, char[][] parameterNames, char[] methodDescriptor, boolean isStatic, StringBuffer buffer, String lineSeparator, int tabNumber, int mode) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DefaultStackMapFrame.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DefaultStackMapFrame.java index 0df39fd019..8465926f2f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DefaultStackMapFrame.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DefaultStackMapFrame.java @@ -25,19 +25,14 @@ public class DefaultStackMapFrame extends ClassFileStruct implements IStackMapFr private static final IVerificationTypeInfo[] EMPTY_LOCALS_OR_STACK_ITEMS = new IVerificationTypeInfo[0]; private int readOffset; - private int numberOfLocals; - private int numberOfStackItems; + private final int numberOfLocals; + private final int numberOfStackItems; private IVerificationTypeInfo[] locals; private IVerificationTypeInfo[] stackItems; - private int offsetDelta; + private final int offsetDelta; /** * Constructor for StackMapFrame. - * - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public DefaultStackMapFrame( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/EnclosingMethodAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/EnclosingMethodAttribute.java index ccfc7e2af4..79c5c10ee4 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/EnclosingMethodAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/EnclosingMethodAttribute.java @@ -26,13 +26,13 @@ */ public class EnclosingMethodAttribute extends ClassFileAttribute implements IEnclosingMethodAttribute { - private int enclosingClassIndex; - private char[] enclosingClassName; + private final int enclosingClassIndex; + private final char[] enclosingClassName; private int methodDescriptorIndex; private char[] methodDescriptor; private int methodNameIndex; private char[] methodName; - private int methodNameAndTypeIndex; + private final int methodNameAndTypeIndex; EnclosingMethodAttribute(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException { super(classFileBytes, constantPool, offset); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionAttribute.java index d89209d90c..2069276510 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionAttribute.java @@ -24,7 +24,7 @@ * Default implementation of IExceptionAttribute. */ public class ExceptionAttribute extends ClassFileAttribute implements IExceptionAttribute { - private int exceptionsNumber; + private final int exceptionsNumber; private char[][] exceptionNames; private int[] exceptionIndexes; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionTableEntry.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionTableEntry.java index 329048479f..2a7afd1199 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionTableEntry.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionTableEntry.java @@ -27,10 +27,10 @@ public class ExceptionTableEntry extends ClassFileStruct implements IExceptionTableEntry { - private int startPC; - private int endPC; - private int handlerPC; - private int catchTypeIndex; + private final int startPC; + private final int endPC; + private final int handlerPC; + private final int catchTypeIndex; private char[] catchType; ExceptionTableEntry(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExtendedAnnotation.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExtendedAnnotation.java index 078f80ed67..a76e420614 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExtendedAnnotation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExtendedAnnotation.java @@ -61,13 +61,13 @@ public class ExtendedAnnotation extends ClassFileStruct implements IExtendedAnno private final static int[][] NO_TYPEPATH = new int[0][0]; private final static ILocalVariableReferenceInfo[] NO_LOCAL_VARIABLE_TABLE_ENTRIES = new ILocalVariableReferenceInfo[0]; - private int targetType; + private final int targetType; private int annotationTypeIndex; private int[][] typePath; - private int typeIndex; + private final int typeIndex; private char[] typeName; - private int componentsNumber; + private final int componentsNumber; private IAnnotationComponent[] components; private int readOffset; private int offset; @@ -76,14 +76,9 @@ public class ExtendedAnnotation extends ClassFileStruct implements IExtendedAnno private int parameterIndex; private int exceptionTableIndex; private ILocalVariableReferenceInfo[] localVariableTable = NO_LOCAL_VARIABLE_TABLE_ENTRIES; - + /** * Constructor for ExtendedAnnotation, builds an annotation from the supplied bytestream. - * - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public ExtendedAnnotation( byte[] classFileBytes, @@ -94,7 +89,7 @@ public ExtendedAnnotation( int index = u1At(classFileBytes,0,offset); this.targetType = index; this.readOffset = 1; - + readTargetInfo(index, classFileBytes, constantPool, offset); // Read type_path @@ -111,7 +106,7 @@ public ExtendedAnnotation( typePathEntry[1] = u1At(classFileBytes, this.readOffset++, offset); } } - + // Read annotation index = u2At(classFileBytes, this.readOffset, offset); this.typeIndex = index; @@ -142,7 +137,7 @@ public ExtendedAnnotation( this.annotationTypeIndex = -1; } } - + private void readTargetInfo( int localTargetType, byte[] classFileBytes, @@ -167,24 +162,24 @@ private void readTargetInfo( this.typeParameterBoundIndex = u1At(classFileBytes, this.readOffset, localOffset); this.readOffset++; break; - + case IExtendedAnnotationConstants.FIELD : case IExtendedAnnotationConstants.METHOD_RETURN : case IExtendedAnnotationConstants.METHOD_RECEIVER : // nothing to do, target_info is empty_target break; - + case IExtendedAnnotationConstants.METHOD_FORMAL_PARAMETER : this.parameterIndex = u1At(classFileBytes, this.readOffset, localOffset); this.readOffset++; break; - + case IExtendedAnnotationConstants.THROWS : this.annotationTypeIndex = u2At(classFileBytes, this.readOffset, localOffset); this.readOffset+=2; break; - + case IExtendedAnnotationConstants.LOCAL_VARIABLE : case IExtendedAnnotationConstants.RESOURCE_VARIABLE : int tableLength = u2At(classFileBytes, this.readOffset, localOffset); @@ -207,11 +202,11 @@ private void readTargetInfo( case IExtendedAnnotationConstants.CONSTRUCTOR_REFERENCE : this.offset = u2At(classFileBytes, this.readOffset, localOffset); this.readOffset += 2; - break; + break; case IExtendedAnnotationConstants.CAST : this.offset = u2At(classFileBytes, this.readOffset, localOffset); - this.readOffset += 2; + this.readOffset += 2; // read type_argument_index this.annotationTypeIndex = u1At(classFileBytes, this.readOffset, localOffset); this.readOffset++; @@ -258,7 +253,7 @@ public char[] getTypeName() { public int getTargetType() { return this.targetType; } - + @Override public int getExceptionTableIndex() { return this.exceptionTableIndex; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/FieldInfo.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/FieldInfo.java index 15622a2394..003b3a9387 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/FieldInfo.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/FieldInfo.java @@ -29,17 +29,17 @@ * Default implementation of IFieldInfo. */ public class FieldInfo extends ClassFileStruct implements IFieldInfo { - private int accessFlags; - private int attributeBytes; + private final int accessFlags; + private final int attributeBytes; private IClassFileAttribute[] attributes; - private int attributesCount; + private final int attributesCount; private IConstantValueAttribute constantValueAttribute; - private char[] descriptor; - private int descriptorIndex; + private final char[] descriptor; + private final int descriptorIndex; private boolean isDeprecated; private boolean isSynthetic; - private char[] name; - private int nameIndex; + private final char[] name; + private final int nameIndex; /** * @param classFileBytes byte[] diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/HandleFactory.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/HandleFactory.java index 0874ed606a..3b42afb852 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/HandleFactory.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/HandleFactory.java @@ -63,9 +63,9 @@ public class HandleFactory { */ private HashtableOfArrayToObject packageHandles; - private JavaModel javaModel; + private final JavaModel javaModel; - private HashtableOfObjectToInt localOccurrenceCounts = new HashtableOfObjectToInt(5); + private final HashtableOfObjectToInt localOccurrenceCounts = new HashtableOfObjectToInt(5); public HandleFactory() { this.javaModel = JavaModelManager.getJavaModelManager().getJavaModel(); @@ -104,7 +104,7 @@ public Openable createOpenable(String resourcePath, IJavaSearchScope scope) { String module = null; String rootPath = this.lastPkgFragmentRoot.getPath().toOSString(); if (org.eclipse.jdt.internal.compiler.util.Util.isJrt(rootPath)) { - module = resourcePath.substring(separatorIndex + 1, + module = resourcePath.substring(separatorIndex + 1, (separatorIndex = resourcePath.lastIndexOf(IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR))); } String classFilePath= resourcePath.substring(separatorIndex + 1); @@ -240,7 +240,7 @@ public IJavaElement createElement(Scope scope, int elementPosition, ICompilation if (scope.isLambdaScope()) { parentElement = createElement(scope.parent, elementPosition, unit, existingElements, knownScopes); LambdaExpression expression = (LambdaExpression) scope.originalReferenceContext(); - if (expression.resolvedType != null && expression.resolvedType.isValidBinding() && + if (expression.resolvedType != null && expression.resolvedType.isValidBinding() && !(expression.descriptor instanceof ProblemMethodBinding)) { // chain in lambda element only if resolved properly. //newElement = new org.eclipse.jdt.internal.core.SourceLambdaExpression((JavaElement) parentElement, expression).getMethod(); newElement = LambdaFactory.createLambdaExpression((JavaElement) parentElement, expression).getMethod(); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttribute.java index 60910b57ab..aac388d928 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttribute.java @@ -24,14 +24,10 @@ public class InnerClassesAttribute extends ClassFileAttribute implements IInnerClassesAttribute { private static final IInnerClassesAttributeEntry[] NO_ENTRIES = new IInnerClassesAttributeEntry[0]; - private int numberOfClasses; + private final int numberOfClasses; private IInnerClassesAttributeEntry[] entries; /** * Constructor for InnerClassesAttribute. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public InnerClassesAttribute( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttributeEntry.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttributeEntry.java index bc4f245712..3d71d1c90a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttributeEntry.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttributeEntry.java @@ -26,13 +26,13 @@ public class InnerClassesAttributeEntry extends ClassFileStruct implements IInnerClassesAttributeEntry { - private int innerClassNameIndex; - private int outerClassNameIndex; - private int innerNameIndex; + private final int innerClassNameIndex; + private final int outerClassNameIndex; + private final int innerNameIndex; private char[] innerClassName; private char[] outerClassName; private char[] innerName; - private int accessFlags; + private final int accessFlags; public InnerClassesAttributeEntry(byte classFileBytes[], IConstantPool constantPool, int offset) throws ClassFormatException { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/JavaElementFinder.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/JavaElementFinder.java index 61db0f9f71..6866a49e56 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/JavaElementFinder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/JavaElementFinder.java @@ -33,11 +33,11 @@ @SuppressWarnings({"rawtypes", "unchecked"}) public class JavaElementFinder extends BindingKeyParser { - private JavaProject project; - private WorkingCopyOwner owner; + private final JavaProject project; + private final WorkingCopyOwner owner; public IJavaElement element; public JavaModelException exception; - private ArrayList types = new ArrayList(); + private final ArrayList types = new ArrayList(); public JavaElementFinder(String key, JavaProject project, WorkingCopyOwner owner) { super(key); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/KeyToSignature.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/KeyToSignature.java index 1e1a239b1d..d83a9e7942 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/KeyToSignature.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/KeyToSignature.java @@ -35,7 +35,7 @@ public class KeyToSignature extends BindingKeyParser { public static final int THROWN_EXCEPTIONS = 3; public StringBuffer signature = new StringBuffer(); - private int kind; + private final int kind; private boolean asBinarySignature = false; // '.' vs. '/' and '$' private ArrayList arguments = new ArrayList(); private ArrayList typeArguments = new ArrayList(); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LineNumberAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LineNumberAttribute.java index 2486563596..bccbcca565 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LineNumberAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LineNumberAttribute.java @@ -25,15 +25,11 @@ public class LineNumberAttribute implements ILineNumberAttribute { private static final int[][] NO_ENTRIES = new int[0][0]; - private int lineNumberTableLength; + private final int lineNumberTableLength; private int[][] lineNumberTable; /** * Constructor for LineNumberAttribute. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public LineNumberAttribute( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableAttribute.java index 9e584f38cc..797fdd15bb 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableAttribute.java @@ -26,15 +26,11 @@ public class LocalVariableAttribute implements ILocalVariableAttribute { private static final ILocalVariableTableEntry[] NO_ENTRIES = new ILocalVariableTableEntry[0]; - private int localVariableTableLength; + private final int localVariableTableLength; private ILocalVariableTableEntry[] localVariableTable; /** * Constructor for LocalVariableAttribute. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public LocalVariableAttribute( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableReferenceInfo.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableReferenceInfo.java index 698979133c..85c9919884 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableReferenceInfo.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableReferenceInfo.java @@ -22,17 +22,12 @@ public class LocalVariableReferenceInfo extends ClassFileStruct implements ILocalVariableReferenceInfo { - private int startPC; - private int length; - private int index; + private final int startPC; + private final int length; + private final int index; /** * Constructor for LocalVariableTableEntry. - * - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public LocalVariableReferenceInfo( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTableEntry.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTableEntry.java index dbc2221eec..538e6b31ac 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTableEntry.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTableEntry.java @@ -24,21 +24,16 @@ */ public class LocalVariableTableEntry extends ClassFileStruct implements ILocalVariableTableEntry { - private int startPC; - private int length; - private int nameIndex; - private int descriptorIndex; - private char[] name; - private char[] descriptor; - private int index; + private final int startPC; + private final int length; + private final int nameIndex; + private final int descriptorIndex; + private final char[] name; + private final char[] descriptor; + private final int index; /** * Constructor for LocalVariableTableEntry. - * - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public LocalVariableTableEntry( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTypeAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTypeAttribute.java index 79709476e7..8d55472c77 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTypeAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTypeAttribute.java @@ -26,15 +26,11 @@ public class LocalVariableTypeAttribute implements ILocalVariableTypeTableAttribute { private static final ILocalVariableTypeTableEntry[] NO_ENTRIES = new ILocalVariableTypeTableEntry[0]; - private int localVariableTypeTableLength; + private final int localVariableTypeTableLength; private ILocalVariableTypeTableEntry[] localVariableTypeTableEntries; /** * Constructor for LocalVariableTypeAttribute. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public LocalVariableTypeAttribute( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTypeTableEntry.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTypeTableEntry.java index 4c66744dc9..638ab12572 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTypeTableEntry.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTypeTableEntry.java @@ -24,21 +24,16 @@ */ public class LocalVariableTypeTableEntry extends ClassFileStruct implements ILocalVariableTypeTableEntry { - private int startPC; - private int length; - private int nameIndex; - private int signatureIndex; - private char[] name; - private char[] signature; - private int index; + private final int startPC; + private final int length; + private final int nameIndex; + private final int signatureIndex; + private final char[] name; + private final char[] signature; + private final int index; /** * Constructor for LocalVariableTypeTableEntry. - * - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public LocalVariableTypeTableEntry( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MethodInfo.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MethodInfo.java index 7d568e590d..2c9268e65f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MethodInfo.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MethodInfo.java @@ -33,18 +33,18 @@ * Default implementation of IMethodInfo. */ public class MethodInfo extends ClassFileStruct implements IMethodInfo { - private int accessFlags; - private int attributeBytes; + private final int accessFlags; + private final int attributeBytes; private IClassFileAttribute[] attributes; - private int attributesCount; + private final int attributesCount; private ICodeAttribute codeAttribute; - private char[] descriptor; - private int descriptorIndex; + private final char[] descriptor; + private final int descriptorIndex; private IExceptionAttribute exceptionAttribute; private boolean isDeprecated; private boolean isSynthetic; - private char[] name; - private int nameIndex; + private final char[] name; + private final int nameIndex; /** * @param classFileBytes byte[] diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ModuleAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ModuleAttribute.java index 215a2593dd..aac119d03c 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ModuleAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ModuleAttribute.java @@ -33,21 +33,21 @@ public class ModuleAttribute extends ClassFileAttribute implements IModuleAttrib static final IPackageVisibilityInfo[] NO_PACKAGE_VISIBILITY_INFOS = new IPackageVisibilityInfo[0]; static final int[] NO_USES = new int[0]; static final IProvidesInfo[] NO_PROVIDES_INFOS = new IProvidesInfo[0]; - private int moduleNameIndex; - private char[] moduleName; - private int moduleFlags; - private int moduleVersionIndex; + private final int moduleNameIndex; + private final char[] moduleName; + private final int moduleFlags; + private final int moduleVersionIndex; private char[] moduleVersionValue; - private int requiresCount; + private final int requiresCount; private IRequiresInfo[] requiresInfo; - private int exportsCount; + private final int exportsCount; private IPackageVisibilityInfo[] exportsInfo; - private int opensCount; + private final int opensCount; private IPackageVisibilityInfo[] opensInfo; - private int usesCount; + private final int usesCount; private int[] usesIndices; private char[][] usesNames; - private int providesCount; + private final int providesCount; private IProvidesInfo[] providesInfo; ModuleAttribute(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ModuleMainClassAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ModuleMainClassAttribute.java index 968e7c9aeb..45db1061e4 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ModuleMainClassAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ModuleMainClassAttribute.java @@ -29,10 +29,6 @@ public class ModuleMainClassAttribute extends ClassFileAttribute implements IMod /** * Constructor for ModuleMainClassAttribute. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public ModuleMainClassAttribute( byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException { super(classFileBytes, constantPool, offset); @@ -54,4 +50,4 @@ public int getMainClassIndex() { public char[] getMainClassName() { return this.mainClassName; } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ModulePackagesAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ModulePackagesAttribute.java index c2641d05ec..12b05875b7 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ModulePackagesAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ModulePackagesAttribute.java @@ -26,16 +26,12 @@ */ public class ModulePackagesAttribute extends ClassFileAttribute implements IModulePackagesAttribute { - private int packagesCount; + private final int packagesCount; private int[] packageIndices; private char[][] packageNames; /** * Constructor for ModulePackagesAttribute. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public ModulePackagesAttribute( byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException { super(classFileBytes, constantPool, offset); @@ -76,4 +72,4 @@ public int[] getPackageIndices() { public char[][] getPackageNames() { return this.packageNames; } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/NestHostAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/NestHostAttribute.java index 864b0e9743..47eec1bb58 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/NestHostAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/NestHostAttribute.java @@ -18,8 +18,8 @@ public class NestHostAttribute extends ClassFileAttribute implements INestHostAttribute { - private int hostIndex; - private char[] hostName; + private final int hostIndex; + private final char[] hostName; public NestHostAttribute(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException { @@ -46,4 +46,4 @@ public int getNestHostIndex() { public String toString() { return new String(this.hostName); } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/NestMembersAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/NestMembersAttribute.java index 020187c6a6..c7ad7ccb21 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/NestMembersAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/NestMembersAttribute.java @@ -21,15 +21,11 @@ public class NestMembersAttribute extends ClassFileAttribute implements INestMembersAttribute { private static final INestMemberAttributeEntry[] NO_ENTRIES = new INestMemberAttributeEntry[0]; - private int nestMembers; + private final int nestMembers; private INestMemberAttributeEntry[] entries; /** * Constructor for NestMembersAttribute. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public NestMembersAttribute( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/NestMembersAttributeEntry.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/NestMembersAttributeEntry.java index 5456c78f8c..61888edfcd 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/NestMembersAttributeEntry.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/NestMembersAttributeEntry.java @@ -18,7 +18,7 @@ public class NestMembersAttributeEntry extends ClassFileStruct implements INestMemberAttributeEntry { - private int memberClassNameIndex; + private final int memberClassNameIndex; private char[] memberClassName; public NestMembersAttributeEntry(byte[] classFileBytes, IConstantPool constantPool, int offset) @@ -43,7 +43,7 @@ public char[] getNestMemberName() { public int getNestMemberIndex() { return this.memberClassNameIndex; } - + @Override public String toString() { return new String(this.memberClassName); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PackageVisibilityInfo.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PackageVisibilityInfo.java index 1eeb364d06..25f5c793c7 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PackageVisibilityInfo.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PackageVisibilityInfo.java @@ -23,10 +23,10 @@ public class PackageVisibilityInfo extends ClassFileStruct implements IPackageVisibilityInfo { - private int index; - private char[] packageName; - private int flags; - private int targetsCount; + private final int index; + private final char[] packageName; + private final int flags; + private final int targetsCount; private int[] targetModuleIndices; private char[][] targetModuleNames; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ParameterAnnotation.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ParameterAnnotation.java index 42b2057b83..3887607b76 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ParameterAnnotation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ParameterAnnotation.java @@ -25,17 +25,12 @@ public class ParameterAnnotation extends ClassFileStruct implements IParameterAn private static final IAnnotation[] NO_ENTRIES = new IAnnotation[0]; - private int annotationsNumber; + private final int annotationsNumber; private IAnnotation[] annotations; private int readOffset; /** * Constructor for Annotation. - * - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public ParameterAnnotation( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PermittedSubclassesAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PermittedSubclassesAttribute.java index 7b19f861cd..77985d2b92 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PermittedSubclassesAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PermittedSubclassesAttribute.java @@ -24,15 +24,11 @@ public class PermittedSubclassesAttribute extends ClassFileAttribute implements IPermittedSubclassesAttribute { private static final IPermittedSubclassesAttributeEntry[] NO_ENTRIES = new IPermittedSubclassesAttributeEntry[0]; - private int permittedSubclasses; + private final int permittedSubclasses; private IPermittedSubclassesAttributeEntry[] entries; /** * Constructor for PermittedSubclassesAttribute. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public PermittedSubclassesAttribute( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PermittedSubclassesAttributeEntry.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PermittedSubclassesAttributeEntry.java index bb33b4b2ae..4e51fa2421 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PermittedSubclassesAttributeEntry.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PermittedSubclassesAttributeEntry.java @@ -21,7 +21,7 @@ public class PermittedSubclassesAttributeEntry extends ClassFileStruct implements IPermittedSubclassesAttributeEntry { - private int permittedClassNameIndex; + private final int permittedClassNameIndex; private char[] permittedClassName; public PermittedSubclassesAttributeEntry(byte[] classFileBytes, IConstantPool constantPool, int offset) diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ProvidesInfo.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ProvidesInfo.java index f8af74dee4..4c56332946 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ProvidesInfo.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ProvidesInfo.java @@ -20,9 +20,9 @@ import org.eclipse.jdt.core.util.IProvidesInfo; public class ProvidesInfo extends ClassFileStruct implements IProvidesInfo { - private int index; - private char[] serviceName; - private int implementationsCount; + private final int index; + private final char[] serviceName; + private final int implementationsCount; private int[] implementationIndices; private char[][] implementationNames; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java index 1b3e3ba2a0..dfc4c5b8bd 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java @@ -267,7 +267,7 @@ private int translateTokenToTerminalSymbol(int nextToken) throws InvalidInputExc case TerminalTokens.TokenNamewhile : nextToken = ITerminalSymbols.TokenNamewhile; break; case TerminalTokens.TokenNameRestrictedIdentifierWhen : nextToken = ITerminalSymbols.TokenNameRestrictedIdentifierWhen; break; default: - throw new InvalidInputException("Unknown token (check Scanner/TerminalTokens): " + nextToken); //$NON-NLS-1$ + throw Scanner.invalidToken(nextToken); } return nextToken; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RecordAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RecordAttribute.java index df638107a0..dff2c7aa3f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RecordAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RecordAttribute.java @@ -23,7 +23,7 @@ public class RecordAttribute extends ClassFileAttribute implements IRecordAttribute { private static final IComponentInfo[] NO_ENTRIES = new IComponentInfo[0]; - private int nComponents; + private final int nComponents; private IComponentInfo[] entries; public RecordAttribute( diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RequiresInfo.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RequiresInfo.java index 118a42ba8a..88bddb48f6 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RequiresInfo.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RequiresInfo.java @@ -23,10 +23,10 @@ public class RequiresInfo extends ClassFileStruct implements IRequiresInfo { - private int index; - private char[] moduleName; - private int flags; - private int versionIndex; + private final int index; + private final char[] moduleName; + private final int flags; + private final int versionIndex; private char[] versionName; public RequiresInfo(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException{ diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ResourceCompilationUnit.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ResourceCompilationUnit.java index 579ab6a4ca..d1ab950667 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ResourceCompilationUnit.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ResourceCompilationUnit.java @@ -23,11 +23,11 @@ */ public class ResourceCompilationUnit implements ICompilationUnit { - private IFile file; + private final IFile file; private char[] contents; - private char[] fileName; - private char[] mainTypeName; - private char[] module; + private final char[] fileName; + private final char[] mainTypeName; + private final char[] module; public ResourceCompilationUnit(IFile file, char[] mod) { this.file = file; this.module = mod; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeInvisibleAnnotationsAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeInvisibleAnnotationsAttribute.java index 0cb954e634..f464a4605e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeInvisibleAnnotationsAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeInvisibleAnnotationsAttribute.java @@ -26,15 +26,11 @@ public class RuntimeInvisibleAnnotationsAttribute implements IRuntimeInvisibleAnnotationsAttribute { private static final IAnnotation[] NO_ENTRIES = new IAnnotation[0]; - private int annotationsNumber; + private final int annotationsNumber; private IAnnotation[] annotations; /** * Constructor for RuntimeInvisibleAnnotations. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public RuntimeInvisibleAnnotationsAttribute( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeInvisibleParameterAnnotationsAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeInvisibleParameterAnnotationsAttribute.java index 5f683a39de..cf0dae374a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeInvisibleParameterAnnotationsAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeInvisibleParameterAnnotationsAttribute.java @@ -27,14 +27,10 @@ public class RuntimeInvisibleParameterAnnotationsAttribute private static final IParameterAnnotation[] NO_ENTRIES = new IParameterAnnotation[0]; private IParameterAnnotation[] parameterAnnotations; - private int parametersNumber; + private final int parametersNumber; /** * Constructor for RuntimeVisibleParameterAnnotations. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public RuntimeInvisibleParameterAnnotationsAttribute( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeInvisibleTypeAnnotationsAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeInvisibleTypeAnnotationsAttribute.java index 9402995e0a..3eb591ae8f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeInvisibleTypeAnnotationsAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeInvisibleTypeAnnotationsAttribute.java @@ -28,15 +28,11 @@ public class RuntimeInvisibleTypeAnnotationsAttribute implements IRuntimeInvisibleTypeAnnotationsAttribute { private static final IExtendedAnnotation[] NO_ENTRIES = new IExtendedAnnotation[0]; - private int extendedAnnotationsNumber; + private final int extendedAnnotationsNumber; private IExtendedAnnotation[] extendedAnnotations; /** * Constructor for RuntimeInvisibleTypeAnnotations. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public RuntimeInvisibleTypeAnnotationsAttribute( byte[] classFileBytes, @@ -69,4 +65,4 @@ public IExtendedAnnotation[] getExtendedAnnotations() { public int getExtendedAnnotationsNumber() { return this.extendedAnnotationsNumber; } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeVisibleAnnotationsAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeVisibleAnnotationsAttribute.java index c7300c7a42..eeff127a10 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeVisibleAnnotationsAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeVisibleAnnotationsAttribute.java @@ -26,15 +26,11 @@ public class RuntimeVisibleAnnotationsAttribute implements IRuntimeVisibleAnnotationsAttribute { private static final IAnnotation[] NO_ENTRIES = new IAnnotation[0]; - private int annotationsNumber; + private final int annotationsNumber; private IAnnotation[] annotations; /** * Constructor for RuntimeVisibleAnnotations. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public RuntimeVisibleAnnotationsAttribute( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeVisibleParameterAnnotationsAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeVisibleParameterAnnotationsAttribute.java index 674ec145ff..8874c7e992 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeVisibleParameterAnnotationsAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeVisibleParameterAnnotationsAttribute.java @@ -26,15 +26,11 @@ public class RuntimeVisibleParameterAnnotationsAttribute implements IRuntimeVisibleParameterAnnotationsAttribute { private static final IParameterAnnotation[] NO_ENTRIES = new IParameterAnnotation[0]; - private int parametersNumber; + private final int parametersNumber; private IParameterAnnotation[] parameterAnnotations; /** * Constructor for RuntimeVisibleParameterAnnotations. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public RuntimeVisibleParameterAnnotationsAttribute( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeVisibleTypeAnnotationsAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeVisibleTypeAnnotationsAttribute.java index 568e30c1cf..d2605eec0a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeVisibleTypeAnnotationsAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/RuntimeVisibleTypeAnnotationsAttribute.java @@ -28,15 +28,11 @@ public class RuntimeVisibleTypeAnnotationsAttribute implements IRuntimeVisibleTypeAnnotationsAttribute { private static final IExtendedAnnotation[] NO_ENTRIES = new IExtendedAnnotation[0]; - private int extendedAnnotationsNumber; + private final int extendedAnnotationsNumber; private IExtendedAnnotation[] extendedAnnotations; /** * Constructor for RuntimeVisibleTypeAnnotations. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public RuntimeVisibleTypeAnnotationsAttribute( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SignatureAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SignatureAttribute.java index 2dfedf7e94..934c9c8986 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SignatureAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SignatureAttribute.java @@ -24,8 +24,8 @@ */ public class SignatureAttribute extends ClassFileAttribute implements ISignatureAttribute { - private int signatureIndex; - private char[] signature; + private final int signatureIndex; + private final char[] signature; SignatureAttribute(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException { super(classFileBytes, constantPool, offset); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SimpleDocument.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SimpleDocument.java index dbf479af9d..2a94bab0ec 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SimpleDocument.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SimpleDocument.java @@ -27,7 +27,7 @@ */ public class SimpleDocument implements IDocument { - private StringBuffer buffer; + private final StringBuffer buffer; public SimpleDocument(String source) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SourceFileAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SourceFileAttribute.java index ba663fde00..8f39aa010c 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SourceFileAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SourceFileAttribute.java @@ -26,15 +26,11 @@ public class SourceFileAttribute extends ClassFileAttribute implements ISourceAttribute { - private int sourceFileIndex; - private char[] sourceFileName; + private final int sourceFileIndex; + private final char[] sourceFileName; /** * Constructor for SourceFileAttribute. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public SourceFileAttribute( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StackMapAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StackMapAttribute.java index 4831e0b647..add9d84478 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StackMapAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StackMapAttribute.java @@ -28,17 +28,13 @@ public class StackMapAttribute private static final IStackMapFrame[] NO_FRAMES = new IStackMapFrame[0]; private static final byte[] NO_ENTRIES = new byte[0]; - private int numberOfEntries; + private final int numberOfEntries; private IStackMapFrame[] frames; private byte[] bytes; /** * Constructor for LineNumberAttribute. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public StackMapAttribute( byte[] classFileBytes, @@ -79,8 +75,6 @@ public IStackMapFrame[] getStackMapFrame() { return this.frames; } - /** - */ public byte[] getBytes() { return this.bytes; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StackMapFrame.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StackMapFrame.java index c7d1c5c6a7..1a1ea0b596 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StackMapFrame.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StackMapFrame.java @@ -25,7 +25,7 @@ public class StackMapFrame extends ClassFileStruct implements IStackMapFrame { private static final IVerificationTypeInfo[] EMPTY_LOCALS_OR_STACK_ITEMS = new IVerificationTypeInfo[0]; private int readOffset; - private int frameType; + private final int frameType; private int numberOfLocals; private int numberOfStackItems; private IVerificationTypeInfo[] locals; @@ -34,11 +34,6 @@ public class StackMapFrame extends ClassFileStruct implements IStackMapFrame { /** * Constructor for StackMapFrame. - * - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public StackMapFrame( byte[] classFileBytes, diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StackMapTableAttribute.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StackMapTableAttribute.java index c5205507ee..59616de04f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StackMapTableAttribute.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StackMapTableAttribute.java @@ -28,17 +28,13 @@ public class StackMapTableAttribute private static final IStackMapFrame[] NO_FRAMES = new IStackMapFrame[0]; private static final byte[] NO_ENTRIES = new byte[0]; - private int numberOfEntries; + private final int numberOfEntries; private IStackMapFrame[] frames; private byte[] bytes; /** * Constructor for LineNumberAttribute. - * @param classFileBytes - * @param constantPool - * @param offset - * @throws ClassFormatException */ public StackMapTableAttribute( byte[] classFileBytes, @@ -79,8 +75,6 @@ public IStackMapFrame[] getStackMapFrame() { return this.frames; } - /** - */ public byte[] getBytes() { return this.bytes; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java index e7b4a8aa9a..d1b306bc38 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java @@ -15,6 +15,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.util; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.*; import java.net.URI; import java.util.*; @@ -445,7 +447,9 @@ public final static String editedString(String original, TextEdit edit) { edit.apply(document, TextEdit.NONE); return document.get(); } catch (MalformedTreeException | BadLocationException e) { - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + trace("", e); //$NON-NLS-1$ + } } return original; } @@ -1268,7 +1272,9 @@ public static void setSourceAttachmentProperty(IPath path, String property) { try { ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(getSourceAttachmentPropertyName(path), property); } catch (CoreException e) { - e.printStackTrace(); + if (JavaModelManager.VERBOSE) { + trace("", e); //$NON-NLS-1$ + } } } @@ -1650,7 +1656,6 @@ protected static boolean isAttributeSupported(int attribute) { /** * Returns whether the given resource is read-only or not. - * @param resource * @return true if the resource is read-only, false if it is not or * if the file system does not support the read-only attribute. */ @@ -2759,20 +2764,6 @@ public static void validateMethodSignature(String sig) { public static void validateTypeSignature(String sig, boolean allowVoid) { Assert.isTrue(isValidTypeSignature(sig, allowVoid)); } - public static void verbose(String log) { - verbose(log, System.out); - } - public static synchronized void verbose(String log, PrintStream printStream) { - int start = 0; - do { - int end = log.indexOf('\n', start); - printStream.print(Thread.currentThread()); - printStream.print(" "); //$NON-NLS-1$ - printStream.print(log.substring(start, end == -1 ? log.length() : end+1)); - start = end+1; - } while (start != 0); - printStream.println(); - } /** * Returns true if the given name ends with one of the known java like extension. @@ -3337,7 +3328,6 @@ public static void fixTaskTags(Map defaultOptionsMap) { * @param paramTypeSignatures the type signatures of the method arguments * @param isConstructor whether we're looking for a constructor * @return an IMethod if found, otherwise null - * @throws JavaModelException */ public static IMethod findMethod(IType type, char[] selector, String[] paramTypeSignatures, boolean isConstructor) throws JavaModelException { IMethod method = null; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/VerificationInfo.java b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/VerificationInfo.java index d874de8fc6..ded21361ac 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/VerificationInfo.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/VerificationInfo.java @@ -21,7 +21,7 @@ public class VerificationInfo extends ClassFileStruct implements IVerificationTypeInfo { - private int tag; + private final int tag; private int offset; private int constantPoolIndex; private char[] classTypeName; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/FieldReferenceMatch.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/FieldReferenceMatch.java index de864bcdb1..e1b66b21ed 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/FieldReferenceMatch.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/FieldReferenceMatch.java @@ -27,8 +27,8 @@ */ public class FieldReferenceMatch extends ReferenceMatch { -private boolean isReadAccess; -private boolean isWriteAccess; +private final boolean isReadAccess; +private final boolean isWriteAccess; /** * Creates a new field reference match. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/LocalVariableReferenceMatch.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/LocalVariableReferenceMatch.java index e73554c94f..e0d21dc716 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/LocalVariableReferenceMatch.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/LocalVariableReferenceMatch.java @@ -27,8 +27,8 @@ */ public class LocalVariableReferenceMatch extends SearchMatch { - private boolean isReadAccess; - private boolean isWriteAccess; + private final boolean isReadAccess; + private final boolean isWriteAccess; /** * Creates a new local variable reference match. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/MethodNameMatch.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/MethodNameMatch.java index 1643f0693d..654d84f108 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/MethodNameMatch.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/MethodNameMatch.java @@ -40,7 +40,6 @@ public abstract class MethodNameMatch { * {@link IAccessRule#K_ACCESSIBLE}, {@link IAccessRule#K_DISCOURAGED} * or {@link IAccessRule#K_NON_ACCESSIBLE}. * The default returned value is {@link IAccessRule#K_ACCESSIBLE}. - * */ public abstract int getAccessibility(); @@ -66,4 +65,4 @@ public abstract class MethodNameMatch { */ public abstract IMethod getMethod(); -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/MethodNameRequestor.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/MethodNameRequestor.java index 27e9b712dd..62b96d3381 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/MethodNameRequestor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/MethodNameRequestor.java @@ -14,27 +14,26 @@ package org.eclipse.jdt.core.search; /** - * + * * A MethodDeclarationRequestor collects search results from a searchAllMethodDeclarations * query to a SearchEngine. Clients must subclass this abstract class and pass an instance to the - * SearchEngine.searchAllMethodDeclarations method. - * + * SearchEngine.searchAllMethodDeclarations method. + * *

    * This class may be subclassed by clients *

    * @since 3.12 - * */ public abstract class MethodNameRequestor { - + /** * Accepts a method. - * + * *

    - * The default implementation of this method does nothing. + * The default implementation of this method does nothing. * Subclasses should override. *

    - * + * * @param methodName name of the method. * @param parameterCount number of parameters in this method. * @param declaringQualifier the qualified name of parent of the enclosing type of this method. @@ -70,4 +69,4 @@ public void acceptMethod( int methodIndex) { //do nothing } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchDocument.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchDocument.java index e2bdb3b5c8..e49cf97006 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchDocument.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchDocument.java @@ -29,8 +29,8 @@ public abstract class SearchDocument { private Index index; private String containerRelativePath; private SourceElementParser parser; - private String documentPath; - private SearchParticipant participant; + private final String documentPath; + private final SearchParticipant participant; private boolean shouldIndexResolvedDocument = false; /** @@ -121,7 +121,7 @@ private String getContainerRelativePath() { public SourceElementParser getParser() { return this.parser; } - + /** * Returns the participant that created this document. * @@ -151,7 +151,7 @@ public void removeAllIndexEntries() { if (this.index != null) this.index.remove(getContainerRelativePath()); } - + /** * @nooverride This method is not intended to be re-implemented or extended by clients. * @noreference This method is not intended to be referenced by clients. @@ -159,7 +159,7 @@ public void removeAllIndexEntries() { public void setIndex(Index indexToSet) { this.index = indexToSet; } - + /** * @nooverride This method is not intended to be re-implemented or extended by clients. * @noreference This method is not intended to be referenced by clients. @@ -168,16 +168,16 @@ public void setParser(SourceElementParser sourceElementParser) { this.parser = sourceElementParser; } - /** Flags the document as requiring indexing after symbol and type resolution. A participant would be asked - * to resolve the document via {@link SearchParticipant#resolveDocument} and to index the document adding - * additional entries via {@link SearchParticipant#indexResolvedDocument} - * - * @since 3.10 + /** Flags the document as requiring indexing after symbol and type resolution. A participant would be asked + * to resolve the document via {@link SearchParticipant#resolveDocument} and to index the document adding + * additional entries via {@link SearchParticipant#indexResolvedDocument} + * + * @since 3.10 */ public void requireIndexingResolvedDocument() { this.shouldIndexResolvedDocument = true; } - + /** * @nooverride This method is not intended to be re-implemented or extended by clients. * @noreference This method is not intended to be referenced by clients. diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java index c058c885b5..00c1b55d93 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java @@ -110,7 +110,7 @@ public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, } // Search engine now uses basic engine functionalities - private BasicSearchEngine basicEngine; + private final BasicSearchEngine basicEngine; /** * Creates a new search engine. @@ -382,7 +382,6 @@ public static IJavaSearchScope createJavaSearchScope(IJavaElement[] elements, in * files of this package fragment will be included. Subpackages will NOT be * included.

    * - * @param excludeTestCode * @param elements the Java elements the scope is limited to * @param includeMask the bit-wise OR of all include types of interest * @return a new Java search scope diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java index 08aba1a63f..fd370af35e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java @@ -2802,7 +2802,6 @@ private static int validateMatchRule(String stringPattern, int searchFor, int li /* * Validate pattern for a camel case match rule - * @return */ private static boolean validateCamelCasePattern(String stringPattern) { if (stringPattern == null) return true; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchRequestor.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchRequestor.java index e7819fa37e..778063e9aa 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchRequestor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchRequestor.java @@ -38,7 +38,6 @@ public abstract class SearchRequestor { * Accepts the given search match. * * @param match the found match - * @throws CoreException */ public abstract void acceptSearchMatch(SearchMatch match) throws CoreException; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/EntryResult.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/EntryResult.java index da654e9706..ab8f17f265 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/EntryResult.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/EntryResult.java @@ -18,7 +18,7 @@ public class EntryResult { -private char[] word; +private final char[] word; private Object[] documentTables; private SimpleSet documentNames; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/Index.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/Index.java index 959ce35093..d9a3fc07f8 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/Index.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/Index.java @@ -209,8 +209,6 @@ public void remove(String containerRelativePath) { } /** * Reset memory and disk indexes. - * - * @throws IOException */ public void reset() throws IOException { this.memoryIndex = new MemoryIndex(); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IndexLocation.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IndexLocation.java index e691a2e723..c60322f830 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IndexLocation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IndexLocation.java @@ -30,7 +30,6 @@ * * This is an abstract class to allow different implementation for a jar entry and a file * on the disk. Some of these functions could mean different for a jar entry or a file - * */ public abstract class IndexLocation { @@ -104,7 +103,6 @@ public void close() { /** * Creates a new file for the given index location * @return true if the file is created - * @throws IOException */ public abstract boolean createNewFile() throws IOException; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/JarIndexLocation.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/JarIndexLocation.java index 1b05f7314f..22558065c1 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/JarIndexLocation.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/JarIndexLocation.java @@ -28,7 +28,7 @@ public class JarIndexLocation extends IndexLocation { private JarFile jarFile = null; private JarEntry jarEntry = null; - private URL localUrl; + private final URL localUrl; public JarIndexLocation(URL url, URL localUrl2) { super(url); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/MetaIndex.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/MetaIndex.java index 0b0e966b94..8df80f45a0 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/MetaIndex.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/MetaIndex.java @@ -26,7 +26,7 @@ import org.eclipse.jdt.internal.core.search.indexing.ReadWriteMonitor; public class MetaIndex { - private Index decoratee; + private final Index decoratee; private Set indexesNotInMeta = null; public MetaIndex(Index decoratee) { @@ -68,7 +68,6 @@ public EntryResult[] query(char[][] categories, char[] indexQualifier, int match * * @param indexes all indexes as a {@link SimpleLookupTable} where key is {@link IndexLocation} and value is {@link Index} * @return index names which are not part of or empty. - * @throws IOException */ public Set getIndexesNotInMeta(SimpleLookupTable indexes) throws IOException { // this method is accessed in a single thread diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/java/model/BinaryModuleFactory.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/java/model/BinaryModuleFactory.java index 6596c12c2d..7474c0ebee 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/java/model/BinaryModuleFactory.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/java/model/BinaryModuleFactory.java @@ -85,8 +85,6 @@ private static BinaryModuleDescriptor createDescriptor(PackageFragmentRoot root, * the file on disk, the type is read from the index. Otherwise the type is read from disk. Returns null if * no such type exists. * caveat modules are not yet supported in the index. - * - * @throws ClassFormatException */ public static IBinaryModule readModule(BinaryModuleDescriptor descriptor, IProgressMonitor monitor) throws JavaModelException, ClassFormatException { // FIXME: support module in the new index diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/java/model/BinaryTypeFactory.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/java/model/BinaryTypeFactory.java index b315738694..32933f2529 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/java/model/BinaryTypeFactory.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/java/model/BinaryTypeFactory.java @@ -110,7 +110,6 @@ public static IBinaryType create(IOrdinaryClassFile classFile, IProgressMonitor * Reads the given binary type. If the type can be found in the index with a fingerprint that exactly matches * the file on disk, the type is read from the index. Otherwise the type is read from disk. Returns null if * no such type exists. - * @throws ClassFormatException */ public static IBinaryType readType(BinaryTypeDescriptor descriptor, IProgressMonitor monitor) throws JavaModelException, ClassFormatException { return rawReadType(descriptor, true); @@ -203,7 +202,6 @@ public static IPath getLocationForElement(IJavaElement next) { * the field descriptor points to any other type, this returns the empty string. The field descriptor may optionally * contain a trailing ';'. * - * @param fieldDescriptor * @return "" */ public static char[] fieldDescriptorToBinaryName(char[] fieldDescriptor) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/util/CharArrayUtils.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/util/CharArrayUtils.java index aeb2e31cbc..7ab03b1f04 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/util/CharArrayUtils.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/util/CharArrayUtils.java @@ -250,7 +250,6 @@ public static final char[] concat(char[] first, char[] second, char[] third, cha /** * Answers a new array which is the concatenation of all the given arrays. * - * @param toCatenate * @since 3.12 */ public static char[] concat(char[]... toCatenate) { @@ -452,11 +451,6 @@ static final public char[] lastSegment(char[] array, char[] separator) { return subarray(array, pos + separator.length, array.length); } - /** - * @param buff - * @param i - * @param charImage - */ public static void overWrite(char[] buff, int i, char[] charImage) { if (buff.length < i + charImage.length) return; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java index 4fe3d04abd..2bfb4180fb 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java @@ -15,6 +15,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.util.*; import java.util.regex.Pattern; @@ -37,7 +39,6 @@ import org.eclipse.jdt.internal.core.search.indexing.*; import org.eclipse.jdt.internal.core.search.matching.*; import org.eclipse.jdt.internal.core.util.Messages; -import org.eclipse.jdt.internal.core.util.Util; /** * Search basic engine. Public search engine (see {@link org.eclipse.jdt.core.search.SearchEngine} @@ -210,11 +211,13 @@ public static IJavaSearchScope createWorkspaceScope() { void findMatches(SearchPattern pattern, SearchParticipant[] participants, IJavaSearchScope scope, SearchRequestor requestor, IProgressMonitor monitor) throws CoreException { try { if (VERBOSE) { - Util.verbose("Searching for pattern: " + pattern.toString()); //$NON-NLS-1$ - Util.verbose(scope.toString()); + trace("Searching for pattern: " + pattern.toString()); //$NON-NLS-1$ + trace(scope.toString()); } if (participants == null) { - if (VERBOSE) Util.verbose("No participants => do nothing!"); //$NON-NLS-1$ + if (VERBOSE) { + trace("No participants => do nothing!"); //$NON-NLS-1$ + } return; } @@ -272,9 +275,6 @@ public static SearchParticipant getDefaultSearchParticipant() { return new JavaSearchParticipant(); } - /** - * @param matchRule - */ public static String getMatchRuleString(final int matchRule) { if (matchRule == 0) { return "R_EXACT_MATCH"; //$NON-NLS-1$ @@ -318,8 +318,6 @@ public static String getMatchRuleString(final int matchRule) { /** * Return kind of search corresponding to given value. - * - * @param searchFor */ public static String getSearchForString(final int searchFor) { switch (searchFor) { @@ -597,7 +595,7 @@ boolean match(char[] patternFusedQualifier, int matchRuleFusedQualifier, */ public void search(SearchPattern pattern, SearchParticipant[] participants, IJavaSearchScope scope, SearchRequestor requestor, IProgressMonitor monitor) throws CoreException { if (VERBOSE) { - Util.verbose("BasicSearchEngine.search(SearchPattern, SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)"); //$NON-NLS-1$ + trace("BasicSearchEngine.search(SearchPattern, SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)"); //$NON-NLS-1$ } findMatches(pattern, participants, scope, requestor, monitor); } @@ -647,14 +645,14 @@ public void searchAllConstructorDeclarations( // Debug if (VERBOSE) { - Util.verbose("BasicSearchEngine.searchAllConstructorDeclarations(char[], char[], int, IJavaSearchScope, IRestrictedAccessConstructorRequestor, int, IProgressMonitor)"); //$NON-NLS-1$ - Util.verbose(" - package name: "+(packageName==null?"null":new String(packageName))); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" - type name: "+(typeName==null?"null":new String(typeName))); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" - type match rule: "+getMatchRuleString(typeMatchRule)); //$NON-NLS-1$ + trace("BasicSearchEngine.searchAllConstructorDeclarations(char[], char[], int, IJavaSearchScope, IRestrictedAccessConstructorRequestor, int, IProgressMonitor)"); //$NON-NLS-1$ + trace(" - package name: "+(packageName==null?"null":new String(packageName))); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" - type name: "+(typeName==null?"null":new String(typeName))); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" - type match rule: "+getMatchRuleString(typeMatchRule)); //$NON-NLS-1$ if (validatedTypeMatchRule != typeMatchRule) { - Util.verbose(" - validated type match rule: "+getMatchRuleString(validatedTypeMatchRule)); //$NON-NLS-1$ + trace(" - validated type match rule: "+getMatchRuleString(validatedTypeMatchRule)); //$NON-NLS-1$ } - Util.verbose(" - scope: "+scope); //$NON-NLS-1$ + trace(" - scope: "+scope); //$NON-NLS-1$ } if (validatedTypeMatchRule == -1) return; // invalid match rule => return no results @@ -993,15 +991,15 @@ public void searchAllMethodNames( final int validatedMethodMatchRule = SearchPattern.validateMatchRule(methodName == null ? null : new String (methodName), methodMatchRule); // Debug if (VERBOSE) { - Util.verbose("BasicSearchEngine.searchAllMethodDeclarations(char[] qualifier, "//$NON-NLS-1$ + trace("BasicSearchEngine.searchAllMethodDeclarations(char[] qualifier, "//$NON-NLS-1$ + "char[] methodName, int methodMatchRule, IJavaSearchScope, IRestrictedAccessConstructorRequestor, int waitingPolicy, IProgressMonitor)"); //$NON-NLS-1$ - Util.verbose(" - qualifier name: "+(qualifier==null?"null":new String(qualifier))); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" - method name: "+(methodName==null?"null":new String(methodName))); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" - method match rule: "+getMatchRuleString(methodMatchRule)); //$NON-NLS-1$ + trace(" - qualifier name: "+(qualifier==null?"null":new String(qualifier))); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" - method name: "+(methodName==null?"null":new String(methodName))); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" - method match rule: "+getMatchRuleString(methodMatchRule)); //$NON-NLS-1$ if (validatedMethodMatchRule != methodMatchRule) { - Util.verbose(" - validated method match rule: "+getMatchRuleString(validatedMethodMatchRule)); //$NON-NLS-1$ + trace(" - validated method match rule: "+getMatchRuleString(validatedMethodMatchRule)); //$NON-NLS-1$ } - Util.verbose(" - scope: "+scope); //$NON-NLS-1$ + trace(" - scope: "+scope); //$NON-NLS-1$ } if (validatedMethodMatchRule == -1) return; // invalid match rule => return no results @@ -1261,17 +1259,17 @@ public void searchAllMethodNames( final int validatedMethodMatchRule = SearchPattern.validateMatchRule(methodName == null ? null : new String (methodName), methodMatchRule); // Debug if (VERBOSE) { - Util.verbose("BasicSearchEngine.searchAllMethodDeclarations(char[] packageName, char[] declaringQualification, char[] declaringSimpleName, "//$NON-NLS-1$ + trace("BasicSearchEngine.searchAllMethodDeclarations(char[] packageName, char[] declaringQualification, char[] declaringSimpleName, "//$NON-NLS-1$ + "char[] methodName, int methodMatchRule, IJavaSearchScope, IRestrictedAccessConstructorRequestor, int waitingPolicy, IProgressMonitor)"); //$NON-NLS-1$ - Util.verbose(" - package name: "+(packageName==null?"null":new String(packageName))); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" - declaringQualification name: "+(declaringQualification==null?"null":new String(declaringQualification))); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" - declaringSimple name: "+(declaringSimpleName==null?"null":new String(declaringSimpleName))); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" - method name: "+(methodName==null?"null":new String(methodName))); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" - method match rule: "+getMatchRuleString(methodMatchRule)); //$NON-NLS-1$ + trace(" - package name: "+(packageName==null?"null":new String(packageName))); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" - declaringQualification name: "+(declaringQualification==null?"null":new String(declaringQualification))); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" - declaringSimple name: "+(declaringSimpleName==null?"null":new String(declaringSimpleName))); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" - method name: "+(methodName==null?"null":new String(methodName))); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" - method match rule: "+getMatchRuleString(methodMatchRule)); //$NON-NLS-1$ if (validatedMethodMatchRule != methodMatchRule) { - Util.verbose(" - validated method match rule: "+getMatchRuleString(validatedMethodMatchRule)); //$NON-NLS-1$ + trace(" - validated method match rule: "+getMatchRuleString(validatedMethodMatchRule)); //$NON-NLS-1$ } - Util.verbose(" - scope: "+scope); //$NON-NLS-1$ + trace(" - scope: "+scope); //$NON-NLS-1$ } if (validatedMethodMatchRule == -1) return; // invalid match rule => return no results @@ -1616,7 +1614,7 @@ public void searchAllSecondaryTypeNames( try { if (VERBOSE) { - Util.verbose("BasicSearchEngine.searchAllSecondaryTypeNames(IPackageFragmentRoot[], IRestrictedAccessTypeRequestor, boolean, IProgressMonitor)"); //$NON-NLS-1$ + trace("BasicSearchEngine.searchAllSecondaryTypeNames(IPackageFragmentRoot[], IRestrictedAccessTypeRequestor, boolean, IProgressMonitor)"); //$NON-NLS-1$ StringBuilder buffer = new StringBuilder(" - source folders: "); //$NON-NLS-1$ int length = sourceFolders.length; for (int i=0; i return no results @@ -2059,12 +2057,12 @@ public void searchAllTypeNames( try { // Debug if (VERBOSE) { - Util.verbose("BasicSearchEngine.searchAllTypeNames(char[][], char[][], int, int, IJavaSearchScope, IRestrictedAccessTypeRequestor, int, IProgressMonitor)"); //$NON-NLS-1$ - Util.verbose(" - package name: "+(qualifications==null?"null":new String(CharOperation.concatWith(qualifications, ',')))); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" - type name: "+(typeNames==null?"null":new String(CharOperation.concatWith(typeNames, ',')))); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose(" - match rule: "+getMatchRuleString(matchRule)); //$NON-NLS-1$ - Util.verbose(" - search for: "+searchFor); //$NON-NLS-1$ - Util.verbose(" - scope: "+scope); //$NON-NLS-1$ + trace("BasicSearchEngine.searchAllTypeNames(char[][], char[][], int, int, IJavaSearchScope, IRestrictedAccessTypeRequestor, int, IProgressMonitor)"); //$NON-NLS-1$ + trace(" - package name: "+(qualifications==null?"null":new String(CharOperation.concatWith(qualifications, ',')))); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" - type name: "+(typeNames==null?"null":new String(CharOperation.concatWith(typeNames, ',')))); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" - match rule: "+getMatchRuleString(matchRule)); //$NON-NLS-1$ + trace(" - search for: "+searchFor); //$NON-NLS-1$ + trace(" - scope: "+scope); //$NON-NLS-1$ } IndexManager indexManager = JavaModelManager.getIndexManager(); @@ -2278,7 +2276,7 @@ public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope classScop public void searchDeclarations(IJavaElement enclosingElement, SearchRequestor requestor, SearchPattern pattern, IProgressMonitor monitor) throws JavaModelException { try { if (VERBOSE) { - Util.verbose(" - java element: "+enclosingElement); //$NON-NLS-1$ + trace(" - java element: "+enclosingElement); //$NON-NLS-1$ } IJavaSearchScope scope = createJavaSearchScope(new IJavaElement[] {enclosingElement}); IResource resource = ((JavaElement) enclosingElement).resource(); @@ -2298,7 +2296,7 @@ public void searchDeclarations(IJavaElement enclosingElement, SearchRequestor re try { requestor.beginReporting(); if (VERBOSE) { - Util.verbose("Searching for " + pattern + " in " + resource.getFullPath()); //$NON-NLS-1$//$NON-NLS-2$ + trace("Searching for " + pattern + " in " + resource.getFullPath()); //$NON-NLS-1$//$NON-NLS-2$ } SearchParticipant participant = getDefaultSearchParticipant(); SearchDocument[] documents = MatchLocator.addWorkingCopies( @@ -2345,7 +2343,7 @@ public void searchDeclarations(IJavaElement enclosingElement, SearchRequestor re */ public void searchDeclarationsOfAccessedFields(IJavaElement enclosingElement, SearchRequestor requestor, IProgressMonitor monitor) throws JavaModelException { if (VERBOSE) { - Util.verbose("BasicSearchEngine.searchDeclarationsOfAccessedFields(IJavaElement, SearchRequestor, SearchPattern, IProgressMonitor)"); //$NON-NLS-1$ + trace("BasicSearchEngine.searchDeclarationsOfAccessedFields(IJavaElement, SearchRequestor, SearchPattern, IProgressMonitor)"); //$NON-NLS-1$ } // Do not accept other kind of element type than those specified in the spec switch (enclosingElement.getElementType()) { @@ -2372,7 +2370,7 @@ public void searchDeclarationsOfAccessedFields(IJavaElement enclosingElement, Se */ public void searchDeclarationsOfReferencedTypes(IJavaElement enclosingElement, SearchRequestor requestor, IProgressMonitor monitor) throws JavaModelException { if (VERBOSE) { - Util.verbose("BasicSearchEngine.searchDeclarationsOfReferencedTypes(IJavaElement, SearchRequestor, SearchPattern, IProgressMonitor)"); //$NON-NLS-1$ + trace("BasicSearchEngine.searchDeclarationsOfReferencedTypes(IJavaElement, SearchRequestor, SearchPattern, IProgressMonitor)"); //$NON-NLS-1$ } // Do not accept other kind of element type than those specified in the spec switch (enclosingElement.getElementType()) { @@ -2399,7 +2397,7 @@ public void searchDeclarationsOfReferencedTypes(IJavaElement enclosingElement, S */ public void searchDeclarationsOfSentMessages(IJavaElement enclosingElement, SearchRequestor requestor, IProgressMonitor monitor) throws JavaModelException { if (VERBOSE) { - Util.verbose("BasicSearchEngine.searchDeclarationsOfSentMessages(IJavaElement, SearchRequestor, SearchPattern, IProgressMonitor)"); //$NON-NLS-1$ + trace("BasicSearchEngine.searchDeclarationsOfSentMessages(IJavaElement, SearchRequestor, SearchPattern, IProgressMonitor)"); //$NON-NLS-1$ } // Do not accept other kind of element type than those specified in the spec switch (enclosingElement.getElementType()) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IndexSelector.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IndexSelector.java index 8c100c0745..6f440f2e3b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IndexSelector.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IndexSelector.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.util.Collection; import java.util.LinkedHashSet; import java.util.Optional; @@ -51,7 +53,6 @@ import org.eclipse.jdt.internal.core.search.matching.MethodPattern; import org.eclipse.jdt.internal.core.search.matching.ModulePattern; import org.eclipse.jdt.internal.core.search.processing.JobManager; -import org.eclipse.jdt.internal.core.util.Util; /** * Selects the indexes that correspond to projects in a given search scope @@ -323,7 +324,7 @@ public IndexLocation[] getIndexLocations() { .toArray(IndexLocation[]::new); if (filtered.length == 0) { if (JobManager.VERBOSE) { - Util.verbose(String.format( + trace(String.format( "-> current index selection and qualifying indexes has no intersection, " + //$NON-NLS-1$ "to keep search backward compatible using selected index locations - %s", //$NON-NLS-1$ this.toString())); @@ -333,7 +334,7 @@ public IndexLocation[] getIndexLocations() { } } if (JobManager.VERBOSE) { - Util.verbose(String.format("-> selected %s indexes out of total indexes %s after qualify filtering - %s", //$NON-NLS-1$ + trace(String.format("-> selected %s indexes out of total indexes %s after qualify filtering - %s", //$NON-NLS-1$ filtered.length, this.indexLocations.length, this.toString())); } return filtered; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchDocument.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchDocument.java index d3a30d679f..682db63277 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchDocument.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchDocument.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; @@ -50,7 +52,7 @@ public byte[] getByteContents() { return Util.getResourceContentsAsByteArray(getFile()); } catch (JavaModelException e) { if (BasicSearchEngine.VERBOSE || JobManager.VERBOSE) { // used during search and during indexing - e.printStackTrace(); + trace("", e); //$NON-NLS-1$ } return null; } @@ -62,7 +64,7 @@ public char[] getCharContents() { return Util.getResourceContentsAsCharArray(getFile()); } catch (JavaModelException e) { if (BasicSearchEngine.VERBOSE || JobManager.VERBOSE) { // used during search and during indexing - e.printStackTrace(); + trace("", e); //$NON-NLS-1$ } return null; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchMethodNameMatch.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchMethodNameMatch.java index 895bce5571..ee5c5c4c01 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchMethodNameMatch.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchMethodNameMatch.java @@ -19,13 +19,12 @@ /** * Java Search concrete class for a method name match. - * */ public class JavaSearchMethodNameMatch extends MethodNameMatch { - + IMethod method = null; int modifiers = -1; - + private int accessibility = IAccessRule.K_ACCESSIBLE; // TODO: this pertains to class/type - need to revisit whether this is required in method name match public JavaSearchMethodNameMatch(IMethod method, int modifiers) { this.method = method; @@ -46,11 +45,11 @@ public int getModifiers() { public IMethod getMethod() { return this.method; } - + public void setAccessibility(int accessibility) { this.accessibility = accessibility; } - + @Override public String toString() { return this.method == null ? super.toString() : this.method.toString(); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaWorkspaceScope.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaWorkspaceScope.java index fd16bd2518..2570110fa8 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaWorkspaceScope.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaWorkspaceScope.java @@ -118,7 +118,7 @@ public IPath[] enclosingProjectsAndJars() { if (BasicSearchEngine.VERBOSE) { long time = System.currentTimeMillis() - start; int length = result == null ? 0 : result.length; - Util.verbose("JavaWorkspaceScope.enclosingProjectsAndJars: "+length+" paths computed in "+time+"ms."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + JavaModelManager.trace("JavaWorkspaceScope.enclosingProjectsAndJars: "+length+" paths computed in "+time+"ms."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/MethodNameRequestorWrapper.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/MethodNameRequestorWrapper.java index d8b4a788b1..86526dba1b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/MethodNameRequestorWrapper.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/MethodNameRequestorWrapper.java @@ -45,13 +45,12 @@ * IJavaSearchScope scope, * MethodNameRequestor methodRequestor, * int waitingPolicy, - * IProgressMonitor progressMonitor)}. - * + * IProgressMonitor progressMonitor)}. */ public class MethodNameRequestorWrapper implements IRestrictedAccessMethodRequestor { - + MethodNameRequestor requestor; - + public MethodNameRequestorWrapper(MethodNameRequestor requestor) { this.requestor = requestor; } @@ -61,7 +60,7 @@ public void acceptMethod(char[] methodName, int parameterCount, char[] declaring char[] simpleTypeName, int typeModifiers, char[] packageName, char[] signature, char[][] parameterTypes, char[][] parameterNames, char[] returnType, int modifiers, String path, AccessRestriction access, int methodIndex) { - this.requestor.acceptMethod(methodName, parameterCount, declaringQualification, simpleTypeName, typeModifiers, + this.requestor.acceptMethod(methodName, parameterCount, declaringQualification, simpleTypeName, typeModifiers, packageName, signature, parameterTypes, parameterNames, returnType, modifiers, path, methodIndex); } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PatternSearchJob.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PatternSearchJob.java index daf2518378..13af4d4843 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PatternSearchJob.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PatternSearchJob.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -122,11 +124,11 @@ public boolean execute(IProgressMonitor progressMonitor) { if (JobManager.VERBOSE) { if (this.parallel) { long wallClockTime = System.currentTimeMillis() - startTime; - Util.verbose("-> execution time: " + wallClockTime + "ms - " + this);//$NON-NLS-1$//$NON-NLS-2$ - Util.verbose("-> cumulative execution time (" + ForkJoinPool.getCommonPoolParallelism() + "): " //$NON-NLS-1$//$NON-NLS-2$ + trace("-> execution time: " + wallClockTime + "ms - " + this);//$NON-NLS-1$//$NON-NLS-2$ + trace("-> cumulative execution time (" + ForkJoinPool.getCommonPoolParallelism() + "): " //$NON-NLS-1$//$NON-NLS-2$ + this.executionTime.get() + "ms - " + this);//$NON-NLS-1$ } else { - Util.verbose("-> execution time: " + this.executionTime.get() + "ms - " + this);//$NON-NLS-1$//$NON-NLS-2$ + trace("-> execution time: " + this.executionTime.get() + "ms - " + this);//$NON-NLS-1$//$NON-NLS-2$ } } return isComplete; @@ -243,7 +245,9 @@ public boolean search(Index index, IndexQueryRequestor queryRequestor, IProgress return COMPLETE; } catch (IOException e) { if (e instanceof java.io.EOFException) { - e.printStackTrace(); + if(JavaModelManager.VERBOSE) { + trace("", e); //$NON-NLS-1$ + } } else { Throwable cause = e.getCause(); if (cause != null) { @@ -336,7 +340,7 @@ static class IndexMatch { static class ParallelSearchMonitor extends NullProgressMonitor { private volatile boolean canceled; - private IProgressMonitor original; + private final IProgressMonitor original; public ParallelSearchMonitor(IProgressMonitor original) { this.original = original; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/UnindexedSearchScope.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/UnindexedSearchScope.java index 089dfd5b65..6d4b439424 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/UnindexedSearchScope.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/UnindexedSearchScope.java @@ -25,7 +25,7 @@ import org.eclipse.jdt.core.search.IJavaSearchScope; public class UnindexedSearchScope extends AbstractSearchScope { - private IJavaSearchScope searchScope; + private final IJavaSearchScope searchScope; private UnindexedSearchScope(IJavaSearchScope scope) { this.searchScope = scope; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AbstractIndexer.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AbstractIndexer.java index f148f82a1d..9feae79ef1 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AbstractIndexer.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AbstractIndexer.java @@ -29,7 +29,7 @@ public abstract class AbstractIndexer implements IIndexConstants { - SearchDocument document; + final SearchDocument document; public AbstractIndexer(SearchDocument document) { this.document = document; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddFolderToIndex.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddFolderToIndex.java index ced479ad09..d657040f3f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddFolderToIndex.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddFolderToIndex.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search.indexing; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -103,8 +105,7 @@ public boolean visit(IResourceProxy proxy) /* throws CoreException */{ } } catch (CoreException e) { if (JobManager.VERBOSE) { - Util.verbose("-> failed to add " + this.folderPath + " to index because of the following exception:", System.err); //$NON-NLS-1$ //$NON-NLS-2$ - e.printStackTrace(); + trace("-> failed to add " + this.folderPath + " to index because of the following exception:", e); //$NON-NLS-1$ //$NON-NLS-2$ } return false; } finally { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java index 2250f10396..9ea7f19876 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search.indexing; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.File; import java.io.IOException; import java.net.URI; @@ -106,20 +108,20 @@ public boolean execute(IProgressMonitor progressMonitor) { Index index = this.manager.getIndexForUpdate(this.containerPath, false, /*do not reuse index file*/ false /*do not create if none*/); if (index != null) { if (JobManager.VERBOSE) - org.eclipse.jdt.internal.core.util.Util.verbose("-> no indexing required (index already exists) for " + this.containerPath); //$NON-NLS-1$ + trace("-> no indexing required (index already exists) for " + this.containerPath); //$NON-NLS-1$ return true; } index = this.manager.getIndexForUpdate(this.containerPath, true, /*reuse index file*/ true /*create if none*/); if (index == null) { if (JobManager.VERBOSE) - org.eclipse.jdt.internal.core.util.Util.verbose("-> index could not be created for " + this.containerPath); //$NON-NLS-1$ + trace("-> index could not be created for " + this.containerPath); //$NON-NLS-1$ return true; } ReadWriteMonitor monitor = index.monitor; if (monitor == null) { if (JobManager.VERBOSE) - org.eclipse.jdt.internal.core.util.Util.verbose("-> index for " + this.containerPath + " just got deleted"); //$NON-NLS-1$//$NON-NLS-2$ + trace("-> index for " + this.containerPath + " just got deleted"); //$NON-NLS-1$//$NON-NLS-2$ return true; // index got deleted since acquired } index.separator = JAR_SEPARATOR; @@ -134,29 +136,28 @@ public boolean execute(IProgressMonitor progressMonitor) { URI location = this.resource.getLocationURI(); if (location == null) return false; if (JavaModelManager.ZIP_ACCESS_VERBOSE) - System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + location.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ + trace("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + location.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ File file = null; try { file = org.eclipse.jdt.internal.core.util.Util.toLocalFile(location, progressMonitor); } catch (CoreException e) { if (JobManager.VERBOSE) { - org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + location.getPath() + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ - e.printStackTrace(); + trace("-> failed to index " + location.getPath() + " because of the following exception:", e); //$NON-NLS-1$ //$NON-NLS-2$ } } if (file == null) { if (JobManager.VERBOSE) - org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + location.getPath() + " because the file could not be fetched"); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> failed to index " + location.getPath() + " because the file could not be fetched"); //$NON-NLS-1$ //$NON-NLS-2$ return false; } if (JavaModelManager.ZIP_ACCESS_VERBOSE) - System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + this.containerPath); //$NON-NLS-1$ //$NON-NLS-2$ + trace("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + this.containerPath); //$NON-NLS-1$ //$NON-NLS-2$ zip = new ZipFile(file); zipFilePath = (Path) this.resource.getFullPath().makeRelative(); // absolute path relative to the workspace } else { if (JavaModelManager.ZIP_ACCESS_VERBOSE) - System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + this.containerPath); //$NON-NLS-1$ //$NON-NLS-2$ + trace("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + this.containerPath); //$NON-NLS-1$ //$NON-NLS-2$ // external file -> it is ok to use toFile() zip = new ZipFile(this.containerPath.toFile()); zipFilePath = (Path) this.containerPath; @@ -165,12 +166,12 @@ public boolean execute(IProgressMonitor progressMonitor) { if (this.isCancelled) { if (JobManager.VERBOSE) - org.eclipse.jdt.internal.core.util.Util.verbose("-> indexing of " + zip.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> indexing of " + zip.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$ return false; } if (JobManager.VERBOSE) - org.eclipse.jdt.internal.core.util.Util.verbose("-> indexing " + zip.getName()); //$NON-NLS-1$ + trace("-> indexing " + zip.getName()); //$NON-NLS-1$ long initialTime = System.currentTimeMillis(); String[] paths = index.queryDocumentNames(""); // all file names //$NON-NLS-1$ @@ -205,7 +206,7 @@ public boolean execute(IProgressMonitor progressMonitor) { } if (!needToReindex) { if (JobManager.VERBOSE) - org.eclipse.jdt.internal.core.util.Util.verbose("-> no indexing required (index is consistent with library) for " //$NON-NLS-1$ + trace("-> no indexing required (index is consistent with library) for " //$NON-NLS-1$ + zip.getName() + " (" //$NON-NLS-1$ + (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$ this.manager.saveIndex(index); // to ensure its placed into the saved state @@ -232,7 +233,7 @@ public boolean execute(IProgressMonitor progressMonitor) { for (Enumeration e = zip.entries(); e.hasMoreElements();) { if (this.isCancelled) { if (JobManager.VERBOSE) - org.eclipse.jdt.internal.core.util.Util.verbose("-> indexing of " + zip.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> indexing of " + zip.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$ return false; } @@ -260,8 +261,9 @@ public boolean execute(IProgressMonitor progressMonitor) { JavaSearchDocument entryDocument = new JavaSearchDocument(ze, zipFilePath, new String(contents).getBytes(Charset.defaultCharset()), participant); this.manager.indexDocument(entryDocument, participant, index, indexPath); } catch (CoreException e) { - // TODO Auto-generated catch block -// e.printStackTrace(); + if (JobManager.VERBOSE) { + JavaModelManager.trace("", e); //$NON-NLS-1$ + } } } if(this.forceIndexUpdate) { @@ -271,13 +273,14 @@ public boolean execute(IProgressMonitor progressMonitor) { this.manager.saveIndex(index); } if (JobManager.VERBOSE) - org.eclipse.jdt.internal.core.util.Util.verbose("-> done indexing of " //$NON-NLS-1$ + trace("-> done indexing of " //$NON-NLS-1$ + zip.getName() + " (" //$NON-NLS-1$ + (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$ } finally { if (zip != null) { - if (JavaModelManager.ZIP_ACCESS_VERBOSE) - System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Closing ZipFile " + this.containerPath); //$NON-NLS-1$ //$NON-NLS-2$ + if (JavaModelManager.ZIP_ACCESS_VERBOSE) { + trace("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Closing ZipFile " + this.containerPath); //$NON-NLS-1$ //$NON-NLS-2$ + } zip.close(); } monitor.exitWrite(); // free write lock @@ -320,4 +323,4 @@ public String toString() { protected boolean hasPreBuiltIndex() { return !this.forceIndexUpdate && (this.indexFileURL != null && this.indexFileURL.exists()); } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJrtToIndex.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJrtToIndex.java index 8593cdd3a1..48427b9066 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJrtToIndex.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJrtToIndex.java @@ -14,6 +14,7 @@ package org.eclipse.jdt.internal.core.search.indexing; import static org.eclipse.jdt.internal.compiler.util.Util.isClassFileName; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; import java.io.File; import java.io.IOException; @@ -166,22 +167,25 @@ public boolean execute(IProgressMonitor progressMonitor) { // if index is already cached, then do not perform any check // MUST reset the IndexManager if a jar file is changed if (this.manager.getIndexForUpdate(this.containerPath, false, /*do not reuse index file*/ false /*do not create if none*/) != null) { - if (JobManager.VERBOSE) - Util.verbose("-> no indexing required (index already exists) for " + this.containerPath); //$NON-NLS-1$ + if (JobManager.VERBOSE) { + trace("-> no indexing required (index already exists) for " + this.containerPath); //$NON-NLS-1$ + } return true; } final Index index = this.manager.getIndexForUpdate(this.containerPath, true, /*reuse index file*/ true /*create if none*/); if (index == null) { - if (JobManager.VERBOSE) - Util.verbose("-> index could not be created for " + this.containerPath); //$NON-NLS-1$ + if (JobManager.VERBOSE) { + trace("-> index could not be created for " + this.containerPath); //$NON-NLS-1$ + } return true; } index.separator = JAR_SEPARATOR; ReadWriteMonitor monitor = index.monitor; if (monitor == null) { - if (JobManager.VERBOSE) - Util.verbose("-> index for " + this.containerPath + " just got deleted"); //$NON-NLS-1$//$NON-NLS-2$ + if (JobManager.VERBOSE) { + trace("-> index for " + this.containerPath + " just got deleted"); //$NON-NLS-1$//$NON-NLS-2$ + } return true; // index got deleted since acquired } try { @@ -192,20 +196,21 @@ public boolean execute(IProgressMonitor progressMonitor) { if (this.resource != null) { URI location = this.resource.getLocationURI(); if (location == null) return false; - if (JavaModelManager.JRT_ACCESS_VERBOSE) - System.out.println("(" + Thread.currentThread() + ") [AddJrtFileToIndex.execute()] Creating ZipFile on " + location.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ + if (JavaModelManager.JRT_ACCESS_VERBOSE) { + trace("(" + Thread.currentThread() + ") [AddJrtFileToIndex.execute()] Creating ZipFile on " + location.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ + } File file = null; try { file = Util.toLocalFile(location, progressMonitor); } catch (CoreException e) { if (JobManager.VERBOSE) { - Util.verbose("-> failed to index " + location.getPath() + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ - e.printStackTrace(); + trace("-> failed to index " + location.getPath() + " because of the following exception:", e); //$NON-NLS-1$ //$NON-NLS-2$ } } if (file == null) { - if (JobManager.VERBOSE) - Util.verbose("-> failed to index " + location.getPath() + " because the file could not be fetched"); //$NON-NLS-1$ //$NON-NLS-2$ + if (JobManager.VERBOSE) { + trace("-> failed to index " + location.getPath() + " because the file could not be fetched"); //$NON-NLS-1$ //$NON-NLS-2$ + } return false; } fileName = file.getAbsolutePath(); @@ -218,8 +223,9 @@ public boolean execute(IProgressMonitor progressMonitor) { } - if (JobManager.VERBOSE) - Util.verbose("-> indexing " + fileName); //$NON-NLS-1$ + if (JobManager.VERBOSE) { + trace("-> indexing " + fileName); //$NON-NLS-1$ + } long initialTime = System.currentTimeMillis(); String[] paths = index.queryDocumentNames(""); // all file names //$NON-NLS-1$ if (paths != null) { @@ -248,7 +254,7 @@ public boolean execute(IProgressMonitor progressMonitor) { } if (!needToReindex) { if (JobManager.VERBOSE) - Util.verbose("-> no indexing required (index is consistent with library) for " //$NON-NLS-1$ + trace("-> no indexing required (index is consistent with library) for " //$NON-NLS-1$ + fileName + " (" //$NON-NLS-1$ + (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$ this.manager.saveIndex(index); // to ensure its placed into the saved state @@ -276,7 +282,7 @@ public boolean execute(IProgressMonitor progressMonitor) { this.manager.saveIndex(index); } if (JobManager.VERBOSE) - Util.verbose("-> done indexing of " //$NON-NLS-1$ + trace("-> done indexing of " //$NON-NLS-1$ + fileName + " (" //$NON-NLS-1$ + (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$ } finally { @@ -315,4 +321,4 @@ public String toString() { protected boolean hasPreBuiltIndex() { return !this.forceIndexUpdate && (this.indexFileURL != null && this.indexFileURL.exists()); } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java index d88fe60a34..d247ead530 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java @@ -15,6 +15,8 @@ package org.eclipse.jdt.internal.core.search.indexing; import java.io.File; +import java.net.URI; +import java.net.URISyntaxException; import org.codehaus.jdt.groovy.integration.LanguageSupportFactory; import org.eclipse.core.runtime.IStatus; @@ -657,6 +659,23 @@ private char[] extractType(int[] constantPoolOffsets, ClassFileReader reader, in int utf8Offset = constantPoolOffsets[reader.u2At(constantPoolOffsets[constantPoolIndex] + 3)]; return reader.utf8At(utf8Offset + 3, reader.u2At(utf8Offset + 1)); } + + /** + * same as new java.io.File(absoluteNormalFilePath).toURI() if absoluteNormalFilePath is not a + * directory but faster because it avoid IO for the isDirectory check. + **/ + private URI toUri(final String absoluteNormalFilePath) { + String p = absoluteNormalFilePath.replace(File.separatorChar, '/'); + if (!p.startsWith("/")) { //$NON-NLS-1$ + p = "/" + p; //$NON-NLS-1$ + } + try { + return new URI("file", null, p, null); //$NON-NLS-1$ + } catch (URISyntaxException x) { + throw new RuntimeException(x); + } + } + @Override public void indexDocument() { try { @@ -665,7 +684,8 @@ public void indexDocument() { // contents can potentially be null if a IOException occurs while retrieving the contents if (contents == null) return; final String path = this.document.getPath(); - ClassFileReader reader = new ClassFileReader((new File(path)).toURI(), contents, path == null ? null : path.toCharArray()); + // Here we know the path of a .class file is absolute and not a directory + ClassFileReader reader = new ClassFileReader(toUri(path) , contents, path == null ? null : path.toCharArray()); IModule module = reader.getModuleDeclaration(); if (module != null) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java index a9417fdcbe..9a96b24018 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search.indexing; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.IOException; import java.net.URI; import java.util.HashSet; @@ -230,8 +232,7 @@ public boolean visit(IResourceProxy proxy) throws CoreException { this.manager.request(new SaveIndex(this.containerPath, this.manager)); } catch (CoreException | IOException e) { if (JobManager.VERBOSE) { - Util.verbose("-> failed to index " + this.project + " because of the following exception:", System.err); //$NON-NLS-1$ //$NON-NLS-2$ - e.printStackTrace(); + trace("-> failed to index " + this.project + " because of the following exception:", e); //$NON-NLS-1$ //$NON-NLS-2$ } this.manager.removeIndex(this.containerPath); return false; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexBinaryFolder.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexBinaryFolder.java index 7e5633a0e5..a6b78d17e5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexBinaryFolder.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexBinaryFolder.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search.indexing; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.IOException; import java.net.URI; @@ -137,8 +139,7 @@ public boolean visit(IResourceProxy proxy) throws CoreException { this.manager.request(new SaveIndex(this.containerPath, this.manager)); } catch (CoreException | IOException e) { if (JobManager.VERBOSE) { - Util.verbose("-> failed to index " + this.folder + " because of the following exception:", System.err); //$NON-NLS-1$ //$NON-NLS-2$ - e.printStackTrace(); + trace("-> failed to index " + this.folder + " because of the following exception:", e); //$NON-NLS-1$ //$NON-NLS-2$ } this.manager.removeIndex(this.containerPath); return false; diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java index 9782a1cce4..232459542b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search.indexing; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; @@ -124,8 +126,8 @@ public class IndexManager extends JobManager implements IIndexConstants { * synchronized by IndexManager.this */ private SimpleLookupTable indexStates; - private File indexNamesMapFile = new File(getSavedIndexesDirectory(), "indexNamesMap.txt"); //$NON-NLS-1$ - private File participantIndexNamesFile = new File(getSavedIndexesDirectory(), "participantsIndexNames.txt"); //$NON-NLS-1$ + private final File indexNamesMapFile = new File(getSavedIndexesDirectory(), "indexNamesMap.txt"); //$NON-NLS-1$ + private final File participantIndexNamesFile = new File(getSavedIndexesDirectory(), "participantsIndexNames.txt"); //$NON-NLS-1$ private boolean javaLikeNamesChanged = true; public static final Integer SAVED_STATE = 0; public static final Integer UPDATING_STATE = 1; @@ -342,7 +344,7 @@ public synchronized IndexLocation computeIndexLocation(IPath containerPath) { checksumCalculator.update(pathString.getBytes()); String fileName = Long.toString(checksumCalculator.getValue()) + ".index"; //$NON-NLS-1$ if (VERBOSE) - Util.verbose("-> index name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> index name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$ // to share the indexLocation between the indexLocations and indexStates tables, get the key from the indexStates table indexLocation = (IndexLocation) getIndexStates().getKey(new FileIndexLocation(new File(getSavedIndexesDirectory(), fileName))); this.indexLocations.put(containerPath, indexLocation); @@ -357,7 +359,7 @@ public final void deleteIndexFiles() { } public synchronized void deleteIndexFiles(IProgressMonitor monitor) { if (DEBUG) - Util.verbose("Deleting index files"); //$NON-NLS-1$ + trace("Deleting index files"); //$NON-NLS-1$ this.nameRegistry.delete(); // forget saved indexes & delete each index file deleteIndexFiles(null, monitor); this.metaIndex = null; @@ -374,7 +376,7 @@ private void deleteIndexFiles(SimpleSet pathsToKeep, IProgressMonitor monitor) { String suffix = ".index"; //$NON-NLS-1$ if (fileName.regionMatches(true, fileName.length() - suffix.length(), suffix, 0, suffix.length())) { if (VERBOSE || DEBUG) - Util.verbose("Deleting index file " + indexesFiles[i]); //$NON-NLS-1$ + trace("Deleting index file " + indexesFiles[i]); //$NON-NLS-1$ indexesFiles[i].delete(); } } @@ -470,7 +472,7 @@ public synchronized Index getIndex(IPath containerPath, IndexLocation indexLocat // failed to read the existing file or its no longer compatible if (currentIndexState != REBUILDING_STATE && currentIndexState != REUSE_STATE) { // rebuild index if existing file is corrupt, unless the index is already being rebuilt if (VERBOSE) - Util.verbose("-> cannot reuse existing index: "+indexLocation+" path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> cannot reuse existing index: "+indexLocation+" path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ rebuildIndex(indexLocation, containerPath); return null; } @@ -484,7 +486,7 @@ public synchronized Index getIndex(IPath containerPath, IndexLocation indexLocat if (currentIndexState == REUSE_STATE) { // supposed to be in reuse state but error in the index file, so reindex. if (VERBOSE) - Util.verbose("-> cannot reuse given index: "+indexLocation+" path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> cannot reuse given index: "+indexLocation+" path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ if(!IS_MANAGING_PRODUCT_INDEXES_PROPERTY) { this.indexLocations.put(containerPath, null); indexLocation = computeIndexLocation(containerPath); @@ -500,19 +502,18 @@ public synchronized Index getIndex(IPath containerPath, IndexLocation indexLocat if (createIfMissing) { try { if (VERBOSE) - Util.verbose("-> create empty index: "+indexLocation+" path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> create empty index: "+indexLocation+" path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ index = new Index(indexLocation, containerPathString, false /*do not reuse index file*/); this.indexes.put(indexLocation, index); return index; } catch (IOException e) { if (VERBOSE) - Util.verbose("-> unable to create empty index: "+indexLocation+" path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> unable to create empty index: "+indexLocation+" path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ // The file could not be created. Possible reason: the project has been deleted. return null; } } } - //System.out.println(" index name: " + path.toOSString() + " <----> " + index.getIndexFile().getName()); return index; } /** @@ -550,7 +551,7 @@ public synchronized Index[] getIndexes(IndexLocation[] locations, IProgressMonit File indexFile = index.getIndexFile(); if (indexFile.exists()) { if (DEBUG) - Util.verbose("Change in javaLikeNames - removing index file for " + containerPath ); //$NON-NLS-1$ + trace("Change in javaLikeNames - removing index file for " + containerPath ); //$NON-NLS-1$ indexFile.delete(); } this.indexes.put(indexLocation, null); @@ -602,7 +603,7 @@ private SimpleLookupTable getIndexStates() { if (savedName.length > 0) { IndexLocation indexLocation = new FileIndexLocation(new File(indexesDirectoryPath, String.valueOf(savedName))); // shares indexesDirectoryPath's segments if (VERBOSE) - Util.verbose("Reading saved index file " + indexLocation); //$NON-NLS-1$ + trace("Reading saved index file " + indexLocation); //$NON-NLS-1$ this.indexStates.put(indexLocation, SAVED_STATE); } } @@ -647,13 +648,13 @@ private boolean hasJavaLikeNamesChanged() { char[][] prevNames = readJavaLikeNamesFile(); if (prevNames == null) { if (VERBOSE && current != 1) - Util.verbose("No Java like names found and there is atleast one non-default javaLikeName", System.err); //$NON-NLS-1$ + trace("No Java like names found and there is atleast one non-default javaLikeName"); //$NON-NLS-1$ return (current != 1); //Ignore if only java } int prev = prevNames.length; if (current != prev) { if (VERBOSE) - Util.verbose("Java like names have changed", System.err); //$NON-NLS-1$ + trace("Java like names have changed"); //$NON-NLS-1$ return true; } if (current > 1) { @@ -668,7 +669,7 @@ private boolean hasJavaLikeNamesChanged() { for (int i = 0; i < current; i++) { if (!CharOperation.equals(currentNames[i],prevNames[i])) { if (VERBOSE) - Util.verbose("Java like names have changed", System.err); //$NON-NLS-1$ + trace("Java like names have changed"); //$NON-NLS-1$ return true; } } @@ -861,7 +862,7 @@ private char[][] readJavaLikeNamesFile() { } } catch (IOException ignored) { if (VERBOSE) - Util.verbose("Failed to read javaLikeNames file"); //$NON-NLS-1$ + trace("Failed to read javaLikeNames file"); //$NON-NLS-1$ } return null; } @@ -875,7 +876,7 @@ private void rebuildIndex(IndexLocation indexLocation, IPath containerPath, fina if (target == null) return; if (VERBOSE) - Util.verbose("-> request to rebuild index: "+indexLocation+" path: "+containerPath); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> request to rebuild index: "+indexLocation+" path: "+containerPath); //$NON-NLS-1$ //$NON-NLS-2$ updateIndexState(indexLocation, REBUILDING_STATE); IndexRequest request = null; @@ -910,7 +911,7 @@ public synchronized Index recreateIndex(IPath containerPath) { ReadWriteMonitor monitor = index == null ? null : index.monitor; if (VERBOSE) - Util.verbose("-> recreating index: "+indexLocation+" for path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> recreating index: "+indexLocation+" for path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ index = new Index(indexLocation, containerPathString, false /*do not reuse index file*/); this.indexes.put(indexLocation, index); index.monitor = monitor; @@ -918,8 +919,7 @@ public synchronized Index recreateIndex(IPath containerPath) { } catch (IOException e) { // The file could not be created. Possible reason: the project has been deleted. if (VERBOSE) { - Util.verbose("-> failed to recreate index for path: "+containerPathString); //$NON-NLS-1$ - e.printStackTrace(); + trace("-> failed to recreate index for path: "+containerPathString, e); //$NON-NLS-1$ } return null; } @@ -942,7 +942,7 @@ public void removeIndex(IPath containerPath) { Index index = null; synchronized (this) { if (VERBOSE || DEBUG) - Util.verbose("removing index " + containerPath); //$NON-NLS-1$ + trace("removing index " + containerPath); //$NON-NLS-1$ // New index is disabled, see bug 544898 // this.indexer.makeWorkspacePathDirty(containerPath); IndexLocation indexLocation = computeIndexLocation(containerPath); @@ -958,7 +958,7 @@ public void removeIndex(IPath containerPath) { this.indexLocations.put(containerPath, null); } else if (indexFile != null && indexFile.exists()) { if (DEBUG) - Util.verbose("removing index file " + indexFile); //$NON-NLS-1$ + trace("removing index file " + indexFile); //$NON-NLS-1$ indexFile.delete(); } this.indexes.removeKey(indexLocation); @@ -982,9 +982,8 @@ void removeFromMetaIndex(Index index, File indexFile, IPath containerPath) { updateMetaIndex(indexFile.getName(), Collections.emptyList()); } else { if (VERBOSE) { - Util.verbose( - String.format("Unable to update meta index for container path %s because index file is null", //$NON-NLS-1$ - containerPath)); + trace(String.format("Unable to update meta index for container path %s because index file is null", //$NON-NLS-1$ + containerPath)); } } } @@ -996,7 +995,7 @@ public void removeIndexPath(IPath path) { synchronized (this) { if (VERBOSE || DEBUG) - Util.verbose("removing index path " + path); //$NON-NLS-1$ + trace("removing index path " + path); //$NON-NLS-1$ // New index is disabled, see bug 544898 // this.indexer.makeWorkspacePathDirty(path); Object[] keyTable = this.indexes.keyTable; @@ -1022,7 +1021,7 @@ public void removeIndexPath(IPath path) { indexLocation.close(); } else { if (DEBUG) - Util.verbose("removing index file " + indexLocation); //$NON-NLS-1$ + trace("removing index file " + indexLocation); //$NON-NLS-1$ indexLocation.delete(); } } else { @@ -1114,7 +1113,7 @@ public synchronized boolean resetIndex(IPath containerPath) { IndexLocation indexLocation = computeIndexLocation(containerPath); Index index = getIndex(indexLocation); if (VERBOSE) { - Util.verbose("-> reseting index: "+indexLocation+" for path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> reseting index: "+indexLocation+" for path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ } if (index == null) { // the index does not exist, try to recreate it @@ -1125,8 +1124,7 @@ public synchronized boolean resetIndex(IPath containerPath) { } catch (IOException e) { // The file could not be created. Possible reason: the project has been deleted. if (VERBOSE) { - Util.verbose("-> failed to reset index for path: "+containerPathString); //$NON-NLS-1$ - e.printStackTrace(); + trace("-> failed to reset index for path: "+containerPathString, e); //$NON-NLS-1$ } return false; } @@ -1141,7 +1139,7 @@ public synchronized boolean resetIndex(IPath containerPath) { public void savePreBuiltIndex(Index index) throws IOException { if (index.hasChanged()) { if (VERBOSE) - Util.verbose("-> saving pre-build index " + index.getIndexLocation()); //$NON-NLS-1$ + trace("-> saving pre-build index " + index.getIndexLocation()); //$NON-NLS-1$ index.save(); updateMetaIndex(index); } @@ -1156,12 +1154,12 @@ public void saveIndex(Index index) throws IOException { // must have permission to write from the write monitor if (index.hasChanged()) { if (VERBOSE) - Util.verbose("-> saving index " + index.getIndexLocation()); //$NON-NLS-1$ + trace("-> saving index " + index.getIndexLocation()); //$NON-NLS-1$ if (index.save()) { updateMetaIndex(index); } else { if (VERBOSE) - Util.verbose("-> saving index cancelled " + index.getIndexLocation()); //$NON-NLS-1$ + trace("-> saving index cancelled " + index.getIndexLocation()); //$NON-NLS-1$ return; } } @@ -1346,7 +1344,7 @@ private void readIndexMap() { } } catch (IOException ignored) { if (VERBOSE) - Util.verbose("Failed to read saved index file names"); //$NON-NLS-1$ + trace("Failed to read saved index file names"); //$NON-NLS-1$ } return; } @@ -1368,7 +1366,7 @@ private void readParticipantsIndexNamesFile() { } } catch (IOException ignored) { if (VERBOSE) - Util.verbose("Failed to read participant index file names"); //$NON-NLS-1$ + trace("Failed to read participant index file names"); //$NON-NLS-1$ } this.participantsContainers = containers; return; @@ -1382,7 +1380,7 @@ private synchronized void removeIndexesState(IndexLocation[] locations) { if ((this.indexStates.removeKey(locations[i]) != null)) { changed = true; if (VERBOSE) { - Util.verbose("-> index state updated to: ? for: "+locations[i]); //$NON-NLS-1$ + trace("-> index state updated to: ? for: "+locations[i]); //$NON-NLS-1$ } } } @@ -1408,7 +1406,7 @@ private synchronized void updateIndexState(IndexLocation indexLocation, Integer if (VERBOSE) { if (indexState == null) { - Util.verbose("-> index state removed for: "+indexLocation); //$NON-NLS-1$ + trace("-> index state removed for: "+indexLocation); //$NON-NLS-1$ } else { String state = "?"; //$NON-NLS-1$ if (indexState == SAVED_STATE) state = "SAVED"; //$NON-NLS-1$ @@ -1416,7 +1414,7 @@ private synchronized void updateIndexState(IndexLocation indexLocation, Integer else if (indexState == UNKNOWN_STATE) state = "UNKNOWN"; //$NON-NLS-1$ else if (indexState == REBUILDING_STATE) state = "REBUILDING"; //$NON-NLS-1$ else if (indexState == REUSE_STATE) state = "REUSE"; //$NON-NLS-1$ - Util.verbose("-> index state updated to: " + state + " for: "+indexLocation); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> index state updated to: " + state + " for: "+indexLocation); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -1454,7 +1452,7 @@ private void writeJavaLikeNamesFile() { } catch (IOException ignored) { if (VERBOSE) - Util.verbose("Failed to write javaLikeNames file", System.err); //$NON-NLS-1$ + trace("Failed to write javaLikeNames file"); //$NON-NLS-1$ } finally { if (writer != null) { try { @@ -1487,7 +1485,7 @@ private void writeIndexMapFile() { } } catch (IOException ignored) { if (VERBOSE) - Util.verbose("Failed to write saved index file names", System.err); //$NON-NLS-1$ + trace("Failed to write saved index file names"); //$NON-NLS-1$ } finally { if (writer != null) { try { @@ -1517,7 +1515,7 @@ private void writeParticipantsIndexNamesFile() { } } catch (IOException ignored) { if (VERBOSE) - Util.verbose("Failed to write participant index file names", System.err); //$NON-NLS-1$ + trace("Failed to write participant index file names"); //$NON-NLS-1$ } finally { if (writer != null) { try { @@ -1605,7 +1603,7 @@ public Optional> findMatchingIndexNames(QualifierQuery query) { indexesNotInMeta = mindex.getIndexesNotInMeta(this.indexes); } if (VERBOSE) { - Util.verbose("-> not in meta-index: " + indexesNotInMeta.size() + ", in: "+results.size() + " for query " + query); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + trace("-> not in meta-index: " + indexesNotInMeta.size() + ", in: "+results.size() + " for query " + query); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } final Index i = mindex.getIndex(); return Optional.of(Stream.concat(indexesNotInMeta.stream(), results.stream().flatMap(r -> { @@ -1625,7 +1623,7 @@ public Optional> findMatchingIndexNames(QualifierQuery query) { } finally { if (VERBOSE) { long wallClockTime = System.currentTimeMillis() - startTime; - Util.verbose("-> execution time: " + wallClockTime + "ms - IndexManager#findMatchingIndexNames");//$NON-NLS-1$//$NON-NLS-2$ + trace("-> execution time: " + wallClockTime + "ms - IndexManager#findMatchingIndexNames");//$NON-NLS-1$//$NON-NLS-2$ } } } @@ -1650,21 +1648,21 @@ private MetaIndex loadMetaIndexIfNeeded() throws IOException { Integer currentIndexState = state == null ? UNKNOWN_STATE : (Integer) state; if(UNKNOWN_STATE.equals(currentIndexState)) { if (VERBOSE) { - Util.verbose("-> create empty meta-index: "+indexLocation+" path: "+INDEX_META_CONTAINER); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> create empty meta-index: "+indexLocation+" path: "+INDEX_META_CONTAINER); //$NON-NLS-1$ //$NON-NLS-2$ } this.metaIndex = new MetaIndex(new Index(indexLocation, INDEX_META_CONTAINER, false)); updateIndexState(indexLocation, REUSE_STATE); } else if(indexLocation.exists()) { if (VERBOSE) { - Util.verbose("-> load existing meta-index: "+indexLocation+" path: "+INDEX_META_CONTAINER); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> load existing meta-index: "+indexLocation+" path: "+INDEX_META_CONTAINER); //$NON-NLS-1$ //$NON-NLS-2$ } try { this.metaIndex = new MetaIndex(new Index(indexLocation, INDEX_META_CONTAINER, true)); } catch (IOException e) { Util.log(e, "Failed to read saved meta index, re-creating"); //$NON-NLS-1$ if (VERBOSE) { - Util.verbose("-> failed to read saved meta-index: "+indexLocation+" path: "+INDEX_META_CONTAINER); //$NON-NLS-1$ //$NON-NLS-2$ - Util.verbose("-> re-create meta-index: "+indexLocation+" path: "+INDEX_META_CONTAINER); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> failed to read saved meta-index: "+indexLocation+" path: "+INDEX_META_CONTAINER); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> re-create meta-index: "+indexLocation+" path: "+INDEX_META_CONTAINER); //$NON-NLS-1$ //$NON-NLS-2$ } indexLocation.delete(); this.metaIndex = new MetaIndex(new Index(indexLocation, INDEX_META_CONTAINER, false)); @@ -1705,7 +1703,7 @@ void updateMetaIndex(String indexFileName, List qualifications) } if (VERBOSE) { int qsize = qualifications.size(); - Util.verbose("-> updating meta-index with " + qsize + " elements for " + indexFileName); //$NON-NLS-1$ //$NON-NLS-2$ + trace("-> updating meta-index with " + qsize + " elements for " + indexFileName); //$NON-NLS-1$ //$NON-NLS-2$ } monitor.enterWrite(); // clean existing entries for current document @@ -1715,12 +1713,11 @@ void updateMetaIndex(String indexFileName, List qualifications) mindex.addIndexEntry(qualifier.getCategory(), qualifier.getKey(), indexFileName); } if (VERBOSE) { - Util.verbose("-> meta-index updated for " + indexFileName); //$NON-NLS-1$ + trace("-> meta-index updated for " + indexFileName); //$NON-NLS-1$ } } catch (IOException e) { if (JobManager.VERBOSE) { - Util.verbose("-> failed to update meta index for index " + indexFileName + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ - e.printStackTrace(); + trace("-> failed to update meta index for index " + indexFileName + " because of the following exception:", e); //$NON-NLS-1$ //$NON-NLS-2$ } } finally { if(monitor != null) { @@ -1745,7 +1742,7 @@ public Optional getMetaIndex() { void scheduleForMetaIndexUpdate(Index index) { synchronized(this.metaIndexUpdates){ if (!this.metaIndexUpdates.add(index) && VERBOSE) { - Util.verbose("-> already waiting for meta-index update for " + index); //$NON-NLS-1$ + trace("-> already waiting for meta-index update for " + index); //$NON-NLS-1$ } } requestIfNotWaiting(new MetaIndexUpdateRequest()); @@ -1794,7 +1791,7 @@ public boolean execute(IProgressMonitor progress) { continue; } if (VERBOSE) { - Util.verbose("-> meta-index update from queue with size " + metaIndexUpdatesSize); //$NON-NLS-1$ + trace("-> meta-index update from queue with size " + metaIndexUpdatesSize); //$NON-NLS-1$ } try { updateMetaIndex(indexFile.getName(), index.getMetaIndexQualifications()); @@ -1804,9 +1801,8 @@ public boolean execute(IProgressMonitor progress) { Util.log(e, "Failed to update meta index"); //$NON-NLS-1$ } else { if (JobManager.VERBOSE) { - Util.verbose("-> failed to update meta index for index " + indexFile.getName() //$NON-NLS-1$ - + " because of the following exception:"); //$NON-NLS-1$ - e.printStackTrace(); + trace("-> failed to update meta index for index " + indexFile.getName() //$NON-NLS-1$ + + " because of the following exception:", e); //$NON-NLS-1$ } } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexNamesRegistry.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexNamesRegistry.java index e9ec3562d1..63881567ae 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexNamesRegistry.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexNamesRegistry.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search.indexing; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; @@ -25,7 +27,6 @@ import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.core.index.DiskIndex; import org.eclipse.jdt.internal.core.search.processing.JobManager; -import org.eclipse.jdt.internal.core.util.Util; public class IndexNamesRegistry { private final File savedIndexNamesFile; @@ -83,7 +84,7 @@ public char[][] read(IProgressMonitor monitor) { } } catch (IOException ignored) { if (JobManager.VERBOSE) - Util.verbose("Failed to read saved index file names"); //$NON-NLS-1$ + trace("Failed to read saved index file names"); //$NON-NLS-1$ } return null; } @@ -100,7 +101,7 @@ private void save(IProgressMonitor monitor) { } subMonitor.setWorkRemaining(newContents.length); - + try (BufferedWriter writer = new BufferedWriter(new FileWriter(this.savedIndexNamesFile))) { writer.write(DiskIndex.SIGNATURE); writer.write('+'); @@ -113,7 +114,7 @@ private void save(IProgressMonitor monitor) { } } catch (IOException ignored) { if (JobManager.VERBOSE) - Util.verbose("Failed to write saved index file names", System.err); //$NON-NLS-1$ + trace("Failed to write saved index file names"); //$NON-NLS-1$ } synchronized (this.queueMutex) { @@ -136,6 +137,6 @@ public void delete() { synchronized (this.queueMutex) { this.pendingWrite = null; } - this.savedIndexNamesFile.delete(); + this.savedIndexNamesFile.delete(); } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/QualifierQuery.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/QualifierQuery.java index a84f09fe2f..79acc13417 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/QualifierQuery.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/QualifierQuery.java @@ -33,11 +33,11 @@ public static QueryCategory[] fromEncoded(char[][] encoded) { } - private QueryCategory[] categories; + private final QueryCategory[] categories; - private char[] simpleKey; + private final char[] simpleKey; - private char[] qualifiedKey; + private final char[] qualifiedKey; private QualifierQuery(QueryCategory[] categories, char[] simpleKey, char[] qualifiedKey) { this.categories = categories; @@ -67,4 +67,4 @@ public char[] getQualifiedKey() { public char[] getSimpleKey() { return this.simpleKey; } -} \ No newline at end of file +} diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFolderFromIndex.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFolderFromIndex.java index 791fb697c0..9d7c1d7c21 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFolderFromIndex.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFolderFromIndex.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search.indexing; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.IOException; import org.eclipse.core.resources.IProject; @@ -65,8 +67,7 @@ public boolean execute(IProgressMonitor progressMonitor) { } } catch (IOException e) { if (JobManager.VERBOSE) { - Util.verbose("-> failed to remove " + this.folderPath + " from index because of the following exception:", System.err); //$NON-NLS-1$ //$NON-NLS-2$ - e.printStackTrace(); + trace("-> failed to remove " + this.folderPath + " from index because of the following exception:", e); //$NON-NLS-1$ //$NON-NLS-2$ } return false; } finally { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SaveIndex.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SaveIndex.java index ce04b3f0dc..5c24d5197e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SaveIndex.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SaveIndex.java @@ -13,13 +13,14 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search.indexing; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.IOException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jdt.internal.core.index.Index; import org.eclipse.jdt.internal.core.search.processing.JobManager; -import org.eclipse.jdt.internal.core.util.Util; /* * Save the index of a project. @@ -44,8 +45,7 @@ public boolean execute(IProgressMonitor progressMonitor) { this.manager.saveIndex(index); } catch (IOException e) { if (JobManager.VERBOSE) { - Util.verbose("-> failed to save index " + this.containerPath + " because of the following exception:", System.err); //$NON-NLS-1$ //$NON-NLS-2$ - e.printStackTrace(); + trace("-> failed to save index " + this.containerPath + " because of the following exception:", e); //$NON-NLS-1$ //$NON-NLS-2$ } return false; } finally { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java index e2050983f8..5f5548c600 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java @@ -13,6 +13,7 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search.indexing; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; @@ -114,7 +115,7 @@ public void indexDocument() { this.document.requireIndexingResolvedDocument(); } catch (Exception e) { if (JobManager.VERBOSE) { - e.printStackTrace(); + trace("", e); //$NON-NLS-1$ } } } @@ -172,7 +173,7 @@ public void resolveDocument() { this.cud.resolve(); } catch (Exception e) { if (JobManager.VERBOSE) { - e.printStackTrace(); + trace("", e); //$NON-NLS-1$ } } } @@ -213,7 +214,9 @@ private void purgeMethodStatements(TypeDeclaration type) { @Override public void indexResolvedDocument() { try { - if (DEBUG) System.out.println(new String(this.cud.compilationResult.fileName) + ':'); + if (DEBUG) { + trace(new String(this.cud.compilationResult.fileName) + ':'); + } for (int i = 0, length = this.cud.functionalExpressionsCount; i < length; i++) { FunctionalExpression expression = this.cud.functionalExpressions[i]; if (expression instanceof LambdaExpression) { @@ -221,7 +224,7 @@ public void indexResolvedDocument() { if (lambdaExpression.binding != null && lambdaExpression.binding.isValidBinding()) { final char[] superinterface = lambdaExpression.resolvedType.sourceName(); if (DEBUG) { - System.out.println('\t' + new String(superinterface) + '.' + + trace('\t' + new String(superinterface) + '.' + new String(lambdaExpression.descriptor.selector) + "-> {}"); //$NON-NLS-1$ } SourceIndexer.this.addIndexEntry(IIndexConstants.METHOD_DECL, MethodPattern.createIndexKey(lambdaExpression.descriptor.selector, lambdaExpression.descriptor.parameters.length)); @@ -236,7 +239,9 @@ public void indexResolvedDocument() { true); // not primary. } else { - if (DEBUG) System.out.println("\tnull/bad binding in lambda"); //$NON-NLS-1$ + if (DEBUG) { + trace("\tnull/bad binding in lambda"); //$NON-NLS-1$ + } } } else { ReferenceExpression referenceExpression = (ReferenceExpression) expression; @@ -245,7 +250,7 @@ public void indexResolvedDocument() { MethodBinding binding = referenceExpression.getMethodBinding(); if (binding != null && binding.isValidBinding()) { if (DEBUG) { - System.out.println('\t' + new String(referenceExpression.resolvedType.sourceName()) + "::" //$NON-NLS-1$ + trace('\t' + new String(referenceExpression.resolvedType.sourceName()) + "::" //$NON-NLS-1$ + new String(referenceExpression.descriptor.selector) + " == " + new String(binding.declaringClass.sourceName()) + '.' + //$NON-NLS-1$ new String(binding.selector)); } @@ -254,13 +259,15 @@ public void indexResolvedDocument() { else SourceIndexer.this.addConstructorReference(binding.declaringClass.sourceName(), binding.parameters.length); } else { - if (DEBUG) System.out.println("\tnull/bad binding in reference expression"); //$NON-NLS-1$ + if (DEBUG) { + trace("\tnull/bad binding in reference expression"); //$NON-NLS-1$ + } } } } } catch (Exception e) { if (JobManager.VERBOSE) { - e.printStackTrace(); + trace("", e); //$NON-NLS-1$ } } } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java index cf7ed4173b..0570c7c52a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java @@ -13,10 +13,14 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search.indexing; +import static org.eclipse.jdt.internal.core.JavaModelManager.traceDumpStack; + import java.util.ArrayList; import java.util.List; + import org.eclipse.jdt.core.Signature; -import org.eclipse.jdt.core.compiler.*; +import org.eclipse.jdt.core.compiler.CategorizedProblem; +import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.compiler.ExtraFlags; import org.eclipse.jdt.internal.compiler.ISourceElementRequestor; import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; @@ -522,11 +526,7 @@ public void popTypeName() { this.enclosingTypeNames[--this.depth] = null; } else if (JobManager.VERBOSE) { // dump a trace so it can be tracked down - try { - this.enclosingTypeNames[-1] = null; - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - } + traceDumpStack(); } } public void pushTypeName(char[] typeName) { @@ -534,4 +534,12 @@ public void pushTypeName(char[] typeName) { System.arraycopy(this.enclosingTypeNames, 0, this.enclosingTypeNames = new char[this.depth*2][], 0, this.depth); this.enclosingTypeNames[this.depth++] = typeName; } +@Override +public void enterCompactConstructor(MethodInfo methodInfo) { + this.enterConstructor(methodInfo); +} +@Override +public void exitCompactConstructor(int declarationEnd) { + this.exitConstructor(declarationEnd); +} } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldLocator.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldLocator.java index c2129a04d8..9aa486118e 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldLocator.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldLocator.java @@ -260,7 +260,6 @@ protected void matchReportReference(ASTNode reference, IJavaElement element, IJa /* (non-Javadoc) * Overridden to reject unexact matches. * @see org.eclipse.jdt.internal.core.search.matching.PatternLocator#updateMatch(org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding, char[][][], org.eclipse.jdt.internal.core.search.matching.MatchLocator) - * */ @Override protected void updateMatch(ParameterizedTypeBinding parameterizedBinding, char[][][] patternTypeArguments, MatchLocator locator) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java index 8f478e9322..2a103fe53d 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java @@ -14,6 +14,7 @@ package org.eclipse.jdt.internal.core.search.matching; import static java.util.stream.Collectors.joining; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; import java.util.Collections; import java.util.HashMap; @@ -56,6 +57,7 @@ import org.eclipse.jdt.internal.core.NameLookup; import org.eclipse.jdt.internal.core.PackageFragmentRoot; import org.eclipse.jdt.internal.core.builder.ClasspathLocation; +import org.eclipse.jdt.internal.core.search.processing.JobManager; import org.eclipse.jdt.internal.core.util.Util; /* @@ -86,9 +88,9 @@ public JavaSearchNameEnvironment(IJavaProject javaProject, org.eclipse.jdt.core. long start = 0; if (NameLookup.VERBOSE) { - Util.verbose(" BUILDING JavaSearchNameEnvironment"); //$NON-NLS-1$ - Util.verbose(" -> project: " + javaProject); //$NON-NLS-1$ - Util.verbose(" -> working copy size: " + (copies == null ? 0 : copies.length)); //$NON-NLS-1$ + trace(" BUILDING JavaSearchNameEnvironment"); //$NON-NLS-1$ + trace(" -> project: " + javaProject); //$NON-NLS-1$ + trace(" -> working copy size: " + (copies == null ? 0 : copies.length)); //$NON-NLS-1$ start = System.currentTimeMillis(); } @@ -109,7 +111,7 @@ public JavaSearchNameEnvironment(IJavaProject javaProject, org.eclipse.jdt.core. */ //throw new IllegalArgumentException("Missing source folder for searching working copies: " + javaProject); //$NON-NLS-1$ if (NameLookup.VERBOSE) { - Util.verbose(" -> ignoring working copies; no ClasspathSourceDirectory on project classpath "); //$NON-NLS-1$ + trace(" -> ignoring working copies; no ClasspathSourceDirectory on project classpath "); //$NON-NLS-1$ } } else { for (String qualifiedMainTypeName : this.workingCopies.keySet()) { @@ -126,9 +128,9 @@ public JavaSearchNameEnvironment(IJavaProject javaProject, org.eclipse.jdt.core. if (NameLookup.VERBOSE) { - Util.verbose(" -> pkg roots size: " + (this.locationSet == null ? 0 : this.locationSet.size())); //$NON-NLS-1$ - Util.verbose(" -> pkgs size: " + this.packageNameToClassPathLocations.size()); //$NON-NLS-1$ - Util.verbose(" -> spent: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" -> pkg roots size: " + (this.locationSet == null ? 0 : this.locationSet.size())); //$NON-NLS-1$ + trace(" -> pkgs size: " + this.packageNameToClassPathLocations.size()); //$NON-NLS-1$ + trace(" -> spent: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -168,8 +170,8 @@ public void cleanup() { void addProjectClassPath(JavaProject javaProject, boolean onlyExported) { long start = 0; if (NameLookup.VERBOSE) { - Util.verbose(" EXTENDING JavaSearchNameEnvironment"); //$NON-NLS-1$ - Util.verbose(" -> project: " + javaProject); //$NON-NLS-1$ + trace(" EXTENDING JavaSearchNameEnvironment"); //$NON-NLS-1$ + trace(" -> project: " + javaProject); //$NON-NLS-1$ start = System.currentTimeMillis(); } @@ -177,9 +179,9 @@ void addProjectClassPath(JavaProject javaProject, boolean onlyExported) { if (locations != null) this.locationSet.addAll(locations); if (NameLookup.VERBOSE) { - Util.verbose(" -> pkg roots size: " + (this.locationSet == null ? 0 : this.locationSet.size())); //$NON-NLS-1$ - Util.verbose(" -> pkgs size: " + this.packageNameToClassPathLocations.size()); //$NON-NLS-1$ - Util.verbose(" -> spent: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" -> pkg roots size: " + (this.locationSet == null ? 0 : this.locationSet.size())); //$NON-NLS-1$ + trace(" -> pkgs size: " + this.packageNameToClassPathLocations.size()); //$NON-NLS-1$ + trace(" -> spent: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -199,7 +201,9 @@ private LinkedHashSet computeClasspathLocations(JavaProject j try { projectModule = javaProject.getModuleDescription(); } catch (JavaModelException e) { - // e.printStackTrace(); // ignore + if (JobManager.VERBOSE) { + trace("", e); //$NON-NLS-1$ + } } LinkedHashSet locations = new LinkedHashSet(); @@ -399,9 +403,9 @@ private NameEnvironmentAnswer findClass(String qualifiedTypeName, char[] typeNam if (!answer.ignoreIfBetter()) { if (answer.isBetter(suggestedAnswer)) { if(NameLookup.VERBOSE) { - Util.verbose(" Result for JavaSearchNameEnvironment#findClass( " + qualifiedTypeName + ", " + CharOperation.charToString(typeName) + ", " + strategy + ", " + moduleName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - Util.verbose(" -> answer: " + answer); //$NON-NLS-1$ - Util.verbose(" -> location: " + location); //$NON-NLS-1$ + trace(" Result for JavaSearchNameEnvironment#findClass( " + qualifiedTypeName + ", " + CharOperation.charToString(typeName) + ", " + strategy + ", " + moduleName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + trace(" -> answer: " + answer); //$NON-NLS-1$ + trace(" -> location: " + location); //$NON-NLS-1$ } return answer; } @@ -409,9 +413,9 @@ private NameEnvironmentAnswer findClass(String qualifiedTypeName, char[] typeNam // remember suggestion and keep looking suggestedAnswer = answer; if(NameLookup.VERBOSE) { - Util.verbose(" Potential answer for JavaSearchNameEnvironment#findClass( " + qualifiedTypeName + ", " + CharOperation.charToString(typeName) + ", " + strategy + ", " + moduleName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - Util.verbose(" -> answer: " + answer); //$NON-NLS-1$ - Util.verbose(" -> location: " + location); //$NON-NLS-1$ + trace(" Potential answer for JavaSearchNameEnvironment#findClass( " + qualifiedTypeName + ", " + CharOperation.charToString(typeName) + ", " + strategy + ", " + moduleName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + trace(" -> answer: " + answer); //$NON-NLS-1$ + trace(" -> location: " + location); //$NON-NLS-1$ } } } @@ -420,7 +424,7 @@ private NameEnvironmentAnswer findClass(String qualifiedTypeName, char[] typeNam // no better answer was found return suggestedAnswer; if(NameLookup.VERBOSE) { - Util.verbose(" NO result for JavaSearchNameEnvironment#findClass( " + qualifiedTypeName + ", " + CharOperation.charToString(typeName) + ", " + strategy + ", " + moduleName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + trace(" NO result for JavaSearchNameEnvironment#findClass( " + qualifiedTypeName + ", " + CharOperation.charToString(typeName) + ", " + strategy + ", " + moduleName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ } return null; } @@ -436,18 +440,18 @@ private NameEnvironmentAnswer findClass(String qualifiedTypeName, char[] typeNam LinkedHashSet cpls = this.packageNameToClassPathLocations.get(qualifiedPackageName); if(cpls == null) { if(NameLookup.VERBOSE) { - Util.verbose(" No result for JavaSearchNameEnvironment#getLocationsFor( " + moduleName + ", " + qualifiedPackageName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + trace(" No result for JavaSearchNameEnvironment#getLocationsFor( " + moduleName + ", " + qualifiedPackageName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } return Collections.emptySet(); } if(NameLookup.VERBOSE) { - Util.verbose(" Result for JavaSearchNameEnvironment#getLocationsFor( " + moduleName + ", " + qualifiedPackageName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - Util.verbose(" -> " + cpls.stream().map(Object::toString).collect(joining(" | "))); //$NON-NLS-1$ //$NON-NLS-2$ + trace(" Result for JavaSearchNameEnvironment#getLocationsFor( " + moduleName + ", " + qualifiedPackageName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + trace(" -> " + cpls.stream().map(Object::toString).collect(joining(" | "))); //$NON-NLS-1$ //$NON-NLS-2$ } return cpls; } if(NameLookup.VERBOSE) { - Util.verbose(" Potentially expensive search in JavaSearchNameEnvironment#getLocationsFor( " + moduleName + ", " + qualifiedPackageName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + trace(" Potentially expensive search in JavaSearchNameEnvironment#getLocationsFor( " + moduleName + ", " + qualifiedPackageName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } return this.locationSet; } @@ -502,8 +506,8 @@ public char[][] getModulesDeclaringPackage(char[][] packageName, char[] moduleNa } } if(NameLookup.VERBOSE) { - Util.verbose(" Result for JavaSearchNameEnvironment#getModulesDeclaringPackage( " + qualifiedPackageName + ", " + CharOperation.charToString(moduleName) + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - Util.verbose(" -> " + CharOperation.toString(moduleNames)); //$NON-NLS-1$ + trace(" Result for JavaSearchNameEnvironment#getModulesDeclaringPackage( " + qualifiedPackageName + ", " + CharOperation.charToString(moduleName) + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + trace(" -> " + CharOperation.toString(moduleNames)); //$NON-NLS-1$ } return moduleNames == CharOperation.NO_CHAR_CHAR ? null : moduleNames; } @@ -540,8 +544,8 @@ public boolean hasCompilationUnit(char[][] qualifiedPackageName, char[] moduleNa if (strategy.matches(location, ClasspathLocation::hasModule) ) if (location.hasCompilationUnit(qualifiedPackageNameString, moduleNameString)) { if(NameLookup.VERBOSE) { - Util.verbose(" Result for JavaSearchNameEnvironment#hasCompilationUnit( " + qualifiedPackageNameString + ", " + moduleNameString + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - Util.verbose(" -> " + location); //$NON-NLS-1$ + trace(" Result for JavaSearchNameEnvironment#hasCompilationUnit( " + qualifiedPackageNameString + ", " + moduleNameString + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + trace(" -> " + location); //$NON-NLS-1$ } return true; } @@ -592,7 +596,6 @@ private static boolean isComplianceJava9OrHigher(IJavaProject javaProject) { /** * Computes matching module for given {@link PackageFragmentRoot} - * @param root * @param defaultModule project module or {@code null} * @return may return {@code null} */ diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchPattern.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchPattern.java index 2764cb8a5b..6e2d78496f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchPattern.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchPattern.java @@ -95,9 +95,6 @@ protected JavaSearchPattern(int patternKind, int matchRule) { this.matchMode = rule & MATCH_MODE_MASK; } - /** - * @param fineGrain - */ public static String getFineGrainFlagString(final int fineGrain) { if (fineGrain == 0) { return "none"; //$NON-NLS-1$ @@ -281,8 +278,6 @@ public final boolean hasTypeParameters() { * Note that obvious compatibility values as equals and {@link IIndexConstants#TYPE_SUFFIX} * has to be tested by caller to avoid unnecessary method call... * - * @param typeSuffix - * @param patternSuffix * @return true if suffixes are compatible, false otherwise */ boolean matchDifferentTypeSuffixes(int typeSuffix, int patternSuffix) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java index 60631a4807..14b4f311b8 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java @@ -17,6 +17,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search.matching; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -97,6 +99,7 @@ import org.eclipse.jdt.internal.core.index.Index; import org.eclipse.jdt.internal.core.search.*; import org.eclipse.jdt.internal.core.search.indexing.QualifierQuery; +import org.eclipse.jdt.internal.core.search.processing.JobManager; import org.eclipse.jdt.internal.core.util.ASTNodeFinder; import org.eclipse.jdt.internal.core.util.HandleFactory; import org.eclipse.jdt.internal.core.util.Util; @@ -285,8 +288,9 @@ public static IBinaryType classFileReader(IType type) { ZipFile zipFile = null; try { IPath zipPath = root.getPath(); - if (JavaModelManager.ZIP_ACCESS_VERBOSE) - System.out.println("(" + Thread.currentThread() + ") [MatchLocator.classFileReader()] Creating ZipFile on " + zipPath); //$NON-NLS-1$ //$NON-NLS-2$ + if (JavaModelManager.ZIP_ACCESS_VERBOSE) { + trace("(" + Thread.currentThread() + ") [MatchLocator.classFileReader()] Creating ZipFile on " + zipPath); //$NON-NLS-1$ //$NON-NLS-2$ + } zipFile = manager.getZipFile(zipPath); String classFileName = classFile.getElementName(); String path = Util.concatWith(pkg.names, classFileName, '/'); @@ -393,7 +397,7 @@ public void accept(ICompilationUnit sourceUnit, AccessRestriction accessRestrict // Display unit error in debug mode if (BasicSearchEngine.VERBOSE) { if (unitResult.problemCount > 0) { - System.out.println(unitResult); + trace(unitResult.toString()); } } } @@ -539,7 +543,7 @@ protected IJavaElement createHandle(AbstractMethodDeclaration method, IJavaEleme typeName = declaringType.getFullyQualifiedName().toCharArray(); } else { if (BasicSearchEngine.VERBOSE) { - System.out.println("Null declaring type for " + type); //$NON-NLS-1$ + trace("Null declaring type for " + type); //$NON-NLS-1$ } } } else if (arguments != null) { @@ -571,7 +575,7 @@ protected IJavaElement createHandle(AbstractMethodDeclaration method, IJavaEleme return binaryMethod; } if (BasicSearchEngine.VERBOSE) { - System.out.println("Not able to createHandle for the method " + //$NON-NLS-1$ + trace("Not able to createHandle for the method " + //$NON-NLS-1$ CharOperation.charToString(method.selector) + " May miss some results"); //$NON-NLS-1$ } return null; @@ -926,7 +930,9 @@ protected IBinaryType getBinaryInfo(ClassFile classFile, IResource resource) thr if (info == null) throw binaryType.newNotPresentException(); return info; } catch (ClassFormatException e) { - //e.printStackTrace(); + if (JobManager.VERBOSE) { + trace("", e); //$NON-NLS-1$ + } return null; } catch (java.io.IOException e) { throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION); @@ -1437,10 +1443,11 @@ public void locateMatches(SearchDocument[] searchDocuments) throws CoreException int docsLength = searchDocuments.length; int progressLength = docsLength; if (BasicSearchEngine.VERBOSE) { - System.out.println("Locating matches in documents ["); //$NON-NLS-1$ - for (int i = 0; i < docsLength; i++) - System.out.println("\t" + searchDocuments[i]); //$NON-NLS-1$ - System.out.println("]"); //$NON-NLS-1$ + trace("Locating matches in documents ["); //$NON-NLS-1$ + for (int i = 0; i < docsLength; i++) { + trace("\t" + searchDocuments[i]); //$NON-NLS-1$ + } + trace("]"); //$NON-NLS-1$ } IJavaProject[] javaModelProjects = null; if (this.searchPackageDeclaration) { @@ -1961,8 +1968,9 @@ protected boolean parseAndBuildBindings(PossibleMatch possibleMatch, boolean mus throw new OperationCanceledException(); try { - if (BasicSearchEngine.VERBOSE) - System.out.println("Parsing " + possibleMatch.openable.toStringWithAncestors()); //$NON-NLS-1$ + if (BasicSearchEngine.VERBOSE) { + trace("Parsing " + possibleMatch.openable.toStringWithAncestors()); //$NON-NLS-1$ + } this.parser.nodeSet = possibleMatch.nodeSet; CompilationResult unitResult = new CompilationResult(possibleMatch, 1, 1, this.options.maxProblemsPerUnit); @@ -2055,8 +2063,9 @@ protected void process(PossibleMatch possibleMatch, boolean bindingsWereCreated) boolean mustResolve = (this.pattern.mustResolve || possibleMatch.nodeSet.mustResolve); if (bindingsWereCreated && mustResolve) { if (unit.types != null) { - if (BasicSearchEngine.VERBOSE) - System.out.println("Resolving " + this.currentPossibleMatch.openable.toStringWithAncestors()); //$NON-NLS-1$ + if (BasicSearchEngine.VERBOSE) { + trace("Resolving " + this.currentPossibleMatch.openable.toStringWithAncestors()); //$NON-NLS-1$ + } this.lookupEnvironment.unitBeingCompleted = unit; reduceParseTree(unit); @@ -2067,12 +2076,14 @@ protected void process(PossibleMatch possibleMatch, boolean bindingsWereCreated) } unit.resolve(); } else if (unit.isPackageInfo()) { - if (BasicSearchEngine.VERBOSE) - System.out.println("Resolving " + this.currentPossibleMatch.openable.toStringWithAncestors()); //$NON-NLS-1$ + if (BasicSearchEngine.VERBOSE) { + trace("Resolving " + this.currentPossibleMatch.openable.toStringWithAncestors()); //$NON-NLS-1$ + } unit.resolve(); } else if (unit.isModuleInfo()) { - if (BasicSearchEngine.VERBOSE) - System.out.println("Resolving " + this.currentPossibleMatch.openable.toStringWithAncestors()); //$NON-NLS-1$ + if (BasicSearchEngine.VERBOSE) { + trace("Resolving " + this.currentPossibleMatch.openable.toStringWithAncestors()); //$NON-NLS-1$ + } this.lookupEnvironment.unitBeingCompleted = unit; if (unit.scope != null && unit.moduleDeclaration != null) { unit.moduleDeclaration.resolveTypeDirectives(unit.scope); @@ -2082,8 +2093,7 @@ protected void process(PossibleMatch possibleMatch, boolean bindingsWereCreated) reportMatching(unit, mustResolve); } catch (AbortCompilation e) { if (BasicSearchEngine.VERBOSE) { - System.out.println("AbortCompilation while resolving unit " + String.valueOf(unit.getFileName())); //$NON-NLS-1$ - e.printStackTrace(); + trace("AbortCompilation while resolving unit " + String.valueOf(unit.getFileName()), e); //$NON-NLS-1$ } // could not resolve: report inaccurate matches reportMatching(unit, false); // do not resolve when cu has errors @@ -2143,35 +2153,35 @@ public SearchParticipant getParticipant() { protected void report(SearchMatch match) throws CoreException { if (match == null) { if (BasicSearchEngine.VERBOSE) { - System.out.println("Cannot report a null match!!!"); //$NON-NLS-1$ + trace("Cannot report a null match!!!"); //$NON-NLS-1$ } return; } if (filterEnum(match)){ if (BasicSearchEngine.VERBOSE) { - System.out.println("Filtered package with name enum"); //$NON-NLS-1$ + trace("Filtered package with name enum"); //$NON-NLS-1$ } return; } long start = -1; if (BasicSearchEngine.VERBOSE) { start = System.currentTimeMillis(); - System.out.println("Reporting match"); //$NON-NLS-1$ - System.out.println("\tResource: " + match.getResource());//$NON-NLS-1$ - System.out.println("\tPositions: [offset=" + match.getOffset() + ", length=" + match.getLength() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + trace("Reporting match"); //$NON-NLS-1$ + trace("\tResource: " + match.getResource());//$NON-NLS-1$ + trace("\tPositions: [offset=" + match.getOffset() + ", length=" + match.getLength() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ try { if (this.parser != null && match.getOffset() > 0 && match.getLength() > 0 && !(match.getElement() instanceof BinaryMember)) { String selection = new String(this.parser.scanner.source, match.getOffset(), match.getLength()); - System.out.println("\tSelection: -->" + selection + "<--"); //$NON-NLS-1$ //$NON-NLS-2$ + trace("\tSelection: -->" + selection + "<--"); //$NON-NLS-1$ //$NON-NLS-2$ } } catch (Exception e) { // it's just for debug purposes... ignore all exceptions in this area } try { JavaElement javaElement = (JavaElement)match.getElement(); - System.out.println("\tJava element: "+ javaElement.toStringWithAncestors()); //$NON-NLS-1$ + trace("\tJava element: "+ javaElement.toStringWithAncestors()); //$NON-NLS-1$ if (!javaElement.exists()) { - System.out.println("\t\tWARNING: this element does NOT exist!"); //$NON-NLS-1$ + trace("\t\tWARNING: this element does NOT exist!"); //$NON-NLS-1$ } } catch (Exception e) { // it's just for debug purposes... ignore all exceptions in this area @@ -2181,17 +2191,17 @@ protected void report(SearchMatch match) throws CoreException { ReferenceMatch refMatch = (ReferenceMatch) match; JavaElement local = (JavaElement) refMatch.getLocalElement(); if (local != null) { - System.out.println("\tLocal element: "+ local.toStringWithAncestors()); //$NON-NLS-1$ + trace("\tLocal element: "+ local.toStringWithAncestors()); //$NON-NLS-1$ } if (match instanceof TypeReferenceMatch) { IJavaElement[] others = ((TypeReferenceMatch) refMatch).getOtherElements(); if (others != null) { int length = others.length; if (length > 0) { - System.out.println("\tOther elements:"); //$NON-NLS-1$ + trace("\tOther elements:"); //$NON-NLS-1$ for (int i=0; i accuracy -private HashtableOfLong matchingNodesKeys = new HashtableOfLong(3); // sourceRange -> node +private final HashtableOfLong matchingNodesKeys = new HashtableOfLong(3); // sourceRange -> node static Integer EXACT_MATCH = Integer.valueOf(SearchMatch.A_ACCURATE); static Integer POTENTIAL_MATCH = Integer.valueOf(SearchMatch.A_INACCURATE); static Integer ERASURE_MATCH = Integer.valueOf(SearchPattern.R_ERASURE_MATCH); @@ -49,7 +49,7 @@ public class MatchingNodeSet { * to determine if they really match the search pattern. */ SimpleSet possibleMatchingNodesSet = new SimpleSet(7); -private HashtableOfLong possibleMatchingNodesKeys = new HashtableOfLong(7); +private final HashtableOfLong possibleMatchingNodesKeys = new HashtableOfLong(7); public MatchingNodeSet(boolean mustResolvePattern) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MemberDeclarationVisitor.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MemberDeclarationVisitor.java index aa71153f38..67352e74b5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MemberDeclarationVisitor.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MemberDeclarationVisitor.java @@ -54,7 +54,7 @@ class MemberDeclarationVisitor extends ASTVisitor { IJavaElement[][] allOtherElements; int ptr = -1; int[] ptrs; - private boolean typeInHierarchy; + private final boolean typeInHierarchy; public MemberDeclarationVisitor(IJavaElement element, ASTNode[] nodes, MatchingNodeSet set, MatchLocator locator, boolean typeInHierarchy) { this.enclosingElement = element; @@ -226,7 +226,7 @@ public boolean visit(LambdaExpression lambdaExpression, BlockScope scope) { if (lambdaExpression.resolvedType != null && lambdaExpression.resolvedType.isValidBinding() && !(lambdaExpression.descriptor instanceof ProblemMethodBinding)) this.locator.reportMatching(lambdaExpression, this.enclosingElement, level != null ? level.intValue() : -1, this.nodeSet, this.typeInHierarchy); - else + else return true; } catch (CoreException e) { throw new WrappedCoreException(e); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java index e030f240ad..324b94023f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java @@ -11,11 +11,13 @@ * Contributors: * IBM Corporation - initial API and implementation * Samrat Dhillon samrat.dhillon@gmail.com - Search for method references is - * returning methods as overriden even if the superclass's method is + * returning methods as overriden even if the superclass's method is * only package-visible - https://bugs.eclipse.org/357547 *******************************************************************************/ package org.eclipse.jdt.internal.core.search.matching; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.util.Arrays; import java.util.HashMap; @@ -42,7 +44,7 @@ public class MethodLocator extends PatternLocator { // This is set only if focus is null. In these cases // it will be hard to determine if the super class is of the same package -// at a latter point. Hence, this array is created with all the super class +// at a latter point. Hence, this array is created with all the super class // names of the same package name as of the matching class name. // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=357547 private char[][][] samePkgSuperDeclaringTypeNames; @@ -117,7 +119,7 @@ public void initializePolymorphicSearch(MatchLocator locator) { start = System.currentTimeMillis(); } try { - SuperTypeNamesCollector namesCollector = + SuperTypeNamesCollector namesCollector = new SuperTypeNamesCollector( this.pattern, this.pattern.declaringSimpleName, @@ -127,12 +129,12 @@ public void initializePolymorphicSearch(MatchLocator locator) { locator.progressMonitor); this.allSuperDeclaringTypeNames = namesCollector.collect(); this.samePkgSuperDeclaringTypeNames = namesCollector.getSamePackageSuperTypeNames(); - this.matchLocator = locator; + this.matchLocator = locator; } catch (JavaModelException e) { // inaccurate matches will be found } if (BasicSearchEngine.VERBOSE) { - System.out.println("Time to initialize polymorphic search: "+(System.currentTimeMillis()-start)); //$NON-NLS-1$ + trace("Time to initialize polymorphic search: "+(System.currentTimeMillis()-start)); //$NON-NLS-1$ } } /* @@ -154,13 +156,13 @@ private boolean isTypeInSuperDeclaringTypeNames(char[][] typeName) { */ protected boolean isVirtualInvoke(MethodBinding method, MessageSend messageSend) { return !method.isStatic() && !method.isPrivate() && !messageSend.isSuperAccess() - && !(method.isDefault() && this.pattern.focus != null + && !(method.isDefault() && this.pattern.focus != null && !CharOperation.equals(this.pattern.declaringPackageName, method.declaringClass.qualifiedPackageName())); } protected ReferenceBinding checkMethodRef(MethodBinding method, ReferenceExpression referenceExpression) { boolean result = (!method.isStatic() && !method.isPrivate() - && referenceExpression.isMethodReference() - && !(method.isDefault() && this.pattern.focus != null + && referenceExpression.isMethodReference() + && !(method.isDefault() && this.pattern.focus != null && !CharOperation.equals(this.pattern.declaringPackageName, method.declaringClass.qualifiedPackageName()))); if (result) { Expression lhs = referenceExpression.lhs; @@ -170,7 +172,7 @@ protected ReferenceBinding checkMethodRef(MethodBinding method, ReferenceExpress return (ReferenceBinding) binding; } } - + return null; } @Override @@ -360,7 +362,7 @@ protected int matchMethod(MethodBinding method, boolean skipImpossibleArg) { if (focusMethodBinding != null) {// textual comparison insufficient TypeBinding[] parameters = focusMethodBinding.parameters; if (parameters.length >= parameterCount) { - newLevel = (isBinary ? argType.erasure().isEquivalentTo((parameters[i].erasure())) :argType.isEquivalentTo((parameters[i]))) ? + newLevel = (isBinary ? argType.erasure().isEquivalentTo((parameters[i].erasure())) :argType.isEquivalentTo((parameters[i]))) ? ACCURATE_MATCH : IMPOSSIBLE_MATCH; foundLevel = true; } @@ -390,7 +392,7 @@ protected int matchMethod(MethodBinding method, boolean skipImpossibleArg) { } if (foundTypeVariable) { if (!method.isStatic() && !method.isPrivate()) { - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=123836, No point in textually comparing type variables, captures etc with concrete types. + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=123836, No point in textually comparing type variables, captures etc with concrete types. if (!checkedFocus) focusMethodBinding = this.matchLocator.getMethodBinding(this.pattern); if (focusMethodBinding != null) { @@ -398,7 +400,7 @@ protected int matchMethod(MethodBinding method, boolean skipImpossibleArg) { return ACCURATE_MATCH; } } - } + } return IMPOSSIBLE_MATCH; } } @@ -674,7 +676,7 @@ protected void reportDeclaration(MethodBinding methodBinding, MatchLocator locat } method = locator.createBinaryMethodHandle(type, methodBinding.selector, parameterTypes); if (method == null || knownMethods.addIfNotIncluded(method) == null) return; - + IResource resource = type.getResource(); if (resource == null) resource = type.getJavaProject().getProject(); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ModuleLocator.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ModuleLocator.java index 3e4388da49..e57f5066d5 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ModuleLocator.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ModuleLocator.java @@ -25,7 +25,7 @@ *******************************************************************************/ public class ModuleLocator extends PatternLocator { - private ModulePattern pattern; + private final ModulePattern pattern; /* package */ boolean target = false; public ModuleLocator(ModulePattern pattern) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java index a1c79e6668..204317f62a 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java @@ -278,8 +278,6 @@ protected boolean matchesName(char[] pattern, char[] name) { * Return how the given name matches the given pattern. * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=79866" * - * @param pattern - * @param name * @return Possible values are: *
      *
    • {@link #ACCURATE_MATCH}
    • @@ -470,7 +468,7 @@ public int resolveLevel(ASTNode possibleMatchingNode) { * Set the flavors for which the locator has to be focused on. * If not set, the locator will accept all matches with or without flavors. * When set, the locator will only accept match having the corresponding flavors. - * + * * @param flavors Bits mask specifying the flavors to be accepted or * 0 to ignore the flavors while accepting matches. */ @@ -814,7 +812,7 @@ protected int resolveLevelForType(char[] qualifiedPattern, TypeBinding type) { IntersectionTypeBinding18 i18 = (IntersectionTypeBinding18) type; for (ReferenceBinding ref : i18.intersectingTypes) { result = resolveLevelForType(qualifiedPattern, ref); - if (result == ACCURATE_MATCH) return result; + if (result == ACCURATE_MATCH) return result; if (result == IMPOSSIBLE_MATCH) continue; if (prev == IMPOSSIBLE_MATCH) prev = result; } diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationLocator.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationLocator.java index bef2fc667d..5dcc406e1f 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationLocator.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationLocator.java @@ -162,11 +162,13 @@ private void addRequiredModules(MatchLocator matchLocator) { } } }; - final SearchRequestor requestor = new SearchRequestor() { + final SearchRequestor requestor = new SearchRequestor() { @Override public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException { - System.out.println(searchMatch.toString()); // do nothing + if (JavaModelManager.VERBOSE) { + JavaModelManager.trace(searchMatch.toString()); + } } }; try { @@ -198,13 +200,13 @@ private char[][] getModuleList(TypeDeclarationPattern typePattern) { char[][] tmp = new char[sz][]; for (int i = 0; i < sz; ++i) { tmp[i] = ar[i].toCharArray(); - } + } typePattern.moduleGraphElements = tmp; } return typePattern.moduleGraphElements; } private int matchModule(TypeDeclarationPattern typePattern, TypeBinding type) { - if (!(type instanceof ReferenceBinding)) + if (!(type instanceof ReferenceBinding)) return INACCURATE_MATCH; // a safety net, should not come here for error free code. ReferenceBinding reference = (ReferenceBinding) type; ModuleBinding module = reference.module(); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationPattern.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationPattern.java index b30a2a3af1..301770d6c9 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationPattern.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationPattern.java @@ -21,7 +21,6 @@ import org.eclipse.jdt.core.search.SearchPattern; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.core.index.*; -import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants; public class TypeDeclarationPattern extends JavaSearchPattern { @@ -29,7 +28,6 @@ public class TypeDeclarationPattern extends JavaSearchPattern { public char[] pkg; public char[][] enclosingTypeNames; public char[][] moduleNames = null; -private boolean allowModuleRegex = false; // enable to try experimental Module Regex Match /* package */ Pattern[] modulePatterns = null; public boolean moduleGraph = false; /* package */ char[][] moduleGraphElements = null; @@ -186,19 +184,10 @@ protected void addModuleNames(char[] modNames) { final String explicit_unnamed = new String(IJavaSearchConstants.ALL_UNNAMED); String[] names = new String(modNames).split(String.valueOf(CharOperation.COMMA_SEPARATOR)); int len = names.length; - if (this.allowModuleRegex && len > 0 && names[0] != null && names[0].length() > 0 - && names[0].charAt(0) == IIndexConstants.ZERO_CHAR) { //pattern - names[0] = names[0].substring(1); - this.modulePatterns = new Pattern[len]; - for (int i = 0; i < len; ++i) { - this.modulePatterns[i] = Pattern.compile(names[i]); - } - } else { // 'normal' matching - flag if don't care conditions are passed - for (int i = 0; i < len; ++i) { - names[i] = names[i].trim(); - if (explicit_unnamed.equals(names[i])) - names[i] = ""; //$NON-NLS-1$ - } + for (int i = 0; i < len; ++i) { + names[i] = names[i].trim(); + if (explicit_unnamed.equals(names[i])) + names[i] = ""; //$NON-NLS-1$ } this.moduleNames = new char[len][]; for (int i = 0; i < len; ++i) { diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeParameterPattern.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeParameterPattern.java index b2c6ff0824..8edcb5e714 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeParameterPattern.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeParameterPattern.java @@ -49,12 +49,6 @@ public class TypeParameterPattern extends JavaSearchPattern { protected char[] methodDeclaringClassName; protected char[][] methodArgumentTypes; - /** - * @param findDeclarations - * @param findReferences - * @param typeParameter - * @param matchRule - */ public TypeParameterPattern(boolean findDeclarations, boolean findReferences, ITypeParameter typeParameter, int matchRule) { super(TYPE_PARAM_PATTERN, matchRule); diff --git a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java index 57973b4911..381c04952b 100644 --- a/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java +++ b/jdt-patch/e430/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search.processing; +import static org.eclipse.jdt.internal.core.JavaModelManager.trace; + import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -37,7 +39,7 @@ public abstract class JobManager { *
      * synchronized by JobManager.this */ - private List awaitingJobs = new LinkedList<>(); + private final List awaitingJobs = new LinkedList<>(); private volatile boolean executing; @@ -67,7 +69,7 @@ public abstract class JobManager { */ private boolean activated; - private AtomicInteger awaitingClients = new AtomicInteger(); + private final AtomicInteger awaitingClients = new AtomicInteger(); private final Object idleMonitor = new Object(); @@ -117,8 +119,9 @@ public synchronized IJob currentJobForced() { public synchronized void disable() { this.enableCount--; - if (VERBOSE) - Util.verbose("DISABLING background indexing"); //$NON-NLS-1$ + if (VERBOSE) { + trace("DISABLING background indexing"); //$NON-NLS-1$ + } } /** @@ -134,8 +137,9 @@ public synchronized boolean isEnabled() { */ public void discardJobs(String jobFamily) { - if (VERBOSE) - Util.verbose("DISCARD background job family - " + jobFamily); //$NON-NLS-1$ + if (VERBOSE) { + trace("DISCARD background job family - " + jobFamily); //$NON-NLS-1$ + } try { IJob currentJob; @@ -151,8 +155,9 @@ public void discardJobs(String jobFamily) { // wait until current active job has finished while (getProcessingThread() != null && this.executing){ try { - if (VERBOSE) - Util.verbose("-> waiting end of current background job - " + currentJob); //$NON-NLS-1$ + if (VERBOSE) { + trace("-> waiting end of current background job - " + currentJob); //$NON-NLS-1$ + } this.wait(50); } catch(InterruptedException e){ // ignore @@ -168,7 +173,7 @@ public void discardJobs(String jobFamily) { currentJob = it.next(); if (jobFamily == null || currentJob.belongsTo(jobFamily)) { if (VERBOSE) { - Util.verbose("-> discarding background job - " + currentJob); //$NON-NLS-1$ + trace("-> discarding background job - " + currentJob); //$NON-NLS-1$ } currentJob.cancel(); it.remove(); @@ -182,13 +187,15 @@ public void discardJobs(String jobFamily) { } finally { enable(); } - if (VERBOSE) - Util.verbose("DISCARD DONE with background job family - " + jobFamily); //$NON-NLS-1$ + if (VERBOSE) { + trace("DISCARD DONE with background job family - " + jobFamily); //$NON-NLS-1$ + } } public synchronized void enable() { this.enableCount++; - if (VERBOSE) - Util.verbose("ENABLING background indexing"); //$NON-NLS-1$ + if (VERBOSE) { + trace("ENABLING background indexing"); //$NON-NLS-1$ + } notifyAll(); // wake up the background thread if it is waiting (context must be synchronized) } protected synchronized boolean isJobWaiting(IJob request) { @@ -253,11 +260,11 @@ protected synchronized void moveToNextJob() { * IJobConstants.ForceImmediateSearch * IJobConstants.CancelIfNotReadyToSearch * IJobConstants.WaitUntilReadyToSearch - * */ public boolean performConcurrentJob(IJob searchJob, int waitingPolicy, IProgressMonitor monitor) { - if (VERBOSE) - Util.verbose("STARTING concurrent job - " + searchJob); //$NON-NLS-1$ + if (VERBOSE) { + trace("STARTING concurrent job - " + searchJob); //$NON-NLS-1$ + } searchJob.ensureReadyToRun(); @@ -265,29 +272,32 @@ public boolean performConcurrentJob(IJob searchJob, int waitingPolicy, IProgress try { SubMonitor subMonitor = SubMonitor.convert(monitor); if (awaitingJobsCount() > 0) { - if (VERBOSE) - Util.verbose("-> NOT READY - " + awaitingJobsCount() + " awaiting jobs - " + searchJob);//$NON-NLS-1$ //$NON-NLS-2$ + if (VERBOSE) { + trace("-> NOT READY - " + awaitingJobsCount() + " awaiting jobs - " + searchJob);//$NON-NLS-1$ //$NON-NLS-2$ + } switch (waitingPolicy) { case IJob.ForceImmediate : - if (VERBOSE) - Util.verbose("-> NOT READY - forcing immediate - " + searchJob);//$NON-NLS-1$ + if (VERBOSE) { + trace("-> NOT READY - forcing immediate - " + searchJob);//$NON-NLS-1$ + } try { disable(); // pause indexing status = searchJob.execute(subMonitor); } finally { enable(); } - if (VERBOSE) - Util.verbose("FINISHED concurrent job - " + searchJob); //$NON-NLS-1$ + if (VERBOSE) { + trace("FINISHED concurrent job - " + searchJob); //$NON-NLS-1$ + } return status; case IJob.CancelIfNotReady : - if (VERBOSE) - Util.verbose("-> NOT READY - cancelling - " + searchJob); //$NON-NLS-1$ - if (VERBOSE) - Util.verbose("CANCELED concurrent job - " + searchJob); //$NON-NLS-1$ + if (VERBOSE) { + trace("-> NOT READY - cancelling - " + searchJob); //$NON-NLS-1$ + trace("CANCELED concurrent job - " + searchJob); //$NON-NLS-1$ + } throw new OperationCanceledException(); case IJob.WaitUntilReady : @@ -314,10 +324,11 @@ public boolean performConcurrentJob(IJob searchJob, int waitingPolicy, IProgress IJob currentJob = currentJobForced(); if (currentJob != null) { if (!isEnabled()) { - if (VERBOSE) - Util.verbose("-> NOT READY (" + this.enableCount //$NON-NLS-1$ + if (VERBOSE) { + trace("-> NOT READY (" + this.enableCount //$NON-NLS-1$ + ") - enabling indexer to process " //$NON-NLS-1$ + awaitingJobsCount + " jobs - " + searchJob);//$NON-NLS-1$ + } enable(); shouldDisable = true; } @@ -326,8 +337,9 @@ public boolean performConcurrentJob(IJob searchJob, int waitingPolicy, IProgress } } if (currentJob != null && currentJob != previousJob) { - if (VERBOSE) - Util.verbose("-> NOT READY - waiting until ready to process " + awaitingJobsCount + " awaiting jobs - " + searchJob);//$NON-NLS-1$ //$NON-NLS-2$ + if (VERBOSE) { + trace("-> NOT READY - waiting until ready to process " + awaitingJobsCount + " awaiting jobs - " + searchJob);//$NON-NLS-1$ //$NON-NLS-2$ + } String indexing = Messages.bind(Messages.jobmanager_filesToIndex, currentJob.getJobFamily(), Integer.toString(awaitingJobsCount)); waitMonitor.subTask(indexing); // ratio of the amount of work relative to the total work @@ -355,9 +367,10 @@ public boolean performConcurrentJob(IJob searchJob, int waitingPolicy, IProgress } } if (shouldDisable) { - if (VERBOSE) - Util.verbose("-> NOT READY (" + this.enableCount + ") - disabling indexer again, still awaiting jobs: " //$NON-NLS-1$ //$NON-NLS-2$ + if (VERBOSE) { + trace("-> NOT READY (" + this.enableCount + ") - disabling indexer again, still awaiting jobs: " //$NON-NLS-1$ //$NON-NLS-2$ + awaitingJobsCount + " - " + searchJob);//$NON-NLS-1$ + } disable(); } } @@ -371,8 +384,9 @@ public boolean performConcurrentJob(IJob searchJob, int waitingPolicy, IProgress status = searchJob.execute(subMonitor); } finally { SubMonitor.done(monitor); - if (VERBOSE) - Util.verbose("FINISHED concurrent job - " + searchJob); //$NON-NLS-1$ + if (VERBOSE) { + trace("FINISHED concurrent job - " + searchJob); //$NON-NLS-1$ + } } return status; } @@ -397,8 +411,8 @@ public synchronized void request(IJob job) { // append the job to the list of ones to process later on this.awaitingJobs.add(job); if (VERBOSE) { - Util.verbose("REQUEST background job - " + job); //$NON-NLS-1$ - Util.verbose("AWAITING JOBS count: " + awaitingJobsCount()); //$NON-NLS-1$ + trace("REQUEST background job - " + job); //$NON-NLS-1$ + trace("AWAITING JOBS count: " + awaitingJobsCount()); //$NON-NLS-1$ } notifyAll(); // wake up the background thread if it is waiting } @@ -406,8 +420,9 @@ public synchronized void request(IJob job) { * Flush current state */ public void reset() { - if (VERBOSE) - Util.verbose("Reset"); //$NON-NLS-1$ + if (VERBOSE) { + trace("Reset"); //$NON-NLS-1$ + } Thread thread = getProcessingThread(); @@ -508,8 +523,8 @@ protected IStatus run(IProgressMonitor monitor) { } idlingStart = null; if (VERBOSE) { - Util.verbose(awaitingJobsCount() + " awaiting jobs"); //$NON-NLS-1$ - Util.verbose("STARTING background job - " + job); //$NON-NLS-1$ + trace(awaitingJobsCount() + " awaiting jobs"); //$NON-NLS-1$ + trace("STARTING background job - " + job); //$NON-NLS-1$ } try { this.executing = true; @@ -527,12 +542,13 @@ protected IStatus run(IProgressMonitor monitor) { job.execute(null); // may enqueue a new job } finally { this.executing = false; - if (VERBOSE) - Util.verbose("FINISHED background job - " + job); //$NON-NLS-1$ + if (VERBOSE) { + trace("FINISHED background job - " + job); //$NON-NLS-1$ + } moveToNextJob(); if (this.awaitingClients.get() == 0 && job.waitNeeded()) { if (VERBOSE) { - Util.verbose("WAITING after job - " + job); //$NON-NLS-1$ + trace("WAITING after job - " + job); //$NON-NLS-1$ } synchronized (this.idleMonitor) { this.idleMonitor.wait(5); // avoid sleep fixed time @@ -570,8 +586,9 @@ protected IStatus run(IProgressMonitor monitor) { */ public void shutdown() { - if (VERBOSE) - Util.verbose("Shutdown"); //$NON-NLS-1$ + if (VERBOSE) { + trace("Shutdown"); //$NON-NLS-1$ + } disable(); discardJobs(null); // will wait until current executing job has completed diff --git a/pom.xml b/pom.xml index b7a50b20ce..8e71ce5ad5 100644 --- a/pom.xml +++ b/pom.xml @@ -108,7 +108,7 @@ milestone p2 - https://download.eclipse.org/eclipse/updates/4.30-I-builds/I20230927-1800 + https://download.eclipse.org/eclipse/updates/4.30-I-builds/I20231109-0710