geertjanw closed pull request #273: Backport of thurka's fixes made after Apr 22, 2017 URL: https://github.com/apache/incubator-netbeans/pull/273
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/api.intent/manifest.mf b/api.intent/manifest.mf index 5a0f3d307..4aa5a3804 100644 --- a/api.intent/manifest.mf +++ b/api.intent/manifest.mf @@ -1,5 +1,5 @@ Manifest-Version: 1.0 -AutoUpdate-Show-In-Client: true +AutoUpdate-Show-In-Client: false OpenIDE-Module: org.netbeans.api.intent OpenIDE-Module-Localizing-Bundle: org/netbeans/api/intent/Bundle.properties OpenIDE-Module-Specification-Version: 1.3 diff --git a/core.startup/src/org/netbeans/core/startup/ModuleLifecycleManager.java b/core.startup/src/org/netbeans/core/startup/ModuleLifecycleManager.java index e4344c6ad..ff33d3afc 100644 --- a/core.startup/src/org/netbeans/core/startup/ModuleLifecycleManager.java +++ b/core.startup/src/org/netbeans/core/startup/ModuleLifecycleManager.java @@ -97,7 +97,8 @@ public void run() { * do not support restart and may throw an exception to indicate that */ static void markReadyForRestart() throws UnsupportedOperationException { - if (!TopSecurityManager.class.getClassLoader().getClass().getName().endsWith(".Launcher$AppClassLoader")) { + String classLoaderName = TopSecurityManager.class.getClassLoader().getClass().getName(); + if (!classLoaderName.endsWith(".Launcher$AppClassLoader") && !classLoaderName.endsWith(".ClassLoaders$AppClassLoader")) { // NOI18N throw new UnsupportedOperationException("not running in regular module system, cannot restart"); // NOI18N } File userdir = Places.getUserDirectory(); diff --git a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/Win32APISupport.java b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/Win32APISupport.java index a3aab9c66..089105b35 100644 --- a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/Win32APISupport.java +++ b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/Win32APISupport.java @@ -33,7 +33,7 @@ public interface Win32APISupport extends StdCallLibrary { - final Map<Object, Object> DEFAULT_OPTIONS = Collections.unmodifiableMap(new HashMap<Object, Object>() { + final Map<String, Object> DEFAULT_OPTIONS = Collections.unmodifiableMap(new HashMap<String, Object>() { { put(OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE); diff --git a/keyring.impl/src/org/netbeans/modules/keyring/gnome/GnomeKeyringLibrary.java b/keyring.impl/src/org/netbeans/modules/keyring/gnome/GnomeKeyringLibrary.java index 425986919..479bbdfd5 100644 --- a/keyring.impl/src/org/netbeans/modules/keyring/gnome/GnomeKeyringLibrary.java +++ b/keyring.impl/src/org/netbeans/modules/keyring/gnome/GnomeKeyringLibrary.java @@ -46,7 +46,7 @@ // http://packages.ubuntu.com/search?suite=precise&arch=any&mode=exactfilename&searchon=contents&keywords=libgnome-keyring.so.0 private static final String EXPLICIT_ONEIRIC = "/usr/lib/libgnome-keyring.so.0"; @SuppressWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME") - private static Object load(Map<?,?> options) { + private static Object load(Map<String,?> options) { try { return Native.loadLibrary(GENERIC, GnomeKeyringLibrary.class, options); } catch (UnsatisfiedLinkError x) { diff --git a/lib.profiler/src/org/netbeans/lib/profiler/heap/ClassDump.java b/lib.profiler/src/org/netbeans/lib/profiler/heap/ClassDump.java index d7be365f8..fbed003d5 100644 --- a/lib.profiler/src/org/netbeans/lib/profiler/heap/ClassDump.java +++ b/lib.profiler/src/org/netbeans/lib/profiler/heap/ClassDump.java @@ -493,7 +493,7 @@ public boolean hasNext() { public Object next() { while (hasNext()) { - Instance i = heap.getInstanceByOffset(offset, classId); + Instance i = heap.getInstanceByOffset(offset, ClassDump.this, classId); if (i != null) { instancesCount--; return i; diff --git a/lib.profiler/src/org/netbeans/lib/profiler/heap/HprofArrayValue.java b/lib.profiler/src/org/netbeans/lib/profiler/heap/HprofArrayValue.java index 639c9098e..1d728f825 100644 --- a/lib.profiler/src/org/netbeans/lib/profiler/heap/HprofArrayValue.java +++ b/lib.profiler/src/org/netbeans/lib/profiler/heap/HprofArrayValue.java @@ -24,25 +24,26 @@ * * @author Tomas Hurka */ -class HprofArrayValue implements ArrayItemValue { +class HprofArrayValue extends HprofObject implements ArrayItemValue { //~ Instance fields ---------------------------------------------------------------------------------------------------------- final ClassDump dumpClass; final int index; - final long instanceArrayOffset; //~ Constructors ------------------------------------------------------------------------------------------------------------- HprofArrayValue(ClassDump cls, long offset, int number) { + // compute HprofArrayValue unique (file) offset. + // (+1) added to differ this instance with number == 0 from defining instance + super(offset + number + 1); dumpClass = cls; - instanceArrayOffset = offset; index = number; } //~ Methods ------------------------------------------------------------------------------------------------------------------ public Instance getDefiningInstance() { - return new ObjectArrayDump(dumpClass, instanceArrayOffset); + return new ObjectArrayDump(dumpClass, getInstanceArrayOffset()); } public int getIndex() { @@ -54,8 +55,13 @@ public Instance getInstance() { HprofByteBuffer dumpBuffer = heap.dumpBuffer; int idSize = dumpBuffer.getIDSize(); - long instanceId = dumpBuffer.getID(instanceArrayOffset + 1 + idSize + 4 + 4 + idSize + ((long)index * (long)idSize)); + long instanceId = dumpBuffer.getID(getInstanceArrayOffset() + 1 + idSize + 4 + 4 + idSize + ((long)index * (long)idSize)); return heap.getInstanceByID(instanceId); } + + private long getInstanceArrayOffset() { + // see computation in super() above + return fileOffset - index - 1; + } } diff --git a/lib.profiler/src/org/netbeans/lib/profiler/heap/HprofHeap.java b/lib.profiler/src/org/netbeans/lib/profiler/heap/HprofHeap.java index d80c222b7..e1210908b 100644 --- a/lib.profiler/src/org/netbeans/lib/profiler/heap/HprofHeap.java +++ b/lib.profiler/src/org/netbeans/lib/profiler/heap/HprofHeap.java @@ -194,18 +194,25 @@ public Collection getJavaClassesByRegExp(String regexp) { private class InstancesIterator implements Iterator { private long[] offset; + private Instance nextInstance; private InstancesIterator() { offset = new long[] { allInstanceDumpBounds.startOffset }; } public boolean hasNext() { - return offset[0] < allInstanceDumpBounds.endOffset; + while (offset[0] < allInstanceDumpBounds.endOffset && nextInstance == null) { + nextInstance = getInstanceByOffset(offset); + } + return nextInstance != null; } public Object next() { if (hasNext()) { - return getInstanceByOffset(offset); + Instance ni = nextInstance; + + nextInstance = null; + return ni; } throw new NoSuchElementException(); } @@ -304,10 +311,10 @@ int getValueSize(final byte type) { } Instance getInstanceByOffset(long[] offset) { - return getInstanceByOffset(offset, -1); + return getInstanceByOffset(offset, null, -1); } - Instance getInstanceByOffset(long[] offset, long instanceClassId) { + Instance getInstanceByOffset(long[] offset, ClassDump instanceClassDump, long instanceClassId) { long start = offset[0]; assert start != 0L; ClassDump classDump; @@ -337,7 +344,11 @@ Instance getInstanceByOffset(long[] offset, long instanceClassId) { if (instanceClassId != -1 && classId != instanceClassId) { return null; } - classDump = classDumpBounds.getClassDumpByID(classId); + if (instanceClassDump == null) { + classDump = classDumpBounds.getClassDumpByID(classId); + } else { + classDump = instanceClassDump; + } } if (classDump == null) { diff --git a/libs.jna.platform/external/binaries-list b/libs.jna.platform/external/binaries-list index 5c3b44b64..130014d90 100644 --- a/libs.jna.platform/external/binaries-list +++ b/libs.jna.platform/external/binaries-list @@ -15,4 +15,4 @@ # specific language governing permissions and limitations # under the License. -030FA67B23CF2C0327A02CFAECBEF76A20160E7B net.java.dev.jna:jna-platform:4.2.2 +F396B0CEB7ABABB8B4A5EA25E6742CED81E3D86F net.java.dev.jna:jna-platform:4.4.0 diff --git a/libs.jna.platform/external/jna-platform-4.2.2-license.txt b/libs.jna.platform/external/jna-platform-4.4.0-license.txt similarity index 99% rename from libs.jna.platform/external/jna-platform-4.2.2-license.txt rename to libs.jna.platform/external/jna-platform-4.4.0-license.txt index efacc6d91..0de905688 100644 --- a/libs.jna.platform/external/jna-platform-4.2.2-license.txt +++ b/libs.jna.platform/external/jna-platform-4.4.0-license.txt @@ -1,5 +1,5 @@ Name: Java Native Access -Version: 4.2.2 +Version: 4.4.0 License: Apache-2.0 Description: Dynamically access native libraries from Java without JNI. Origin: Java Native Access diff --git a/libs.jna.platform/manifest.mf b/libs.jna.platform/manifest.mf index c32f2f753..e7ad862f8 100644 --- a/libs.jna.platform/manifest.mf +++ b/libs.jna.platform/manifest.mf @@ -1,4 +1,4 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.libs.jna.platform/1 OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/jna/platform/Bundle.properties -OpenIDE-Module-Specification-Version: 1.15 +OpenIDE-Module-Specification-Version: 1.16 diff --git a/libs.jna.platform/nbproject/project.properties b/libs.jna.platform/nbproject/project.properties index a093f7298..391c01380 100644 --- a/libs.jna.platform/nbproject/project.properties +++ b/libs.jna.platform/nbproject/project.properties @@ -17,5 +17,5 @@ is.autoload=true javac.source=1.6 -release.external/jna-platform-4.2.2.jar=modules/ext/jna-platform-4.2.2.jar +release.external/jna-platform-4.4.0.jar=modules/ext/jna-platform-4.4.0.jar sigtest.gen.fail.on.error=false diff --git a/libs.jna.platform/nbproject/project.xml b/libs.jna.platform/nbproject/project.xml index 0e3792ee8..251d44d70 100644 --- a/libs.jna.platform/nbproject/project.xml +++ b/libs.jna.platform/nbproject/project.xml @@ -44,8 +44,8 @@ <package>com.sun.jna.platform.wince</package> </friend-packages> <class-path-extension> - <runtime-relative-path>ext/jna-platform-4.2.2.jar</runtime-relative-path> - <binary-origin>external/jna-platform-4.2.2.jar</binary-origin> + <runtime-relative-path>ext/jna-platform-4.4.0.jar</runtime-relative-path> + <binary-origin>external/jna-platform-4.4.0.jar</binary-origin> </class-path-extension> </data> </configuration> diff --git a/libs.jna/external/binaries-list b/libs.jna/external/binaries-list index 47bbfba80..4f58b1252 100644 --- a/libs.jna/external/binaries-list +++ b/libs.jna/external/binaries-list @@ -15,4 +15,4 @@ # specific language governing permissions and limitations # under the License. -5012450AEE579C3118FF09461D5CE210E0CDC2A9 net.java.dev.jna:jna:4.2.2 +CB208278274BF12EBDB56C61BD7407E6F774D65A net.java.dev.jna:jna:4.4.0 diff --git a/libs.jna/external/jna-4.2.2-license.txt b/libs.jna/external/jna-4.4.0-license.txt similarity index 99% rename from libs.jna/external/jna-4.2.2-license.txt rename to libs.jna/external/jna-4.4.0-license.txt index efacc6d91..0de905688 100644 --- a/libs.jna/external/jna-4.2.2-license.txt +++ b/libs.jna/external/jna-4.4.0-license.txt @@ -1,5 +1,5 @@ Name: Java Native Access -Version: 4.2.2 +Version: 4.4.0 License: Apache-2.0 Description: Dynamically access native libraries from Java without JNI. Origin: Java Native Access diff --git a/libs.jna/manifest.mf b/libs.jna/manifest.mf index f839e15ed..53468c12d 100644 --- a/libs.jna/manifest.mf +++ b/libs.jna/manifest.mf @@ -4,4 +4,4 @@ OpenIDE-Module: org.netbeans.libs.jna/1 OpenIDE-Module-Install: org/netbeans/libs/jna/Installer.class OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/jna/Bundle.properties AutoUpdate-Essential-Module: true -OpenIDE-Module-Specification-Version: 1.47 +OpenIDE-Module-Specification-Version: 1.48 diff --git a/libs.jna/nbproject/project.properties b/libs.jna/nbproject/project.properties index 421d62ce8..fbb496fb5 100644 --- a/libs.jna/nbproject/project.properties +++ b/libs.jna/nbproject/project.properties @@ -16,17 +16,17 @@ # under the License. javac.source=1.6 -release.external/jna-4.2.2.jar=modules/ext/jna-4.2.2.jar +release.external/jna-4.4.0.jar=modules/ext/jna-4.4.0.jar # Do not forget to rename native libs being extracted from the JAR when upgrading the JNA library, and patch org.netbeans.libs.jna.Installer as well. -release.external/jna-4.2.2.jar!/com/sun/jna/darwin/libjnidispatch.jnilib=modules/lib/libjnidispatch-422.jnilib -release.external/jna-4.2.2.jar!/com/sun/jna/linux-x86-64/libjnidispatch.so=modules/lib/amd64/linux/libjnidispatch-422.so -release.external/jna-4.2.2.jar!/com/sun/jna/linux-x86/libjnidispatch.so=modules/lib/i386/linux/libjnidispatch-422.so -release.external/jna-4.2.2.jar!/com/sun/jna/win32-x86-64/jnidispatch.dll=modules/lib/amd64/jnidispatch-422.dll -release.external/jna-4.2.2.jar!/com/sun/jna/win32-x86/jnidispatch.dll=modules/lib/x86/jnidispatch-422.dll +release.external/jna-4.4.0.jar!/com/sun/jna/darwin/libjnidispatch.jnilib=modules/lib/libjnidispatch-440.jnilib +release.external/jna-4.4.0.jar!/com/sun/jna/linux-x86-64/libjnidispatch.so=modules/lib/amd64/linux/libjnidispatch-440.so +release.external/jna-4.4.0.jar!/com/sun/jna/linux-x86/libjnidispatch.so=modules/lib/i386/linux/libjnidispatch-440.so +release.external/jna-4.4.0.jar!/com/sun/jna/win32-x86-64/jnidispatch.dll=modules/lib/amd64/jnidispatch-440.dll +release.external/jna-4.4.0.jar!/com/sun/jna/win32-x86/jnidispatch.dll=modules/lib/x86/jnidispatch-440.dll jnlp.verify.excludes=\ - modules/lib/amd64/jnidispatch-422.dll,\ - modules/lib/amd64/linux/libjnidispatch-422.so,\ - modules/lib/i386/linux/libjnidispatch-422.so,\ - modules/lib/x86/jnidispatch-422.dll,\ - modules/lib/libjnidispatch-422.jnilib + modules/lib/amd64/jnidispatch-440.dll,\ + modules/lib/amd64/linux/libjnidispatch-440.so,\ + modules/lib/i386/linux/libjnidispatch-440.so,\ + modules/lib/x86/jnidispatch-440.dll,\ + modules/lib/libjnidispatch-440.jnilib sigtest.gen.fail.on.error=false diff --git a/libs.jna/nbproject/project.xml b/libs.jna/nbproject/project.xml index db00b1a1b..d9d630f9d 100644 --- a/libs.jna/nbproject/project.xml +++ b/libs.jna/nbproject/project.xml @@ -77,8 +77,8 @@ <package>com.sun.jna.win32</package> </friend-packages> <class-path-extension> - <runtime-relative-path>ext/jna-4.2.2.jar</runtime-relative-path> - <binary-origin>external/jna-4.2.2.jar</binary-origin> + <runtime-relative-path>ext/jna-4.4.0.jar</runtime-relative-path> + <binary-origin>external/jna-4.4.0.jar</binary-origin> </class-path-extension> </data> </configuration> diff --git a/libs.jna/src/org/netbeans/libs/jna/Installer.java b/libs.jna/src/org/netbeans/libs/jna/Installer.java index 2077866fd..4eb5757d0 100644 --- a/libs.jna/src/org/netbeans/libs/jna/Installer.java +++ b/libs.jna/src/org/netbeans/libs/jna/Installer.java @@ -27,6 +27,6 @@ public void validate() { super.validate(); //#211655 - System.setProperty( "jna.boot.library.name", "jnidispatch-422" ); //NOI18N + System.setProperty( "jna.boot.library.name", "jnidispatch-440" ); //NOI18N } } diff --git a/openide.explorer/src/org/openide/explorer/view/CustomPopupFactory.java b/openide.explorer/src/org/openide/explorer/view/CustomPopupFactory.java index aae0bf537..cebebb99a 100644 --- a/openide.explorer/src/org/openide/explorer/view/CustomPopupFactory.java +++ b/openide.explorer/src/org/openide/explorer/view/CustomPopupFactory.java @@ -197,6 +197,8 @@ public boolean isShowing() { @Override void dispose() { + window.setVisible(false); + window.dispose(); window = null; super.dispose(); } diff --git a/profiler.oql/nbproject/project.xml b/profiler.oql/nbproject/project.xml index 69ba1b1f3..9493b2d3a 100644 --- a/profiler.oql/nbproject/project.xml +++ b/profiler.oql/nbproject/project.xml @@ -40,7 +40,7 @@ <compile-dependency/> <run-dependency> <release-version>1</release-version> - <specification-version>1.87</specification-version> + <specification-version>1.103</specification-version> </run-dependency> </dependency> <dependency> diff --git a/profiler.oql/src/org/netbeans/modules/profiler/oql/engine/api/impl/ReachableObjects.java b/profiler.oql/src/org/netbeans/modules/profiler/oql/engine/api/impl/ReachableObjects.java index 7e1d399b0..07055a314 100644 --- a/profiler.oql/src/org/netbeans/modules/profiler/oql/engine/api/impl/ReachableObjects.java +++ b/profiler.oql/src/org/netbeans/modules/profiler/oql/engine/api/impl/ReachableObjects.java @@ -21,7 +21,9 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.Iterator; +import java.util.Set; import org.netbeans.lib.profiler.heap.Field; import org.netbeans.lib.profiler.heap.FieldValue; import org.netbeans.lib.profiler.heap.Instance; @@ -35,10 +37,12 @@ public class ReachableObjects { private ReachableExcludes excludes; private Instance root; + private Set<Instance> alreadyReached; public ReachableObjects(Instance root, final ReachableExcludes excludes) { this.root = root; this.excludes = excludes; + alreadyReached = new HashSet(); } public Instance getRoot() { @@ -55,14 +59,21 @@ public Instance getRoot() { if (fv instanceof ObjectFieldValue) { if (excludes == null || !excludes.isExcluded(getFQFieldName(((FieldValue)fv).getField()))) { Instance i = ((ObjectFieldValue)fv).getInstance(); - if (i != null) { + if (i != null && !alreadyReached.contains(i)) { instances.add(i); + alreadyReached.add(i); } } } } if (popped instanceof ObjectArrayInstance) { - instances.addAll(((ObjectArrayInstance)popped).getValues()); + for(Object el : ((ObjectArrayInstance)popped).getValues()) { + Instance i = (Instance) el; + if (i != null && !alreadyReached.contains(i)) { + instances.add(i); + alreadyReached.add(i); + } + } } return instances.iterator(); } @@ -81,7 +92,11 @@ public Instance getRoot() { } } if (popped instanceof ObjectArrayInstance) { - instances.addAll(((ObjectArrayInstance)popped).getValues()); + for(Object el : ((ObjectArrayInstance)popped).getValues()) { + if (el instanceof Instance) { + instances.add((Instance)el); + } + } } return instances.iterator(); } diff --git a/profiler.oql/src/org/netbeans/modules/profiler/oql/engine/api/impl/Snapshot.java b/profiler.oql/src/org/netbeans/modules/profiler/oql/engine/api/impl/Snapshot.java index 3d30f001d..f8d575169 100644 --- a/profiler.oql/src/org/netbeans/modules/profiler/oql/engine/api/impl/Snapshot.java +++ b/profiler.oql/src/org/netbeans/modules/profiler/oql/engine/api/impl/Snapshot.java @@ -36,6 +36,7 @@ import org.netbeans.modules.profiler.oql.engine.api.ReferenceChain; import static org.netbeans.lib.profiler.utils.VMUtils.*; +import org.openide.util.Enumerations; /** * @@ -141,6 +142,23 @@ public GCRoot findRoot(Instance object) { return null; } + public int distanceToGCRoot(Instance object) { + Instance gcInstance = object; + int distance = 0; + do { + gcInstance = gcInstance.getNearestGCRootPointer(); + if (gcInstance == null) { + return 0; + } + distance++; + } while (!gcInstance.isGCRoot()); + return distance; + } + + public Enumeration concat(Enumeration en1, Enumeration en2) { + return Enumerations.concat(en1, en2); + } + /** * Return an Iterator of all of the classes in this snapshot. **/ @@ -168,6 +186,10 @@ public void remove() { } public Iterator getInstances(final JavaClass clazz, final boolean includeSubclasses) { + // special case for all subclasses of java.lang.Object + if (includeSubclasses && clazz.getSuperClass() == null) { + return delegate.getAllInstancesIterator(); + } return new TreeIterator<Instance, JavaClass>(clazz) { @Override diff --git a/profiler.oql/src/org/netbeans/modules/profiler/oql/engine/api/impl/hat.js b/profiler.oql/src/org/netbeans/modules/profiler/oql/engine/api/impl/hat.js index a52d0d6c4..4da2105a9 100644 --- a/profiler.oql/src/org/netbeans/modules/profiler/oql/engine/api/impl/hat.js +++ b/profiler.oql/src/org/netbeans/modules/profiler/oql/engine/api/impl/hat.js @@ -228,7 +228,7 @@ function JavaClassProto() { } this.instances = function() { - return jclass(this).instances.iterator; + return wrapIterator(jclass(this).instances.iterator(), true) } this.toString = function() { @@ -1116,6 +1116,21 @@ function root(jobject) { } /** + * If given jobject has a path to GC root, return distance + * to nearest GC root. + * + * @param jobject object whose distance to the nearest GC root is returned + */ +function rootDistance(jobject) { + try { + jobject = unwrapJavaObject(jobject); + return snapshot.distanceToGCRoot(jobject); + } catch (e) { + return 0; + } +} + +/** * Returns size of the given Java object * * @param jobject object whose size is returned @@ -1387,7 +1402,7 @@ function concat(array1, array2) { return array1.concat(array2); } else if (array1 instanceof java.util.Enumeration && array2 instanceof java.util.Enumeration) { - return new Packages.com.sun.tools.hat.internal.util.CompositeEnumeration(array1, array2); + return this.snapshot.concat(array1, array2); } else { return undefined; } ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services