Skip to content

Commit

Permalink
Merge branch 'master' into issue1164
Browse files Browse the repository at this point in the history
  • Loading branch information
jarthana authored Jul 18, 2023
2 parents 04ce81f + 14d8d9a commit b82b4e4
Show file tree
Hide file tree
Showing 25 changed files with 384 additions and 256 deletions.
1 change: 1 addition & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Pbuild-individual-bundles
9 changes: 6 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pipeline {
steps {
sh """#!/bin/bash -x
/opt/tools/java/openjdk/jdk-11/latest/bin/java -version
# /opt/tools/java/openjdk/jdk-11/latest/bin/java -version
java -version
mkdir -p $WORKSPACE/tmp
Expand All @@ -29,10 +29,13 @@ pipeline {
# via configuration/argLine property in pom.xml
# export MAVEN_OPTS="-Xmx2G"
mvn clean install -f org.eclipse.jdt.core.compiler.batch -DlocalEcjVersion=99.99 -Dmaven.repo.local=$WORKSPACE/.m2/repository
mvn -U clean verify --batch-mode --fail-at-end -Dmaven.repo.local=$WORKSPACE/.m2/repository \
-Pbuild-individual-bundles -Ptest-on-javase-20 -Pbree-libs -Papi-check \
-Ptest-on-javase-20 -Pbree-libs -Papi-check \
-Djava.io.tmpdir=$WORKSPACE/tmp -Dproject.build.sourceEncoding=UTF-8 \
-Dtycho.surefire.argLine="--add-modules ALL-SYSTEM -Dcompliance=1.8,11,17,20 -Djdt.performance.asserts=disabled"
-Dtycho.surefire.argLine="--add-modules ALL-SYSTEM -Dcompliance=1.8,11,17,20 -Djdt.performance.asserts=disabled" \
-Dcbi-ecj-version=99.99
"""
}
post {
Expand Down
172 changes: 24 additions & 148 deletions org.eclipse.jdt.core.compiler.batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<properties>
<defaultSigning-excludeInnerJars>true</defaultSigning-excludeInnerJars>
<code.ignoredWarnings>-warn:+fieldHiding,-unavoidableGenericProblems</code.ignoredWarnings>
<localEcjVersion>${project.version}</localEcjVersion>
</properties>

<build>
Expand All @@ -48,157 +49,32 @@
</execution>
</executions>
</plugin>
<!-- XXX ???
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-batch-compiler-source</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/scripts/source</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/scripts/source</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
-->
<!-- XXX ???
<plugin>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-custom-bundle-plugin</artifactId>
<version>${tycho.version}</version>
<executions>
<execution>
<id>batch-compiler-src</id>
<phase>package</phase>
<goals>
<goal>custom-bundle</goal>
</goals>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
<bundleLocation>${project.build.directory}/scripts/source</bundleLocation>
<classifier>batch-compiler-src</classifier>
<fileSets>
<fileSet>
<directory>${project.basedir}/batch</directory>
<excludes>
<exclude>org/eclipse/jdt/internal/compiler/batch/messages.properties</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/classes</directory>
<includes>
<include>org/eclipse/jdt/internal/compiler/batch/messages.properties</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/compiler</directory>
</fileSet>
<fileSet>
<directory>${project.basedir}/antadapter</directory>
<excludes>
<exclude>org/eclipse/jdt/core/CheckDebugAttributes.java</exclude>
<exclude>org/eclipse/jdt/core/BuildJarIndex.java</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../org.eclipse.jdt.compiler.tool/src</directory>
</fileSet>
<fileSet>
<directory>${project.basedir}/../org.eclipse.jdt.compiler.apt/src</directory>
</fileSet>
<fileSet>
<directory>${project.basedir}/scripts</directory>
<includes>
<include>about.html</include>
<include>build.xml</include>
<include>ecj.1</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}</directory>
<includes>
<include>scripts/binary/**</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../org.eclipse.jdt.compiler.tool/lib</directory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
</configuration>
</execution>
<execution>
<id>batch-compiler</id>
<phase>package</phase>
<goals>
<goal>custom-bundle</goal>
</goals>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
<bundleLocation>${project.basedir}/scripts/binary</bundleLocation>
<classifier>batch-compiler</classifier>
<fileSets>
<fileSet>
<directory>${project.build.directory}/jdtCompilerAdapter.jar-classes</directory>
<includes>
<include>META-INF/eclipse.inf</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/scripts</directory>
<includes>
<include>about.html</include>
<include>ecj.1</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/classes</directory>
<includes>
<include>org/eclipse/jdt/internal/compiler/**</include>
<include>org/eclipse/jdt/core/compiler/**</include>
</includes>
<excludes>
<exclude>**/package.htm*</exclude>
<exclude>org/eclipse/jdt/core/compiler/CompilationParticipant*.class</exclude>
<exclude>org/eclipse/jdt/core/compiler/BuildContext.class</exclude>
<exclude>org/eclipse/jdt/core/compiler/IScanner.class</exclude>
<exclude>org/eclipse/jdt/core/compiler/ITerminalSymbols*.class</exclude>
<exclude>org/eclipse/jdt/core/compiler/ReconcileContext*.class</exclude>
<exclude>org/eclipse/jdt/internal/compiler/DocumentElementParser*.class</exclude>
<exclude>org/eclipse/jdt/internal/compiler/IDocumentElementRequestor.class</exclude>
<exclude>org/eclipse/jdt/internal/compiler/ISourceElementRequestor*.class</exclude>
<exclude>org/eclipse/jdt/internal/compiler/SourceElementParser*.class</exclude>
<exclude>org/eclipse/jdt/internal/compiler/SourceElementRequestorAdapter*.class</exclude>
<exclude>org/eclipse/jdt/internal/compiler/SourceJavadocParser*.class</exclude>
<exclude>org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter*.class</exclude>
</excludes>
</fileSet>
</fileSets>
</configuration>
</execution>
</executions>
</plugin>
-->
<!-- ECJ is deployed to maven central under a different artifact id, this ensures that in a local build we also deploy the artifact under that artifact id -->
<!-- Additionally it allow to specify -DlocalEcjVersion=<my custom version> for pin the version used for local deploy -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>deploy-ecj</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>install</phase>
<configuration>
<file>${project.build.directory}/${project.build.finalName}.jar</file>
<artifactId>ecj</artifactId>
<groupId>${project.groupId}</groupId>
<version>${localEcjVersion}</version>
<packaging>jar</packaging>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<baselineMode>warn</baselineMode>
<baselineReplace>common</baselineReplace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ private ReferenceBinding findGroundTargetType(BlockScope blockScope, TypeBinding
freshInferenceContext.cleanUp();
}
} else {
return findGroundTargetTypeForElidedLambda(blockScope, withWildCards);
return withWildCards.getNonWildcardParameterization(blockScope);
}
}
if (targetType instanceof ReferenceBinding)
Expand All @@ -542,15 +542,6 @@ private ReferenceBinding findGroundTargetType(BlockScope blockScope, TypeBinding
return null;
}

