Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ private String getTaskInheritance(Task t) {
"shouldRunAfter",
"enabled",
"description",
"vendor",
"group"
"group",
"toolchainDownloadUrls" // UpdateDaemonJvm fron org.gradle.toolchains.foojay-resolver-convention accesses online sevice for URLs
));

private void detectTaskProperties(NbProjectInfoModel model) {
Expand Down Expand Up @@ -718,6 +718,11 @@ private void inspectObjectAndValues0(Class clazz, Object object, String prefix,
if ((mp.getModifiers() & Modifier.PUBLIC) == 0) {
continue;
}
// ignore static properties for now. If needed, they must be exported somehow per-class and protected
// against recursion.
if ((mp.getModifiers() & Modifier.STATIC) != 0) {
continue;
}
if (object != null) {
// Provider must NOT be asked for a value, otherwise it might run a Task in order to compute
// the value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.netbeans.modules.gradle.tooling;

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

/**
* A simple holder to add JVM arguments on top of other args provide by other plugins.
* DO NOT store Project or other resource-bound references here, keep static. It is attached to a task
* as a provider and serialized/cached. See Micronaut Configuration
* Cache requirements.
*/
private static class JvmArgumentsHolder implements CommandLineArgumentProvider {
private final List<String> jvmArguments;

public JvmArgumentsHolder(List<String> jvmArguments) {
this.jvmArguments = jvmArguments;
}

@Override
public Iterable<String> asArguments() {
return jvmArguments;
}
}
}
4 changes: 2 additions & 2 deletions java/java.disco/external/binaries-list
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
# specific language governing permissions and limitations
# under the License.
4FCCADF37F1C61A0895BAC3D42FE0C530438826C org.checkerframework:checker-qual:3.9.1
CE10D968585304A7463430DD53254E6D6893DF16 io.foojay.api:discoclient:2.0.24
F66F9FC72A84FCAB1579202728EE572BDBB46DD7 eu.hansolo:jdktools:11.0.11
BB975ACE8403330DCC7ABF61A3142B0B59ADC755 io.foojay.api:discoclient:2.0.39
AD117688D24FACCF74D3B76AFFFC2693C4F5D122 eu.hansolo:jdktools:11.0.19
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: DiscoClient
Origin: Gerrit Grunwald
Version: 2.0.24
Version: 2.0.39
License: Apache-2.0
Description: Library to access the Foojay.io Discovery API service.
Origin: https://github.com/foojayio/discoclient
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: JDKTools
Origin: Gerrit Grunwald
Version: 11.0.11
Version: 11.0.19
License: Apache-2.0
Description: Collection of classes for working with OpenJDK related things.
Origin: https://github.com/HanSolo/jdktools
Expand Down
6 changes: 3 additions & 3 deletions java/java.disco/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

is.autoload=true
release.external/checker-qual-3.9.1.jar=modules/ext/checker-qual-3.9.1.jar
release.external/jdktools-11.0.11.jar=modules/ext/jdktools-11.0.11.jar
release.external/discoclient-2.0.24.jar=modules/ext/discoclient-2.0.24.jar
javac.release=11
release.external/jdktools-11.0.19.jar=modules/ext/jdktools-11.0.19.jar
release.external/discoclient-2.0.39.jar=modules/ext/discoclient-2.0.39.jar
javac.release=17
javac.compilerargs=-Xlint -Xlint:-serial
10 changes: 5 additions & 5 deletions java/java.disco/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>2.8.5</specification-version>
<specification-version>2.9.1</specification-version>
</run-dependency>
</dependency>
<dependency>
Expand Down Expand Up @@ -202,12 +202,12 @@
</module-dependencies>
<public-packages/>
<class-path-extension>
<runtime-relative-path>ext/discoclient-2.0.24.jar</runtime-relative-path>
<binary-origin>external/discoclient-2.0.24.jar</binary-origin>
<runtime-relative-path>ext/discoclient-2.0.39.jar</runtime-relative-path>
<binary-origin>external/discoclient-2.0.39.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/jdktools-11.0.11.jar</runtime-relative-path>
<binary-origin>external/jdktools-11.0.11.jar</binary-origin>
<runtime-relative-path>ext/jdktools-11.0.19.jar</runtime-relative-path>
<binary-origin>external/jdktools-11.0.19.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/checker-qual-3.9.1.jar</runtime-relative-path>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
import com.sun.tools.javac.tree.JCTree.JCOpens;
import com.sun.tools.javac.tree.JCTree.JCPackageDecl;
import com.sun.tools.javac.tree.JCTree.JCParens;
import com.sun.tools.javac.tree.JCTree.JCPatternCaseLabel;
import com.sun.tools.javac.tree.JCTree.JCPrimitiveTypeTree;
import com.sun.tools.javac.tree.JCTree.JCProvides;
import com.sun.tools.javac.tree.JCTree.JCRecordPattern;
Expand Down Expand Up @@ -2096,6 +2097,10 @@ protected int diffConstantCaseLabel(JCConstantCaseLabel oldT, JCConstantCaseLabe
return diffTree((JCTree) oldT.expr, (JCTree) newT.expr, bounds);
}

protected int diffPatternCaseLabel(JCPatternCaseLabel oldT, JCPatternCaseLabel newT, int[] bounds) {
return diffTree(oldT.pat, newT.pat, bounds);
}

protected int diffCase(JCCase oldT, JCCase newT, int[] bounds) {
int localPointer = bounds[0];
List<? extends JCTree.JCCaseLabel> oldPatterns = oldT.getLabels();
Expand Down Expand Up @@ -5873,6 +5878,9 @@ private int diffTreeImpl0(JCTree oldT, JCTree newT, JCTree parent /*used only fo
case CONSTANTCASELABEL:
retVal = diffConstantCaseLabel((JCConstantCaseLabel) oldT, (JCConstantCaseLabel) newT, elementBounds);
break;
case PATTERNCASELABEL:
retVal = diffPatternCaseLabel((JCPatternCaseLabel)oldT, (JCPatternCaseLabel)newT, elementBounds);
break;
case RECORDPATTERN:
retVal = diffRecordPattern((JCRecordPattern) oldT, (JCRecordPattern) newT, elementBounds);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import com.sun.source.tree.BlockTree;
import com.sun.source.tree.CaseTree;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.IdentifierTree;
import com.sun.source.tree.IfTree;
import com.sun.source.tree.StatementTree;
import com.sun.source.tree.SwitchTree;
import com.sun.source.tree.Tree.Kind;
import com.sun.source.tree.VariableTree;
import com.sun.source.util.TreePath;
import com.sun.tools.javac.tree.JCTree;
import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
Expand Down Expand Up @@ -238,9 +240,6 @@ public void run(final WorkingCopy copy) throws IOException {
}

public void testCaseMultiTest() throws Exception {
if (!enhancedSwitchAvailable())
return;

class TestCase {
public final String caseText;
public final BiFunction<WorkingCopy, CaseTree, CaseTree> convertCase;
Expand Down Expand Up @@ -369,9 +368,6 @@ public void run(CompilationController cc) throws Exception {
}

public void testStatement2Rule() throws Exception {
if (!enhancedSwitchAvailable())
return;

testFile = new File(getWorkDir(), "Test.java");
String test = "public class Test {\n" +
" void m(int p) {\n" +
Expand Down Expand Up @@ -417,9 +413,6 @@ public void run(final WorkingCopy copy) throws IOException {
}

public void testRule2Statement() throws Exception {
if (!enhancedSwitchAvailable())
return;

testFile = new File(getWorkDir(), "Test.java");
String test = "public class Test {\n" +
" void m(int p) {\n" +
Expand Down Expand Up @@ -467,9 +460,6 @@ public void run(final WorkingCopy copy) throws IOException {
}

public void testDefaultRewrite() throws Exception {
if (!enhancedSwitchAvailable())
return;

testFile = new File(getWorkDir(), "Test.java");
String test = "public class Test {\n" +
" void m(int p) {\n" +
Expand Down Expand Up @@ -511,9 +501,6 @@ public void run(final WorkingCopy copy) throws IOException {
}

public void testStatement2RuleNoSpace() throws Exception {
if (!enhancedSwitchAvailable())
return;

testFile = new File(getWorkDir(), "Test.java");
String test = "public class Test {\n" +
" void m(int p) {\n" +
Expand Down Expand Up @@ -561,9 +548,6 @@ public void run(final WorkingCopy copy) throws IOException {
}

public void testNestedSwitches() throws Exception {
if (!enhancedSwitchAvailable())
return;

testFile = new File(getWorkDir(), "Test.java");
String test = "public class Test {\n" +
" void m(int p) {\n" +
Expand Down Expand Up @@ -613,14 +597,64 @@ public void run(final WorkingCopy copy) throws IOException {
assertEquals(golden, res);
}

private boolean enhancedSwitchAvailable() {
try {
Class.forName("com.sun.source.tree.CaseTree$CaseKind", false, JCTree.class.getClassLoader());
return true;
} catch (ClassNotFoundException ex) {
//OK
return false;
}
//github issue 8296:
public void testPatternSwitch1() throws Exception {
testFile = new File(getWorkDir(), "Test.java");
String test = """
public class Test {
void m(Object o) {
switch (o) {
case String s -> s.getClass();
}
}
}
""";
String golden = """
public class Test {
void m(Object o) {
switch (o) {
case String nue -> nue.getClass();
default -> {
}
}
}
}
""";
TestUtilities.copyStringToFile(testFile, test.replace("|", ""));
JavaSource src = getJavaSource(testFile);
Task<WorkingCopy> task = new Task<WorkingCopy>() {
public void run(final WorkingCopy copy) throws IOException {
if (copy.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) {
return;
}
final TreeMaker make = copy.getTreeMaker();
new ErrorAwareTreePathScanner<Void, Void>() {
@Override
public Void visitVariable(VariableTree node, Void p) {
if (node.getName().contentEquals("s")) {
copy.rewrite(node, make.setLabel(node, "nue"));
}
return super.visitVariable(node, p);
}
@Override
public Void visitIdentifier(IdentifierTree node, Void p) {
if (node.getName().contentEquals("s")) {
copy.rewrite(node, make.setLabel(node, "nue"));
}
return super.visitIdentifier(node, p);
}
@Override
public Void visitSwitch(SwitchTree node, Void p) {
copy.rewrite(node, make.addSwitchCase(node, make.Case(List.of(), make.Block(List.of(), false))));
return super.visitSwitch(node, p);
}
}.scan(copy.getCompilationUnit(), null);
}
};
src.runModificationTask(task).commit();
String res = TestUtilities.copyFileToString(testFile);
//System.err.println(res);
assertEquals(golden, res);
}

// XXX I don't understand what these are used for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ HINT_ApplicationCoS=<html>Classes compiled with the Compile on Save feature in t
RunJarPanel.lblConfiguration.text=&Configuration:
ActionMappings.txtPackagings.text=
ActionMappings.lblPackagings.text=Supported Packagings:
CompilePanel.cbCompileOnSave.text=Compile on &Save (deprecated)
CompilePanel.cbCompileOnSave.text=Compile on &Save
CompilePanel.lblJavaPlatform1.text=Target Release:
CompilePanel.compilerPanel.border.title=Compiler Plugin
CompilePanel.idePanel.border.title=IDE Settings
Expand Down
Loading