Skip to content

Commit

Permalink
Merge master into BETA_JAVA24
Browse files Browse the repository at this point in the history
  • Loading branch information
jarthana authored Oct 28, 2024
2 parents 2ba50f8 + ecb8933 commit 6407141
Show file tree
Hide file tree
Showing 148 changed files with 7,339 additions and 1,722 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: Event File
path: ${{ github.event_path }}
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
mvn -U clean verify --batch-mode --fail-at-end -Ptest-on-javase-21 -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" -Dcbi-ecj-version=99.99
- name: Upload Test Results for Linux
if: always()
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: test-results-linux
if-no-files-found: warn
Expand Down
35 changes: 35 additions & 0 deletions JCL/converterJclMin9/src/java/io/PrintStream.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package java.io;

public class PrintStream {

public void println() {
}

public void println(String s) {
}

public void println(int i) {
}

public void println(Object o) {
}

public void print(String s) {
}

public void print(Object o) {
}

public void print(int i) {
}
}
5 changes: 5 additions & 0 deletions JCL/converterJclMin9/src/java/lang/AutoCloseable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package java.lang;

public interface AutoCloseable {
void close() throws Exception;
}
20 changes: 20 additions & 0 deletions JCL/converterJclMin9/src/java/lang/Override.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*******************************************************************************
* Copyright (c) 2005 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package java.lang;

import java.lang.annotation.ElementType;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;

@Target(ElementType.METHOD) @Retention(RetentionPolicy.SOURCE)
public @interface Override {
}
24 changes: 24 additions & 0 deletions JCL/converterJclMin9/src/java/lang/System.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package java.lang;

import java.io.PrintStream;