public ReferenceBinding findGroundTargetTypeForElidedLambda(BlockScope blockScope, ParameterizedTypeBinding withWildCards) {
// non-wildcard parameterization (9.8) of the target type
TypeBinding[] types = withWildCards.getNonWildcardParameterization(blockScope);
if (types == null)
return null;
ReferenceBinding genericType = withWildCards.genericType();
return blockScope.environment().createParameterizedType(genericType, types, withWildCards.enclosingType());
}

@Override
public boolean argumentsTypeElided() {
return (this.arguments.length > 0 && this.arguments[0].hasElidedType()) || this.argumentsTypeVar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void traverse(ASTVisitor visitor, ClassScope scope) {
@Override
public void updateWithAnnotations(Scope scope, int location) {
super.updateWithAnnotations(scope, location);
if (this.resolvedType instanceof TypeVariableBinding) {
if (this.resolvedType instanceof TypeVariableBinding && !this.resolvedType.hasNullTypeAnnotations()) {
// refresh this binding in case a decorated binding was created during ClassScope.connectTypeVariables()
TypeVariableBinding tvb = (TypeVariableBinding) this.resolvedType;
Binding declaringElement = tvb.declaringElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,8 @@ public TypeBinding resolveTypeInternal(BlockScope upperScope) {
for (int i = 0; i < resultExpressionsCount; i++) {
Expression resultExpr = this.resultExpressions.get(i);
TypeBinding origType = this.originalTypeMap.get(resultExpr);
if (origType == null || origType.kind() == Binding.POLY_TYPE) {
// NB: if origType == null we assume that initial resolving failed hard, rendering re-resolving impossible
if (origType != null && origType.kind() == Binding.POLY_TYPE) {
this.finalValueResultExpressionTypes[i] = this.originalValueResultExpressionTypes[i] =
resultExpr.resolveTypeExpecting(upperScope, this.expectedType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.eclipse.jdt.internal.compiler.env.IMultiModuleEntry;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.ExternalAnnotationStatus;
import org.eclipse.jdt.internal.compiler.util.CtSym;
import org.eclipse.jdt.internal.compiler.util.JRTUtil;

@SuppressWarnings({"rawtypes", "unchecked"})
Expand Down Expand Up @@ -405,4 +406,11 @@ public IModule getModule(char[] moduleName) {
public boolean servesModule(char[] moduleName) {
return getModule(moduleName) != null;
}

public static void clearCache(String path, String releaseVersion) {
if (releaseVersion != null) {
path += '|'+ CtSym.getReleaseCode(releaseVersion);
}
ModulesCache.remove(path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;

import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.util.Util;

// clinit methods (synthetics too?) can be returned from IBinaryType>>getMethods()
// BUT do not have to be... the compiler will ignore them when building the binding.
// The synthetic argument of a member type's constructor (i.e. the first arg of a non-static
Expand Down Expand Up @@ -101,4 +104,36 @@ public interface IBinaryMethod extends IGenericMethod {
* Answer the type annotations on this method.
*/
IBinaryTypeAnnotation[] getTypeAnnotations();

/**
* Answer the number of method parameters based on analysis of the method descriptor.
* @return the number of parameters or {@code -1} if the descriptor was malformed.
*/
default int getParameterCount() {
// copy-adjusted from org.eclipse.jdt.core.Signature.getParameterCount(char[])
char[] methodSignature = getMethodDescriptor();
try {
int count = 0;
int i = CharOperation.indexOf(Util.C_PARAM_START, methodSignature);
if (i < 0) {
return -1;
} else {
i++;
}
for (;;) {
if (methodSignature[i] == Util.C_PARAM_END) {
return count;
}
int e= Util.scanTypeSignature(methodSignature, i);
if (e < 0) {
return -1;
} else {
i = e + 1;
}
count++;
}
} catch (ArrayIndexOutOfBoundsException e) {
return -1;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ private MethodBinding createMethod(IBinaryMethod method, IBinaryType binaryType,
walker = binaryType.enrichWithExternalAnnotationsFor(walker, method, this.environment);
}
if (walker == ITypeAnnotationWalker.EMPTY_ANNOTATION_WALKER && this.environment.globalOptions.isAnnotationBasedNullAnalysisEnabled) {
walker = provideSyntheticEEA(method, argumentNames, walker);
walker = provideSyntheticEEA(method, walker);
}
methodModifiers |= ExtraCompilerModifiers.AccGenericSignature;
// MethodTypeSignature = ParameterPart(optional) '(' TypeSignatures ')' return_typeSignature ['^' TypeSignature (optional)]
Expand Down Expand Up @@ -1153,17 +1153,20 @@ private MethodBinding createMethod(IBinaryMethod method, IBinaryType binaryType,
return result;
}

protected ITypeAnnotationWalker provideSyntheticEEA(IBinaryMethod method, char[][] argumentNames, ITypeAnnotationWalker walker) {
protected ITypeAnnotationWalker provideSyntheticEEA(IBinaryMethod method, ITypeAnnotationWalker walker) {
switch (this.id) {
case TypeIds.T_JavaUtilObjects:
if (this.environment.globalOptions.complianceLevel >= ClassFileConstants.JDK1_8
&& CharOperation.equals(method.getSelector(), TypeConstants.REQUIRE_NON_NULL)
&& argumentNames != null && argumentNames.length > 0)
&& CharOperation.equals(method.getSelector(), TypeConstants.REQUIRE_NON_NULL))
{
String eeaSource = argumentNames.length == 1
? "<TT;>(T0T;)T1T;" //$NON-NLS-1$
: "<TT;>(T0T;L0java/lang/String;)T1T;"; //$NON-NLS-1$
walker = ExternalAnnotationProvider.synthesizeForMethod(eeaSource.toCharArray(), this.environment);
String eeaSource = switch(method.getParameterCount()) {
case 1 -> "<TT;>(T0T;)T1T;"; //$NON-NLS-1$
case 2 -> "<TT;>(T0T;L0java/lang/String;)T1T;"; //$NON-NLS-1$
default -> null;
};
if (eeaSource != null) {
walker = ExternalAnnotationProvider.synthesizeForMethod(eeaSource.toCharArray(), this.environment);
}
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public static ReferenceBinding findGroundTargetType(InferenceContext18 inference
LambdaExpression lambda, ParameterizedTypeBinding targetTypeWithWildCards)
{
if (lambda.argumentsTypeElided()) {
return lambda.findGroundTargetTypeForElidedLambda(scope, targetTypeWithWildCards);
return targetTypeWithWildCards.getNonWildcardParameterization(scope);
} else {
SuspendedInferenceRecord previous = inferenceContext.enterLambda(lambda);
try {
Expand Down
Loading

0 comments on commit b82b4e4

Please sign in to comment.