geertjanw closed pull request #344: Backport of mentlicher's changes done after
donation.
URL: https://github.com/apache/incubator-netbeans/pull/344
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/debugger.jpda.ui/nbproject/project.xml
b/debugger.jpda.ui/nbproject/project.xml
index 633a7a724..c905198b4 100644
--- a/debugger.jpda.ui/nbproject/project.xml
+++ b/debugger.jpda.ui/nbproject/project.xml
@@ -353,6 +353,7 @@
</test-type>
</test-dependencies>
<friend-packages>
+ <friend>org.netbeans.modules.debugger.jpda.truffle</friend>
<friend>org.netbeans.modules.debugger.jpda.visual</friend>
<friend>org.netbeans.modules.web.debug</friend>
<package>org.netbeans.modules.debugger.jpda.ui</package>
diff --git
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java
index f7f5e023d..04442422e 100644
--- a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java
+++ b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java
@@ -1985,8 +1985,8 @@ public JPDAThreadGroup getThreadGroup
(ThreadGroupReference tgr) {
return (JPDAThreadGroup) threadsTranslation.translate (tgr);
}
- public Variable getLocalVariable(LocalVariable lv, Value v) {
- return (Variable) localsTranslation.translate(lv, v);
+ public Variable getLocalVariable(JPDAThread thread, LocalVariable lv,
Value v) {
+ return (Variable) localsTranslation.translateOnThread(thread, lv, v);
}
public JPDAClassType getClassType(ReferenceType cr) {
diff --git
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/AbstractVariable.java
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/AbstractVariable.java
index 1a3e24e2a..10b8cb2d3 100644
---
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/AbstractVariable.java
+++
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/AbstractVariable.java
@@ -330,7 +330,7 @@ private Value convertValue(Value value, Type type) {
* Override, but do not call directly!
*/
protected void setValue (Value value) throws InvalidExpressionException {
- throw new InternalError ();
+ throw new InternalError (getClass().getName());
}
@Override
diff --git
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/CallStackFrameImpl.java
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/CallStackFrameImpl.java
index cc9a9db9e..7b4d2f352 100644
---
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/CallStackFrameImpl.java
+++
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/CallStackFrameImpl.java
@@ -454,7 +454,7 @@ public synchronized String getSourcePath (String stratum)
throws AbsentInformati
for (int i = 0; i < n; i++) {
com.sun.jdi.LocalVariable lv = (com.sun.jdi.LocalVariable)
l.get (i);
Value v = StackFrameWrapper.getValue(getStackFrame(), lv);
- LocalVariable local = (LocalVariable)
debugger.getLocalVariable(lv, v);
+ LocalVariable local = (LocalVariable)
debugger.getLocalVariable(thread, lv, v);
if (local instanceof Local) {
Local localImpl = (Local) local;
localImpl.setFrame(this);
@@ -502,7 +502,7 @@ public synchronized String getSourcePath (String stratum)
throws AbsentInformati
return null;
}
Value v = StackFrameWrapper.getValue(getStackFrame(), lv);
- LocalVariable local = (LocalVariable)
debugger.getLocalVariable(lv, v);
+ LocalVariable local = (LocalVariable)
debugger.getLocalVariable(thread, lv, v);
if (local instanceof Local) {
Local localImpl = (Local) local;
localImpl.setFrame(this);
diff --git
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ObjectTranslation.java
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ObjectTranslation.java
index 924714b55..cd96fa7af 100644
---
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ObjectTranslation.java
+++
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ObjectTranslation.java
@@ -33,7 +33,9 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Map;
import java.util.WeakHashMap;
+import org.netbeans.api.debugger.jpda.JPDAThread;
import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl;
@@ -53,8 +55,8 @@
private int translationID;
/* original Object to a new one.*/
- private final WeakHashMap<Mirror, WeakReference<Object>> cache
- = new WeakHashMap<Mirror, WeakReference<Object>>();
+ private final Map<Mirror, WeakReference<Object>> cache = new
WeakHashMap<>();
+ private final Map<JPDAThread, Map<Mirror, WeakReference<Object>>>
threadCache = new WeakHashMap<>();
/**
@@ -221,6 +223,40 @@ public Object translate (Mirror o, Object v) {
return r;
}
+ /**
+ * Translates a debuggee Mirror to a thread-specific wrapper object.
+ *
+ * @param thread the thread on which the object lives
+ * @param o the Mirror object in the debuggee
+ * @param v an additional argument used for the translation
+ * @return translated object or <code>null</code> when the argument
+ * is not possible to translate.
+ */
+ public Object translateOnThread (JPDAThread thread, Mirror o, Object v) {
+ Object r = null;
+ boolean verify = false;
+ synchronized (threadCache) {
+ Map<Mirror, WeakReference<Object>> cache = threadCache.get(thread);
+ if (cache == null) {
+ cache = new WeakHashMap<>();
+ threadCache.put(thread, cache);
+ }
+ WeakReference wr = cache.get (o);
+ if (wr != null)
+ r = wr.get ();
+ if (r == null) {
+ r = createTranslation (o, v);
+ cache.put (o, new WeakReference<Object>(r));
+ } else {
+ verify = true;
+ }
+ }
+ if (verify) {
+ verifyTranslation(r, o, v);
+ }
+ return r;
+ }
+
/**
* Explicitly remove the translation of the mirror object.
*/
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
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