Java Code Examples for com.sun.jdi.StringReference
The following examples show how to use
com.sun.jdi.StringReference. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: dragonwell8_jdk Source File: GetUninitializedStringValue.java License: GNU General Public License v2.0 | 6 votes |
/********** test core **********/ protected void runTests() throws Exception { /* * Run to String.<init> */ startUp("GetUninitializedStringValueTarg"); BreakpointEvent bpe = resumeTo("java.lang.String", "<init>", "(Ljava/lang/String;)V"); /* * We've arrived. Look at 'this' - it will be uninitialized (the value field will not be set yet). */ StackFrame frame = bpe.thread().frame(0); StringReference sr = (StringReference)frame.thisObject(); if (!sr.value().equals("")) { throw new Exception("Unexpected value for the uninitialized String"); } /* * resume the target listening for events */ listenUntilVMDisconnect(); }
Example 2
Source Project: TencentKona-8 Source File: GetUninitializedStringValue.java License: GNU General Public License v2.0 | 6 votes |
/********** test core **********/ protected void runTests() throws Exception { /* * Run to String.<init> */ startUp("GetUninitializedStringValueTarg"); BreakpointEvent bpe = resumeTo("java.lang.String", "<init>", "(Ljava/lang/String;)V"); /* * We've arrived. Look at 'this' - it will be uninitialized (the value field will not be set yet). */ StackFrame frame = bpe.thread().frame(0); StringReference sr = (StringReference)frame.thisObject(); if (!sr.value().equals("")) { throw new Exception("Unexpected value for the uninitialized String"); } /* * resume the target listening for events */ listenUntilVMDisconnect(); }
Example 3
Source Project: jdk8u60 Source File: GetUninitializedStringValue.java License: GNU General Public License v2.0 | 6 votes |
/********** test core **********/ protected void runTests() throws Exception { /* * Run to String.<init> */ startUp("GetUninitializedStringValueTarg"); BreakpointEvent bpe = resumeTo("java.lang.String", "<init>", "(Ljava/lang/String;)V"); /* * We've arrived. Look at 'this' - it will be uninitialized (the value field will not be set yet). */ StackFrame frame = bpe.thread().frame(0); StringReference sr = (StringReference)frame.thisObject(); if (!sr.value().equals("")) { throw new Exception("Unexpected value for the uninitialized String"); } /* * resume the target listening for events */ listenUntilVMDisconnect(); }
Example 4
Source Project: openjdk-jdk8u Source File: GetUninitializedStringValue.java License: GNU General Public License v2.0 | 6 votes |
/********** test core **********/ protected void runTests() throws Exception { /* * Run to String.<init> */ startUp("GetUninitializedStringValueTarg"); BreakpointEvent bpe = resumeTo("java.lang.String", "<init>", "(Ljava/lang/String;)V"); /* * We've arrived. Look at 'this' - it will be uninitialized (the value field will not be set yet). */ StackFrame frame = bpe.thread().frame(0); StringReference sr = (StringReference)frame.thisObject(); if (!sr.value().equals("")) { throw new Exception("Unexpected value for the uninitialized String"); } /* * resume the target listening for events */ listenUntilVMDisconnect(); }
Example 5
Source Project: netbeans Source File: TruffleAccess.java License: Apache License 2.0 | 6 votes |
public static SourcePosition getSourcePosition(JPDADebugger debugger, ObjectVariable sourcePositionVar) { Field varSrcId = sourcePositionVar.getField(VAR_SRC_ID); if (varSrcId == null) { // sourcePositionVar represents null return null; } long id = (Long) varSrcId.createMirrorObject(); String sourceSection = (String) sourcePositionVar.getField(VAR_SRC_SOURCESECTION).createMirrorObject(); Source src = Source.getExistingSource(debugger, id); if (src == null) { String name = (String) sourcePositionVar.getField(VAR_SRC_NAME).createMirrorObject(); String path = (String) sourcePositionVar.getField(VAR_SRC_PATH).createMirrorObject(); URI uri = (URI) sourcePositionVar.getField(VAR_SRC_URI).createMirrorObject(); StringReference codeRef = (StringReference) ((JDIVariable) sourcePositionVar.getField(VAR_SRC_CODE)).getJDIValue(); src = Source.getSource(debugger, id, name, path, uri, codeRef); } return new SourcePosition(debugger, id, src, sourceSection); }
Example 6
Source Project: netbeans Source File: Source.java License: Apache License 2.0 | 6 votes |
private Source(JPDADebugger jpda, String name, URI uri, long hash, StringReference codeRef) { this.name = name; this.codeRef = codeRef; URL url = null; if (uri == null || !"file".equalsIgnoreCase(uri.getScheme())) { try { url = SourceFilesCache.get(jpda).getSourceFile(name, hash, uri, getContent()); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } if (url == null) { try { url = uri.toURL(); } catch (MalformedURLException muex) { Exceptions.printStackTrace(muex); } } this.url = url; this.uri = uri; this.hash = hash; }
Example 7
Source Project: netbeans Source File: Source.java License: Apache License 2.0 | 6 votes |
public static Source getSource(JPDADebugger debugger, long id, String name, String path, URI uri, StringReference codeRef) { synchronized (KNOWN_SOURCES) { Map<Long, Source> dbgSources = KNOWN_SOURCES.get(debugger); if (dbgSources != null) { Source src = dbgSources.get(id); if (src != null) { return src; } } } return getTheSource(debugger, id, name, path, uri, codeRef); }
Example 8
Source Project: netbeans Source File: Source.java License: Apache License 2.0 | 6 votes |
private static Source getTheSource(JPDADebugger debugger, long id, String name, String path, URI uri, StringReference codeRef) { Source src = new Source(debugger, name, uri, id, codeRef); synchronized (KNOWN_SOURCES) { Map<Long, Source> dbgSources = KNOWN_SOURCES.get(debugger); if (dbgSources == null) { dbgSources = new HashMap<>(); KNOWN_SOURCES.put(debugger, dbgSources); } dbgSources.put(id, src); } return src; }
Example 9
Source Project: netbeans Source File: JPDAThreadImpl.java License: Apache License 2.0 | 6 votes |
public Variable getPendingVariable(Object action) { Variable var; synchronized (pendingActionsLock) { var = (action == pendingAction) ? pendingVariable : null; } if (var == null) { StringReference sr = threadReference.virtualMachine().mirrorOf(getPendingString(action)); var = new AbstractObjectVariable (debugger, sr, null); } synchronized (pendingActionsLock) { if (action == pendingAction) { pendingVariable = var; } } return var; }
Example 10
Source Project: netbeans Source File: InvocationExceptionTranslated.java License: Apache License 2.0 | 6 votes |
private String getMessageFromField() throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper, ClassNotPreparedExceptionWrapper { List<ReferenceType> throwableClasses = VirtualMachineWrapper.classesByName(exeption.virtualMachine(), Throwable.class.getName()); if (throwableClasses.isEmpty()) { return null; } Field detailMessageField = ReferenceTypeWrapper.fieldByName(throwableClasses.get(0), "detailMessage"); if (detailMessageField != null) { Value messageValue = ObjectReferenceWrapper.getValue(exeption, detailMessageField); if (messageValue instanceof StringReference) { message = StringReferenceWrapper.value((StringReference) messageValue); if (invocationMessage != null) { return invocationMessage + ": " + message; } else { return message; } } } return null; }
Example 11
Source Project: netbeans Source File: EvaluatorTest.java License: Apache License 2.0 | 6 votes |
@Override public boolean equals(Object obj) { if (!(obj instanceof JDIValue)) return false; Value v = ((JDIValue) obj).value; if (value == null) return v == null; if (value instanceof StringReference) { if (!(v instanceof StringReference)) return false; return ((StringReference) value).value().equals(((StringReference) v).value()); } if (value instanceof ArrayReference) { if (!(v instanceof ArrayReference)) return false; ArrayReference a1 = (ArrayReference) value; ArrayReference a2 = (ArrayReference) v; if (!a1.type().equals(a2.type())) return false; if (a1.length() != a2.length()) return false; int n = a1.length(); for (int i = 0; i < n; i++) { if (!new JDIValue(a1.getValue(i)).equals(new JDIValue(a2.getValue(i)))) { return false; } } return true; } return value.equals(v); }
Example 12
Source Project: openjdk-jdk8u-backup Source File: GetUninitializedStringValue.java License: GNU General Public License v2.0 | 6 votes |
/********** test core **********/ protected void runTests() throws Exception { /* * Run to String.<init> */ startUp("GetUninitializedStringValueTarg"); BreakpointEvent bpe = resumeTo("java.lang.String", "<init>", "(Ljava/lang/String;)V"); /* * We've arrived. Look at 'this' - it will be uninitialized (the value field will not be set yet). */ StackFrame frame = bpe.thread().frame(0); StringReference sr = (StringReference)frame.thisObject(); if (!sr.value().equals("")) { throw new Exception("Unexpected value for the uninitialized String"); } /* * resume the target listening for events */ listenUntilVMDisconnect(); }
Example 13
Source Project: openjdk-jdk9 Source File: GetUninitializedStringValue.java License: GNU General Public License v2.0 | 6 votes |
/********** test core **********/ protected void runTests() throws Exception { /* * Run to String.<init> */ startUp("GetUninitializedStringValueTarg"); BreakpointEvent bpe = resumeTo("java.lang.String", "<init>", "(Ljava/lang/String;)V"); /* * We've arrived. Look at 'this' - it will be uninitialized (the value field will not be set yet). */ StackFrame frame = bpe.thread().frame(0); StringReference sr = (StringReference)frame.thisObject(); if (!sr.value().equals("")) { throw new Exception("Unexpected value for the uninitialized String"); } /* * resume the target listening for events */ listenUntilVMDisconnect(); }
Example 14
Source Project: jdk8u-jdk Source File: GetUninitializedStringValue.java License: GNU General Public License v2.0 | 6 votes |
/********** test core **********/ protected void runTests() throws Exception { /* * Run to String.<init> */ startUp("GetUninitializedStringValueTarg"); BreakpointEvent bpe = resumeTo("java.lang.String", "<init>", "(Ljava/lang/String;)V"); /* * We've arrived. Look at 'this' - it will be uninitialized (the value field will not be set yet). */ StackFrame frame = bpe.thread().frame(0); StringReference sr = (StringReference)frame.thisObject(); if (!sr.value().equals("")) { throw new Exception("Unexpected value for the uninitialized String"); } /* * resume the target listening for events */ listenUntilVMDisconnect(); }
Example 15
Source Project: hottub Source File: GetUninitializedStringValue.java License: GNU General Public License v2.0 | 6 votes |
/********** test core **********/ protected void runTests() throws Exception { /* * Run to String.<init> */ startUp("GetUninitializedStringValueTarg"); BreakpointEvent bpe = resumeTo("java.lang.String", "<init>", "(Ljava/lang/String;)V"); /* * We've arrived. Look at 'this' - it will be uninitialized (the value field will not be set yet). */ StackFrame frame = bpe.thread().frame(0); StringReference sr = (StringReference)frame.thisObject(); if (!sr.value().equals("")) { throw new Exception("Unexpected value for the uninitialized String"); } /* * resume the target listening for events */ listenUntilVMDisconnect(); }
Example 16
Source Project: openjdk-8-source Source File: GetUninitializedStringValue.java License: GNU General Public License v2.0 | 6 votes |
/********** test core **********/ protected void runTests() throws Exception { /* * Run to String.<init> */ startUp("GetUninitializedStringValueTarg"); BreakpointEvent bpe = resumeTo("java.lang.String", "<init>", "(Ljava/lang/String;)V"); /* * We've arrived. Look at 'this' - it will be uninitialized (the value field will not be set yet). */ StackFrame frame = bpe.thread().frame(0); StringReference sr = (StringReference)frame.thisObject(); if (!sr.value().equals("")) { throw new Exception("Unexpected value for the uninitialized String"); } /* * resume the target listening for events */ listenUntilVMDisconnect(); }
Example 17
Source Project: openjdk-8 Source File: GetUninitializedStringValue.java License: GNU General Public License v2.0 | 6 votes |
/********** test core **********/ protected void runTests() throws Exception { /* * Run to String.<init> */ startUp("GetUninitializedStringValueTarg"); BreakpointEvent bpe = resumeTo("java.lang.String", "<init>", "(Ljava/lang/String;)V"); /* * We've arrived. Look at 'this' - it will be uninitialized (the value field will not be set yet). */ StackFrame frame = bpe.thread().frame(0); StringReference sr = (StringReference)frame.thisObject(); if (!sr.value().equals("")) { throw new Exception("Unexpected value for the uninitialized String"); } /* * resume the target listening for events */ listenUntilVMDisconnect(); }
Example 18
Source Project: jdk8u_jdk Source File: GetUninitializedStringValue.java License: GNU General Public License v2.0 | 6 votes |
/********** test core **********/ protected void runTests() throws Exception { /* * Run to String.<init> */ startUp("GetUninitializedStringValueTarg"); BreakpointEvent bpe = resumeTo("java.lang.String", "<init>", "(Ljava/lang/String;)V"); /* * We've arrived. Look at 'this' - it will be uninitialized (the value field will not be set yet). */ StackFrame frame = bpe.thread().frame(0); StringReference sr = (StringReference)frame.thisObject(); if (!sr.value().equals("")) { throw new Exception("Unexpected value for the uninitialized String"); } /* * resume the target listening for events */ listenUntilVMDisconnect(); }
Example 19
Source Project: jdk8u-jdk Source File: GetUninitializedStringValue.java License: GNU General Public License v2.0 | 6 votes |
/********** test core **********/ protected void runTests() throws Exception { /* * Run to String.<init> */ startUp("GetUninitializedStringValueTarg"); BreakpointEvent bpe = resumeTo("java.lang.String", "<init>", "(Ljava/lang/String;)V"); /* * We've arrived. Look at 'this' - it will be uninitialized (the value field will not be set yet). */ StackFrame frame = bpe.thread().frame(0); StringReference sr = (StringReference)frame.thisObject(); if (!sr.value().equals("")) { throw new Exception("Unexpected value for the uninitialized String"); } /* * resume the target listening for events */ listenUntilVMDisconnect(); }
Example 20
Source Project: jdk8u-dev-jdk Source File: GetUninitializedStringValue.java License: GNU General Public License v2.0 | 6 votes |
/********** test core **********/ protected void runTests() throws Exception { /* * Run to String.<init> */ startUp("GetUninitializedStringValueTarg"); BreakpointEvent bpe = resumeTo("java.lang.String", "<init>", "(Ljava/lang/String;)V"); /* * We've arrived. Look at 'this' - it will be uninitialized (the value field will not be set yet). */ StackFrame frame = bpe.thread().frame(0); StringReference sr = (StringReference)frame.thisObject(); if (!sr.value().equals("")) { throw new Exception("Unexpected value for the uninitialized String"); } /* * resume the target listening for events */ listenUntilVMDisconnect(); }
Example 21
Source Project: netbeans Source File: RemoteFXScreenshot.java License: Apache License 2.0 | 5 votes |
private static void retrieveScreenshots(JPDAThreadImpl t, final ThreadReference tr, VirtualMachine vm, DebuggerEngine engine, JPDADebuggerImpl d, final List<RemoteScreenshot> screenshots) throws RetrievalException { try { final ClassType windowClass = getClass(vm, tr, "javafx.stage.Window"); Method getWindows = windowClass.concreteMethodByName("impl_getWindows", "()Ljava/util/Iterator;"); Method windowName = windowClass.concreteMethodByName("impl_getMXWindowType", "()Ljava/lang/String;"); ObjectReference iterator = (ObjectReference)windowClass.invokeMethod(tr, getWindows, Collections.emptyList(), ObjectReference.INVOKE_SINGLE_THREADED); ClassType iteratorClass = (ClassType)iterator.referenceType(); Method hasNext = iteratorClass.concreteMethodByName("hasNext", "()Z"); Method next = iteratorClass.concreteMethodByName("next", "()Ljava/lang/Object;"); boolean nextFlag = false; do { BooleanValue bv = (BooleanValue)iterator.invokeMethod(tr, hasNext, Collections.emptyList(), ObjectReference.INVOKE_SINGLE_THREADED); nextFlag = bv.booleanValue(); if (nextFlag) { ObjectReference window = (ObjectReference)iterator.invokeMethod(tr, next, Collections.emptyList(), ObjectReference.INVOKE_SINGLE_THREADED); StringReference name = (StringReference)window.invokeMethod(tr, windowName, Collections.emptyList(), ObjectReference.INVOKE_SINGLE_THREADED); SGComponentInfo windowInfo = new SGComponentInfo(t, window); screenshots.add(createRemoteFXScreenshot(engine, vm, tr, name.value(), window, windowInfo)); } } while (nextFlag); } catch (Exception e) { throw new RetrievalException(e.getMessage(), e); } }
Example 22
Source Project: netbeans Source File: RemoteFXScreenshot.java License: Apache License 2.0 | 5 votes |
private static ReferenceType getType(VirtualMachine vm, ThreadReference tr, String name) { List<ReferenceType> classList = VirtualMachineWrapper.classesByName0(vm, name); if (!classList.isEmpty()) { return classList.iterator().next(); } List<ReferenceType> classClassList = VirtualMachineWrapper.classesByName0(vm, "java.lang.Class"); // NOI18N if (classClassList.isEmpty()) { throw new IllegalStateException("Cannot load class Class"); // NOI18N } ClassType cls = (ClassType) classClassList.iterator().next(); try { Method m = ClassTypeWrapper.concreteMethodByName(cls, "forName", "(Ljava/lang/String;)Ljava/lang/Class;"); // NOI18N StringReference mirrorOfName = VirtualMachineWrapper.mirrorOf(vm, name); ClassTypeWrapper.invokeMethod(cls, tr, m, Collections.singletonList(mirrorOfName), ObjectReference.INVOKE_SINGLE_THREADED); List<ReferenceType> classList2 = VirtualMachineWrapper.classesByName0(vm, name); if (!classList2.isEmpty()) { return classList2.iterator().next(); } } catch (ClassNotLoadedException | ClassNotPreparedExceptionWrapper | IncompatibleThreadStateException | InvalidTypeException | InvocationException | InternalExceptionWrapper | ObjectCollectedExceptionWrapper | UnsupportedOperationExceptionWrapper | VMDisconnectedExceptionWrapper ex) { logger.log(Level.FINE, "Cannot load class " + name, ex); // NOI18N } return null; }
Example 23
Source Project: netbeans Source File: TruffleBreakpointsHandler.java License: Apache License 2.0 | 5 votes |
@Override public void propertyChange(PropertyChangeEvent evt) { final JSLineBreakpoint jsbp = (JSLineBreakpoint) evt.getSource(); String propertyName = evt.getPropertyName(); final TruffleBPMethods method; final List<? extends Value> args; final VirtualMachine vm = ((JPDADebuggerImpl) debugger).getVirtualMachine(); if (vm == null) { return ; } switch (propertyName) { case JSLineBreakpoint.PROP_ENABLED: method = TruffleBPMethods.setEnabled; args = Collections.singletonList(vm.mirrorOf(jsbp.isEnabled())); break; case JSLineBreakpoint.PROP_CONDITION: method = TruffleBPMethods.setCondition; String condition = jsbp.getCondition(); StringReference conditionRef = (condition != null) ? vm.mirrorOf(condition) : null; args = Collections.singletonList(conditionRef); break; case Breakpoint.PROP_HIT_COUNT_FILTER: method = TruffleBPMethods.setIgnoreCount; args = Collections.singletonList(vm.mirrorOf(getIgnoreCount(jsbp))); break; default: return ; } ((JPDADebuggerImpl) debugger).getRequestProcessor().post(new Runnable() { @Override public void run() { setBreakpointProperty(jsbp, method, args); } }); }
Example 24
Source Project: netbeans Source File: TruffleStackInfo.java License: Apache License 2.0 | 5 votes |
private TruffleStackFrame[] loadStackFrames(boolean includeInternal) { JPDAClassType debugAccessor = TruffleDebugManager.getDebugAccessorJPDAClass(debugger); try { Variable internalVar = debugger.createMirrorVar(includeInternal, true); Variable framesVar = debugAccessor.invokeMethod(METHOD_GET_FRAMES_INFO, METHOD_GET_FRAMES_INFO_SIG, new Variable[] { stackTrace, internalVar }); Field[] framesInfos = ((ObjectVariable) framesVar).getFields(0, Integer.MAX_VALUE); String framesDesc = (String) framesInfos[0].createMirrorObject(); Field[] codes = ((ObjectVariable) framesInfos[1]).getFields(0, Integer.MAX_VALUE); Field[] thiss = ((ObjectVariable) framesInfos[2]).getFields(0, Integer.MAX_VALUE); areInternalFrames = false; if (!includeInternal) { areInternalFrames = (Boolean) framesInfos[3].createMirrorObject(); } int i1 = 0; int i2; int depth = 1; List<TruffleStackFrame> truffleFrames = new ArrayList<>(); while ((i2 = framesDesc.indexOf("\n\n", i1)) > 0) { StringReference codeRef = (StringReference) ((JDIVariable) codes[depth-1]).getJDIValue(); ObjectVariable frameInstance = (ObjectVariable) stackTrace.getFields(0, Integer.MAX_VALUE)[depth - 1]; TruffleStackFrame tsf = new TruffleStackFrame( debugger, thread, depth, frameInstance, framesDesc.substring(i1, i2), codeRef, null, (ObjectVariable) thiss[depth-1], includeInternal); truffleFrames.add(tsf); if (includeInternal && tsf.isInternal()) { areInternalFrames = true; } i1 = i2 + 2; depth++; } return truffleFrames.toArray(new TruffleStackFrame[truffleFrames.size()]); } catch (InvalidExpressionException | NoSuchMethodException | InvalidObjectException ex) { Exceptions.printStackTrace(ex); return new TruffleStackFrame[] {}; } }
Example 25
Source Project: netbeans Source File: AbstractVariable.java License: Apache License 2.0 | 5 votes |
static String getValue (Value v) { if (v == null) { return "null"; } if (v instanceof VoidValue) { return "void"; } if (v instanceof CharValue) { return "\'" + v.toString () + "\'"; } if (v instanceof PrimitiveValue) { return v.toString (); } try { if (v instanceof StringReference) { String str = ShortenedStrings.getStringWithLengthControl((StringReference) v); return "\"" + str + "\""; } if (v instanceof ClassObjectReference) { return "class " + ReferenceTypeWrapper.name(ClassObjectReferenceWrapper.reflectedType((ClassObjectReference) v)); } if (v instanceof ArrayReference) { return "#" + ObjectReferenceWrapper.uniqueID((ArrayReference) v) + "(length=" + ArrayReferenceWrapper.length((ArrayReference) v) + ")"; } return "#" + ObjectReferenceWrapper.uniqueID((ObjectReference) v); } catch (InternalExceptionWrapper iex) { return ""; } catch (ObjectCollectedExceptionWrapper oex) { return ""; } catch (VMDisconnectedExceptionWrapper dex) { return ""; } }
Example 26
Source Project: netbeans Source File: MethodInvocationTest.java License: Apache License 2.0 | 5 votes |
public void testTargetMirrors() throws Exception { try { Utils.BreakPositions bp = Utils.getBreakPositions(System.getProperty ("test.dir.src") + "org/netbeans/api/debugger/jpda/testapps/MirrorValuesApp.java"); LineBreakpoint lb = bp.getLineBreakpoints().get(0); dm.addBreakpoint (lb); support = JPDASupport.attach ("org.netbeans.api.debugger.jpda.testapps.MirrorValuesApp"); support.waitState (JPDADebugger.STATE_STOPPED); // breakpoint hit JPDADebugger debugger = support.getDebugger(); List<JPDAClassType> systemClasses = debugger.getClassesByName("java.lang.System"); assertEquals(systemClasses.size(), 1); JPDAClassType systemClass = systemClasses.get(0); Properties properties = System.getProperties(); Variable propertiesVar = systemClass.invokeMethod("getProperties", "()Ljava/util/Properties;", new Variable[]{}); Value pv = ((JDIVariable) propertiesVar).getJDIValue(); assertTrue("Properties "+pv, (pv instanceof ObjectReference) && Properties.class.getName().equals(((ClassType) pv.type()).name())); String userHomeProperty = properties.getProperty("user.home"); Variable propVar = ((ObjectVariable) propertiesVar).invokeMethod("getProperty", "(Ljava/lang/String;)Ljava/lang/String;", new Variable[] { debugger.createMirrorVar("user.home") }); Value p = ((JDIVariable) propVar).getJDIValue(); assertTrue(p instanceof StringReference); assertEquals(userHomeProperty, ((StringReference) p).value()); } finally { support.doFinish (); } }
Example 27
Source Project: netbeans Source File: MirrorValuesTest.java License: Apache License 2.0 | 5 votes |
public void testTargetMirrors() throws Exception { try { Utils.BreakPositions bp = Utils.getBreakPositions(System.getProperty ("test.dir.src") + "org/netbeans/api/debugger/jpda/testapps/MirrorValuesApp.java"); LineBreakpoint lb = bp.getLineBreakpoints().get(0); dm.addBreakpoint (lb); support = JPDASupport.attach (CLASS_NAME); support.waitState (JPDADebugger.STATE_STOPPED); // breakpoint hit JPDADebugger debugger = support.getDebugger(); Variable mirrorVar = debugger.createMirrorVar("Test"); Value v = ((JDIVariable) mirrorVar).getJDIValue(); assertTrue("Value "+v+" should be a String", v instanceof StringReference); assertEquals("Test", ((StringReference) v).value()); Point p = new Point(-1, 1); mirrorVar = debugger.createMirrorVar(p); Object mp = mirrorVar.createMirrorObject(); assertTrue("Correct point was created: "+mp, p.equals(mp)); mirrorVar = debugger.createMirrorVar(1); v = ((JDIVariable) mirrorVar).getJDIValue(); assertTrue("Value "+v+" should be an Integer object.", (v.type() instanceof ClassType) && Integer.class.getName().equals(((ClassType) v.type()).name())); mirrorVar = debugger.createMirrorVar(1, true); v = ((JDIVariable) mirrorVar).getJDIValue(); assertTrue("Value "+v+" should be an int.", v instanceof IntegerValue); assertEquals(((IntegerValue) v).value(), 1); } finally { support.doFinish (); } }
Example 28
Source Project: java-debug Source File: StringObjectFormatterTest.java License: Eclipse Public License 1.0 | 5 votes |
@Test public void testToString() throws Exception { Value string = this.getLocalValue("str"); Map<String, Object> options = formatter.getDefaultOptions(); options.put(MAX_STRING_LENGTH_OPTION, 4); assertEquals("Should be able to format string type.", "\"s...\"", formatter.toString(string, options)); options.put(MAX_STRING_LENGTH_OPTION, 5); assertEquals("Should be able to format string type.", "\"st...\"", formatter.toString(string, options)); assertTrue("Should not trim long string by default", formatter.toString(string, new HashMap<>()).contains(((StringReference) string).value())); }
Example 29
Source Project: gravel Source File: VMTargetRemoteTest.java License: Apache License 2.0 | 5 votes |
@Test public void testDNU() throws Throwable { ObjectReference promise = remote.evaluateForked("3 fromage"); ThreadReference thread = ((ThreadReference) remote.invokeMethod( promise, "thread")); remote.invokeMethod(thread, "start"); ObjectReference state = (ObjectReference) remote.invokeMethod(thread, "getState"); StringReference str = (StringReference) remote.invokeMethod(state, "toString"); System.out.println(str.value()); printStack(thread); // assertFalse(thread.isSuspended()); printThreadState(); System.out.println("VMTargetStarter.sleep(1000)"); VMTargetStarter.sleep(1000); printStack(thread); printThreadState(); boolean isFinished = ((BooleanValue) remote.invokeMethod(promise, "isFinished")).booleanValue(); assertFalse(isFinished); printThreadState(); printStack(thread); assertTrue(thread.isAtBreakpoint()); }
Example 30
Source Project: netbeans Source File: JavaComponentInfo.java License: Apache License 2.0 | 4 votes |
private void addProperties() { addPropertySet(new PropertySet("main", NbBundle.getMessage(JavaComponentInfo.class, "MSG_ComponentPropMain"), NbBundle.getMessage(JavaComponentInfo.class, "MSG_ComponentPropMainDescr")) { @Override public Property<?>[] getProperties() { return new Property[] { new ReadOnly("name", String.class, NbBundle.getMessage(JavaComponentInfo.class, "MSG_ComponentPropName"), NbBundle.getMessage(JavaComponentInfo.class, "MSG_ComponentPropNameDescr")) { @Override public Object getValue() throws IllegalAccessException, InvocationTargetException { return JavaComponentInfo.this.getName(); } }, new ReadOnly("type", String.class, NbBundle.getMessage(JavaComponentInfo.class, "MSG_ComponentPropType"), NbBundle.getMessage(JavaComponentInfo.class, "MSG_ComponentPropTypeDescr")) { @Override public Object getValue() throws IllegalAccessException, InvocationTargetException { return JavaComponentInfo.this.getType(); } }, new ReadOnly("bounds", String.class, NbBundle.getMessage(JavaComponentInfo.class, "MSG_ComponentPropBounds"), NbBundle.getMessage(JavaComponentInfo.class, "MSG_ComponentPropBoundsDescr")) { @Override public Object getValue() throws IllegalAccessException, InvocationTargetException { Rectangle r = JavaComponentInfo.this.getWindowBounds(); return "[x=" + r.x + ",y=" + r.y + ",width=" + r.width + ",height=" + r.height + "]"; } }, }; } }); final LazyProperties lazyProperties = new LazyProperties(); addPropertySet( new PropertySet("Properties", NbBundle.getMessage(JavaComponentInfo.class, "MSG_ComponentProps"), NbBundle.getMessage(JavaComponentInfo.class, "MSG_ComponentPropsDescr")) { @Override public Property<?>[] getProperties() { //System.err.println("JavaComponentInfo.Properties PropertySet.getProperties()"); // To fix https://netbeans.org/bugzilla/show_bug.cgi?id=243065 // https://netbeans.org/bugzilla/show_bug.cgi?id=241154 // Do not compute properties above, compute them on demand in a separate thread now. // When done, fire Node.PROP_PROPERTY_SETS, null, null. Property<?>[] props = lazyProperties.getProperties(); //System.err.println("\nprops = "+props.length+"\n"); return props; } }); try { Method getTextMethod = ClassTypeWrapper.concreteMethodByName( (ClassType) ObjectReferenceWrapper.referenceType(component), "getText", "()Ljava/lang/String;"); //Method getTextMethod = methodsByName.get("getText"); // NOI18N if (getTextMethod != null) { try { Value theText = ObjectReferenceWrapper.invokeMethod(component, getThread().getThreadReference(), getTextMethod, Collections.emptyList(), ObjectReference.INVOKE_SINGLE_THREADED); if (theText instanceof StringReference) { setComponentText(StringReferenceWrapper.value((StringReference) theText)); } } catch (VMDisconnectedExceptionWrapper vmdex) { return; } catch (Exception ex) { Exceptions.printStackTrace(ex); } } } catch (ClassNotPreparedExceptionWrapper | InternalExceptionWrapper | ObjectCollectedExceptionWrapper | VMDisconnectedExceptionWrapper cnpe) { } }