Merge pull request #3840 from Rawi01/jdk24

Add JDK 24 support
This commit is contained in:
Reinier Zwitserloot authored and GitHub committed 2025-03-07 00:12:29 +01:00
commit e29f9a4b52
4 files changed
+34 -21

No files matched your search

+2 -2
View File
@@ -41,10 +41,10 @@ jobs:
runs-on: ubuntu-24.04
needs: build
env:
EA_JDK: 23
EA_JDK: 24
strategy:
matrix:
jdk: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
jdk: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
goal: [javacCurrent]
include:
- jdk: 11
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2022 The Project Lombok Authors.
* Copyright (C) 2009-2025 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -592,38 +592,42 @@ public class JavacHandlerUtil {
private static final Field astField;
private static final Field originalAnnos;
private static final Method findRecordComponentToRemove;
private static final Method getRecordComponents = Permit.permissiveGetMethod(ClassSymbol.class, "getRecordComponents");
static {
Field a = null;
Field o = null;
Method m = null;
try {
Class<?> forName = Class.forName("com.sun.tools.javac.code.Symbol$RecordComponent");
a = Permit.permissiveGetField(forName, "ast");
o = Permit.permissiveGetField(forName, "originalAnnos");
m = Permit.permissiveGetMethod(ClassSymbol.class, "findRecordComponentToRemove", JCVariableDecl.class);
} catch (Throwable e) {
// Ignore
}
astField = a;
originalAnnos = o;
findRecordComponentToRemove = m;
}
static void deleteAnnotation(JCClassDecl record, JCVariableDecl component, JCTree annotation) {
if ((astField == null && originalAnnos == null) || findRecordComponentToRemove == null) return;
if ((astField == null && originalAnnos == null) || getRecordComponents == null) return;
try {
Object toRemove = Permit.invokeSneaky(findRecordComponentToRemove, record.sym, component);
if (astField != null) {
// OpenJDK
JCVariableDecl variable = Permit.get(astField, toRemove);
variable.mods.annotations = filterListByPos(variable.mods.annotations, annotation);
} else {
// Zulu JDK 17
List<JCAnnotation> annotations = Permit.get(originalAnnos, toRemove);
Permit.set(originalAnnos, toRemove, filterListByPos(annotations, annotation));
List<?> recordComponents = (List<?>) Permit.invokeSneaky(getRecordComponents, record.sym);
for (Object recordComponent : recordComponents) {
Name recordComponentName = ((Symbol) recordComponent).name;
if (!recordComponentName.equals(component.name)) continue;
if (astField != null) {
// OpenJDK
JCVariableDecl variable = Permit.get(astField, recordComponent);
variable.mods.annotations = filterListByPos(variable.mods.annotations, annotation);
} else {
// Zulu JDK 17
List<JCAnnotation> annotations = Permit.get(originalAnnos, recordComponent);
Permit.set(originalAnnos, recordComponent, filterListByPos(annotations, annotation));
}
return;
}
} catch (Throwable e) {
// Ignore
+11 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2024 The Project Lombok Authors.
* Copyright (C) 2009-2025 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -184,7 +184,16 @@ public class Javac {
public static final TypeTag CTC_NONE = typeTag("NONE");
public static final TypeTag CTC_BOT = typeTag("BOT");
public static final TypeTag CTC_ERROR = typeTag("ERROR");
public static final TypeTag CTC_UNKNOWN = typeTag("UNKNOWN");
public static final TypeTag CTC_UNKNOWN; // Removed in JDK24
static {
TypeTag unknonwTypeTag = null;
try {
unknonwTypeTag = typeTag("UNKNOWN");
} catch (Exception e) {
if (!(e instanceof NoSuchFieldException)) throw Javac.sneakyThrow(e);
}
CTC_UNKNOWN = unknonwTypeTag;
}
public static final TypeTag CTC_UNDETVAR = typeTag("UNDETVAR");
public static final TypeTag CTC_CLASS = typeTag("CLASS");
+2 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 The Project Lombok Authors.
* Copyright (C) 2010-2025 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -105,7 +105,7 @@ public class TreeMirrorMaker extends TreeCopier<Void> {
boolean wipeSymAndType = copy.type.isErroneous();
if (!wipeSymAndType) {
TypeTag typeTag = TypeTag.typeTag(copy.type);
wipeSymAndType = (CTC_NONE.equals(typeTag) || CTC_ERROR.equals(typeTag) || CTC_UNKNOWN.equals(typeTag) || CTC_UNDETVAR.equals(typeTag));
wipeSymAndType = (typeTag.equals(CTC_NONE) || typeTag.equals(CTC_ERROR) || typeTag.equals(CTC_UNKNOWN) || typeTag.equals(CTC_UNDETVAR));
}
if (wipeSymAndType) {