Skip to content

Commit b572b48

Browse files
authored
Merge pull request #8709 from apache/delivery
Sync delivery to master after 27-rc3
2 parents 078fb05 + e2eb87d commit b572b48

File tree

10 files changed

+109
-50
lines changed

10 files changed

+109
-50
lines changed

extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ private String getTaskInheritance(Task t) {
307307
"shouldRunAfter",
308308
"enabled",
309309
"description",
310-
"vendor",
311-
"group"
310+
"group",
311+
"toolchainDownloadUrls" // UpdateDaemonJvm fron org.gradle.toolchains.foojay-resolver-convention accesses online sevice for URLs
312312
));
313313

314314
private void detectTaskProperties(NbProjectInfoModel model) {
@@ -718,6 +718,11 @@ private void inspectObjectAndValues0(Class clazz, Object object, String prefix,
718718
if ((mp.getModifiers() & Modifier.PUBLIC) == 0) {
719719
continue;
720720
}
721+
// ignore static properties for now. If needed, they must be exported somehow per-class and protected
722+
// against recursion.
723+
if ((mp.getModifiers() & Modifier.STATIC) != 0) {
724+
continue;
725+
}
721726
if (object != null) {
722727
// Provider must NOT be asked for a value, otherwise it might run a Task in order to compute
723728
// the value.

extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NetBeansRunSinglePlugin.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.netbeans.modules.gradle.tooling;
2121

2222
import static java.util.Arrays.asList;
23+
import java.util.List;
2324
import java.util.Set;
2425
import org.gradle.api.DefaultTask;
2526
import org.gradle.api.logging.Logger;
@@ -76,15 +77,8 @@ private void configureJavaExec(Project project, JavaExec je) {
7677
je.setArgs(asList(project.property(RUN_SINGLE_ARGS).toString().split(" ")));
7778
}
7879
if (project.hasProperty(RUN_SINGLE_JVM_ARGS)) {
79-
// Property jvmArgumentProviders should not be implemented as a lambda to allow execution optimizations.
80-
// See https://docs.gradle.org/current/userguide/validation_problems.html#implementation_unknown
81-
je.getJvmArgumentProviders().add(new CommandLineArgumentProvider() {
82-
// Do not convert to lambda.
83-
@Override
84-
public Iterable<String> asArguments() {
85-
return asList(project.property(RUN_SINGLE_JVM_ARGS).toString().split(" "));
86-
}
87-
});
80+
// do not use plain setter, as other Plugins may provide their own JVM flags + providers.
81+
je.getJvmArgumentProviders().add(new JvmArgumentsHolder(asList(project.property(RUN_SINGLE_JVM_ARGS).toString().split(" "))));
8882
}
8983
try {
9084
je.setStandardInput(System.in);
@@ -112,4 +106,22 @@ private void addTask(Project project, Task runTask) {
112106
runSingle.configure((task) -> task.doFirst((action) -> project.getLogger().warn(DEPRECATE_RUN_SINGLE)));
113107
}
114108

109+
/**
110+
* A simple holder to add JVM arguments on top of other args provide by other plugins.
111+
* DO NOT store Project or other resource-bound references here, keep static. It is attached to a task
112+
* as a provider and serialized/cached. See Micronaut Configuration
113+
* Cache requirements.
114+
*/
115+
private static class JvmArgumentsHolder implements CommandLineArgumentProvider {
116+
private final List<String> jvmArguments;
117+
118+
public JvmArgumentsHolder(List<String> jvmArguments) {
119+
this.jvmArguments = jvmArguments;
120+
}
121+
122+
@Override
123+
public Iterable<String> asArguments() {
124+
return jvmArguments;
125+
}
126+
}
115127
}

java/java.disco/external/binaries-list

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
4FCCADF37F1C61A0895BAC3D42FE0C530438826C org.checkerframework:checker-qual:3.9.1
18-
CE10D968585304A7463430DD53254E6D6893DF16 io.foojay.api:discoclient:2.0.24
19-
F66F9FC72A84FCAB1579202728EE572BDBB46DD7 eu.hansolo:jdktools:11.0.11
18+
BB975ACE8403330DCC7ABF61A3142B0B59ADC755 io.foojay.api:discoclient:2.0.39
19+
AD117688D24FACCF74D3B76AFFFC2693C4F5D122 eu.hansolo:jdktools:11.0.19

java/java.disco/external/discoclient-2.0.24-license.txt renamed to java/java.disco/external/discoclient-2.0.39-license.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Name: DiscoClient
22
Origin: Gerrit Grunwald
3-
Version: 2.0.24
3+
Version: 2.0.39
44
License: Apache-2.0
55
Description: Library to access the Foojay.io Discovery API service.
66
Origin: https://github.com/foojayio/discoclient

java/java.disco/external/jdktools-11.0.11-license.txt renamed to java/java.disco/external/jdktools-11.0.19-license.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Name: JDKTools
22
Origin: Gerrit Grunwald
3-
Version: 11.0.11
3+
Version: 11.0.19
44
License: Apache-2.0
55
Description: Collection of classes for working with OpenJDK related things.
66
Origin: https://github.com/HanSolo/jdktools

java/java.disco/nbproject/project.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
is.autoload=true
1919
release.external/checker-qual-3.9.1.jar=modules/ext/checker-qual-3.9.1.jar
20-
release.external/jdktools-11.0.11.jar=modules/ext/jdktools-11.0.11.jar
21-
release.external/discoclient-2.0.24.jar=modules/ext/discoclient-2.0.24.jar
22-
javac.release=11
20+
release.external/jdktools-11.0.19.jar=modules/ext/jdktools-11.0.19.jar
21+
release.external/discoclient-2.0.39.jar=modules/ext/discoclient-2.0.39.jar
22+
javac.release=17
2323
javac.compilerargs=-Xlint -Xlint:-serial

java/java.disco/nbproject/project.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<build-prerequisite/>
3737
<compile-dependency/>
3838
<run-dependency>
39-
<specification-version>2.8.5</specification-version>
39+
<specification-version>2.9.1</specification-version>
4040
</run-dependency>
4141
</dependency>
4242
<dependency>
@@ -202,12 +202,12 @@
202202
</module-dependencies>
203203
<public-packages/>
204204
<class-path-extension>
205-
<runtime-relative-path>ext/discoclient-2.0.24.jar</runtime-relative-path>
206-
<binary-origin>external/discoclient-2.0.24.jar</binary-origin>
205+
<runtime-relative-path>ext/discoclient-2.0.39.jar</runtime-relative-path>
206+
<binary-origin>external/discoclient-2.0.39.jar</binary-origin>
207207
</class-path-extension>
208208
<class-path-extension>
209-
<runtime-relative-path>ext/jdktools-11.0.11.jar</runtime-relative-path>
210-
<binary-origin>external/jdktools-11.0.11.jar</binary-origin>
209+
<runtime-relative-path>ext/jdktools-11.0.19.jar</runtime-relative-path>
210+
<binary-origin>external/jdktools-11.0.19.jar</binary-origin>
211211
</class-path-extension>
212212
<class-path-extension>
213213
<runtime-relative-path>ext/checker-qual-3.9.1.jar</runtime-relative-path>

java/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
import com.sun.tools.javac.tree.JCTree.JCOpens;
106106
import com.sun.tools.javac.tree.JCTree.JCPackageDecl;
107107
import com.sun.tools.javac.tree.JCTree.JCParens;
108+
import com.sun.tools.javac.tree.JCTree.JCPatternCaseLabel;
108109
import com.sun.tools.javac.tree.JCTree.JCPrimitiveTypeTree;
109110
import com.sun.tools.javac.tree.JCTree.JCProvides;
110111
import com.sun.tools.javac.tree.JCTree.JCRecordPattern;
@@ -2096,6 +2097,10 @@ protected int diffConstantCaseLabel(JCConstantCaseLabel oldT, JCConstantCaseLabe
20962097
return diffTree((JCTree) oldT.expr, (JCTree) newT.expr, bounds);
20972098
}
20982099

2100+
protected int diffPatternCaseLabel(JCPatternCaseLabel oldT, JCPatternCaseLabel newT, int[] bounds) {
2101+
return diffTree(oldT.pat, newT.pat, bounds);
2102+
}
2103+
20992104
protected int diffCase(JCCase oldT, JCCase newT, int[] bounds) {
21002105
int localPointer = bounds[0];
21012106
List<? extends JCTree.JCCaseLabel> oldPatterns = oldT.getLabels();
@@ -5873,6 +5878,9 @@ private int diffTreeImpl0(JCTree oldT, JCTree newT, JCTree parent /*used only fo
58735878
case CONSTANTCASELABEL:
58745879
retVal = diffConstantCaseLabel((JCConstantCaseLabel) oldT, (JCConstantCaseLabel) newT, elementBounds);
58755880
break;
5881+
case PATTERNCASELABEL:
5882+
retVal = diffPatternCaseLabel((JCPatternCaseLabel)oldT, (JCPatternCaseLabel)newT, elementBounds);
5883+
break;
58765884
case RECORDPATTERN:
58775885
retVal = diffRecordPattern((JCRecordPattern) oldT, (JCRecordPattern) newT, elementBounds);
58785886
break;

java/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/SwitchTest.java

Lines changed: 60 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
import com.sun.source.tree.BlockTree;
2222
import com.sun.source.tree.CaseTree;
2323
import com.sun.source.tree.ExpressionTree;
24+
import com.sun.source.tree.IdentifierTree;
2425
import com.sun.source.tree.IfTree;
2526
import com.sun.source.tree.StatementTree;
2627
import com.sun.source.tree.SwitchTree;
2728
import com.sun.source.tree.Tree.Kind;
29+
import com.sun.source.tree.VariableTree;
2830
import com.sun.source.util.TreePath;
2931
import com.sun.tools.javac.tree.JCTree;
3032
import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
@@ -238,9 +240,6 @@ public void run(final WorkingCopy copy) throws IOException {
238240
}
239241

240242
public void testCaseMultiTest() throws Exception {
241-
if (!enhancedSwitchAvailable())
242-
return;
243-
244243
class TestCase {
245244
public final String caseText;
246245
public final BiFunction<WorkingCopy, CaseTree, CaseTree> convertCase;
@@ -369,9 +368,6 @@ public void run(CompilationController cc) throws Exception {
369368
}
370369

371370
public void testStatement2Rule() throws Exception {
372-
if (!enhancedSwitchAvailable())
373-
return;
374-
375371
testFile = new File(getWorkDir(), "Test.java");
376372
String test = "public class Test {\n" +
377373
" void m(int p) {\n" +
@@ -417,9 +413,6 @@ public void run(final WorkingCopy copy) throws IOException {
417413
}
418414

419415
public void testRule2Statement() throws Exception {
420-
if (!enhancedSwitchAvailable())
421-
return;
422-
423416
testFile = new File(getWorkDir(), "Test.java");
424417
String test = "public class Test {\n" +
425418
" void m(int p) {\n" +
@@ -467,9 +460,6 @@ public void run(final WorkingCopy copy) throws IOException {
467460
}
468461

469462
public void testDefaultRewrite() throws Exception {
470-
if (!enhancedSwitchAvailable())
471-
return;
472-
473463
testFile = new File(getWorkDir(), "Test.java");
474464
String test = "public class Test {\n" +
475465
" void m(int p) {\n" +
@@ -511,9 +501,6 @@ public void run(final WorkingCopy copy) throws IOException {
511501
}
512502

513503
public void testStatement2RuleNoSpace() throws Exception {
514-
if (!enhancedSwitchAvailable())
515-
return;
516-
517504
testFile = new File(getWorkDir(), "Test.java");
518505
String test = "public class Test {\n" +
519506
" void m(int p) {\n" +
@@ -561,9 +548,6 @@ public void run(final WorkingCopy copy) throws IOException {
561548
}
562549

563550
public void testNestedSwitches() throws Exception {
564-
if (!enhancedSwitchAvailable())
565-
return;
566-
567551
testFile = new File(getWorkDir(), "Test.java");
568552
String test = "public class Test {\n" +
569553
" void m(int p) {\n" +
@@ -613,14 +597,64 @@ public void run(final WorkingCopy copy) throws IOException {
613597
assertEquals(golden, res);
614598
}
615599

616-
private boolean enhancedSwitchAvailable() {
617-
try {
618-
Class.forName("com.sun.source.tree.CaseTree$CaseKind", false, JCTree.class.getClassLoader());
619-
return true;
620-
} catch (ClassNotFoundException ex) {
621-
//OK
622-
return false;
623-
}
600+
//github issue 8296:
601+
public void testPatternSwitch1() throws Exception {
602+
testFile = new File(getWorkDir(), "Test.java");
603+
String test = """
604+
public class Test {
605+
void m(Object o) {
606+
switch (o) {
607+
case String s -> s.getClass();
608+
}
609+
}
610+
}
611+
""";
612+
String golden = """
613+
public class Test {
614+
void m(Object o) {
615+
switch (o) {
616+
case String nue -> nue.getClass();
617+
default -> {
618+
}
619+
}
620+
}
621+
}
622+
""";
623+
TestUtilities.copyStringToFile(testFile, test.replace("|", ""));
624+
JavaSource src = getJavaSource(testFile);
625+
Task<WorkingCopy> task = new Task<WorkingCopy>() {
626+
public void run(final WorkingCopy copy) throws IOException {
627+
if (copy.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) {
628+
return;
629+
}
630+
final TreeMaker make = copy.getTreeMaker();
631+
new ErrorAwareTreePathScanner<Void, Void>() {
632+
@Override
633+
public Void visitVariable(VariableTree node, Void p) {
634+
if (node.getName().contentEquals("s")) {
635+
copy.rewrite(node, make.setLabel(node, "nue"));
636+
}
637+
return super.visitVariable(node, p);
638+
}
639+
@Override
640+
public Void visitIdentifier(IdentifierTree node, Void p) {
641+
if (node.getName().contentEquals("s")) {
642+
copy.rewrite(node, make.setLabel(node, "nue"));
643+
}
644+
return super.visitIdentifier(node, p);
645+
}
646+
@Override
647+
public Void visitSwitch(SwitchTree node, Void p) {
648+
copy.rewrite(node, make.addSwitchCase(node, make.Case(List.of(), make.Block(List.of(), false))));
649+
return super.visitSwitch(node, p);
650+
}
651+
}.scan(copy.getCompilationUnit(), null);
652+
}
653+
};
654+
src.runModificationTask(task).commit();
655+
String res = TestUtilities.copyFileToString(testFile);
656+
//System.err.println(res);
657+
assertEquals(golden, res);
624658
}
625659

626660
// XXX I don't understand what these are used for

java/maven/src/org/netbeans/modules/maven/customizer/Bundle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ HINT_ApplicationCoS=<html>Classes compiled with the Compile on Save feature in t
141141
RunJarPanel.lblConfiguration.text=&Configuration:
142142
ActionMappings.txtPackagings.text=
143143
ActionMappings.lblPackagings.text=Supported Packagings:
144-
CompilePanel.cbCompileOnSave.text=Compile on &Save (deprecated)
144+
CompilePanel.cbCompileOnSave.text=Compile on &Save
145145
CompilePanel.lblJavaPlatform1.text=Target Release:
146146
CompilePanel.compilerPanel.border.title=Compiler Plugin
147147
CompilePanel.idePanel.border.title=IDE Settings

0 commit comments

Comments
 (0)