Skip to content

Commit

Permalink
Merge pull request #7629 from apache/delivery
Browse files Browse the repository at this point in the history
Sync delivery to release230 for 23-rc2
  • Loading branch information
ebarboni authored Aug 7, 2024
2 parents b2b45ae + 3134074 commit cc863fd
Show file tree
Hide file tree
Showing 29 changed files with 161 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
Expand All @@ -49,6 +47,7 @@
import org.netbeans.modules.maven.model.pom.Project;
import org.netbeans.modules.maven.model.pom.Repository;
import org.netbeans.modules.maven.model.pom.RepositoryPolicy;
import org.netbeans.modules.maven.options.MavenVersionSettings;
import org.netbeans.modules.maven.spi.newproject.CreateProjectBuilder;
import org.openide.util.Exceptions;

Expand All @@ -58,12 +57,12 @@
*/
final class NBMNativeMWI {

static void instantiate(ProjectInfo vi, File projFile, String version, boolean useOsgi, MavenProject mp) {
static void instantiate(ProjectInfo vi, File projFile, String nbVersion, boolean useOsgi, MavenProject mp) {
CreateProjectBuilder builder = new CreateProjectBuilder(projFile, vi.groupId, vi.artifactId, vi.version)
.setPackageName(vi.packageName)
.setPackaging("nbm")
.setAdditionalNonPomWork(new AdditionalFiles())
.setAdditionalOperations(new AdditionalOperations(version, useOsgi));
.setAdditionalOperations(new AdditionalOperations(nbVersion, useOsgi));
if (mp != null) {
builder = builder.setParentProject(mp);
}
Expand Down Expand Up @@ -237,7 +236,6 @@ public void performOperation(POMModel model) {
//nbm-maven-plugin
boolean addPlugin = true;
String managedPVersion = null;
String pVersion = MavenNbModuleImpl.getLatestNbmPluginVersion();
// boolean useOsgiDepsSet = false;
if (parent != null) {
//TODO do we want to support the case when the plugin is defined in parent pom with inherited=true?
Expand All @@ -259,12 +257,13 @@ public void performOperation(POMModel model) {
}
}
}
MavenVersionSettings settings = MavenVersionSettings.getDefault();
if (addPlugin) {
Plugin p = model.getFactory().createPlugin();
p.setGroupId(MavenNbModuleImpl.GROUPID_APACHE);
p.setArtifactId(MavenNbModuleImpl.NBM_PLUGIN);
if (managedPVersion == null) {
p.setVersion(pVersion);
p.setVersion(MavenNbModuleImpl.getLatestNbmPluginVersion());
}
p.setExtensions(true);
if (useOsgi) {
Expand All @@ -278,52 +277,44 @@ public void performOperation(POMModel model) {
//now comes the compiler plugin
addPlugin = true;
managedPVersion = null;
String source = null;
String target = null;
pVersion = "3.11.0";
if (parent != null) {
//TODO do we want to support the case when the plugin is defined in parent pom with inherited=true?
PluginManagement pm = parent.getPluginManagement();
if (pm != null) {
for (org.apache.maven.model.Plugin p : pm.getPlugins()) {
if (Constants.GROUP_APACHE_PLUGINS.equals(p.getGroupId()) && Constants.PLUGIN_COMPILER.equals(p.getArtifactId())) {
managedPVersion = p.getVersion();
Xpp3Dom conf = (Xpp3Dom) p.getConfiguration();
if (conf != null) {
Xpp3Dom sourceEl = conf.getChild("source");
if (sourceEl != null) {
source = sourceEl.getValue();
}
Xpp3Dom targetEl = conf.getChild("target");
if (targetEl != null) {
target = targetEl.getValue();
if (parent.getProperties().getProperty("maven.compiler.release") != null) {
addPlugin = false;
} else {
for (org.apache.maven.model.Plugin p : pm.getPlugins()) {
if (Constants.GROUP_APACHE_PLUGINS.equals(p.getGroupId()) && Constants.PLUGIN_COMPILER.equals(p.getArtifactId())) {
managedPVersion = p.getVersion();
Xpp3Dom conf = (Xpp3Dom) p.getConfiguration();
if (conf != null) {
if ( conf.getChild("release") != null
|| conf.getChild("source") != null
|| conf.getChild("target") != null) {
addPlugin = false;
}
}
break;
}
break;
}
}
}
}
addPlugin = target == null || source == null;
if (addPlugin) {
Plugin p = model.getFactory().createPlugin();
p.setGroupId(Constants.GROUP_APACHE_PLUGINS);
p.setArtifactId(Constants.PLUGIN_COMPILER);
if (managedPVersion == null) {
p.setVersion(pVersion);
p.setVersion(settings.getVersion(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER));
}
Configuration c = model.getFactory().createConfiguration();
c.setSimpleParameter("source", "1.8");
c.setSimpleParameter("target", "1.8");
p.setConfiguration(c);
getOrCreateBuild(model).addPlugin(p);
model.getProject().getProperties().setProperty("maven.compiler.release", "17");
}

//now the jar plugin
addPlugin = true;
managedPVersion = null;
String useManifest = null;
pVersion = "3.3.0";
if (parent != null) {
//TODO do we want to support the case when the plugin is defined in parent pom with inherited=true?
PluginManagement pm = parent.getPluginManagement();
Expand Down Expand Up @@ -359,6 +350,7 @@ public void performOperation(POMModel model) {
p.setGroupId(Constants.GROUP_APACHE_PLUGINS);
p.setArtifactId(Constants.PLUGIN_JAR);
if (managedPVersion == null) {
String pVersion = settings.getVersion(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_JAR);
p.setVersion(pVersion);
managedPVersion = pVersion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

public class NBMNativeMWITest extends NbTestCase {

private static final String EXPECTED_JAVAC_PLUGIN_VERSION = "3.13.0";

private FileObject wd;

public NBMNativeMWITest(String testName) {
Expand All @@ -64,7 +66,7 @@ public void testPathNoParent() throws IOException, XmlPullParserException {
assertEquals("nbm-maven-plugin", model.getBuild().getPlugins().get(0).getArtifactId());
assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), model.getBuild().getPlugins().get(0).getVersion());
assertEquals("maven-compiler-plugin", model.getBuild().getPlugins().get(1).getArtifactId());
assertEquals("3.11.0", model.getBuild().getPlugins().get(1).getVersion());
assertEquals(EXPECTED_JAVAC_PLUGIN_VERSION, model.getBuild().getPlugins().get(1).getVersion());
assertEquals(0, model.getRepositories().size());
}

Expand All @@ -82,7 +84,7 @@ public void testPathNoParentSnapshot() throws IOException, XmlPullParserExceptio
assertEquals("nbm-maven-plugin", model.getBuild().getPlugins().get(0).getArtifactId());
assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), model.getBuild().getPlugins().get(0).getVersion());
assertEquals("maven-compiler-plugin", model.getBuild().getPlugins().get(1).getArtifactId());
assertEquals("3.11.0", model.getBuild().getPlugins().get(1).getVersion());
assertEquals(EXPECTED_JAVAC_PLUGIN_VERSION, model.getBuild().getPlugins().get(1).getVersion());
assertEquals(1, model.getRepositories().size());
}

Expand All @@ -109,7 +111,7 @@ public void testPathParent() throws IOException, XmlPullParserException {
assertEquals("nbm-maven-plugin", model.getBuild().getPlugins().get(0).getArtifactId());
assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), model.getBuild().getPlugins().get(0).getVersion());
assertEquals("maven-compiler-plugin", model.getBuild().getPlugins().get(1).getArtifactId());
assertEquals("3.11.0", model.getBuild().getPlugins().get(1).getVersion());
assertEquals(EXPECTED_JAVAC_PLUGIN_VERSION, model.getBuild().getPlugins().get(1).getVersion());
assertEquals(0, model.getRepositories().size());
}

Expand All @@ -135,7 +137,7 @@ public void testPathParentSnapshot() throws IOException, XmlPullParserException
assertEquals("nbm-maven-plugin", model.getBuild().getPlugins().get(0).getArtifactId());
assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), model.getBuild().getPlugins().get(0).getVersion());
assertEquals("maven-compiler-plugin", model.getBuild().getPlugins().get(1).getArtifactId());
assertEquals("3.11.0", model.getBuild().getPlugins().get(1).getVersion());
assertEquals(EXPECTED_JAVAC_PLUGIN_VERSION, model.getBuild().getPlugins().get(1).getVersion());
assertEquals(1, model.getRepositories().size());
}

Expand Down Expand Up @@ -190,7 +192,7 @@ public void testPathParentJar() throws IOException, XmlPullParserException {
assertEquals("nbm-maven-plugin", modeloutput.getBuild().getPlugins().get(0).getArtifactId());
assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), modeloutput.getBuild().getPlugins().get(0).getVersion());
assertEquals("maven-compiler-plugin", modeloutput.getBuild().getPlugins().get(1).getArtifactId());
assertEquals("3.11.0", modeloutput.getBuild().getPlugins().get(1).getVersion());
assertEquals(EXPECTED_JAVAC_PLUGIN_VERSION, modeloutput.getBuild().getPlugins().get(1).getVersion());
assertEquals(0, model.getRepositories().size());
}

Expand Down
2 changes: 1 addition & 1 deletion java/debugger.jpda.truffle/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

javac.compilerargs=-Xlint:unchecked
javac.source=1.8
javac.release=11
javadoc.arch=${basedir}/arch.xml
nbm.module.author=Martin Entlicher
requires.nb.javac=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,7 @@ private static ObjectReference getContextClassLoader(ThreadReference tawt, Virtu

private static int getTargetMajorVersion(VirtualMachine vm) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper {
String version = VirtualMachineWrapper.version(vm);
int dot = version.indexOf(".");
if (dot < 0) {
dot = version.length();
}
return Integer.parseInt(version.substring(0, dot));
return Runtime.Version.parse(version).feature();
}

public static ClassObjectReference uploadBasicClasses(JPDAThreadImpl t, String basicClassName) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException, IOException, PropertyVetoException, InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper, UnsupportedOperationExceptionWrapper, ClassNotPreparedExceptionWrapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import java.io.InvalidObjectException;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.InaccessibleObjectException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -250,7 +250,12 @@ private static Object setFieldsValues(Object newInstance, Class clazz, Map<Field
logger.log(Level.CONFIG, "No Such Field({0}) of class {1}", new Object[]{name, clazz});
return null;
}
field.setAccessible(true);
try {
field.setAccessible(true);
} catch(InaccessibleObjectException ex) {
logger.log(Level.CONFIG, "InaccessibleObjectException({0}) of field {1}", new Object[]{ex.getLocalizedMessage(), field});
return null;
}
Value v = fieldValues.get(f);
try {
if (v == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ public CharSequence getAssignToVarText() {
public String toString() {
return (typeName != null ? typeName + " " : "") + varName; //NOI18N
}
}
}

static class FieldItem extends WhiteListJavaCompletionItem<VariableElement> {

Expand All @@ -1545,6 +1545,7 @@ static class FieldItem extends WhiteListJavaCompletionItem<VariableElement> {
private String typeName;
private String leftText;
private String rightText;
private CharSequence sortText;
private boolean autoImportEnclosingType;
private CharSequence enclSortText;
private int castEndOffset;
Expand Down Expand Up @@ -1597,7 +1598,10 @@ public int getSortPriority() {

@Override
public CharSequence getSortText() {
return simpleName + "#" + enclSortText; //NOI18N
if (sortText == null) {
sortText = LazySortText.link(simpleName, enclSortText);
}
return sortText;
}

@Override
Expand Down Expand Up @@ -1827,7 +1831,7 @@ static class MethodItem extends WhiteListJavaCompletionItem<ExecutableElement> {
protected List<ParamDesc> params;
private String typeName;
private boolean addSemicolon;
private String sortText;
private CharSequence sortText;
private String leftText;
private String rightText;
private boolean autoImportEnclosingType;
Expand Down Expand Up @@ -1910,7 +1914,7 @@ public CharSequence getSortText() {
cnt++;
}
sortParams.append(')');
sortText = simpleName + "#" + enclSortText + "#" + ((cnt < 10 ? "0" : "") + cnt) + "#" + sortParams.toString(); //NOI18N
sortText = LazySortText.link(simpleName, enclSortText, ((cnt < 10 ? "0" : "") + cnt) + "#" + sortParams.toString()); //NOI18N
}
return sortText;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@
import org.netbeans.api.java.source.support.ReferencesCount;

/**
* Characters are lazily computed in charAt(), avoid toString().
*
* Use link() to combine lazy sequences.
*
* @author Dusan Balek
*/
class LazySortText implements CharSequence {
final class LazySortText implements CharSequence {

private String simpleName;
private String enclName;
private ElementHandle<TypeElement> handle;
private ReferencesCount referencesCount;
private final String simpleName;
private final String enclName;
private final ElementHandle<TypeElement> handle;
private final ReferencesCount referencesCount;
private String importanceLevel = null;

LazySortText(String simpleName, String enclName, ElementHandle<TypeElement> handle, ReferencesCount referencesCount) {
Expand All @@ -48,6 +51,7 @@ public int length() {
}

@Override
@SuppressWarnings("AssignmentToMethodParameter")
public char charAt(int index) {
if ((index < 0) || (index >= length())) {
throw new StringIndexOutOfBoundsException(index);
Expand All @@ -74,10 +78,61 @@ public CharSequence subSequence(int start, int end) {
throw new UnsupportedOperationException("Not supported yet."); //NOI18N
}

@Override
public String toString() {
return new StringBuilder(this).toString();
}

private String getImportanceLevel() {
if (importanceLevel == null) {
importanceLevel = String.format("%8d", Utilities.getImportanceLevel(referencesCount, handle)); //NOI18N
}
return importanceLevel;
}

public static CharSequence link(CharSequence first, CharSequence second) {
return new LinkedLazyCharSequence(first, second);
}

public static CharSequence link(CharSequence first, CharSequence second, CharSequence third) {
return new LinkedLazyCharSequence(first, new LinkedLazyCharSequence(second, third));
}

private static final class LinkedLazyCharSequence implements CharSequence {

private final CharSequence first;
private final CharSequence second;
private final int length;

private LinkedLazyCharSequence(CharSequence first, CharSequence second) {
this.first = first;
this.second = second;
this.length = first.length() + second.length() + 1;
}

@Override
@SuppressWarnings("AssignmentToMethodParameter")
public char charAt(int index) {
if (index < first.length()) {
return first.charAt(index);
}
index -= first.length();
if (index-- == 0) {
return '#';
}
return second.charAt(index);
}

@Override
public int length() {
return length;
}

@Override
public CharSequence subSequence(int start, int end) {
throw new UnsupportedOperationException("Not supported yet."); //NOI18N
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public List<CodeAction> getCodeActions(NbCodeLanguageClient client, ResultIterat
data.put(OFFSET, startOffset);
data.put(CONSTRUCTORS, constructors);
data.put(FIELDS, fields);
return Collections.singletonList(createCodeAction(client, Bundle.DN_GenerateConstructor(), isSource ? CODE_GENERATOR_KIND : CodeActionKind.QuickFix, null, "nbls.generate.code", GENERATE_CONSTRUCTOR, data));
return Collections.singletonList(createCodeAction(client, Bundle.DN_GenerateConstructor(), isSource ? CODE_GENERATOR_KIND : CodeActionKind.QuickFix, null, "nbls.generate.code", Utils.encodeCommand(GENERATE_CONSTRUCTOR, client.getNbCodeCapabilities()), data));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public List<CodeAction> getCodeActions(NbCodeLanguageClient client, ResultIterat
data.put(OFFSET, offset);
data.put(TYPE, typeItem);
data.put(FIELDS, fields);
return Collections.singletonList(createCodeAction(client, Bundle.DN_GenerateDelegateMethod(), CODE_GENERATOR_KIND, null, "nbls.generate.code", GENERATE_DELEGATE_METHOD, data));
return Collections.singletonList(createCodeAction(client, Bundle.DN_GenerateDelegateMethod(), CODE_GENERATOR_KIND, null, "nbls.generate.code", Utils.encodeCommand(GENERATE_DELEGATE_METHOD, client.getNbCodeCapabilities()), data));
}

@Override
Expand Down
Loading

0 comments on commit cc863fd

Please sign in to comment.