Merge pull request #3514 from apache/delivery
Sync delivery to release130 for 13-rc3
diff --git a/enterprise/micronaut/licenseinfo.xml b/enterprise/micronaut/licenseinfo.xml
new file mode 100644
index 0000000..fc0e66d
--- /dev/null
+++ b/enterprise/micronaut/licenseinfo.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<licenseinfo>
+ <fileset>
+ <file>src/org/netbeans/modules/micronaut/resources/warning.png</file>
+ <file>src/org/netbeans/modules/micronaut/resources/micronaut.png</file>
+ <license ref="Apache-2.0-ASF" />
+ <comment type="COMMENT_UNSUPPORTED" />
+ </fileset>
+</licenseinfo>
diff --git a/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/BasePropertiesVisual.form b/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/BasePropertiesVisual.form
index 7a2aff8..7180b93 100644
--- a/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/BasePropertiesVisual.form
+++ b/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/BasePropertiesVisual.form
@@ -45,47 +45,48 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
- <Component id="javaVersionLabel" alignment="0" min="-2" max="-2" attributes="0"/>
- <Component id="groupLabel" alignment="0" min="-2" max="-2" attributes="0"/>
- <Component id="languageLabel" alignment="0" min="-2" max="-2" attributes="0"/>
- <Component id="customRadioButton" alignment="0" min="-2" max="-2" attributes="0"/>
- <Component id="artifactLabel" alignment="0" min="-2" max="-2" attributes="0"/>
- <Component id="applicationTypeLabel" alignment="0" min="-2" pref="90" max="-2" attributes="0"/>
- <Component id="versionLabel" alignment="0" min="-2" max="-2" attributes="0"/>
- <Component id="snapshotRadioButton" alignment="0" min="-2" max="-2" attributes="0"/>
- <Component id="defaultRadioButton" alignment="0" min="-2" max="-2" attributes="0"/>
- <Component id="serviceURLLabel" min="-2" max="-2" attributes="0"/>
- <Component id="testFrameworkLabel" alignment="0" min="-2" max="-2" attributes="0"/>
- </Group>
- <EmptySpace max="-2" attributes="0"/>
- <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="executeDownloadedCodeWarning" pref="0" max="32767" attributes="0"/>
<Group type="102" attributes="0">
- <Group type="103" groupAlignment="0" attributes="0">
- <Component id="javaVersionComboBox" min="-2" pref="63" max="-2" attributes="0"/>
- <Group type="102" alignment="0" attributes="0">
- <Group type="103" groupAlignment="0" attributes="0">
- <Component id="javaRadioButton" min="-2" pref="50" max="-2" attributes="0"/>
- <Component id="junitRadioButton" min="-2" max="-2" attributes="0"/>
- </Group>
- <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
- <Group type="103" groupAlignment="0" attributes="0">
- <Component id="spockRadioButton" alignment="0" min="-2" max="-2" attributes="0"/>
- <Component id="kotlinRadioButton" alignment="0" min="-2" max="-2" attributes="0"/>
- </Group>
- <EmptySpace type="separate" max="-2" attributes="0"/>
- <Group type="103" groupAlignment="0" attributes="0">
- <Component id="groovyRadioButton" min="-2" max="-2" attributes="0"/>
- <Component id="kotestRadioButton" min="-2" max="-2" attributes="0"/>
- </Group>
- </Group>
+ <Group type="103" groupAlignment="0" max="-2" attributes="0">
+ <Component id="javaVersionLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="groupLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="languageLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="customRadioButton" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="artifactLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="versionLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="snapshotRadioButton" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="defaultRadioButton" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="serviceURLLabel" max="32767" attributes="0"/>
+ <Component id="testFrameworkLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="applicationTypeLabel" alignment="0" max="32767" attributes="0"/>
</Group>
- <EmptySpace min="-2" pref="357" max="-2" attributes="0"/>
- </Group>
- <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="javaVersionComboBox" min="-2" pref="63" max="-2" attributes="0"/>
+ <Group type="102" alignment="0" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="javaRadioButton" min="-2" pref="50" max="-2" attributes="0"/>
+ <Component id="junitRadioButton" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="spockRadioButton" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="kotlinRadioButton" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace type="separate" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="groovyRadioButton" min="-2" max="-2" attributes="0"/>
+ <Component id="kotestRadioButton" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
+ <EmptySpace min="0" pref="332" max="32767" attributes="0"/>
+ </Group>
<Component id="defaultURLLabel" max="32767" attributes="0"/>
<Component id="versionTextField" max="32767" attributes="0"/>
<Component id="snapshotURLLabel" alignment="0" max="32767" attributes="0"/>
@@ -94,9 +95,9 @@
<Component id="artifactTextField" alignment="1" max="32767" attributes="0"/>
<Component id="groupTextField" max="32767" attributes="0"/>
</Group>
- <EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
+ <EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -127,7 +128,7 @@
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
- <Component id="groupTextField" alignment="3" min="-2" pref="19" max="-2" attributes="0"/>
+ <Component id="groupTextField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="groupLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
@@ -159,7 +160,9 @@
<Component id="spockRadioButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="kotestRadioButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
- <EmptySpace pref="28" max="32767" attributes="0"/>
+ <EmptySpace type="separate" max="-2" attributes="0"/>
+ <Component id="executeDownloadedCodeWarning" max="-2" attributes="0"/>
+ <EmptySpace pref="17" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -395,5 +398,30 @@
<Property name="actionCommand" type="java.lang.String" value="KOTEST"/>
</Properties>
</Component>
+ <Component class="javax.swing.JLabel" name="executeDownloadedCodeWarning">
+ <Properties>
+ <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+ <Color blue="8b" green="b8" red="f8" type="rgb"/>
+ </Property>
+ <Property name="foreground" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="Color.black" type="code"/>
+ </Property>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="ImageUtilities.loadImageIcon("org/netbeans/modules/micronaut/resources/warning.png", false)" type="code"/>
+ </Property>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/netbeans/modules/micronaut/newproject/Bundle.properties" key="MSG_executeDownloadedCodeWarning" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
+ <LineBorder roundedCorners="true" thickness="5">
+ <Color PropertyName="color" blue="8b" green="b8" red="f8" type="rgb"/>
+ </LineBorder>
+ </Border>
+ </Property>
+ <Property name="opaque" type="boolean" value="true"/>
+ <Property name="verticalTextPosition" type="int" value="1"/>
+ </Properties>
+ </Component>
</SubComponents>
</Form>
diff --git a/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/BasePropertiesVisual.java b/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/BasePropertiesVisual.java
index 5e702a9..d0ab5a7 100644
--- a/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/BasePropertiesVisual.java
+++ b/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/BasePropertiesVisual.java
@@ -18,6 +18,7 @@
*/
package org.netbeans.modules.micronaut.newproject;
+import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
@@ -32,6 +33,7 @@
import org.openide.WizardDescriptor;
import org.openide.WizardValidationException;
import org.openide.util.AsyncGUIJob;
+import org.openide.util.ImageUtilities;
import org.openide.util.RequestProcessor;
/**
@@ -110,6 +112,7 @@
junitRadioButton = new javax.swing.JRadioButton();
spockRadioButton = new javax.swing.JRadioButton();
kotestRadioButton = new javax.swing.JRadioButton();
+ executeDownloadedCodeWarning = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(serviceURLLabel, org.openide.util.NbBundle.getMessage(BasePropertiesVisual.class, "LBL_ChooseServiceURL")); // NOI18N
@@ -184,6 +187,14 @@
org.openide.awt.Mnemonics.setLocalizedText(kotestRadioButton, org.openide.util.NbBundle.getMessage(BasePropertiesVisual.class, "LBL_Kotest")); // NOI18N
kotestRadioButton.setActionCommand("KOTEST");
+ executeDownloadedCodeWarning.setBackground(new java.awt.Color(248, 184, 139));
+ executeDownloadedCodeWarning.setForeground(Color.black);
+ executeDownloadedCodeWarning.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/micronaut/resources/warning.png", false));
+ org.openide.awt.Mnemonics.setLocalizedText(executeDownloadedCodeWarning, org.openide.util.NbBundle.getMessage(BasePropertiesVisual.class, "MSG_executeDownloadedCodeWarning")); // NOI18N
+ executeDownloadedCodeWarning.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(248, 184, 139), 5, true));
+ executeDownloadedCodeWarning.setOpaque(true);
+ executeDownloadedCodeWarning.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -191,45 +202,46 @@
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(javaVersionLabel)
- .addComponent(groupLabel)
- .addComponent(languageLabel)
- .addComponent(customRadioButton)
- .addComponent(artifactLabel)
- .addComponent(applicationTypeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(versionLabel)
- .addComponent(snapshotRadioButton)
- .addComponent(defaultRadioButton)
- .addComponent(serviceURLLabel)
- .addComponent(testFrameworkLabel))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(executeDownloadedCodeWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addComponent(javaVersionLabel)
+ .addComponent(groupLabel)
+ .addComponent(languageLabel)
+ .addComponent(customRadioButton)
+ .addComponent(artifactLabel)
+ .addComponent(versionLabel)
+ .addComponent(snapshotRadioButton)
+ .addComponent(defaultRadioButton)
+ .addComponent(serviceURLLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(testFrameworkLabel)
+ .addComponent(applicationTypeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(javaVersionComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(javaRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(junitRadioButton))
- .addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(spockRadioButton)
- .addComponent(kotlinRadioButton))
- .addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(groovyRadioButton)
- .addComponent(kotestRadioButton))))
- .addGap(357, 357, 357))
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(javaVersionComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(javaRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(junitRadioButton))
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(spockRadioButton)
+ .addComponent(kotlinRadioButton))
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(groovyRadioButton)
+ .addComponent(kotestRadioButton))))
+ .addGap(0, 332, Short.MAX_VALUE))
.addComponent(defaultURLLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(versionTextField)
.addComponent(snapshotURLLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(customTextField)
.addComponent(applicationTypeComboBox, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(artifactTextField, javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(groupTextField))
- .addContainerGap())))
+ .addComponent(groupTextField))))
+ .addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -254,7 +266,7 @@
.addComponent(versionLabel))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(groupTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(groupTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(groupLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
@@ -280,7 +292,9 @@
.addComponent(junitRadioButton)
.addComponent(spockRadioButton)
.addComponent(kotestRadioButton))
- .addContainerGap(28, Short.MAX_VALUE))
+ .addGap(18, 18, 18)
+ .addComponent(executeDownloadedCodeWarning, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(17, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
@@ -293,6 +307,7 @@
private javax.swing.JTextField customTextField;
private javax.swing.JRadioButton defaultRadioButton;
private javax.swing.JLabel defaultURLLabel;
+ private javax.swing.JLabel executeDownloadedCodeWarning;
private javax.swing.JRadioButton groovyRadioButton;
private javax.swing.JLabel groupLabel;
private javax.swing.JTextField groupTextField;
diff --git a/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/Bundle.properties b/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/Bundle.properties
index e1f6f93..6352c4b 100644
--- a/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/Bundle.properties
+++ b/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/Bundle.properties
@@ -36,3 +36,4 @@
LBL_JUnit=JUnit
LBL_Spock=Spock
LBL_Kotest=Kotest
+MSG_executeDownloadedCodeWarning=<html>Only finish this dialog if you trust the chosen service. Code from that service is downloaded and executed on this machine.
diff --git a/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/MicronautProjectWizardIterator.java b/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/MicronautProjectWizardIterator.java
index f58b00c..a7c4ecc 100644
--- a/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/MicronautProjectWizardIterator.java
+++ b/enterprise/micronaut/src/org/netbeans/modules/micronaut/newproject/MicronautProjectWizardIterator.java
@@ -25,6 +25,8 @@
import java.util.Collections;
import java.util.NoSuchElementException;
import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.swing.JComponent;
@@ -52,6 +54,8 @@
@NbBundle.Messages("MicronautProject_DN=Micronaut Project")
public class MicronautProjectWizardIterator implements WizardDescriptor.ProgressInstantiatingIterator<WizardDescriptor> {
+ private static final Logger LOG = Logger.getLogger(MicronautProjectWizardIterator.class.getName());
+
@TemplateRegistration(folder = "Project/Maven2", position = 300, displayName = "#MicronautProject_DN", description = "MicronautMavenProjectDescription.html", iconBase = "org/netbeans/modules/micronaut/resources/micronaut.png")
public static class MavenMicronautProject extends MicronautProjectWizardIterator {
@@ -222,6 +226,19 @@
FileObject fo = FileUtil.createData(folder, entryName);
try (OutputStream out = fo.getOutputStream()) {
FileUtil.copy(zis, out);
+ File backingFile = FileUtil.toFile(fo);
+ if (backingFile != null) {
+ // Workaround for limit of JDK API:
+ // https://bugs.openjdk.java.net/browse/JDK-6194856
+ // The alternative would be to use commons-compress
+ // but at this time only these two elements need to
+ // be executable
+ if (entryName.equals("mvnw") || entryName.equals("gradlew")) {
+ backingFile.setExecutable(true);
+ }
+ } else {
+ LOG.log(Level.WARNING, "FileObject is not backed by file, can not adjust permissions: {0}", fo.getPath());
+ }
}
}
}
diff --git a/enterprise/micronaut/src/org/netbeans/modules/micronaut/resources/warning.png b/enterprise/micronaut/src/org/netbeans/modules/micronaut/resources/warning.png
new file mode 100644
index 0000000..518bc52
--- /dev/null
+++ b/enterprise/micronaut/src/org/netbeans/modules/micronaut/resources/warning.png
Binary files differ
diff --git a/enterprise/micronaut/src/org/netbeans/modules/micronaut/resources/warning.svg b/enterprise/micronaut/src/org/netbeans/modules/micronaut/resources/warning.svg
new file mode 100644
index 0000000..ff5e93b
--- /dev/null
+++ b/enterprise/micronaut/src/org/netbeans/modules/micronaut/resources/warning.svg
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<!-- Generator: Adobe Illustrator 23.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<svg version="1.1" id="Vector_Icons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
+ y="0px" width="16px" height="16px" viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve">
+<style type="text/css">
+ .st0{fill:#FFFFFF;}
+ .st1{opacity:0.25;}
+ .st2{fill:#FAFAFA;}
+ .st3{opacity:0.33;}
+ .st4{fill:none;stroke:#474747;stroke-miterlimit:10;}
+ .st5{opacity:0.42;}
+ .st6{fill:#CAE3FF;}
+ .st7{opacity:0.2;}
+ .st8{opacity:0.03;}
+ .st9{opacity:0.1;}
+ .st10{opacity:0.15;}
+ .st11{opacity:0.45;}
+ .st12{fill:#FFE1B0;}
+ .st13{fill:#B3DBFF;}
+ .st14{fill:#FBDC7C;}
+ .st15{fill:#FFDB43;}
+ .st16{fill:#E79B00;}
+ .st17{fill:#3883CE;}
+ .st18{fill:none;stroke:#003399;stroke-width:1.375;stroke-miterlimit:10;}
+ .st19{fill:#E8513D;}
+ .st20{fill:#1E1E1E;}
+ .st21{fill:#FFC36D;}
+ .st22{fill:#9FCBFF;}
+ .st23{fill:#E9F7FF;}
+ .st24{fill:#62707C;}
+ .st25{fill:#7A8896;}
+ .st26{fill:#57BFFF;}
+ .st27{fill:#E69D35;}
+ .st28{fill:#9CFF73;}
+ .st29{fill:#4891CC;}
+ .st30{fill:#474747;}
+ .st31{fill:#CCA05E;}
+ .st32{opacity:0.67;}
+ .st33{opacity:0.3;}
+ .st34{fill:#EAEAEA;}
+ .st35{fill:#FFE945;}
+ .st36{fill:#FFCF8C;}
+ .st37{fill:#FF5252;}
+ .st38{opacity:0.12;}
+ .st39{fill:#45A5F4;}
+ .st40{fill:url(#SVGID_1_);}
+ .st41{fill:url(#SVGID_2_);}
+ .st42{opacity:0.05;}
+ .st43{fill:#3D81F5;}
+ .st44{fill:#CECECE;}
+ .st45{fill:#B5B5B5;}
+ .st46{opacity:0.4;}
+ .st47{fill:#595959;}
+ .st48{fill:#80FF80;}
+ .st49{fill:#C8FF80;}
+ .st50{fill:#FFEE80;}
+ .st51{fill:#FFA680;}
+ .st52{fill:#FF8080;}
+ .st53{fill:none;}
+ .st54{fill:#007AFF;}
+ .st55{fill:#EFFF78;}
+ .st56{fill:#FFDA00;}
+ .st57{fill:#3EADFF;}
+ .st58{opacity:0.67;fill:#FFFFFF;}
+ .st59{fill:#2E92FF;}
+ .st60{fill:#3AEA00;}
+ .st61{fill:#303030;}
+</style>
+<g>
+ <polygon class="st15" points="1.5,14 15.5,14 8.5,0.5 "/>
+ <g class="st3">
+ <path d="M8.5,2.672L13.855,13H3.145L8.5,2.672 M8.5,0.5L1.5,14h14L8.5,0.5L8.5,0.5z"/>
+ </g>
+</g>
+<path d="M8.495,12.15c-0.378,0-0.679-0.288-0.679-0.659c0-0.353,0.301-0.641,0.679-0.641c0.388,0,0.689,0.288,0.689,0.641
+ C9.184,11.862,8.883,12.15,8.495,12.15z"/>
+<polygon points="8.05,9.75 7.9,5.75 9.1,5.75 8.95,9.75 "/>
+</svg>
diff --git a/harness/apisupport.harness/release/run.xml b/harness/apisupport.harness/release/run.xml
index 51c4c36..dfb5122 100644
--- a/harness/apisupport.harness/release/run.xml
+++ b/harness/apisupport.harness/release/run.xml
@@ -54,8 +54,11 @@
</delete>
<!-- architecture of jvm on which app will run -->
- <condition property="jvm.arch.string" value="64" else="">
- <available file="${run.jdkhome}\jre\lib\amd64" />
+ <condition property="jvm.arch.string" value="" else="64">
+ <or>
+ <available file="${run.jdkhome}\bin\javaaccessbridge-32.dll" /> <!-- 32-bit Java 9+ -->
+ <available file="${run.jdkhome}\jre\bin\JavaAccessBridge-32.dll" /> <!-- 32-bit Java 8 -->
+ </or>
</condition>
<!-- use nb.exe if exists (old platform), netbeans.exe otherwise -->
diff --git a/ide/html/src/org/netbeans/modules/html/templates/html.html b/ide/html/src/org/netbeans/modules/html/templates/html.html
index 3be05dd..859df65 100644
--- a/ide/html/src/org/netbeans/modules/html/templates/html.html
+++ b/ide/html/src/org/netbeans/modules/html/templates/html.html
@@ -18,7 +18,7 @@
under the License.
-->
-${doctype}
+${doctype!""}
<#assign licenseFirst = "<!--">
<#assign licensePrefix = "">
<#assign licenseLast = "-->">
diff --git a/ide/html/src/org/netbeans/modules/html/templates/xhtml.xhtml b/ide/html/src/org/netbeans/modules/html/templates/xhtml.xhtml
index 430b344..cbcd48f 100644
--- a/ide/html/src/org/netbeans/modules/html/templates/xhtml.xhtml
+++ b/ide/html/src/org/netbeans/modules/html/templates/xhtml.xhtml
@@ -23,7 +23,7 @@
<#assign licensePrefix = "">
<#assign licenseLast = "-->">
<#include "${project.licensePath}">
-${doctype}
+${doctype!""}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TODO supply a title</title>
diff --git a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/Matcher.java b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/Matcher.java
index 3e2f58a..d87e171 100644
--- a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/Matcher.java
+++ b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/Matcher.java
@@ -21,6 +21,7 @@
import com.sun.source.tree.Tree;
import com.sun.source.util.TreePath;
+import com.sun.source.util.Trees;
import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
import java.util.Collection;
import java.util.LinkedList;
@@ -90,26 +91,39 @@
return result[0];
}
+ @SuppressWarnings("BoxedValueEquality")
public boolean referencedIn(@NonNull Variable variable, @NonNull Variable in) {
- final Element e = ctx.ctx.getInfo().getTrees().getElement(ctx.getSingleVariable(variable));
+ final Trees trees = ctx.ctx.getInfo().getTrees();
+ final Element e = trees.getElement(ctx.getSingleVariable(variable));
if (e == null) { //TODO: check also error
return false;
}
for (TreePath tp : ctx.getVariable(in)) {
+
+ if (e.equals(trees.getElement(tp))) {
+ return true;
+ }
+
boolean occurs = new ErrorAwareTreePathScanner<Boolean, Void>() {
+ private boolean found = false;
@Override
public Boolean scan(Tree tree, Void p) {
+ if (found) {
+ return true; // fast path
+ }
+
if (tree == null) {
return false;
}
TreePath currentPath = new TreePath(getCurrentPath(), tree);
- Element currentElement = ctx.ctx.getInfo().getTrees().getElement(currentPath);
+ Element currentElement = trees.getElement(currentPath);
if (e.equals(currentElement)) {
- return true; //TODO: throwing an exception might be faster...
+ found = true;
+ return true;
}
return super.scan(tree, p);
diff --git a/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/conditionapi/isReferencedIn.hint b/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/conditionapi/isReferencedIn.hint
new file mode 100644
index 0000000..41e917e
--- /dev/null
+++ b/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/conditionapi/isReferencedIn.hint
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+int $a = 0;
+int $b = $c; :: !referencedIn($a, $c)
+=>
+int $b = $c;
+;;
+
+int $a = 1;
+java.util.Arrays.asList($args$); :: !referencedIn($a, $args$)
+=>
+java.util.Arrays.asList($args$);
+;;
diff --git a/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/conditionapi/isReferencedIn.test b/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/conditionapi/isReferencedIn.test
new file mode 100644
index 0000000..112b544
--- /dev/null
+++ b/java/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/conditionapi/isReferencedIn.test
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+%%TestCase is-referenced-1
+package test;
+public class Test {
+ private void t() {
+ int a = 0;
+ int b = 2 + 1;
+ }
+}
+%%=>
+package test;
+public class Test {
+ private void t() {
+ int b = 2 + 1;
+ }
+}
+%%TestCase is-referenced-2
+package test;
+public class Test {
+ private void t() {
+ int a = 0;
+ int b = a;
+ }
+}
+%%TestCase is-referenced-3
+package test;
+public class Test {
+ private void t() {
+ int a = 0;
+ int b = a + 1;
+ }
+}
+%%TestCase is-referenced-4
+package test;
+import java.util.Arrays;
+public class Test {
+ private void t() {
+ int a = 1;
+ Arrays.asList(0, 5, a);
+ }
+}
+%%TestCase is-referenced-5
+package test;
+import java.util.Arrays;
+public class Test {
+ private void t() {
+ int a = 1;
+ Arrays.asList(0, 5, 4);
+ }
+}
+%%=>
+package test;
+import java.util.Arrays;
+public class Test {
+ private void t() {
+ Arrays.asList(0, 5, 4);
+ }
+}
diff --git a/java/java.lsp.server/vscode/BUILD.md b/java/java.lsp.server/vscode/BUILD.md
index fd2601d..7bec06c 100644
--- a/java/java.lsp.server/vscode/BUILD.md
+++ b/java/java.lsp.server/vscode/BUILD.md
@@ -20,13 +20,17 @@
under the License.
-->
+
## Prerequisities
-It is necessary to have installed:
+
+- JDK, version 11
- Ant, latest version
- Maven, latest version
- node.js, latest LTS (to build VSIX)
-It is recommended to build using JDK 8.
+It is currently possible to use JDK 8 for the build and execution.
+However, as the Apache NetBeans project is slowly moving towards JDK 11,
+using JDK 11 may be the safest bet.
## Getting the Code
@@ -45,17 +49,10 @@
java.lsp.server$ ant build-vscode-ext
```
The resulting extension is then in the `build` directory, with the `.vsix` extension.
-#### Build Options
-- `-Dvsix.version=x.y.z`can be used to set release version. E.g. set this option to `12.3.0` to get proper NetBeans release version for extension.
-- `-D3rdparty.modules=` property can be set to different value than `.*nbjavac.*` to not inlcude nb-javac which allows extension to run out of the box on JDK8.
-
-The build of NetBeans VSCode extension with nb-javac included, for version 12.6.0 then looks like this:
-```bash
-netbeans$ ant build
-netbeans$ cd java/java.lsp.server
-java.lsp.server$ ant build-vscode-ext -Dvsix.version=12.6.0
-```
-
+The typical file name is `apache-netbeans-java-0.1.0.vsix` - the version can be
+changed by using the `-Dvsix.version=x.y.z` property - that's what
+[continuous integration server](https://ci-builds.apache.org/job/Netbeans/job/netbeans-vscode/)
+and release builders do.
### Building for Development
@@ -102,7 +99,7 @@
```
when executing the tests for the first time. That shall overcome the proxy
-and download an instance of `code` execute the tests on.
+and download an instance of `code` to execute the tests with.
### Eating our own Dog Food
@@ -120,28 +117,31 @@
## Running and Debugging
-Have a sample Maven project, open it in NetBeans first and select the main file for both
-the Run and Debug actions.
-
To use the extension created for developement you can run VS Code with
following parameter:
```bash
-vscode$ code --extensionDevelopmentPath=`pwd` path_to_the_maven_project
+vscode$ code --extensionDevelopmentPath=`pwd` path_to_project
```
Or you can open the `vscode` folder in `code` directly and use **F5** to
debug the extension's *typescript code*.
+To start from a clean state, following
+[CLI options](https://code.visualstudio.com/docs/editor/command-line)
+maybe of an interest:
+- `--user-data-dir` - clean any user settings with this option
+- `--extensions-dir` - avoid 3rd party extensions using this option
+
To debug the *Java code*, launch the NetBeans part of the VS Code system first
and specify suitable debug arguments:
```bash
-vscode$ npm run nbcode -- --jdkhome /jdk-14/ -J-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000
+vscode$ npm run nbcode -- --jdkhome /jdk -J-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000
```
Connect to the process with Java debugger, setup all breakpoints. Then launch
-and connect from the VS Code extension:
+the VS Code extension (which connects to the already running Java process):
```bash
vscode$ code --extensionDevelopmentPath=`pwd` path_to_the_maven_project
diff --git a/java/java.lsp.server/vscode/src/extension.ts b/java/java.lsp.server/vscode/src/extension.ts
index d3bd89c..2fd0a89 100644
--- a/java/java.lsp.server/vscode/src/extension.ts
+++ b/java/java.lsp.server/vscode/src/extension.ts
@@ -274,17 +274,15 @@
let conf = workspace.getConfiguration();
if (conf.get("netbeans.conflict.check")) {
- let e = vscode.extensions.getExtension('redhat.java');
+ const id = 'redhat.java';
+ let e = vscode.extensions.getExtension(id);
function disablingFailed(reason: any) {
handleLog(log, 'Disabling some services failed ' + reason);
}
if (e && workspace.name) {
- vscode.window.showInformationMessage(`redhat.java found at ${e.extensionPath} - Suppressing some services to not clash with Apache NetBeans Language Server.`);
- conf.update('java.completion.enabled', false, false).then(() => {
- vscode.window.showInformationMessage('Usage of only one Java extension is recommended. Certain services of redhat.java have been disabled. ');
- conf.update('java.debug.settings.enableRunDebugCodeLens', false, false).then(() => {}, disablingFailed);
- conf.update('java.test.editor.enableShortcuts', false, false).then(() => {}, disablingFailed);
- }, disablingFailed);
+ vscode.window.showInformationMessage(`Another Java support extension is already installed. It is recommended to use only one Java support per workspace.`, `Manually disable`).then(() => {
+ vscode.commands.executeCommand('workbench.extensions.action.showInstalledExtensions');
+ });
}
}
diff --git a/java/java.project.ui/src/org/netbeans/modules/java/project/ui/ExtensionAndImplementationVisualPanel.java b/java/java.project.ui/src/org/netbeans/modules/java/project/ui/ExtensionAndImplementationVisualPanel.java
index fd856fa..d9854e3 100644
--- a/java/java.project.ui/src/org/netbeans/modules/java/project/ui/ExtensionAndImplementationVisualPanel.java
+++ b/java/java.project.ui/src/org/netbeans/modules/java/project/ui/ExtensionAndImplementationVisualPanel.java
@@ -240,14 +240,15 @@
}
private boolean isNotFinalExceptionType(ElementHandle<TypeElement> typeHandle) {
+ // TODO: this should not use Class.forName!
try {
Class<?> clazz = Class.forName(typeHandle.getQualifiedName());
return typeHandle.getKind() == ElementKind.CLASS
&& Exception.class.isAssignableFrom(clazz)
&& !Modifier.isFinal(clazz.getModifiers());
} catch (ClassNotFoundException ex) {
+ return true; // we don't know
}
- return false;
}
private boolean isInterface(ElementHandle<TypeElement> typeHandle) {
@@ -255,12 +256,13 @@
}
private boolean isNotFinalClass(ElementHandle<TypeElement> typeHandle) {
+ // TODO: this should not use Class.forName!
try {
Class<?> clazz = Class.forName(typeHandle.getQualifiedName());
return typeHandle.getKind() == ElementKind.CLASS && !Modifier.isFinal(clazz.getModifiers());
} catch (ClassNotFoundException ex) {
+ return true; // we don't know
}
- return false;
}
private void browseInterfacesButtonActionPerformed(ActionEvent evt) {
diff --git a/java/maven/src/org/netbeans/modules/maven/NbMavenProjectImpl.java b/java/maven/src/org/netbeans/modules/maven/NbMavenProjectImpl.java
index a727e33..2978382 100644
--- a/java/maven/src/org/netbeans/modules/maven/NbMavenProjectImpl.java
+++ b/java/maven/src/org/netbeans/modules/maven/NbMavenProjectImpl.java
@@ -26,6 +26,7 @@
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.net.URI;
+import java.net.URISyntaxException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -64,6 +65,8 @@
import org.apache.maven.project.ProjectBuildingRequest;
import org.netbeans.api.annotations.common.CheckForNull;
import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.annotations.common.NullAllowed;
+import org.netbeans.api.annotations.common.NullUnknown;
import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
import org.netbeans.api.project.Project;
import org.netbeans.api.queries.VisibilityQuery;
@@ -550,10 +553,39 @@
return auxprops;
}
+ /**
+ * The method will migrate to regular FileUtilities after NB13 release. The issue is that the result of
+ * {@link FileUtilities#convertStringToUri(java.lang.String)} result depends on whether the directory
+ * identified by the string exists or not. If it exists, the URI ends with a "/". For non-existent directories
+ * the URI lacks the trailing "/". This can break URI keys in a Map (if the directory gets created) and prevents
+ * from creating a ClassPath from such URLs (/ is checked). But FileUtilities is API and this behaviour is there for
+ * ages, so the correction should be added with a parameter.
+ */
+ public static @NullUnknown URI convertStringToUri(@NullAllowed String str, boolean slashIfNotExist) {
+ if (str != null) {
+ File fil = new File(str);
+ fil = FileUtil.normalizeFile(fil);
+ // this conversion returns URIs that end with "/" if fil is an existing directory, but returns
+ // without the slash if the directory just does not exist yet.
+ URI uri = Utilities.toURI(fil);
+ String s = uri.toString();
+ if (slashIfNotExist && !s.endsWith("/") && (fil.isDirectory() || !fil.exists())) { // NOI18N
+ try {
+ return new URI(s + "/"); // NOI18N
+ } catch (URISyntaxException ex) {
+ throw new IllegalArgumentException(str);
+ }
+ } else {
+ return uri;
+ }
+ }
+ return null;
+ }
+
public URI[] getSourceRoots(boolean test) {
List<URI> uris = new ArrayList<URI>();
for (String root : test ? getOriginalMavenProject().getTestCompileSourceRoots() : getOriginalMavenProject().getCompileSourceRoots()) {
- uris.add(FileUtilities.convertStringToUri(root));
+ uris.add(convertStringToUri(root, true));
}
for (JavaLikeRootProvider rp : getLookup().lookupAll(JavaLikeRootProvider.class)) {
// XXX for a few purposes (listening) it is desirable to list these even before they exist, but usually it is just noise (cf. #196414 comment #2)
diff --git a/java/maven/src/org/netbeans/modules/maven/classpath/RuntimeClassPathImpl.java b/java/maven/src/org/netbeans/modules/maven/classpath/RuntimeClassPathImpl.java
index eb87786..58e7cb5 100644
--- a/java/maven/src/org/netbeans/modules/maven/classpath/RuntimeClassPathImpl.java
+++ b/java/maven/src/org/netbeans/modules/maven/classpath/RuntimeClassPathImpl.java
@@ -27,7 +27,6 @@
import org.apache.maven.model.Build;
import org.apache.maven.project.MavenProject;
import org.netbeans.modules.maven.NbMavenProjectImpl;
-import org.netbeans.modules.maven.api.FileUtilities;
import org.openide.util.Utilities;
/**
@@ -57,7 +56,7 @@
if (build != null) {
String outputDirectory = build.getOutputDirectory();
if (outputDirectory != null) {
- lst.add(FileUtilities.convertStringToUri(outputDirectory));
+ lst.add(NbMavenProjectImpl.convertStringToUri(outputDirectory, true));
}
}
List<Artifact> arts = prj.getRuntimeArtifacts();
diff --git a/java/maven/src/org/netbeans/modules/maven/classpath/TestRuntimeClassPathImpl.java b/java/maven/src/org/netbeans/modules/maven/classpath/TestRuntimeClassPathImpl.java
index cb900c8..1e7a2ed 100644
--- a/java/maven/src/org/netbeans/modules/maven/classpath/TestRuntimeClassPathImpl.java
+++ b/java/maven/src/org/netbeans/modules/maven/classpath/TestRuntimeClassPathImpl.java
@@ -27,7 +27,6 @@
import org.apache.maven.model.Build;
import org.apache.maven.project.MavenProject;
import org.netbeans.modules.maven.NbMavenProjectImpl;
-import org.netbeans.modules.maven.api.FileUtilities;
import org.openide.util.Utilities;
@@ -66,11 +65,11 @@
if (build != null) {
String testOutputDirectory = build.getTestOutputDirectory();
if (testOutputDirectory != null) {
- lst.add(FileUtilities.convertStringToUri(testOutputDirectory));
+ lst.add(NbMavenProjectImpl.convertStringToUri(testOutputDirectory, true));
}
String outputDirectory = build.getOutputDirectory();
if (outputDirectory != null) {
- lst.add(FileUtilities.convertStringToUri(outputDirectory));
+ lst.add(NbMavenProjectImpl.convertStringToUri(outputDirectory, true));
}
}
List<Artifact> arts = prj.getTestArtifacts();
diff --git a/nbbuild/build.xml b/nbbuild/build.xml
index 401a0c1..316e113 100644
--- a/nbbuild/build.xml
+++ b/nbbuild/build.xml
@@ -1182,8 +1182,11 @@
</condition>
<!-- architecture of jvm on which app will run -->
- <condition property="jvm.arch.string" value="64" else="">
- <available file="${nbjdk.home}\jre\lib\amd64" />
+ <condition property="jvm.arch.string" value="" else="64">
+ <or>
+ <available file="${nbjdk.home}\bin\javaaccessbridge-32.dll" /> <!-- 32-bit Java 9+ -->
+ <available file="${nbjdk.home}\jre\bin\JavaAccessBridge-32.dll" /> <!-- 32-bit Java 8 -->
+ </or>
</condition>
<condition property="tryme.launcher.prefix" value="${netbeans.dest.dir}/bin/netbeans" else="${netbeans.dest.dir}/platform/lib/nbexec">
diff --git a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/DebugSession.java b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/DebugSession.java
index bbc3db5..f39b279 100644
--- a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/DebugSession.java
+++ b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/DebugSession.java
@@ -78,6 +78,7 @@
private AtomicReference<DebuggerEngine> engine;
private IDESessionBridge myBridge;
private AtomicReference<String> myFileName;
+ private volatile boolean canceled;
DebugSession(DebuggerOptions options, BackendLauncher backendLauncher) {
commands = new LinkedList<>();
@@ -124,6 +125,14 @@
} catch (Throwable e) {
log(e, Level.SEVERE);
}
+ if (canceled) {
+ synchronized (commands) {
+ if (commands.isEmpty()) {
+ detachRequest.set(true);
+ stop();
+ }
+ }
+ }
}
} finally {
postprocess();
@@ -133,7 +142,9 @@
private void preprocess() {
detachRequest.set(false);
stopRequest.set(false);
- commands.clear();
+ synchronized (commands) {
+ commands.clear();
+ }
sessionId.set(null);
myBridge = new IDESessionBridge();
myFileName = new AtomicReference<>();
@@ -325,14 +336,14 @@
@Override
public boolean cancel() {
- // NETBEANS-5080 detach the request
+ // NETBEANS-5080 request cancellation
// startProcessing() may be called via other ways
// e.g. via command line: nc -vz localhost 9003(debugger port)
// First of all, get the socket after the above command is run
// See: Socket sessionSocket = myServer.accept(); in ServerThread.run()
// Then, invokeLater.get() is called in startProcessing()
// Finally, infinite loop occurs in run() becuase do not still receive anything
- detachRequest.set(true);
+ canceled = true;
return true;
}
diff --git a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/SessionManager.java b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/SessionManager.java
index 9fc0f60..d6c086b 100644
--- a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/SessionManager.java
+++ b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/SessionManager.java
@@ -101,11 +101,6 @@
public synchronized void stopSession(Session session) {
SessionId id = session.lookupFirst(null, SessionId.class);
- // NETBEANS-5080 detach the request of the debug session to finish the task
- DebugSession debugSession = session.lookupFirst(null, DebugSession.class);
- if (debugSession != null) {
- debugSession.cancel();
- }
DebugSession debSess = getSession(id);
if (debSess != null) {
debSess.stopSession();
@@ -122,6 +117,11 @@
}
SessionManager.closeServerThread(session);
resetBreakpoints();
+ // NETBEANS-5080 request cancellation to finish the task
+ DebugSession debugSession = session.lookupFirst(null, DebugSession.class);
+ if (debugSession != null) {
+ debugSession.cancel();
+ }
}
public static SessionId getSessionId(Project project) {
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java
index 309a774..3fb9e88 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java
@@ -1347,6 +1347,7 @@
List<String> invalidProposalsForClsMembers = INVALID_PROPOSALS_FOR_CLS_MEMBERS;
Model model = request.result.getModel();
+ boolean parentContext = false;
boolean selfContext = false;
boolean staticLateBindingContext = false;
boolean specialVariable = false;
@@ -1361,6 +1362,7 @@
staticContext = true;
instanceContext = true;
specialVariable = true;
+ parentContext = true;
} else if (TokenUtilities.textEquals(varName, "static")) { // NOI18N
staticContext = true;
instanceContext = false;
@@ -1381,7 +1383,7 @@
return;
}
final ElementFilter staticFlagFilter = !completeAccessPrefix
- ? new StaticOrInstanceMembersFilter(staticContext, instanceContext, selfContext, staticLateBindingContext)
+ ? new StaticOrInstanceMembersFilter(staticContext, instanceContext, selfContext, staticLateBindingContext, parentContext)
: new ElementFilter() { // NETBEANS-1855
@Override
public boolean isAccepted(PhpElement element) {
@@ -1495,6 +1497,7 @@
List<String> invalidProposalsForClsMembers = INVALID_PROPOSALS_FOR_CLS_MEMBERS;
Model model = request.result.getModel();
+ boolean parentContext = false;
boolean selfContext = false;
boolean staticLateBindingContext = false;
boolean specialVariable = false;
@@ -1509,6 +1512,7 @@
isStaticContext = true;
isInstanceContext = true;
specialVariable = true;
+ parentContext = true;
} else if (TokenUtilities.textEquals(varName, "static")) { // NOI18N
isStaticContext = true;
isInstanceContext = false;
@@ -1523,7 +1527,7 @@
if (CancelSupport.getDefault().isCancelled()) {
return;
}
- final ElementFilter staticFlagFilter = new StaticOrInstanceMembersFilter(isStaticContext, isInstanceContext, selfContext, staticLateBindingContext);
+ final ElementFilter staticFlagFilter = new StaticOrInstanceMembersFilter(isStaticContext, isInstanceContext, selfContext, staticLateBindingContext, true);
final ElementFilter methodsFilter = ElementFilter.allOf(
ElementFilter.forKind(PhpElementKind.METHOD),
ElementFilter.forName(NameKind.exact(functionName.text().toString())),
@@ -2321,15 +2325,17 @@
private final boolean staticAllowed;
private final boolean nonstaticAllowed;
private final boolean forStaticLateBinding;
+ private final boolean forParentContext;
public StaticOrInstanceMembersFilter(final boolean forStaticContext, final boolean forInstanceContext,
- final boolean forSelfContext, final boolean forStaticLateBinding) {
+ final boolean forSelfContext, final boolean forStaticLateBinding, final boolean forParentContext) {
this.forStaticContext = forStaticContext;
this.forInstanceContext = forInstanceContext;
this.forSelfContext = forSelfContext;
this.forStaticLateBinding = forStaticLateBinding;
this.staticAllowed = OptionsUtils.codeCompletionStaticMethods();
this.nonstaticAllowed = OptionsUtils.codeCompletionNonStaticMethods();
+ this.forParentContext = forParentContext;
}
@Override
@@ -2348,6 +2354,13 @@
private boolean isAcceptedForNotStaticContext(final PhpElement element) {
final boolean isStatic = element.getPhpModifiers().isStatic();
+ if (forParentContext
+ && !isStatic
+ && element.getPhpElementKind().equals(PhpElementKind.FIELD)) {
+ // parent::fieldName is invalid
+ // this is constant
+ return false;
+ }
return !isStatic || (staticAllowed && element.getPhpElementKind().equals(PhpElementKind.METHOD));
}
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/elements/IndexQueryImpl.java b/php/php.editor/src/org/netbeans/modules/php/editor/elements/IndexQueryImpl.java
index 0936f89..14d42da 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/elements/IndexQueryImpl.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/elements/IndexQueryImpl.java
@@ -940,6 +940,10 @@
final Set<TypeElement> inheritedTypes = elementQueryIndex.getInheritedTypes(enclosingType);
for (final TypeElement nextType : inheritedTypes) {
filters.add(ElementFilter.forMembersOfType(nextType));
+ // GH #3486
+ for (TypeElement trait : getAllUsedTraits(nextType)) {
+ filters.add(ElementFilter.forMembersOfType(trait));
+ }
}
}
return filters.toArray(new ElementFilter[filters.size()]);
diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/gh3486/gh3486.php b/php/php.editor/test/unit/data/testfiles/completion/lib/gh3486/gh3486.php
new file mode 100644
index 0000000..ea3d6e4
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/completion/lib/gh3486/gh3486.php
@@ -0,0 +1,103 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+trait TestTrait {
+
+ public int $publicTraitField = 1;
+ private int $privateTraitField = 1;
+ protected int $protectedTraitField = 1;
+ public static int $publicStaticTraitField = 1;
+ private static int $privateStaticTraitField = 1;
+ protected static int $protectedStaticTraitField = 1;
+
+ public function publicTraitMethod() {
+ echo "publicTraitMethod" . PHP_EOL;
+ }
+
+ private function privateTraitMethod() {
+ echo "privateTraitMethod" . PHP_EOL;
+ }
+
+ protected function protectedTraitMethod() {
+ echo "protectedTraitMethod" . PHP_EOL;
+ }
+
+ public static function publicStaticTraitMethod() {
+ echo "publicStaticTraitMethod" . PHP_EOL;
+ }
+
+ private static function privateStaticTraitMethod() {
+ echo "privateStaticTraitMethod" . PHP_EOL;
+ }
+
+ protected static function protectedStaticTraitMethod() {
+ echo "protectedStaticTraitMethod" . PHP_EOL;
+ }
+
+}
+
+class A {
+
+ use TestTrait;
+
+ public int $publicClassField = 1;
+ private int $privateClassField = 1;
+ protected int $protectedClassField = 1;
+ public static int $publicStaticClassField = 1;
+ private static int $privateStaticClassField = 1;
+ protected static int $protectedStaticClassField = 1;
+
+ public function publicClassMethod() {
+ echo "publicClassMethod" . PHP_EOL;
+ }
+
+ private function privateClassMethod() {
+ echo "privateClassMethod" . PHP_EOL;
+ }
+
+ protected function protectedClassMethod() {
+ echo "protectedClassMethod" . PHP_EOL;
+ }
+
+ public static function publicStaticClassMethod() {
+ echo "publicStaticClassMethod" . PHP_EOL;
+ }
+
+ private static function privateStaticClassMethod() {
+ echo "privateStaticClassMethod" . PHP_EOL;
+ }
+
+ protected static function protectedStaticClassMethod() {
+ echo "protectedStaticClassMethod" . PHP_EOL;
+ }
+
+ protected function protectedTraitMethod() {
+ echo "protectedTraitMethod" . PHP_EOL;
+ }
+
+}
+
+class B extends A {
+
+ protected function protectedTraitMethod() {
+ parent::protectedTraitMethod();
+ }
+
+}
diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/gh3486/gh3486.php.testGH3486_01.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/gh3486/gh3486.php.testGH3486_01.completion
new file mode 100644
index 0000000..367cf52
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/completion/lib/gh3486/gh3486.php.testGH3486_01.completion
@@ -0,0 +1,16 @@
+Code completion result for source line:
+parent::|protectedTraitMethod();
+(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true)
+METHOD protectedClassMethod() [PROTECTE A
+METHOD protectedStaticClassMethod() [PROTECTE A
+METHOD protectedStaticTraitMethod() [PROTECTE TestTrait
+METHOD protectedTraitMethod() [PROTECTE A
+METHOD publicClassMethod() [PUBLIC] A
+METHOD publicStaticClassMethod() [STATIC] A
+METHOD publicStaticTraitMethod() [STATIC] TestTrait
+METHOD publicTraitMethod() [PUBLIC] TestTrait
+VARIABLE int $protectedStaticClassField [PROTECTE A
+VARIABLE int $protectedStaticTraitField [PROTECTE TestTrait
+VARIABLE int $publicStaticClassField [STATIC] A
+VARIABLE int $publicStaticTraitField [STATIC] TestTrait
+CONSTANT class \A [PUBLIC] Magic Constant
diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/test207345/bar.php.testUseCase1.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/test207345/bar.php.testUseCase1.completion
index 5adc7ba..0b5efc5 100644
--- a/php/php.editor/test/unit/data/testfiles/completion/lib/test207345/bar.php.testUseCase1.completion
+++ b/php/php.editor/test/unit/data/testfiles/completion/lib/test207345/bar.php.testUseCase1.completion
@@ -4,5 +4,4 @@
------------------------------------
METHOD __construct() [PUBLIC] \Testing\Ns\Blah
METHOD baz($param) [PUBLIC] \Testing\Ns\Blah
-VARIABLE ? field [PUBLIC] \Testing\Ns\Blah
CONSTANT class \Testing\Ns\Blah [PUBLIC] Magic Constant
diff --git a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletionGH3486Test.java b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletionGH3486Test.java
new file mode 100644
index 0000000..3084aa9
--- /dev/null
+++ b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletionGH3486Test.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.php.editor.completion;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.Map;
+import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.modules.php.project.api.PhpSourcePath;
+import org.netbeans.spi.java.classpath.support.ClassPathSupport;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+
+public class PHPCodeCompletionGH3486Test extends PHPCodeCompletionTestBase {
+
+ public PHPCodeCompletionGH3486Test(String testName) {
+ super(testName);
+ }
+
+ public void testGH3486_01() throws Exception {
+ checkCompletion("testfiles/completion/lib/gh3486/gh3486.php", " parent::^protectedTraitMethod();", false);
+ }
+
+ @Override
+ protected Map<String, ClassPath> createClassPathsForTest() {
+ return Collections.singletonMap(
+ PhpSourcePath.SOURCE_CP,
+ ClassPathSupport.createClassPath(new FileObject[] {
+ FileUtil.toFileObject(new File(getDataDir(), "/testfiles/completion/lib/gh3486"))
+ })
+ );
+ }
+}
diff --git a/php/php.project/external/binaries-list b/php/php.project/external/binaries-list
index a9138ee..a4f3348 100644
--- a/php/php.project/external/binaries-list
+++ b/php/php.project/external/binaries-list
@@ -14,4 +14,4 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-0013671661CE518C92DA0B1B83D9B54010C5B251 phpsigfiles-1.3.zip
+4EA0C90D7EB03DEC5AC2AD19FE33C3A9F71AD790 phpsigfiles-1.4.zip
diff --git a/php/php.project/external/phpsigfiles-1.3-license.txt b/php/php.project/external/phpsigfiles-1.4-license.txt
similarity index 99%
rename from php/php.project/external/phpsigfiles-1.3-license.txt
rename to php/php.project/external/phpsigfiles-1.4-license.txt
index d82809c..1afd05a 100644
--- a/php/php.project/external/phpsigfiles-1.3-license.txt
+++ b/php/php.project/external/phpsigfiles-1.4-license.txt
@@ -1,5 +1,5 @@
Name: phpsigfiles
-Version: 1.3
+Version: 1.4
Description: Signature files for PHP runtime and PHP runtime extensions for use from code completion etc. The file is build from the PHP manual.
License: CC-BY-3.0
Origin: http://www.php.net/docs.php
diff --git a/php/php.project/external/phpsigfiles-1.3-notice.txt b/php/php.project/external/phpsigfiles-1.4-notice.txt
similarity index 100%
rename from php/php.project/external/phpsigfiles-1.3-notice.txt
rename to php/php.project/external/phpsigfiles-1.4-notice.txt
diff --git a/php/php.project/nbproject/project.properties b/php/php.project/nbproject/project.properties
index ef0c983..cb3f715 100644
--- a/php/php.project/nbproject/project.properties
+++ b/php/php.project/nbproject/project.properties
@@ -20,7 +20,7 @@
javac.source=1.8
javadoc.arch=${basedir}/arch.xml
-release.external/phpsigfiles-1.3.zip=docs/phpsigfiles.zip
+release.external/phpsigfiles-1.4.zip=docs/phpsigfiles.zip
extra.module.files=docs/phpsigfiles.zip
test.config.stableBTD.includes=**/*Test.class
diff --git a/platform/libs.flatlaf/external/binaries-list b/platform/libs.flatlaf/external/binaries-list
index 90013fc..feececd 100644
--- a/platform/libs.flatlaf/external/binaries-list
+++ b/platform/libs.flatlaf/external/binaries-list
@@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.
-A45856E4115136977C662298BAC02F3B428082DB com.formdev:flatlaf:2.0
+5CD4AE96F6B538FB784549F2636E50122FDBB5D8 com.formdev:flatlaf:2.0.1
diff --git a/platform/libs.flatlaf/external/flatlaf-2.0-license.txt b/platform/libs.flatlaf/external/flatlaf-2.0.1-license.txt
similarity index 99%
rename from platform/libs.flatlaf/external/flatlaf-2.0-license.txt
rename to platform/libs.flatlaf/external/flatlaf-2.0.1-license.txt
index 55fd370..6f0e442 100644
--- a/platform/libs.flatlaf/external/flatlaf-2.0-license.txt
+++ b/platform/libs.flatlaf/external/flatlaf-2.0.1-license.txt
@@ -1,7 +1,7 @@
Name: FlatLaf Look and Feel
Description: FlatLaf Look and Feel
-Version: 2.0
-Files: flatlaf-2.0.jar
+Version: 2.0.1
+Files: flatlaf-2.0.1.jar
License: Apache-2.0
Origin: FormDev Software GmbH.
URL: https://www.formdev.com/flatlaf/
diff --git a/platform/libs.flatlaf/nbproject/project.properties b/platform/libs.flatlaf/nbproject/project.properties
index 7014d12..7a58873 100644
--- a/platform/libs.flatlaf/nbproject/project.properties
+++ b/platform/libs.flatlaf/nbproject/project.properties
@@ -20,4 +20,4 @@
javac.source=1.8
nbm.target.cluster=platform
-release.external/flatlaf-2.0.jar=modules/ext/flatlaf-2.0.jar
+release.external/flatlaf-2.0.1.jar=modules/ext/flatlaf-2.0.1.jar
diff --git a/platform/libs.flatlaf/nbproject/project.xml b/platform/libs.flatlaf/nbproject/project.xml
index a0ca5ca..befc44c 100644
--- a/platform/libs.flatlaf/nbproject/project.xml
+++ b/platform/libs.flatlaf/nbproject/project.xml
@@ -30,8 +30,8 @@
<package>com.formdev.flatlaf.util</package>
</public-packages>
<class-path-extension>
- <runtime-relative-path>ext/flatlaf-2.0.jar</runtime-relative-path>
- <binary-origin>external/flatlaf-2.0.jar</binary-origin>
+ <runtime-relative-path>ext/flatlaf-2.0.1.jar</runtime-relative-path>
+ <binary-origin>external/flatlaf-2.0.1.jar</binary-origin>
</class-path-extension>
</data>
</configuration>
diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/CacheDirectory.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/CacheDirectory.java
index 9e54981..19d74e3 100644
--- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/CacheDirectory.java
+++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/CacheDirectory.java
@@ -28,16 +28,19 @@
*/
class CacheDirectory {
- private static final String DIR_EXT = ".hwcache"; // NOI18N
+ private static final String DIR_EXT = ".nbcache"; // NOI18N
private static final String DUMP_AUX_FILE = "NBProfiler.nphd"; // NOI18N
private final File.Factory io;
private File cacheDirectory;
- static CacheDirectory getHeapDumpCacheDirectory(File.Factory io, File heapDump) {
+ static CacheDirectory getHeapDumpCacheDirectory(File.Factory io, File heapDump, int segment) {
String dumpName = heapDump.getName();
+ if (segment != 0) {
+ dumpName += "_" + segment;
+ }
File parent = heapDump.getParentFile();
- File dir = io.newFile(parent, dumpName+DIR_EXT);
+ File dir = io.newFile(parent, dumpName + DIR_EXT);
return new CacheDirectory(io, dir);
}
diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/HeapFactory.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/HeapFactory.java
index f8dde3a..5573496 100644
--- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/HeapFactory.java
+++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/HeapFactory.java
@@ -62,7 +62,7 @@
public static Heap createHeap(java.io.File heapDump, int segment)
throws FileNotFoundException, IOException {
File hd = JavaIoFile.IO.newFile(heapDump);
- CacheDirectory cacheDir = CacheDirectory.getHeapDumpCacheDirectory(JavaIoFile.IO, hd);
+ CacheDirectory cacheDir = CacheDirectory.getHeapDumpCacheDirectory(JavaIoFile.IO, hd, segment);
if (!cacheDir.isTemporary()) {
File savedDump = cacheDir.getHeapDumpAuxFile();
diff --git a/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/HeapFragmentWalker.java b/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/HeapFragmentWalker.java
index 4033479..5b6d6ca 100644
--- a/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/HeapFragmentWalker.java
+++ b/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/HeapFragmentWalker.java
@@ -64,6 +64,7 @@
private List<StateListener> stateListeners;
private int retainedSizesStatus;
+ private final int heapSegment;
//~ Constructors -------------------------------------------------------------------------------------------------------------
@@ -73,7 +74,12 @@
}
public HeapFragmentWalker(Heap heapFragment, HeapWalker heapWalker, boolean supportsRetainedSizes) {
+ this(heapFragment, 0, heapWalker, supportsRetainedSizes);
+ }
+
+ HeapFragmentWalker(Heap heapFragment, int heapSegment, HeapWalker heapWalker, boolean supportsRetainedSizes) {
this.heapFragment = heapFragment;
+ this.heapSegment = heapSegment;
this.heapWalker = heapWalker;
this.retainedSizesStatus = supportsRetainedSizes ? RETAINED_SIZES_UNKNOWN :
@@ -194,6 +200,10 @@
public Heap getHeapFragment() {
return heapFragment;
}
+
+ public int getHeapSegment() {
+ return heapSegment;
+ }
public InstancesController getInstancesController() {
return instancesController;
diff --git a/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/HeapWalker.java b/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/HeapWalker.java
index 62214c6..e0975fe 100644
--- a/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/HeapWalker.java
+++ b/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/HeapWalker.java
@@ -56,19 +56,29 @@
private TopComponent heapWalkerUI;
private Lookup.Provider heapDumpProject;
private String heapWalkerName;
+ private final int segment;
//~ Constructors -------------------------------------------------------------------------------------------------------------
// --- Constructors ----------------------------------------------------------
public HeapWalker(Heap heap) {
+ this(heap, 0);
+ }
+
+ private HeapWalker(Heap heap, int segment) {
+ this.segment = segment;
heapWalkerName = Bundle.ClassesListController_HeapWalkerDefaultName();
- createMainFragment(heap);
+ createMainFragment(heap, segment);
// computeRetainedSizes();
}
public HeapWalker(File heapFile) throws FileNotFoundException, IOException {
- this(createHeap(heapFile));
+ this(heapFile, 0);
+ }
+
+ HeapWalker(File heapFile, int segment) throws FileNotFoundException, IOException {
+ this(createHeap(heapFile, segment), segment);
heapDumpFile = heapFile;
heapDumpProject = computeHeapDumpProject(heapDumpFile);
@@ -86,6 +96,10 @@
return heapDumpFile;
}
+ public int getHeapDumpSegment() {
+ return segment;
+ }
+
public Lookup.Provider getHeapDumpProject() {
return heapDumpProject;
}
@@ -119,8 +133,8 @@
return heapWalkerUI;
}
- void createMainFragment(Heap heap) {
- mainHeapWalker = new HeapFragmentWalker(heap, this, true);
+ void createMainFragment(Heap heap, int segment) {
+ mainHeapWalker = new HeapFragmentWalker(heap, segment, this, true);
}
void createReachableFragment(Instance instance) {
@@ -170,7 +184,7 @@
return ProfilerStorage.getProjectFromFolder(heapDumpDirObj);
}
- private static Heap createHeap(File heapFile) throws FileNotFoundException, IOException {
+ private static Heap createHeap(File heapFile, int segment) throws FileNotFoundException, IOException {
ProgressHandle pHandle = null;
try {
@@ -179,7 +193,7 @@
pHandle.start(HeapProgress.PROGRESS_MAX*2);
setProgress(pHandle,0);
- Heap heap = HeapFactory.createHeap(heapFile);
+ Heap heap = HeapFactory.createHeap(heapFile, segment);
setProgress(pHandle,HeapProgress.PROGRESS_MAX);
heap.getSummary(); // Precompute HeapSummary within progress
diff --git a/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/HeapWalkerManager.java b/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/HeapWalkerManager.java
index f53c14e..f38e052 100644
--- a/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/HeapWalkerManager.java
+++ b/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/HeapWalkerManager.java
@@ -54,7 +54,6 @@
//~ Instance fields ----------------------------------------------------------------------------------------------------------
private Set dumpsBeingDeleted = new HashSet();
- private List<File> heapDumps = new ArrayList();
private List<HeapWalker> heapWalkers = new ArrayList();
final private RequestProcessor heapwalkerRp = new RequestProcessor(HeapWalkerManager.class);
@@ -75,7 +74,7 @@
}
public boolean isHeapWalkerOpened(File file) {
- return getHeapWalker(file) != null;
+ return getHeapWalker(file, 0) != null;
}
public void closeAllHeapWalkers() {
@@ -109,7 +108,7 @@
}
public void deleteHeapDump(final File file) {
- HeapWalker hw = getHeapWalker(file);
+ HeapWalker hw = getHeapWalker(file, 0);
if (hw != null) {
dumpsBeingDeleted.add(file);
@@ -128,7 +127,6 @@
}
final File file = hw.getHeapDumpFile();
- heapDumps.remove(file);
heapWalkers.remove(hw);
if (dumpsBeingDeleted.remove(file)) {
@@ -142,6 +140,10 @@
}
public void openHeapWalker(final File heapDump) {
+ openHeapWalker(heapDump, 0);
+ }
+
+ public void openHeapWalker(final File heapDump, int segment) {
String heapDumpPath;
try {
@@ -151,11 +153,11 @@
return;
}
synchronized (heapDumpPath.intern()) {
- HeapWalker hw = getHeapWalker(heapDump);
+ HeapWalker hw = getHeapWalker(heapDump, segment);
if (hw == null) {
try {
- hw = new HeapWalker(heapDump);
+ hw = new HeapWalker(heapDump, segment);
} catch (IOException e) {
ProfilerDialogs.displayError(Bundle.HeapWalkerManager_CannotOpenHeapWalkerMsg(), null, e.getLocalizedMessage());
} catch (Exception e) {
@@ -173,7 +175,6 @@
public synchronized void openHeapWalker(final HeapWalker hw) {
if (!heapWalkers.contains(hw)) {
- heapDumps.add(hw.getHeapDumpFile());
heapWalkers.add(hw);
}
SwingUtilities.invokeLater(new Runnable() {
@@ -204,10 +205,13 @@
}
}
- private synchronized HeapWalker getHeapWalker(File heapDump) {
- int hdIndex = heapDumps.indexOf(heapDump);
-
- return (hdIndex == -1) ? null : heapWalkers.get(hdIndex);
+ private synchronized HeapWalker getHeapWalker(File heapDump, int segment) {
+ for (HeapWalker hw : heapWalkers) {
+ if (hw.getHeapDumpFile().equals(heapDump) && hw.getHeapDumpSegment() == segment) {
+ return hw;
+ }
+ }
+ return null;
}
private TopComponent getTopComponent(HeapWalker hw) {
diff --git a/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/OverviewController.java b/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/OverviewController.java
index cf5d924..2ead56c 100644
--- a/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/OverviewController.java
+++ b/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/OverviewController.java
@@ -87,6 +87,7 @@
public class OverviewController extends AbstractController {
public static final String SHOW_SYSPROPS_URL = "file:/sysprops"; // NOI18N
+ public static final String SHOW_NEXT_SEGMENT_URL = "file:/next"; // NOI18N
public static final String SHOW_THREADS_URL = "file:/threads"; // NOI18N
private static final String OPEN_THREADS_URL = "file:/stackframe/"; // NOI18N
private static final String CLASS_URL_PREFIX = "file://class/"; // NOI18N
@@ -178,6 +179,9 @@
Bundle.OverviewController_NotAvailableMsg()
);
+ String segmentInfo = LINE_PREFIX + "<b>Segment:</b> " + heapFragmentWalker.getHeapSegment() + " try " // NOI18N
+ + "<a href='" + SHOW_NEXT_SEGMENT_URL + "'>next</a>...<br> ";
+
String oomeString = "";
if (oome != null) {
Instance thread = oome.getInstance();
@@ -190,7 +194,8 @@
String memoryRes = Icons.getResource(ProfilerIcons.HEAP_DUMP);
return "<b><img border='0' align='bottom' src='nbresloc:/" + memoryRes + "'> " // NOI18N
+ Bundle.OverviewController_SummaryString() + "</b><br><hr>" + dateTaken + "<br>" + filename + "<br>" + filesize + "<br><br>" + liveBytes // NOI18N
- + "<br>" + liveClasses + "<br>" + liveInstances + "<br>" + classloaders + "<br>" + gcroots + "<br>" + finalizersInfo + oomeString; // NOI18N
+ + "<br>" + liveClasses + "<br>" + liveInstances + "<br>" + classloaders + "<br>" + gcroots + "<br>" + finalizersInfo + oomeString // NOI18N
+ + "<br>" + segmentInfo; // NOI18N
}
public String computeEnvironment() {
@@ -644,4 +649,11 @@
private final static int JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER = 0x0400;
private final static int JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x0010;
private final static int JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT = 0x0020;
+
+ public void showNextSegment() {
+ HeapWalkerManager.getDefault().openHeapWalker(
+ heapFragmentWalker.getHeapDumpFile(),
+ heapFragmentWalker.getHeapSegment() + 1
+ );
+ }
}
diff --git a/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/ui/OverviewControllerUI.java b/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/ui/OverviewControllerUI.java
index 57b7f85..6df2399 100644
--- a/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/ui/OverviewControllerUI.java
+++ b/profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/ui/OverviewControllerUI.java
@@ -155,6 +155,8 @@
} else if (urls.equals(OverviewController.SHOW_THREADS_URL)) {
showThreads = true;
refreshSummary();
+ } else if (urls.equals(OverviewController.SHOW_NEXT_SEGMENT_URL)) {
+ overviewController.showNextSegment();
} else {
overviewController.showURL(urls);
}