matthiasblaesing commented on code in PR #5299:
URL: https://github.com/apache/netbeans/pull/5299#discussion_r1093605065
##########
java/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ShortenedStrings.java:
##########
@@ -94,6 +95,42 @@ public static StringInfo getShortenedInfo(String s) {
}
}
+ private static boolean isSmallEndian(VirtualMachine virtualMachine) {
+ //TODO: Possibly cache this value
+ List<ReferenceType> possibleClasses = virtualMachine.classesByName(
+ "java.lang.StringUTF16");
Review Comment:
I think this should be cacheable with a WeakHashMap using the Virtualmachine
as Key. This might be slow if the target VM is not local. I experimented a bit
with this code and on JDK 17 initially `possibleClasses` was empty for me. Not
sure how the VM handled this interernally, but I could make it work using this
code:
```java
if (possibleClasses.isEmpty()) {
ClassType ct = (ClassType)
virtualMachine.classesByName("java.lang.Class").iterator().next();
Method m = ct.concreteMethodByName("forName",
"(Ljava/lang/String;)Ljava/lang/Class;");
StringReference referenceString =
virtualMachine.mirrorOf("java.lang.StringUTF16");
try {
ThreadReference threadReference =
virtualMachine.allThreads().get(0);
ct.invokeMethod(threadReference, m,
Collections.singletonList(referenceString), 0);
possibleClasses =
virtualMachine.classesByName("java.lang.StringUTF16");
} catch (InvalidTypeException | ClassNotLoadedException |
IncompatibleThreadStateException | InvocationException ex) {
Exceptions.printStackTrace(ex);
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists