You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "matthiasblaesing (via GitHub)" <gi...@apache.org> on 2023/02/01 18:47:27 UTC
[GitHub] [netbeans] matthiasblaesing commented on a diff in pull request #5299: [NETBEANS-4123] Initial implementation of handling large strings
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: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists