Skip to content

Commit cfddb07

Browse files
committed
Merge remote-tracking branch 'origin/master' into BETA_JAVA26
2 parents 5459bc7 + 7e87ad5 commit cfddb07

File tree

30 files changed

+972
-191
lines changed

30 files changed

+972
-191
lines changed

org.eclipse.jdt.apt.pluggable.core/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.jdt.apt.pluggable.core;singleton:=true
5-
Bundle-Version: 1.4.600.qualifier
5+
Bundle-Version: 1.4.700.qualifier
66
Bundle-Activator: org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin
77
Bundle-Vendor: %providerName
88
Require-Bundle: org.eclipse.core.runtime,

org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeProcessingEnvImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public Map<String, String> getOptions() {
102102

103103
private Function<Entry<String, String>, String> replacePlaceholdersUsing(Map<String, String> commandLineOptions) {
104104
return option -> {
105-
String variable, replacement, optionValue = option.getValue();
105+
String variable, replacement, optionValue = option.getValue() == null ? "" : option.getValue();
106106
Matcher placeholder = Pattern.compile("%([^%]+)%").matcher(optionValue);
107107
if (placeholder.find() && (variable = placeholder.group(1)) != null
108108
&& (replacement = commandLineOptions.get(variable)) != null) {

org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.jdt.apt.pluggable.tests;singleton:=true
5-
Bundle-Version: 3.6.800.qualifier
5+
Bundle-Version: 3.6.900.qualifier
66
Bundle-Activator: org.eclipse.jdt.apt.pluggable.tests.Apt6TestsPlugin
77
Bundle-Localization: plugin
88
Require-Bundle: org.junit,

org.eclipse.jdt.apt.pluggable.tests/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<relativePath>../tests-pom/</relativePath>
2020
</parent>
2121
<artifactId>org.eclipse.jdt.apt.pluggable.tests</artifactId>
22-
<version>3.6.800-SNAPSHOT</version>
22+
<version>3.6.900-SNAPSHOT</version>
2323
<packaging>eclipse-test-plugin</packaging>
2424
<properties>
2525
<testSuite>${project.artifactId}</testSuite>

org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/BuilderTests.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,25 @@ public void testBug341298() throws Throwable {
415415
fullBuild();
416416
assertTrue("Processor should be able to compile with passed options", Bug341298Processor.success());
417417
}
418+
public void testGHIssue4640() throws Throwable {
419+
ProcessorTestStatus.reset();
420+
IJavaProject project = createJavaProject(_projectName);
421+
IPath root = project.getProject().getFullPath().append("src");
422+
env.addClass(root, "test341298", "Annotated",
423+
"package test341298;\n" +
424+
"@Annotation public class Annotated {}"
425+
);
426+
env.addClass(root, "test341298", "Annotation",
427+
"package test341298;\n" +
428+
"public @interface Annotation {}"
429+
);
430+
AptConfig.addProcessorOption(project, "classpath", "%classpath%");
431+
AptConfig.addProcessorOption(project, "sourcepath", "%sourcepath%");
432+
AptConfig.addProcessorOption(project, "phase", null);
433+
AptConfig.setEnabled(project, true);
434+
fullBuild();
435+
assertTrue("Processor should be able to compile with passed options", Bug341298Processor.success());
436+
}
418437

419438
public void testBug539663() throws Throwable {
420439
if (!canRunJava9()) {

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Annotation.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,8 @@ public static void isTypeUseCompatible(TypeReference reference, Scope scope, Ann
13771377

13781378
nextAnnotation:
13791379
for (Annotation annotation : annotations) {
1380+
if (annotation.resolvedType == null) // barked elsewhere or still cooking and we come here due to re-entrancy
1381+
continue;
13801382
long metaTagBits = annotation.resolvedType.getAnnotationTagBits();
13811383
if ((metaTagBits & TagBits.AnnotationForTypeUse) != 0 && (metaTagBits & TagBits.AnnotationForDeclarationMASK) == 0) {
13821384
ReferenceBinding currentType = (ReferenceBinding) resolvedType;

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ public VisibilityInspector(FunctionalExpression expression, Scope scope, boolean
239239
}
240240

241241
private void checkVisibility(ReferenceBinding referenceBinding) {
242+
if (referenceBinding.isUnresolvedType())
243+
referenceBinding = (ReferenceBinding) BinaryTypeBinding.resolveType(referenceBinding, this.scope.environment(), false);
242244
if (!referenceBinding.canBeSeenBy(this.scope)) {
243245
this.visible = false;
244246
if (this.shouldChatter)

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/RecordPattern.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,13 @@ public TypeBinding resolveType(BlockScope scope) {
128128
}
129129
}
130130

131+
RecordComponentBinding[] componentBindings = this.resolvedType.components();
131132
LocalVariableBinding [] bindings = NO_VARIABLES;
132133
for (int i = 0, l = this.patterns.length; i < l; ++i) {
133134
Pattern p = this.patterns[i];
135+
p.setOuterExpressionType(componentBindings[i].type);
134136
p.resolveTypeWithBindings(bindings, scope);
135137
bindings = LocalVariableBinding.merge(bindings, p.bindingsWhenTrue());
136-
p.setOuterExpressionType(this.resolvedType.components()[i].type);
137138
}
138139

139140
if (this.resolvedType == null || !this.resolvedType.isValidBinding()) {

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,9 +1387,9 @@ void buildComponents() {
13871387

13881388
void connectTypeHierarchy() {
13891389
SourceTypeBinding sourceType = this.referenceContext.binding;
1390+
boolean previousFlag = environment().enterSuperTypeLookup(sourceType);
13901391
if ((sourceType.tagBits & TagBits.BeginHierarchyCheck) == 0) {
13911392
sourceType.tagBits |= TagBits.BeginHierarchyCheck;
1392-
environment().typesBeingConnected.add(sourceType);
13931393
boolean noProblems = connectSuperclass();
13941394
noProblems &= connectSuperInterfaces();
13951395
if ((sourceType.typeBits & (TypeIds.BitAutoCloseable|TypeIds.BitCloseable)) != 0) {
@@ -1412,6 +1412,7 @@ void connectTypeHierarchy() {
14121412
throw e;
14131413
} finally {
14141414
env.missingClassFileLocation = null;
1415+
env.root.isResolvingSuperType = previousFlag;
14151416
}
14161417
}
14171418

@@ -1429,17 +1430,20 @@ private void connectTypeHierarchyWithoutMembers() {
14291430
SourceTypeBinding sourceType = this.referenceContext.binding;
14301431
if ((sourceType.tagBits & TagBits.BeginHierarchyCheck) != 0)
14311432
return;
1432-
1433-
sourceType.tagBits |= TagBits.BeginHierarchyCheck;
1434-
environment().typesBeingConnected.add(sourceType);
1435-
boolean noProblems = connectSuperclass();
1436-
noProblems &= connectSuperInterfaces();
1437-
environment().typesBeingConnected.remove(sourceType);
1438-
sourceType.tagBits |= TagBits.EndHierarchyCheck;
1439-
noProblems &= connectTypeVariables(this.referenceContext.typeParameters, false);
1440-
sourceType.tagBits |= TagBits.TypeVariablesAreConnected;
1441-
if (noProblems && sourceType.isHierarchyInconsistent())
1442-
problemReporter().hierarchyHasProblems(sourceType);
1433+
boolean previousFlag = environment().enterSuperTypeLookup(sourceType);
1434+
try {
1435+
sourceType.tagBits |= TagBits.BeginHierarchyCheck;
1436+
boolean noProblems = connectSuperclass();
1437+
noProblems &= connectSuperInterfaces();
1438+
environment().typesBeingConnected.remove(sourceType);
1439+
sourceType.tagBits |= TagBits.EndHierarchyCheck;
1440+
noProblems &= connectTypeVariables(this.referenceContext.typeParameters, false);
1441+
sourceType.tagBits |= TagBits.TypeVariablesAreConnected;
1442+
if (noProblems && sourceType.isHierarchyInconsistent())
1443+
problemReporter().hierarchyHasProblems(sourceType);
1444+
} finally {
1445+
environment().root.isResolvingSuperType = previousFlag;
1446+
}
14431447
}
14441448

14451449
public boolean detectHierarchyCycle(TypeBinding superType, TypeReference reference) {

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public class LookupEnvironment implements ProblemReasons, TypeConstants {
125125
private ArrayList<MissingTypeBinding> missingTypes;
126126
final Set<SourceTypeBinding> typesBeingConnected; // SHARED
127127
public boolean isProcessingAnnotations = false; // ROOT_ONLY
128+
public boolean isResolvingSuperType = false; // ROOT_ONLY
128129
public boolean mayTolerateMissingType = false;
129130

130131
AnnotationBinding nonNullAnnotation;
@@ -154,21 +155,34 @@ public class LookupEnvironment implements ProblemReasons, TypeConstants {
154155
static class GlobalDataMemento {
155156
Set<SourceTypeBinding> typesBeingConnected;
156157
boolean mayTolerateMissingType = false;
157-
GlobalDataMemento(Set<SourceTypeBinding> typesBeingConnected, boolean mayTolerateMissingType) {
158+
boolean isResolvingSuperType = false;
159+
GlobalDataMemento(Set<SourceTypeBinding> typesBeingConnected, boolean mayTolerateMissingType, boolean isResolvingSuperType) {
158160
this.typesBeingConnected = typesBeingConnected;
159161
this.mayTolerateMissingType = mayTolerateMissingType;
162+
this.isResolvingSuperType = isResolvingSuperType;
160163
}
161164
}
162165
GlobalDataMemento stashGlobalData() {
163-
GlobalDataMemento memento = new GlobalDataMemento(new LinkedHashSet<>(this.typesBeingConnected), this.mayTolerateMissingType);
164-
this.typesBeingConnected.clear();
166+
GlobalDataMemento memento = new GlobalDataMemento(new LinkedHashSet<>(this.typesBeingConnected),
167+
this.mayTolerateMissingType, this.root.isResolvingSuperType);
168+
if (!this.root.isResolvingSuperType)
169+
this.typesBeingConnected.clear(); // lookup is not within the hierarchy of these types
170+
this.root.isResolvingSuperType = false;
165171
this.mayTolerateMissingType = false;
166172
return memento;
167173
}
168174
void restoreFrom(GlobalDataMemento memento) {
169175
this.typesBeingConnected.clear();
170176
this.typesBeingConnected.addAll(memento.typesBeingConnected);
171177
this.mayTolerateMissingType = memento.mayTolerateMissingType;
178+
this.root.isResolvingSuperType = memento.isResolvingSuperType;
179+
}
180+
181+
public boolean enterSuperTypeLookup(SourceTypeBinding sourceType) {
182+
this.typesBeingConnected.add(sourceType);
183+
boolean previous = this.root.isResolvingSuperType;
184+
this.root.isResolvingSuperType = true;
185+
return previous;
172186
}
173187

174188
static enum CompleteTypeBindingsSteps {

0 commit comments

Comments
 (0)