bugfix #268284, use HprofProxy.getString() to get value of String profiler-release802 VisualVM_139
authorTomas Hurka <thurka@netbeans.org>
Fri, 30 Sep 2016 15:38:00 +0200
branchprofiler-release802
changeset 311901268c3bcd7a42
parent 311709 f49b49e7d6d7
child 314095 bf41be5d77ac
bugfix #268284, use HprofProxy.getString() to get value of String
(transplanted from baa10ec0f3c3e7e14ef093ddbc175cc051c670cf)
profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/details/jdk/ui/Utils.java
     1.1 --- a/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/details/jdk/ui/Utils.java	Thu Sep 15 13:03:28 2016 +0200
     1.2 +++ b/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/details/jdk/ui/Utils.java	Fri Sep 30 15:38:00 2016 +0200
     1.3 @@ -54,7 +54,7 @@
     1.4  import java.awt.event.MouseAdapter;
     1.5  import java.awt.event.MouseEvent;
     1.6  import java.awt.event.MouseMotionAdapter;
     1.7 -import java.util.List;
     1.8 +import java.lang.reflect.Method;
     1.9  import javax.swing.BorderFactory;
    1.10  import javax.swing.Icon;
    1.11  import javax.swing.JComponent;
    1.12 @@ -69,8 +69,8 @@
    1.13  import org.netbeans.lib.profiler.heap.Instance;
    1.14  import org.netbeans.lib.profiler.ui.UIUtils;
    1.15  import org.netbeans.modules.profiler.heapwalk.details.spi.DetailsProvider;
    1.16 -import org.netbeans.modules.profiler.heapwalk.details.spi.DetailsUtils;
    1.17  import org.netbeans.modules.profiler.heapwalk.model.BrowserUtils;
    1.18 +import org.openide.util.Exceptions;
    1.19  import org.openide.util.NbBundle;
    1.20  
    1.21  /**
    1.22 @@ -103,18 +103,13 @@
    1.23      static String getFieldString(Instance instance, String field) {
    1.24          Object _s = instance.getValueOfField(field);
    1.25          if (_s instanceof Instance) {
    1.26 -            Instance s = (Instance)_s;
    1.27 -            int offset = DetailsUtils.getIntFieldValue(s, "offset", 0);         // NOI18N
    1.28 -            int count = DetailsUtils.getIntFieldValue(s, "count", -1);          // NOI18N
    1.29 -            List<String> ch = DetailsUtils.getPrimitiveArrayFieldValues(s, "value"); // NOI18N
    1.30 -            if (ch != null) {
    1.31 -                int valuesCount = count < 0 ? ch.size() - offset :
    1.32 -                                  Math.min(count, ch.size() - offset);            
    1.33 -                StringBuilder value = new StringBuilder(valuesCount * 2);
    1.34 -                int lastValue = offset + valuesCount - 1;
    1.35 -                for (int i = offset; i <= lastValue; i++)
    1.36 -                    value.append(ch.get(i));
    1.37 -                return value.toString();
    1.38 +            try {
    1.39 +                Class proxy = Class.forName("org.netbeans.lib.profiler.heap.HprofProxy"); // NOI18N
    1.40 +                Method method = proxy.getDeclaredMethod("getString", Instance.class); // NOI18N
    1.41 +                method.setAccessible(true);
    1.42 +                return (String) method.invoke(proxy, _s);
    1.43 +            } catch (Exception ex) {
    1.44 +                Exceptions.printStackTrace(ex);
    1.45              }
    1.46          }
    1.47          return null;