jtulach commented on code in PR #9789:
URL: https://github.com/apache/netbeans/pull/9789#discussion_r4505438105


##########
profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/details/basic/StringDetailsProvider.java:
##########
@@ -62,36 +66,53 @@ public String getDetailsString(String className, Instance 
instance, Heap heap) {
                         0, count, null,
                         "...");                // NOI18N
             } else {
-                return getJDK9String(heap, instance, "value", coder, null, 
"...");          // NOI18N                
+                return getJDK9String(heap, instance, "value", coder, null, 
"...");          // NOI18N
             }
         }
         return null;
     }
     
+    @Override
     public View getDetailsView(String className, Instance instance, Heap heap) 
{
         return new ArrayValueView(className, instance, heap);
     }
     
     private String getJDK9String(Heap heap, Instance instance, String field, 
byte coder, String separator, String trailer) {
         Object byteArray = instance.getValueOfField(field);
         if (byteArray instanceof PrimitiveArrayInstance) {
+            hiShift = -1;
+            loShift = -1;
             List<String> values = ((PrimitiveArrayInstance) 
byteArray).getValues();
             if (values != null) {
-                StringDecoder decoder = new StringDecoder(heap, coder, values);
-                int valuesCount = decoder.getStringLength();
+                int valuesCount = switch (coder) {
+                    case 1 -> values.size() / 2;
+                    default -> values.size();
+                };
                 int separatorLength = separator == null ? 0 : 
separator.length();
                 int trailerLength = trailer == null ? 0 : trailer.length();
                 int estimatedSize = Math.min(valuesCount * (1 + 
separatorLength), DetailsUtils.MAX_ARRAY_LENGTH + trailerLength);
                 StringBuilder value = new StringBuilder(estimatedSize);
                 int lastValue = valuesCount - 1;
                 for (int i = 0; i <= lastValue; i++) {
-                    value.append(decoder.getValueAt(i));
                     if (value.length() >= DetailsUtils.MAX_ARRAY_LENGTH) {
                         if (trailerLength > 0) {
                             value.append(trailer);
                         }
                         break;
                     }
+                    value.append(switch (coder) {

Review Comment:
   - @matthiasblaesing points out similar code is already in 
https://github.com/apache/netbeans/blob/80b4a304a155b281d632a5a6ca26489adeb91f45/java/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ShortenedStrings.java#L71
   - however this code works on `Heap` and `Instance` objects, not on JPDA 
interfaces
   - hence I doubt we can share much...



-- 
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

Reply via email to