Skip to content

Commit

Permalink
Eclipse 4.33 (M3) JDT Patch for Groovy-Eclipse
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Aug 21, 2024
1 parent d6ac73c commit 40ec3dd
Show file tree
Hide file tree
Showing 198 changed files with 6,997 additions and 12,000 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2024 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.
Expand Down Expand Up @@ -48,7 +48,7 @@ public final class BuildAccessRulesTests extends BuilderTestSuite {

@Before
public void setUp() throws Exception {
prj = env.addProject("Project");
prj = env.addProject("Project", "1.8");
src = env.getPackageFragmentRootPath(prj, "src");
env.setClasspath(prj, new IClasspathEntry[] {
JavaCore.newSourceEntry(src),
Expand Down
2 changes: 1 addition & 1 deletion groovy-eclipse.setup
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
<repository
url="https://download.eclipse.org/eclipse/updates/4.33"/>
<repository
url="https://download.eclipse.org/eclipse/updates/4.33-I-builds/I20240704-1800"/>
url="https://download.eclipse.org/eclipse/updates/4.33-I-builds/I20240815-1810"/>
</repositoryList>
<repositoryList
name="2024-06">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</license>

<requires>
<import feature="org.eclipse.jdt" version="3.19.600.v20240704-2057" patch="true"/>
<import feature="org.eclipse.jdt" version="3.19.600.v20240815-2038" patch="true"/>
</requires>

<plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,43 @@ Automatic-Module-Name: org.eclipse.jdt.core.compiler.batch
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-17
Export-Package: META-INF.services,
org.eclipse.jdt.core.compiler;x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.core.compiler;
x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.core.compiler.batch,
org.eclipse.jdt.internal.antadapter;x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.apt.dispatch;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.apt.model;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.apt.util;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.ast;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.batch;x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.classfmt;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.codegen;x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.env;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.flow;x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.impl;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.lookup;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.parser;x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.parser.diagnose;x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.problem;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.tool;x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.util;x-friends:="org.eclipse.jdt.apt.core,org.eclipse.jdt.core,org.eclipse.jdt.core.internal.tools"
org.eclipse.jdt.internal.antadapter;
x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler;
x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.apt.dispatch;
x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.apt.model;
x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.apt.util;
x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.ast;
x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.batch;
x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.classfmt;
x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.codegen;
x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.env;
x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.flow;
x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.impl;
x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.lookup;
x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.parser;
x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.parser.diagnose;
x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.problem;
x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.tool;
x-friends:="org.eclipse.jdt.core",
org.eclipse.jdt.internal.compiler.util;
x-friends:="org.eclipse.jdt.apt.core,org.eclipse.jdt.core,org.eclipse.jdt.core.internal.tools"
DynamicImport-Package: org.codehaus.jdt.groovy.integration
15 changes: 10 additions & 5 deletions jdt-patch/e433/org.eclipse.jdt.core.compiler.batch/grammar/java.g
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $Terminals
abstract assert boolean break byte case catch char class
continue const default do double else enum extends false final finally float
for goto if implements import instanceof int
interface long native new non-sealed null package permits private
interface long native new non-sealed null package private
protected public return short static strictfp super switch
synchronized this throw throws transient true try void
volatile while module open requires transitive exports opens to uses provides with
Expand Down Expand Up @@ -120,6 +120,7 @@ $Terminals
RestrictedIdentifierYield
RestrictedIdentifierrecord
RestrictedIdentifiersealed
RestrictedIdentifierpermits
BeginCaseElement
RestrictedIdentifierWhen
UNDERSCORE
Expand Down Expand Up @@ -230,8 +231,9 @@ Goal ::= '@' TypeAnnotations
-- JSR 354 Reconnaissance mission.
Goal ::= '->' YieldStatement
Goal ::= '->' SwitchLabelCaseLhs
-- JSR 360 Restricted
-- JEP 409 Sealed types Reconnaissance mission.
Goal ::= RestrictedIdentifiersealed Modifiersopt
Goal ::= RestrictedIdentifierpermits PermittedTypes
-- jsr 427 --
Goal ::= BeginCaseElement Pattern
Goal ::= RestrictedIdentifierWhen Expression
Expand Down Expand Up @@ -2410,10 +2412,14 @@ ClassHeaderImplementsopt ::= $empty
ClassHeaderImplementsopt -> ClassHeaderImplements
/:$readableName ClassHeaderImplements:/

-- Production name hardcoded in scanner. Must be ::= and not ->
PermittedTypes ::= ClassTypeList
/:$readableName PermittedTypes:/

PermittedTypesopt -> $empty
PermittedTypesopt ::= 'permits' ClassTypeList
PermittedTypesopt ::= RestrictedIdentifierpermits ClassTypeList
/.$putCase consumePermittedTypes(); $break ./
/:$readableName PermittedTypes:/
/:$readableName PermittedTypesopt:/
/:$compliance 17:/

InterfaceMemberDeclarationsopt ::= $empty
Expand Down Expand Up @@ -3200,4 +3206,3 @@ UNDERSCORE ::= '_'
$end
-- need a carriage return after the $end


Original file line number Diff line number Diff line change
Expand Up @@ -2183,6 +2183,8 @@ public interface IProblem {
int FeatureNotSupported = Compliance + 1107;
/** @since 3.26*/
int PreviewAPIUsed = Compliance + 1108;
/** @since 3.39*/
int JavaVersionNotSupported = Compliance + 1109;

/** @since 3.13 */
int UnlikelyCollectionMethodArgumentType = 1200;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2023 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -4485,7 +4485,7 @@ public int generateMethodInfoAttributes(MethodBinding methodBinding) {
}
}
if ((methodBinding.tagBits & TagBits.HasMissingType) != 0) {
this.missingTypes = methodBinding.collectMissingTypes(this.missingTypes);
this.missingTypes = methodBinding.collectMissingTypes(this.missingTypes, true);
}
return attributesNumber;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,6 @@ public void accept(IBinaryType binaryType, PackageBinding packageBinding, Access
if (this.options.verbose) {
this.out.println(
Messages.bind(Messages.compilation_loadBinary, new String(binaryType.getName())));
// new Exception("TRACE BINARY").printStackTrace(System.out);
// System.out.println();
}
LookupEnvironment env = packageBinding.environment;
env.createBinaryTypeFrom(binaryType, packageBinding, accessRestriction);
Expand Down Expand Up @@ -842,13 +840,33 @@ private void abortIfPreviewNotAllowed(ICompilationUnit[] sourceUnits, int maxUn
throw a;
}
}

private void abortIfVersionNotAllowed(ICompilationUnit[] sourceUnits, int maxUnits) {
try {
long firstSupportedJdkLevel = CompilerOptions.getFirstSupportedJdkLevel();
if (this.options.sourceLevel < firstSupportedJdkLevel
|| this.options.targetJDK < firstSupportedJdkLevel
|| this.options.complianceLevel < firstSupportedJdkLevel) {
long badVersion = Math.min(this.options.complianceLevel, Math.min(this.options.sourceLevel, this.options.targetJDK));
this.problemReporter.abortDueToNotSupportedJavaVersion(CompilerOptions.versionFromJdkLevel(badVersion),
CompilerOptions.getFirstSupportedJavaVersion());
}
} catch (AbortCompilation a) {
// best effort to find a way for reporting this problem: report on the first source
if (a.compilationResult == null) {
a.compilationResult = new CompilationResult(sourceUnits[0], 0, maxUnits, this.options.maxProblemsPerUnit);
}
throw a;
}
}
/**
* Add the initial set of compilation units into the loop
* -> build compilation unit declarations, their bindings and record their results.
*/
protected void internalBeginToCompile(ICompilationUnit[] sourceUnits, int maxUnits) {
abortIfVersionNotAllowed(sourceUnits,maxUnits);
abortIfPreviewNotAllowed(sourceUnits,maxUnits);
if (!this.useSingleThread && maxUnits >= ReadManager.THRESHOLD)
if (!this.useSingleThread)
this.parser.readManager = new ReadManager(sourceUnits, maxUnits);
try {
// Switch the current policy and compilation result for this unit to the requested one.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,41 @@

package org.eclipse.jdt.internal.compiler;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.compiler.util.Messages;

public class ProcessTaskManager implements Runnable {
public class ProcessTaskManager {

Compiler compiler;
private int unitIndex;
private Thread processingThread;
private final Compiler compiler;
private final int startingIndex;
private volatile Future<?> processingTask; // synchronized write, volatile read
CompilationUnitDeclaration unitToProcess;
private Throwable caughtException;

// queue
volatile int currentIndex, availableIndex, size, sleepCount;
CompilationUnitDeclaration[] units;
private final CompilationUnitDeclaration[] units;

public static final int PROCESSED_QUEUE_SIZE = 100;

/** Normally a single thread is created an reused on subsequent builds **/
private static final ExecutorService executor = Executors.newCachedThreadPool(r -> {
Thread t = new Thread(r, "Compiler Processing Task"); //$NON-NLS-1$
t.setDaemon(true);
return t;
});

public ProcessTaskManager(Compiler compiler, int startingIndex) {
this.compiler = compiler;
this.unitIndex = startingIndex;
this.startingIndex = startingIndex;

this.currentIndex = 0;
this.availableIndex = 0;
Expand All @@ -43,9 +57,7 @@ public ProcessTaskManager(Compiler compiler, int startingIndex) {
this.units = new CompilationUnitDeclaration[this.size];

synchronized (this) {
this.processingThread = new Thread(this, "Compiler Processing Task"); //$NON-NLS-1$
this.processingThread.setDaemon(true);
this.processingThread.start();
this.processingTask = executor.submit(this::compile);
}
}

Expand Down Expand Up @@ -77,7 +89,7 @@ public CompilationUnitDeclaration removeNextUnit() throws Error {
next = this.units[this.currentIndex];
if (next == null || this.caughtException != null) {
do {
if (this.processingThread == null) {
if (this.processingTask == null) {
if (this.caughtException != null) {
// rethrow the caught exception from the processingThread in the main compiler thread
if (this.caughtException instanceof Error)
Expand Down Expand Up @@ -112,23 +124,27 @@ public CompilationUnitDeclaration removeNextUnit() throws Error {
return next;
}

@Override
public void run() {
private void compile() {
int unitIndex = this.startingIndex;
synchronized (this) { // wait until processingTask is assigned
@SuppressWarnings("unused")
Future<?> p = this.processingTask;
}
boolean noAnnotations = this.compiler.annotationProcessorManager == null;
while (this.processingThread != null) {
while (this.processingTask != null) {
this.unitToProcess = null;
int index = -1;
boolean cleanup = noAnnotations || this.compiler.shouldCleanup(this.unitIndex);
boolean cleanup = noAnnotations || this.compiler.shouldCleanup(unitIndex);
try {
synchronized (this) {
if (this.processingThread == null) return;
if (this.processingTask == null) return;

this.unitToProcess = this.compiler.getUnitToProcess(this.unitIndex);
this.unitToProcess = this.compiler.getUnitToProcess(unitIndex);
if (this.unitToProcess == null) {
this.processingThread = null;
this.processingTask = null;
return;
}
index = this.unitIndex++;
index = unitIndex++;
if (this.unitToProcess.compilationResult.hasBeenAccepted)
continue;
}
Expand Down Expand Up @@ -159,7 +175,7 @@ public void run() {
addNextUnit(this.unitToProcess);
} catch (Error | RuntimeException e) {
synchronized (this) {
this.processingThread = null;
this.processingTask = null;
this.caughtException = e;
}
return;
Expand All @@ -169,17 +185,19 @@ public void run() {

public void shutdown() {
try {
Thread t = null;
Future<?> t = null;
synchronized (this) {
if (this.processingThread != null) {
t = this.processingThread;
this.processingThread = null;
t = this.processingTask;
if (t != null) {
// stop processing on error:
this.processingTask = null;
notifyAll();
}
}
if (t != null)
t.join(250); // do not wait forever
} catch (InterruptedException ignored) {
if (t != null) {
t.get(250, TimeUnit.MILLISECONDS); // do not wait forever
}
} catch (InterruptedException | ExecutionException | TimeoutException ignored) {
// ignore
}
}
Expand Down
Loading

0 comments on commit 40ec3dd

Please sign in to comment.