Skip to content

Commit dd41653

Browse files
committed
GH-477 JavaClass.getSigners() and JavaClass.getProtectionDomain() implemented
1 parent ff9b0be commit dd41653

File tree

8 files changed

+53
-5
lines changed

8 files changed

+53
-5
lines changed

visualvm/heapviewer/nbproject/project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<build-prerequisite/>
3030
<compile-dependency/>
3131
<run-dependency>
32-
<specification-version>1.2</specification-version>
32+
<specification-version>1.3</specification-version>
3333
</run-dependency>
3434
</dependency>
3535
<dependency>

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/ClassHierarchyPlugin.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.graalvm.visualvm.lib.jfluid.heap.Heap;
4848
import org.graalvm.visualvm.lib.jfluid.heap.Instance;
4949
import org.graalvm.visualvm.lib.jfluid.heap.JavaClass;
50+
import org.graalvm.visualvm.lib.jfluid.heap.ObjectArrayInstance;
5051
import org.graalvm.visualvm.lib.profiler.api.icons.Icons;
5152
import org.graalvm.visualvm.lib.profiler.heapwalk.ui.icons.HeapWalkerIcons;
5253
import org.openide.util.NbBundle;
@@ -176,6 +177,8 @@ private static class FakeClass implements JavaClass {
176177
@Override public long getAllInstancesSize() { throw new UnsupportedOperationException("Not supported."); } // NOI18N
177178
@Override public boolean isArray() { throw new UnsupportedOperationException("Not supported."); } // NOI18N
178179
@Override public Instance getClassLoader() { throw new UnsupportedOperationException("Not supported."); } // NOI18N
180+
@Override public ObjectArrayInstance getSigners() { throw new UnsupportedOperationException("Not supported."); } // NOI18N
181+
@Override public Instance getProtectionDomain() { throw new UnsupportedOperationException("Not supported."); } // NOI18N
179182
@Override public List getFields() { throw new UnsupportedOperationException("Not supported."); } // NOI18N
180183
@Override public int getInstanceSize() { throw new UnsupportedOperationException("Not supported."); } // NOI18N
181184
@Override public List getInstances() { throw new UnsupportedOperationException("Not supported."); } // NOI18N

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/JavaDiffClassesProvider.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.graalvm.visualvm.lib.jfluid.heap.Heap;
5555
import org.graalvm.visualvm.lib.jfluid.heap.Instance;
5656
import org.graalvm.visualvm.lib.jfluid.heap.JavaClass;
57+
import org.graalvm.visualvm.lib.jfluid.heap.ObjectArrayInstance;
5758
import org.graalvm.visualvm.lib.profiler.api.icons.Icons;
5859
import org.graalvm.visualvm.lib.profiler.api.icons.LanguageIcons;
5960
import org.openide.util.lookup.ServiceProvider;
@@ -450,6 +451,16 @@ public Instance getClassLoader() {
450451
return null;
451452
}
452453

454+
@Override
455+
public ObjectArrayInstance getSigners() {
456+
return null;
457+
}
458+
459+
@Override
460+
public Instance getProtectionDomain() {
461+
return null;
462+
}
463+
453464
@Override
454465
public List getFields() {
455466
return null;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Manifest-Version: 1.0
22
OpenIDE-Module: org.graalvm.visualvm.lib.jfluid.heap
33
OpenIDE-Module-Localizing-Bundle: org/graalvm/visualvm/lib/jfluid/heap/Bundle.properties
4-
OpenIDE-Module-Specification-Version: 1.2
4+
OpenIDE-Module-Specification-Version: 1.3
55

visualvm/libs.profiler/lib.profiler.heap/src/org/graalvm/visualvm/lib/jfluid/heap/ClassDump.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ public Instance getClassLoader() {
109109
return getHprof().getInstanceByID(getClassLoaderId());
110110
}
111111

112+
public ObjectArrayInstance getSigners() {
113+
return (ObjectArrayInstance) getHprof().getInstanceByID(getSignersId());
114+
}
115+
116+
public Instance getProtectionDomain() {
117+
return getHprof().getInstanceByID(getProtectionDomainId());
118+
}
119+
112120
public Field getField(String name) {
113121
for (Field field : getFields()) {
114122
if (field.getName().equals(name)) {
@@ -407,6 +415,14 @@ long getClassLoaderId() {
407415
return getHprofBuffer().getID(fileOffset + classDumpSegment.classLoaderIDOffset);
408416
}
409417

418+
long getSignersId() {
419+
return getHprofBuffer().getID(fileOffset + classDumpSegment.signersID);
420+
}
421+
422+
long getProtectionDomainId() {
423+
return getHprofBuffer().getID(fileOffset + classDumpSegment.protectionDomainIDOffset);
424+
}
425+
410426
List<Value> getReferences() {
411427
return getHprof().findReferencesFor(getJavaClassId());
412428
}

visualvm/libs.profiler/lib.profiler.heap/src/org/graalvm/visualvm/lib/jfluid/heap/JavaClass.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@ public interface JavaClass {
7777
*/
7878
Instance getClassLoader();
7979

80+
/**
81+
* returns {@link ObjectArrayInstance} representing the signers of this class.
82+
* <br>
83+
* Speed: fast
84+
* @return the signers of this class, or null if there are no signers. In
85+
* particular, this method returns null if this object represents
86+
* a primitive type or void.
87+
*/
88+
ObjectArrayInstance getSigners();
89+
90+
/**
91+
* returns {@link Instance} representing protection domain of this class.
92+
* <br>
93+
* Speed: fast
94+
* @return the ProtectionDomain of this class
95+
*/
96+
Instance getProtectionDomain();
97+
8098
/**
8199
* returns List of instance fields of this {@link JavaClass}.
82100
* <br>

visualvm/libs.profiler/profiler.oql/nbproject/project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ questions.
3535
<build-prerequisite/>
3636
<compile-dependency/>
3737
<run-dependency>
38-
<specification-version>1.0</specification-version>
38+
<specification-version>1.3</specification-version>
3939
</run-dependency>
4040
</dependency>
4141
<dependency>

visualvm/libs.profiler/profiler.oql/src/org/graalvm/visualvm/lib/profiler/oql/engine/api/impl/hat.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ function JavaClassWrapper(jclass) {
439439
}
440440

441441
this.loader = wrapJavaObject(jclass.classLoader);
442-
this.signers = undefined; //TODO wrapJavaValue(jclass.getSigners());
443-
this.protectionDomain = undefined; //TODO wrapJavaValue(jclass.getProtectionDomain());
442+
this.signers = wrapJavaValue(jclass.getSigners());
443+
this.protectionDomain = wrapJavaValue(jclass.getProtectionDomain());
444444
Object.defineProperty(this, "fields", {
445445
get:function() { return wrapIterator(jclass.fields.iterator(), true); }
446446
});

0 commit comments

Comments
 (0)