diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/AsyncJdwpUtils.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/AsyncJdwpUtils.java index fad2ac223..7f984a809 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/AsyncJdwpUtils.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/AsyncJdwpUtils.java @@ -23,6 +23,7 @@ import java.util.function.Supplier; public class AsyncJdwpUtils { + private AsyncJdwpUtils(){} /** * Create a the thread pool to process JDWP tasks. * JDWP tasks are IO-bounded, so use a relatively large thread pool for JDWP tasks. diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/Configuration.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/Configuration.java index 6e6b34064..706d0f30c 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/Configuration.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/Configuration.java @@ -12,6 +12,7 @@ package com.microsoft.java.debug.core; public class Configuration { + private Configuration(){} public static final String LOGGER_NAME = "java-debug"; public static final String USAGE_DATA_LOGGER_NAME = "java-debug-usage-data"; diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugSession.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugSession.java index fbad52fe2..989f47883 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugSession.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugSession.java @@ -161,9 +161,7 @@ public void setExceptionBreakpoints(boolean notifyCaught, boolean notifyUncaught } catch (VMDisconnectedException ex) { // ignore since removing breakpoints is meaningless when JVM is terminated. } - subscriptions.forEach(subscription -> { - subscription.dispose(); - }); + subscriptions.forEach(Disposable::dispose); subscriptions.clear(); eventRequests.clear(); diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/StackFrameUtility.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/StackFrameUtility.java index 3195747f3..d67011059 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/StackFrameUtility.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/StackFrameUtility.java @@ -19,7 +19,7 @@ import com.sun.jdi.StackFrame; public final class StackFrameUtility { - + private StackFrameUtility(){} public static boolean isNative(StackFrame frame) { return frame.location().method().isNative(); } diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/Watchpoint.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/Watchpoint.java index 3de321ec8..9db53e9eb 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/Watchpoint.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/Watchpoint.java @@ -90,9 +90,7 @@ public void close() throws Exception { } catch (VMDisconnectedException ex) { // ignore since removing breakpoints is meaningless when JVM is terminated. } - subscriptions().forEach(subscription -> { - subscription.dispose(); - }); + subscriptions().forEach(Disposable::dispose); requests.clear(); subscriptions.clear(); } @@ -134,7 +132,7 @@ public void setHitCount(int hitCount) { this.hitCount = hitCount; Observable.fromIterable(this.requests()) - .filter(request -> request instanceof WatchpointRequest) + .filter(WatchpointRequest.class::isInstance) .subscribe(request -> { request.addCountFilter(hitCount); request.enable(); diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/AdapterUtils.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/AdapterUtils.java index c30aa8742..9d7635188 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/AdapterUtils.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/AdapterUtils.java @@ -38,6 +38,7 @@ import com.microsoft.java.debug.core.protocol.Types; public class AdapterUtils { + private AdapterUtils(){} private static final String OS_NAME = System.getProperty("os.name", "").toLowerCase(); private static final Pattern ENCLOSING_CLASS_REGEX = Pattern.compile("^([^\\$]*)"); public static final boolean isWin = isWindows(); @@ -288,7 +289,7 @@ public static String getSHA256HexDigest(String content) { } catch (NoSuchAlgorithmException e) { // ignore it. } - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); if (hashBytes != null) { for (byte b : hashBytes) { buf.append(Integer.toHexString((b & 0xFF) + 0x100).substring(1)); diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/BreakpointManager.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/BreakpointManager.java index eaf1bb56f..cbc6c09cc 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/BreakpointManager.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/BreakpointManager.java @@ -209,7 +209,7 @@ private String getWatchpointKey(IWatchpoint watchpoint) { @Override public IWatchpoint[] getWatchpoints() { - return this.watchpoints.values().stream().filter(wp -> wp != null).toArray(IWatchpoint[]::new); + return this.watchpoints.values().stream().filter(Objects::nonNull).toArray(IWatchpoint[]::new); } @Override diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/Constants.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/Constants.java index 2e523aba2..8035cb3b1 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/Constants.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/Constants.java @@ -12,6 +12,7 @@ package com.microsoft.java.debug.core.adapter; public final class Constants { + private Constants(){} public static final String PROJECT_NAME = "projectName"; public static final String DEBUGGEE_ENCODING = "debuggeeEncoding"; public static final String MAIN_CLASS = "mainClass"; diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/DebugAdapter.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/DebugAdapter.java index 8f595151f..321f5bc27 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/DebugAdapter.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/DebugAdapter.java @@ -90,9 +90,7 @@ public CompletableFuture dispatchRequest(Messages.Request req if (handlers != null && !handlers.isEmpty()) { CompletableFuture future = CompletableFuture.completedFuture(response); for (IDebugRequestHandler handler : handlers) { - future = future.thenCompose((res) -> { - return handler.handle(command, cmdArgs, res, debugContext); - }); + future = future.thenCompose(res -> handler.handle(command, cmdArgs, res, debugContext)); } return future; } else { diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/ErrorCode.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/ErrorCode.java index 6cfe523cf..888424faa 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/ErrorCode.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/ErrorCode.java @@ -56,9 +56,7 @@ public int getId() { * @return the ErrorCode type. */ public static ErrorCode parse(int id) { - ErrorCode[] found = Arrays.stream(ErrorCode.values()).filter(code -> { - return code.getId() == id; - }).toArray(ErrorCode[]::new); + ErrorCode[] found = Arrays.stream(ErrorCode.values()).filter(code -> code.getId() == id).toArray(ErrorCode[]::new); if (found.length > 0) { return found[0]; diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/ProcessConsole.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/ProcessConsole.java index 3d823df91..a94502e58 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/ProcessConsole.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/ProcessConsole.java @@ -86,7 +86,7 @@ public Observable lineMessages() { return this.messages().map((message) -> { String[] lines = message.output.split("(?<=\n)"); return Stream.of(lines).map((line) -> new ConsoleMessage(line, message.category)).toArray(ConsoleMessage[]::new); - }).concatMap((lines) -> Observable.fromArray(lines)); + }).concatMap(Observable::fromArray); } public static class InputStreamObservable { diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/formatter/TypeIdentifiers.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/formatter/TypeIdentifiers.java index 611c9d2d3..ddff22c98 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/formatter/TypeIdentifiers.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/formatter/TypeIdentifiers.java @@ -12,6 +12,7 @@ package com.microsoft.java.debug.core.adapter.formatter; public final class TypeIdentifiers { + private TypeIdentifiers(){} public static final char ARRAY = '['; public static final char BYTE = 'B'; public static final char CHAR = 'C'; diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/ExceptionInfoRequestHandler.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/ExceptionInfoRequestHandler.java index 5e065edd0..807731477 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/ExceptionInfoRequestHandler.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/ExceptionInfoRequestHandler.java @@ -79,7 +79,7 @@ public CompletableFuture handle(Command command, Arguments arguments, String exceptionToString = typeName; if (toStringMethod != null) { try { - Value returnValue = jdiException.exception.invokeMethod(thread, toStringMethod, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED); + Value returnValue = jdiException.exception.invokeMethod(thread, toStringMethod, Collections.emptyList(), ObjectReference.INVOKE_SINGLE_THREADED); exceptionToString = returnValue.toString(); } catch (InvalidTypeException | ClassNotLoadedException | IncompatibleThreadStateException | InvocationException e) { diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/LaunchRequestHandler.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/LaunchRequestHandler.java index e5662f936..ca45e37ea 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/LaunchRequestHandler.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/LaunchRequestHandler.java @@ -66,7 +66,7 @@ public class LaunchRequestHandler implements IDebugRequestHandler { protected static final Logger logger = Logger.getLogger(Configuration.LOGGER_NAME); - protected static final long RUNINTERMINAL_TIMEOUT = 10 * 1000; + protected ILaunchDelegate activeLaunchHandler; private CompletableFuture waitForDebuggeeConsole = new CompletableFuture<>(); diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/LaunchUtils.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/LaunchUtils.java index 27fdb1813..68ed9717c 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/LaunchUtils.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/LaunchUtils.java @@ -45,6 +45,7 @@ import com.microsoft.java.debug.core.adapter.AdapterUtils; public class LaunchUtils { + private LaunchUtils(){} private static final Logger logger = Logger.getLogger(Configuration.LOGGER_NAME); private static Set tempFilesInUse = new HashSet<>(); private static final Charset SYSTEM_CHARSET; @@ -262,7 +263,7 @@ private static long findJavaProcessByCygwinPsCommand(ProcessHandle shellProcess, } if (!javaCandidates.isEmpty()) { - Set descendantWinpids = shellProcess.descendants().map(proc -> proc.pid()).collect(Collectors.toSet()); + Set descendantWinpids = shellProcess.descendants().map(ProcessHandle::pid).collect(Collectors.toSet()); long shellWinpid = shellProcess.pid(); for (PsProcess javaCandidate: javaCandidates) { if (descendantWinpids.contains(javaCandidate.winpid)) { diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/SetBreakpointsRequestHandler.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/SetBreakpointsRequestHandler.java index 09dafd1b0..78dbad68c 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/SetBreakpointsRequestHandler.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/SetBreakpointsRequestHandler.java @@ -187,7 +187,7 @@ private void registerBreakpointHandler(IDebugAdapterContext context) { if (debugSession != null) { debugSession.getEventHub().events().filter(debugEvent -> debugEvent.event instanceof BreakpointEvent).subscribe(debugEvent -> { Event event = debugEvent.event; - if (debugEvent.eventSet.size() > 1 && debugEvent.eventSet.stream().anyMatch(t -> t instanceof StepEvent)) { + if (debugEvent.eventSet.size() > 1 && debugEvent.eventSet.stream().anyMatch(StepEvent.class::isInstance)) { // The StepEvent and BreakpointEvent are grouped in the same event set only if they occurs at the same location and in the same thread. // In order to avoid two duplicated StoppedEvents, the debugger will skip the BreakpointEvent. } else { diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/variables/JavaLogicalStructureManager.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/variables/JavaLogicalStructureManager.java index 2762173cd..45f126c16 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/variables/JavaLogicalStructureManager.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/variables/JavaLogicalStructureManager.java @@ -26,6 +26,7 @@ import com.sun.jdi.Value; public class JavaLogicalStructureManager { + private JavaLogicalStructureManager(){} private static final List supportedLogicalStructures = Collections.synchronizedList(new ArrayList<>()); static { diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/variables/VariableUtils.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/variables/VariableUtils.java index 1a8139fa9..3218f636e 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/variables/VariableUtils.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/variables/VariableUtils.java @@ -62,7 +62,7 @@ public abstract class VariableUtils { * @return true if this value is reference objects. */ public static boolean hasChildren(Value value, boolean includeStatic) { - if (value == null || !(value instanceof ObjectReference)) { + if (!(value instanceof ObjectReference)) { return false; } ReferenceType type = ((ObjectReference) value).referenceType(); @@ -189,7 +189,7 @@ public static List listLocalVariables(StackFrame stackFrame) throws Ab // avoid listing variable on native methods try { - if (stackFrame.location().method().argumentTypes().size() == 0) { + if (stackFrame.location().method().argumentTypes().isEmpty()) { return res; } } catch (ClassNotLoadedException ex2) {