public class System {

public static PrintStream err;
public static PrintStream out;

public static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length);
public static String getProperty(String s) {
return null;
}
}
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ For more information and important links, refer to the [JDT wiki page](https://g

[Contributions are always welcome!](https://github.com/eclipse-jdt/.github/blob/main/CONTRIBUTING.md)

Please bear in mind that this project is almost entirely developed by volunteers. If you do not provide the implementation yourself (or pay someone to do it for you), the bug might never get fixed. If it is a serious bug, other people than you might care enough to provide a fix.
Please bear in mind that this project is almost entirely developed by volunteers.
If you do not provide the implementation yourself (or pay someone to do it for you), the bug might never get fixed.
If it is a serious bug, other people than you might care enough to provide a fix.

[![Create Eclipse Development Environment for JDT Core](https://download.eclipse.org/oomph/www/setups/svg/JDT_Core.svg)](
https://www.eclipse.org/setups/installer/?url=https://raw.githubusercontent.com/eclipse-jdt/eclipse.jdt.core/master/org.eclipse.jdt.core.setup/JdtCoreConfiguration.setup&show=true
"Click to open Eclipse-Installer Auto Launch or drag into your running installer")

## License

Expand All @@ -28,4 +34,4 @@ Please bear in mind that this project is almost entirely developed by volunteers

- https://github.com/eclipse-jdt/eclipse.jdt.core/wiki
- https://github.com/eclipse-jdt/.github/blob/main/CONTRIBUTING.md
- http://www.eclipse.org/projects/project.php?id=eclipse.jdt
- https://projects.eclipse.org/projects/eclipse.jdt
4 changes: 1 addition & 3 deletions org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ Require-Bundle: org.junit,
org.eclipse.jdt.core.tests.compiler,
org.eclipse.test.performance,
org.eclipse.jdt.core;bundle-version="[3.40.0,4.0.0)",
org.eclipse.ui.ide,
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
org.eclipse.ui.ide
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Bundle-RequiredExecutionEnvironment: JavaSE-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2231,6 +2231,8 @@ public interface IProblem {
int PreviewAPIUsed = Compliance + 1108;
/** @since 3.39*/
int JavaVersionNotSupported = Compliance + 1109;
/** @since 3.40*/
int JavaVersionTooRecent = Compliance + 1110;

/** @since 3.13 */
int UnlikelyCollectionMethodArgumentType = 1200;
Expand Down Expand Up @@ -2536,7 +2538,9 @@ public interface IProblem {
int SealedPermittedTypeOutsideOfPackage = TypeRelated + 1859;
/** @since 3.28 */
int SealedSealedTypeMissingPermits = TypeRelated + 1860;
/** @since 3.28 */
/** @since 3.28
* @deprecated problem no longer generated
*/
int SealedInterfaceIsSealedAndNonSealed = TypeRelated + 1861;
/** @since 3.28 */
int SealedDisAllowedNonSealedModifierInInterface = TypeRelated + 1862;
Expand All @@ -2546,11 +2550,19 @@ public interface IProblem {
int SealedLocalDirectSuperTypeSealed = TypeRelated + 1864;
/** @since 3.28 */
int SealedAnonymousClassCannotExtendSealedType = TypeRelated + 1865;
/** @since 3.28 */
/** @since 3.28
* @deprecated problem no longer generated
*/
int SealedSuperTypeInDifferentPackage = TypeRelated + 1866;
/** @since 3.28 */
/** @since 3.28
* @deprecated problem no longer generated
*/
int SealedSuperTypeDisallowed = TypeRelated + 1867;
/* Java15 errors - end */
/**
* @since 3.40
*/
int FunctionalInterfaceMayNotbeSealed = TypeRelated + 1868;
/* Java17 Sealed types errors - end */

/**
* @since 3.28
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,7 @@ else if (this.referenceBinding.isAnnotationType())
attributesNumber += generateBootstrapMethods(this.bootstrapMethods);
}
if (this.targetJDK >= ClassFileConstants.JDK17) {
// add record attributes
attributesNumber += generatePermittedTypeAttributes();
attributesNumber += generatePermittedSubclassesAttribute();
}
// Inner class attribute
int numberOfInnerClasses = this.innerClassesBindings == null ? 0 : this.innerClassesBindings.size();
Expand Down Expand Up @@ -2852,10 +2851,9 @@ private int generateNestAttributes() {
nAttrs += generateNestHostAttribute();
return nAttrs;
}
private int generatePermittedTypeAttributes() {
SourceTypeBinding type = this.referenceBinding;
private int generatePermittedSubclassesAttribute() {
int localContentsOffset = this.contentsOffset;
ReferenceBinding[] permittedTypes = type.permittedTypes();
ReferenceBinding[] permittedTypes = this.referenceBinding.permittedTypes();
int l = permittedTypes != null ? permittedTypes.length : 0;
if (l == 0)
return 0;
Expand All @@ -2864,6 +2862,14 @@ private int generatePermittedTypeAttributes() {
if (exSize + localContentsOffset >= this.contents.length) {
resizeContents(exSize);
}
/*
* PermittedSubclasses_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 number_of_classes;
u2 classes[number_of_classes];
}
*/
int attributeNameIndex =
this.constantPool.literalIndex(AttributeNamesConstants.PermittedSubclasses);
this.contents[localContentsOffset++] = (byte) (attributeNameIndex >> 8);
Expand Down Expand Up @@ -5836,7 +5842,6 @@ private int generateTypeAnnotationAttributeForTypeDeclaration() {
superInterface.getAllAnnotationContexts(AnnotationTargetTypeConstants.CLASS_EXTENDS, i, allTypeAnnotationContexts);
}
}
// TODO: permittedTypes codegen
TypeParameter[] typeParameters = typeDeclaration.typeParameters;
if (typeParameters != null) {
for (int i = 0, max = typeParameters.length; i < max; i++) {
Expand Down Expand Up @@ -6038,7 +6043,7 @@ public void initialize(SourceTypeBinding aType, ClassFile parentClassFile, boole
if (aType.isAnonymousType()) {
ReferenceBinding superClass = aType.superclass;
if (superClass == null || !(superClass.isEnum() && superClass.isSealed()))
accessFlags &= ~ClassFileConstants.AccFinal;
accessFlags &= ~ClassFileConstants.AccFinal;
}
int finalAbstract = ClassFileConstants.AccFinal | ClassFileConstants.AccAbstract;
if ((accessFlags & finalAbstract) == finalAbstract) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ private static void decodeModifiers(Set<Modifier> result, int modifiers, int[] c
try {
appendModifier(result, modifiers, checkBit, Modifier.valueOf("NON_SEALED")); //$NON-NLS-1$
} catch(IllegalArgumentException iae) {
// Don't have JDK 15, just ignore and proceed.
// Don't have JDK 17, just ignore and proceed.
}
break;
case ExtraCompilerModifiers.AccSealed :
try {
appendModifier(result, modifiers, checkBit, Modifier.valueOf("SEALED")); //$NON-NLS-1$
} catch(IllegalArgumentException iae) {
// Don't have JDK 15, just ignore and proceed.
// Don't have JDK 17, just ignore and proceed.
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationPosition;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.StringConstant;
import org.eclipse.jdt.internal.compiler.lookup.*;

@SuppressWarnings({"rawtypes", "unchecked"})
Expand Down Expand Up @@ -498,6 +500,8 @@ public final boolean isFieldUseDeprecated(FieldBinding field, Scope scope, int f
// inside same unit - no report
if (scope.isDefinedInSameUnit(field.declaringClass)) return false;

if (sinceValueUnreached(field, scope)) return false;

// if context is deprecated, may avoid reporting
if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false;
return true;
Expand Down Expand Up @@ -548,6 +552,8 @@ public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope,
// inside same unit - no report
if (scope.isDefinedInSameUnit(method.declaringClass)) return false;

if (sinceValueUnreached(method, scope)) return false;

// non explicit use and non explicitly deprecated - no report
if (!isExplicitUse &&
(method.modifiers & ClassFileConstants.AccDeprecated) == 0) {
Expand All @@ -559,6 +565,37 @@ public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope,
return true;
}

private boolean sinceValueUnreached(Binding binding, Scope scope) {
if (binding instanceof TypeBinding typeBinding) {
if (!typeBinding.isReadyForAnnotations()) {
return false;
}
}
AnnotationBinding[] annotations = binding.getAnnotations();
for (AnnotationBinding annotation : annotations) {
if (annotation != null && annotation.getAnnotationType().id == TypeIds.T_JavaLangDeprecated) {
ElementValuePair[] pairs = annotation.getElementValuePairs();
for (ElementValuePair pair : pairs) {
if (CharOperation.equals(pair.getName(), TypeConstants.SINCE)) {
if (pair.getValue() instanceof StringConstant strConstant) {
try {
String value = strConstant.stringValue();
long sinceLevel = CompilerOptions.versionToJdkLevel(value);
long complianceLevel = scope.compilerOptions().complianceLevel;
if (complianceLevel < sinceLevel) {
return true;
}
} catch (NumberFormatException e) {
// do nothing and fall through
}
}
}
}
}
}
return false;
}

public boolean isSuper() {

return false;
Expand Down Expand Up @@ -619,6 +656,8 @@ public final boolean isTypeUseDeprecated(TypeBinding type, Scope scope) {
// inside same unit - no report
if (scope.isDefinedInSameUnit(refType)) return false;

if (sinceValueUnreached(refType, scope)) return false;

// if context is deprecated, may avoid reporting
if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,13 @@ public TypeBinding resolveType(BlockScope scope) {
protected void checkEarlyConstructionContext(BlockScope scope) {
if (JavaFeature.FLEXIBLE_CONSTRUCTOR_BODIES.isSupported(scope.compilerOptions())
&& this.type != null && this.type.resolvedType instanceof ReferenceBinding currentType) {
TypeBinding uninitialized = scope.getMatchingUninitializedType(currentType, !currentType.isLocalType());
// only enclosing types of non-static member types are relevant
if (currentType.isStatic() || currentType.isLocalType())
return;
currentType = currentType.enclosingType();
if (currentType == null)
return;
TypeBinding uninitialized = scope.getMatchingUninitializedType(currentType, true);
if (uninitialized != null)
scope.problemReporter().allocationInEarlyConstructionContext(this, this.resolvedType, uninitialized);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ private Constant resolveCasePattern(BlockScope scope, TypeBinding caseType, Type
if (type != null) {
constant = IntConstant.fromValue(switchStatement.constantIndex);
switchStatement.caseLabelElements.add(e);
if (e instanceof RecordPattern)
switchStatement.containsRecordPatterns = true;

if (isUnguarded)
switchStatement.caseLabelElementTypes.add(type);
Expand All @@ -379,11 +381,8 @@ private Constant resolveCasePattern(BlockScope scope, TypeBinding caseType, Type
// The following code is copied from InstanceOfExpression#resolve()
// But there are enough differences to warrant a copy
if (!type.isReifiable()) {
if (expressionType != TypeBinding.NULL && !(e instanceof RecordPattern)) {
boolean isLegal = e.checkCastTypesCompatibility(scope, type, expressionType, e, false);
if (!isLegal || (e.bits & ASTNode.UnsafeCast) != 0) {
scope.problemReporter().unsafeCastInInstanceof(e, type, expressionType);
}
if (!e.isApplicable(switchExpressionType, scope, e)) {
return Constant.NotAConstant;
}
} else if (type.isValidBinding()) {
// if not a valid binding, an error has already been reported for unresolved type
Expand Down
Loading

0 comments on commit 6407141

Please sign in to comment.