Skip to content

Commit

Permalink
Merge pull request #7484 from lahodaj/javac23-upgrade
Browse files Browse the repository at this point in the history
Upgrade to nb-javac from JDK 23, build 30
  • Loading branch information
mbien authored Jul 10, 2024
2 parents 846d426 + 75ed6f1 commit fcb864f
Show file tree
Hide file tree
Showing 33 changed files with 137 additions and 813 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1424,10 +1424,10 @@ jobs:
timeout-minutes: 60
strategy:
matrix:
java: [ '17', '22' ]
java: [ '17', '23-ea' ]
config: [ 'batch1', 'batch2' ]
exclude:
- java: ${{ github.event_name == 'pull_request' && 'nothing' || '22' }}
- java: ${{ github.event_name == 'pull_request' && 'nothing' || '23-ea' }}
fail-fast: false
steps:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Signature file v4.1
#Version 1.133.0
#Version 1.134.0

CLSS public abstract interface com.sun.source.tree.TreeVisitor<%0 extends java.lang.Object, %1 extends java.lang.Object>
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitAnnotatedType(com.sun.source.tree.AnnotatedTypeTree,{com.sun.source.tree.TreeVisitor%1})
Expand Down Expand Up @@ -56,7 +56,6 @@ meth public abstract {com.sun.source.tree.TreeVisitor%0} visitPrimitiveType(com.
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitProvides(com.sun.source.tree.ProvidesTree,{com.sun.source.tree.TreeVisitor%1})
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitRequires(com.sun.source.tree.RequiresTree,{com.sun.source.tree.TreeVisitor%1})
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitReturn(com.sun.source.tree.ReturnTree,{com.sun.source.tree.TreeVisitor%1})
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitStringTemplate(com.sun.source.tree.StringTemplateTree,{com.sun.source.tree.TreeVisitor%1})
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitSwitch(com.sun.source.tree.SwitchTree,{com.sun.source.tree.TreeVisitor%1})
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitSwitchExpression(com.sun.source.tree.SwitchExpressionTree,{com.sun.source.tree.TreeVisitor%1})
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitSynchronized(com.sun.source.tree.SynchronizedTree,{com.sun.source.tree.TreeVisitor%1})
Expand Down Expand Up @@ -140,7 +139,6 @@ meth public {com.sun.source.util.TreeScanner%0} visitPrimitiveType(com.sun.sourc
meth public {com.sun.source.util.TreeScanner%0} visitProvides(com.sun.source.tree.ProvidesTree,{com.sun.source.util.TreeScanner%1})
meth public {com.sun.source.util.TreeScanner%0} visitRequires(com.sun.source.tree.RequiresTree,{com.sun.source.util.TreeScanner%1})
meth public {com.sun.source.util.TreeScanner%0} visitReturn(com.sun.source.tree.ReturnTree,{com.sun.source.util.TreeScanner%1})
meth public {com.sun.source.util.TreeScanner%0} visitStringTemplate(com.sun.source.tree.StringTemplateTree,{com.sun.source.util.TreeScanner%1})
meth public {com.sun.source.util.TreeScanner%0} visitSwitch(com.sun.source.tree.SwitchTree,{com.sun.source.util.TreeScanner%1})
meth public {com.sun.source.util.TreeScanner%0} visitSwitchExpression(com.sun.source.tree.SwitchExpressionTree,{com.sun.source.util.TreeScanner%1})
meth public {com.sun.source.util.TreeScanner%0} visitSynchronized(com.sun.source.tree.SynchronizedTree,{com.sun.source.util.TreeScanner%1})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,6 @@ protected void resolve(CompilationController controller) throws IOException {
case DECONSTRUCTION_PATTERN:
insideDeconstructionRecordPattern(env);
break;
case TEMPLATE:
insideStringTemplate(env);
break;
}
}

Expand Down Expand Up @@ -3395,16 +3392,6 @@ private boolean isSealedSupported(final Env env) {
return env.getController().getSourceVersion().compareTo(SourceVersion.RELEASE_15) >= 0;
}

private void insideStringTemplate(Env env) throws IOException {
final int offset = env.getOffset();
final TreePath path = env.getPath();
TokenSequence<JavaTokenId> ts = findLastNonWhitespaceToken(env, path.getLeaf(), offset);
if (ts.token().id() == JavaTokenId.STRING_LITERAL || ts.token().id() == JavaTokenId.MULTILINE_STRING_LITERAL) {
localResult(env);
addValueKeywords(env);
}
}

private void localResult(Env env) throws IOException {
addLocalMembersAndVars(env);
addClassTypes(env, null);
Expand Down Expand Up @@ -6186,10 +6173,6 @@ public boolean accept(Element e, TypeMirror t) {
break;
case BLOCK:
return null;
case TEMPLATE:
//TODO:can there be good smart types?
//(how about incomplete String templates?)
return null;
}
lastTree = tree;
path = path.getParentPath();
Expand Down

This file was deleted.

This file was deleted.

10 changes: 2 additions & 8 deletions java/java.hints/src/org/netbeans/modules/java/hints/Imports.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,8 @@ private static List<TreePathHandle> getAllImportsOfKind(CompilationInfo ci, Impo
if (it.getQualifiedIdentifier() instanceof MemberSelectTree) {
MemberSelectTree ms = (MemberSelectTree) it.getQualifiedIdentifier();
if (kind == ImportHintKind.DEFAULT_PACKAGE) {
if (it.isStatic()) {
if (ms.getExpression().toString().equals("java.lang.StringTemplate") && ms.getIdentifier().toString().equals("STR")) {
result.add(TreePathHandle.create(new TreePath(topLevel, it), ci));
}
} else {
if ((ms.getExpression().toString().equals(DEFAULT_PACKAGE))) {
result.add(TreePathHandle.create(new TreePath(topLevel, it), ci));
}
if (!it.isStatic() && ms.getExpression().toString().equals(DEFAULT_PACKAGE)) {
result.add(TreePathHandle.create(new TreePath(topLevel, it), ci));
}
}
if (it.isStatic()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
import com.sun.source.tree.RequiresTree;
import com.sun.source.tree.ReturnTree;
import com.sun.source.tree.Scope;
import com.sun.source.tree.StringTemplateTree;
import com.sun.source.tree.SwitchExpressionTree;
import com.sun.source.tree.SwitchTree;
import com.sun.source.tree.SynchronizedTree;
Expand Down Expand Up @@ -1432,12 +1431,6 @@ public List<? extends TypeMirror> visitDeconstructionPattern(DeconstructionPatte
return null;
}

@Override
public List<? extends TypeMirror> visitStringTemplate(StringTemplateTree stt, Object p) {
//TODO:
return null;
}

@Override
public List<? extends TypeMirror> visitAnyPattern(AnyPatternTree apt, Object p) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
*/
package org.netbeans.modules.java.hints;

import javax.lang.model.SourceVersion;
import org.netbeans.junit.NbTestCase;
import org.netbeans.modules.java.hints.test.api.HintTest;

import static org.junit.Assume.assumeTrue;

/**
*
* @author lahvac
Expand Down Expand Up @@ -61,33 +58,26 @@ public void testUnusedSimpleRemove() throws Exception {
}

public void testRedundantLangImportRemove() throws Exception {
assumeTrue(Runtime.version().feature() >= 21); // API dependency
HintTest.create()
.sourceLevel(SourceVersion.latest().ordinal())
.options("--enable-preview")
.input(
"package test;\n" +
"import java.lang.Exception;\n" +
"import java.lang.System;\n" +
"import static java.lang.StringTemplate.STR;\n" +
"import static java.lang.StringTemplate.RAW;\n" +
"public class Test {\n" +
" public static void main(String[] args) {\n" +
" System.out.println(STR.\"hello world\");\n" +
" System.out.println(RAW.\"hello world\");" +
" public static void main(String[] args) throws Exception {\n" +
" System.out.println(\"hello world\");\n" +
" }\n" +
"}")
.run(Imports.class)
.assertWarnings("1:0-1:24:verifier:DN_Imports_DEFAULT_PACKAGE", "2:0-2:43:verifier:DN_Imports_DEFAULT_PACKAGE")
.findWarning("1:0-1:24:verifier:DN_Imports_DEFAULT_PACKAGE")
.assertWarnings("1:0-1:27:verifier:DN_Imports_DEFAULT_PACKAGE", "2:0-2:24:verifier:DN_Imports_DEFAULT_PACKAGE")
.findWarning("2:0-2:24:verifier:DN_Imports_DEFAULT_PACKAGE")
.applyFix("LBL_Imports_Fix_All_DEFAULT_PACKAGE")
.assertCompilable()
.assertOutput(
"package test;\n" +
"import static java.lang.StringTemplate.RAW;\n" +
"public class Test {\n" +
" public static void main(String[] args) {\n" +
" System.out.println(STR.\"hello world\");\n" +
" System.out.println(RAW.\"hello world\");" +
" public static void main(String[] args) throws Exception {\n" +
" System.out.println(\"hello world\");\n" +
" }\n" +
"}");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Signature file v4.1
#Version 2.66.0
#Version 2.68.0

CLSS public abstract interface com.sun.source.tree.TreeVisitor<%0 extends java.lang.Object, %1 extends java.lang.Object>
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitAnnotatedType(com.sun.source.tree.AnnotatedTypeTree,{com.sun.source.tree.TreeVisitor%1})
Expand Down Expand Up @@ -56,7 +56,6 @@ meth public abstract {com.sun.source.tree.TreeVisitor%0} visitPrimitiveType(com.
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitProvides(com.sun.source.tree.ProvidesTree,{com.sun.source.tree.TreeVisitor%1})
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitRequires(com.sun.source.tree.RequiresTree,{com.sun.source.tree.TreeVisitor%1})
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitReturn(com.sun.source.tree.ReturnTree,{com.sun.source.tree.TreeVisitor%1})
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitStringTemplate(com.sun.source.tree.StringTemplateTree,{com.sun.source.tree.TreeVisitor%1})
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitSwitch(com.sun.source.tree.SwitchTree,{com.sun.source.tree.TreeVisitor%1})
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitSwitchExpression(com.sun.source.tree.SwitchExpressionTree,{com.sun.source.tree.TreeVisitor%1})
meth public abstract {com.sun.source.tree.TreeVisitor%0} visitSynchronized(com.sun.source.tree.SynchronizedTree,{com.sun.source.tree.TreeVisitor%1})
Expand Down Expand Up @@ -140,7 +139,6 @@ meth public {com.sun.source.util.TreeScanner%0} visitPrimitiveType(com.sun.sourc
meth public {com.sun.source.util.TreeScanner%0} visitProvides(com.sun.source.tree.ProvidesTree,{com.sun.source.util.TreeScanner%1})
meth public {com.sun.source.util.TreeScanner%0} visitRequires(com.sun.source.tree.RequiresTree,{com.sun.source.util.TreeScanner%1})
meth public {com.sun.source.util.TreeScanner%0} visitReturn(com.sun.source.tree.ReturnTree,{com.sun.source.util.TreeScanner%1})
meth public {com.sun.source.util.TreeScanner%0} visitStringTemplate(com.sun.source.tree.StringTemplateTree,{com.sun.source.util.TreeScanner%1})
meth public {com.sun.source.util.TreeScanner%0} visitSwitch(com.sun.source.tree.SwitchTree,{com.sun.source.util.TreeScanner%1})
meth public {com.sun.source.util.TreeScanner%0} visitSwitchExpression(com.sun.source.tree.SwitchExpressionTree,{com.sun.source.util.TreeScanner%1})
meth public {com.sun.source.util.TreeScanner%0} visitSynchronized(com.sun.source.tree.SynchronizedTree,{com.sun.source.util.TreeScanner%1})
Expand Down Expand Up @@ -1506,7 +1504,6 @@ meth public com.sun.source.tree.PrimitiveTypeTree PrimitiveType(javax.lang.model
meth public com.sun.source.tree.ProvidesTree Provides(com.sun.source.tree.ExpressionTree,java.util.List<? extends com.sun.source.tree.ExpressionTree>)
meth public com.sun.source.tree.RequiresTree Requires(boolean,boolean,com.sun.source.tree.ExpressionTree)
meth public com.sun.source.tree.ReturnTree Return(com.sun.source.tree.ExpressionTree)
meth public com.sun.source.tree.StringTemplateTree StringTemplate(com.sun.source.tree.ExpressionTree,java.util.List<java.lang.String>,java.util.List<? extends com.sun.source.tree.ExpressionTree>)
meth public com.sun.source.tree.SwitchTree Switch(com.sun.source.tree.ExpressionTree,java.util.List<? extends com.sun.source.tree.CaseTree>)
meth public com.sun.source.tree.SwitchTree addSwitchCase(com.sun.source.tree.SwitchTree,com.sun.source.tree.CaseTree)
meth public com.sun.source.tree.SwitchTree insertSwitchCase(com.sun.source.tree.SwitchTree,int,com.sun.source.tree.CaseTree)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3917,16 +3917,4 @@ public LambdaExpressionTree setLambdaBody(LambdaExpressionTree method, Tree newB
return delegate.setLambdaBody(method, newBody);
}

/**Creates a new string template expression from the given parameters.
*
* @param processor the processor of the string template
* @param fragments the template fragments
* @param expressions the template expressions
* @return the string template instance
* @since 2.65
*/
public StringTemplateTree StringTemplate(ExpressionTree processor, List<String> fragments, List<? extends ExpressionTree> expressions) {
return delegate.StringTemplate(processor, fragments, expressions);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public class NoJavacHelper {

public static final int REQUIRED_JAVAC_VERSION = 22; // <- TODO: increment on every release
public static final int REQUIRED_JAVAC_VERSION = 23; // <- TODO: increment on every release
private static final boolean HAS_WORKING_JAVAC;

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,6 @@ public PatternCaseLabelTree PatternCaseLabel(PatternTree pat) {
return make.at(NOPOS).PatternCaseLabel((JCPattern) pat);
}

public StringTemplateTree StringTemplate(ExpressionTree processor, List<String> fragments, List<? extends ExpressionTree> expressions) {
return make.at(NOPOS).StringTemplate((JCExpression) processor,
fragments.stream().collect(com.sun.tools.javac.util.List.collector()),
expressions.stream().map(expr -> (JCExpression) expr).collect(com.sun.tools.javac.util.List.collector()));
}

public AnyPatternTree AnyPattern() {
return make.at(NOPOS).AnyPattern();
}
Expand Down
Loading

0 comments on commit fcb864f

Please sign in to comment.