Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion com.microsoft.java.debug.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<version>2.10.0</version>
</dependency>
<!-- Dependencies for test -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

package com.microsoft.java.debug.core.adapter.handler;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;

Expand Down Expand Up @@ -46,7 +46,7 @@ public CompletableFuture<Response> handle(Command command, Arguments arguments,
// completions should be illegal when frameId is zero, it is sent when the program is running, while during running we cannot resolve
// the completion candidates
if (completionsArgs.frameId == 0) {
response.body = new ArrayList<>();
response.body = new Responses.CompletionsResponseBody(Collections.emptyList());
return CompletableFuture.completedFuture(response);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017-2020 Microsoft Corporation and others.
* Copyright (c) 2017-2021 Microsoft Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -14,7 +14,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -106,31 +105,58 @@ public CompletableFuture<Response> handle(Command command, Arguments arguments,
indexedVariables = ((IntegerValue) sizeValue).value();
}
}
} catch (CancellationException | IllegalArgumentException | InterruptedException
| ExecutionException | UnsupportedOperationException e) {
logger.log(Level.INFO,
String.format("Failed to get the logical size for the type %s.", value.type().name()), e);
} catch (Exception e) {
logger.log(Level.INFO, "Failed to get the logical size of the variable", e);
}
}
int referenceId = 0;
if (indexedVariables > 0 || (indexedVariables < 0 && value instanceof ObjectReference)) {
referenceId = context.getRecyclableIdPool().addObject(threadId, varProxy);
}

String valueString = variableFormatter.valueToString(value, options);
boolean hasErrors = false;
String valueString = null;
try {
valueString = variableFormatter.valueToString(value, options);
} catch (OutOfMemoryError e) {
hasErrors = true;
logger.log(Level.SEVERE, "Failed to convert the value of a large object to a string", e);
valueString = "<Unable to display the value of a large object>";
} catch (Exception e) {
hasErrors = true;
logger.log(Level.SEVERE, "Failed to resolve the variable value", e);
valueString = "<Failed to resolve the variable value due to \"" + e.getMessage() + "\">";
}

String detailsString = null;
if (sizeValue != null) {
if (hasErrors) {
// If failed to resolve the variable value, skip the details info as well.
} else if (sizeValue != null) {
detailsString = "size=" + variableFormatter.valueToString(sizeValue, options);
} else if (DebugSettings.getCurrent().showToString) {
detailsString = VariableDetailUtils.formatDetailsValue(value, stackFrameReference.getThread(), variableFormatter, options, engine);
try {
detailsString = VariableDetailUtils.formatDetailsValue(value, stackFrameReference.getThread(), variableFormatter, options, engine);
} catch (OutOfMemoryError e) {
logger.log(Level.SEVERE, "Failed to compute the toString() value of a large object", e);
detailsString = "<Unable to display the details of a large object>";
} catch (Exception e) {
logger.log(Level.SEVERE, "Failed to compute the toString() value", e);
detailsString = "<Failed to resolve the variable details due to \"" + e.getMessage() + "\">";
}
}

if ("clipboard".equals(evalArguments.context) && detailsString != null) {
response.body = new Responses.EvaluateResponseBody(detailsString, -1, "String", 0);
} else {
String typeString = "";
try {
typeString = variableFormatter.typeToString(value == null ? null : value.type(), options);
} catch (Exception e) {
logger.log(Level.SEVERE, "Failed to resolve the variable type", e);
typeString = "";
}
response.body = new Responses.EvaluateResponseBody((detailsString == null) ? valueString : valueString + " " + detailsString,
referenceId, variableFormatter.typeToString(value == null ? null : value.type(), options),
Math.max(indexedVariables, 0));
referenceId, typeString, Math.max(indexedVariables, 0));
}
return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ public static synchronized Path generateClasspathJar(String[] classPaths) throws
public static synchronized Path generateArgfile(String[] classPaths, String[] modulePaths) throws IOException {
String argfile = "";
if (ArrayUtils.isNotEmpty(classPaths)) {
argfile = "-classpath \"" + String.join(File.pathSeparator, classPaths) + "\"";
argfile = "-cp \"" + String.join(File.pathSeparator, classPaths) + "\"";
}

if (ArrayUtils.isNotEmpty(modulePaths)) {
argfile = " --module-path \"" + String.join(File.pathSeparator, modulePaths) + "\"";
argfile += " --module-path \"" + String.join(File.pathSeparator, modulePaths) + "\"";
}

argfile = argfile.replace("\\", "\\\\");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017-2020 Microsoft Corporation and others.
* Copyright (c) 2017-2021 Microsoft Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -19,9 +19,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -136,7 +134,12 @@ public CompletableFuture<Response> handle(Command command, Arguments arguments,
try {
ObjectReference containerObj = (ObjectReference) containerNode.getProxiedVariable();
if (DebugSettings.getCurrent().showLogicalStructure && evaluationEngine != null) {
JavaLogicalStructure logicalStructure = JavaLogicalStructureManager.getLogicalStructure(containerObj);
JavaLogicalStructure logicalStructure = null;
try {
logicalStructure = JavaLogicalStructureManager.getLogicalStructure(containerObj);
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to get the logical structure for the variable, fall back to the Object view.", e);
}
if (isUnboundedTypeContainer && logicalStructure != null && containerEvaluateName != null) {
containerEvaluateName = "((" + logicalStructure.getFullyQualifiedName() + ")" + containerEvaluateName + ")";
isUnboundedTypeContainer = false;
Expand Down Expand Up @@ -165,11 +168,8 @@ public CompletableFuture<Response> handle(Command command, Arguments arguments,
childrenList.add(variable);
}
}
} catch (IllegalArgumentException | CancellationException | InterruptedException | ExecutionException e) {
logger.log(Level.WARNING,
String.format("Failed to get the logical structure for the type %s, fall back to the Object view.",
containerObj.type().name()),
e);
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to get the logical structure for the variable, fall back to the Object view.", e);
}

logicalStructure = null;
Expand Down Expand Up @@ -244,9 +244,8 @@ public CompletableFuture<Response> handle(Command command, Arguments arguments,
indexedVariables = ((IntegerValue) sizeValue).value();
}
}
} catch (CancellationException | IllegalArgumentException | InterruptedException | ExecutionException | UnsupportedOperationException e) {
logger.log(Level.INFO,
String.format("Failed to get the logical size for the type %s.", value.type().name()), e);
} catch (Exception e) {
logger.log(Level.INFO, "Failed to get the logical size of the variable", e);
}
}

Expand Down Expand Up @@ -278,15 +277,46 @@ public CompletableFuture<Response> handle(Command command, Arguments arguments,
varProxy.setUnboundedType(javaVariable.isUnboundedType());
}

Types.Variable typedVariables = new Types.Variable(name, variableFormatter.valueToString(value, options),
variableFormatter.typeToString(value == null ? null : value.type(), options),
referenceId, evaluateName);
boolean hasErrors = false;
String valueString = null;
try {
valueString = variableFormatter.valueToString(value, options);
} catch (OutOfMemoryError e) {
hasErrors = true;
logger.log(Level.SEVERE, "Failed to convert the value of a large object to a string", e);
valueString = "<Unable to display the value of a large object>";
} catch (Exception e) {
hasErrors = true;
logger.log(Level.SEVERE, "Failed to resolve the variable value", e);
valueString = "<Failed to resolve the variable value due to \"" + e.getMessage() + "\">";
}

String typeString = "";
try {
typeString = variableFormatter.typeToString(value == null ? null : value.type(), options);
} catch (Exception e) {
logger.log(Level.SEVERE, "Failed to resolve the variable type", e);
typeString = "";
}

Types.Variable typedVariables = new Types.Variable(name, valueString, typeString, referenceId, evaluateName);
typedVariables.indexedVariables = Math.max(indexedVariables, 0);

String detailsValue = null;
if (sizeValue != null) {
if (hasErrors) {
// If failed to resolve the variable value, skip the details info as well.
} else if (sizeValue != null) {
detailsValue = "size=" + variableFormatter.valueToString(sizeValue, options);
} else if (DebugSettings.getCurrent().showToString) {
detailsValue = VariableDetailUtils.formatDetailsValue(value, containerNode.getThread(), variableFormatter, options, evaluationEngine);
try {
detailsValue = VariableDetailUtils.formatDetailsValue(value, containerNode.getThread(), variableFormatter, options, evaluationEngine);
} catch (OutOfMemoryError e) {
logger.log(Level.SEVERE, "Failed to compute the toString() value of a large object", e);
detailsValue = "<Unable to display the details of a large object>";
} catch (Exception e) {
logger.log(Level.SEVERE, "Failed to compute the toString() value", e);
detailsValue = "<Failed to resolve the variable details due to \"" + e.getMessage() + "\">";
}
}

if (detailsValue != null) {
Expand Down
4 changes: 2 additions & 2 deletions com.microsoft.java.debug.plugin/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="lib/commons-io-2.5.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-io-2.10.0.jar"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry exported="true" kind="lib" path="lib/rxjava-2.1.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/reactive-streams-1.0.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/com.microsoft.java.debug.core-0.32.0.jar" sourcepath="/com.microsoft.java.debug.core"/>
<classpathentry exported="true" kind="lib" path="lib/com.microsoft.java.debug.core-0.33.0.jar" sourcepath="/com.microsoft.java.debug.core"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
6 changes: 3 additions & 3 deletions com.microsoft.java.debug.plugin/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Java Debug Server Plugin
Bundle-SymbolicName: com.microsoft.java.debug.plugin;singleton:=true
Bundle-Version: 0.32.0
Bundle-Version: 0.33.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-Activator: com.microsoft.java.debug.plugin.internal.JavaDebuggerServerPlugin
Expand All @@ -21,8 +21,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.apache.commons.lang3,
org.eclipse.lsp4j,
com.google.guava
Bundle-ClassPath: lib/commons-io-2.5.jar,
Bundle-ClassPath: lib/commons-io-2.10.0.jar,
.,
lib/rxjava-2.1.1.jar,
lib/reactive-streams-1.0.0.jar,
lib/com.microsoft.java.debug.core-0.32.0.jar
lib/com.microsoft.java.debug.core-0.33.0.jar
6 changes: 3 additions & 3 deletions com.microsoft.java.debug.plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.microsoft.java</groupId>
<artifactId>java-debug-parent</artifactId>
<version>0.32.0</version>
<version>0.33.0</version>
</parent>
<artifactId>com.microsoft.java.debug.plugin</artifactId>
<packaging>eclipse-plugin</packaging>
Expand Down Expand Up @@ -40,12 +40,12 @@
<artifactItem>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<version>2.10.0</version>
</artifactItem>
<artifactItem>
<groupId>com.microsoft.java</groupId>
<artifactId>com.microsoft.java.debug.core</artifactId>
<version>0.32.0</version>
<version>0.33.0</version>
</artifactItem>
</artifactItems>
</configuration>
Expand Down
Loading