Skip to content

Commit b6b2430

Browse files
committed
Resolve a few static analysis warnings.
1 parent 2df1c40 commit b6b2430

File tree

2 files changed

+19
-32
lines changed
  • espresso/src
    • com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl
    • com.oracle.truffle.espresso.libjavavm/src/com/oracle/truffle/espresso/libjavavm/arghelper

2 files changed

+19
-32
lines changed

espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/JDWP.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,6 +2730,7 @@ static CommandResult createReply(Packet packet, JDWPContext context) {
27302730
writeValue(sigbyte, value, reply, true, context);
27312731
}
27322732
} catch (ArrayIndexOutOfBoundsException | InteropException ex) {
2733+
ex.printStackTrace();
27332734
// invalid slot provided
27342735
reply.errorCode(ErrorCodes.INVALID_SLOT);
27352736
return new CommandResult(reply);

espresso/src/com.oracle.truffle.espresso.libjavavm/src/com/oracle/truffle/espresso/libjavavm/arghelper/PolyglotArgs.java

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -149,18 +149,15 @@ void parsePolyglotOption(String group, String key, String value, String arg, boo
149149

150150
private OptionDescriptor findOptionDescriptor(String group, String key) {
151151
OptionDescriptors descriptors = null;
152-
switch (group) {
153-
case "engine":
154-
descriptors = getTempEngine().getOptions();
155-
break;
156-
default:
157-
Engine engine = getTempEngine();
158-
if (engine.getLanguages().containsKey(group)) {
159-
descriptors = engine.getLanguages().get(group).getOptions();
160-
} else if (engine.getInstruments().containsKey(group)) {
161-
descriptors = engine.getInstruments().get(group).getOptions();
162-
}
163-
break;
152+
if (group.equals("engine")) {
153+
descriptors = getTempEngine().getOptions();
154+
} else {
155+
Engine engine = getTempEngine();
156+
if (engine.getLanguages().containsKey(group)) {
157+
descriptors = engine.getLanguages().get(group).getOptions();
158+
} else if (engine.getInstruments().containsKey(group)) {
159+
descriptors = engine.getInstruments().get(group).getOptions();
160+
}
164161
}
165162
if (descriptors == null) {
166163
return null;
@@ -219,7 +216,7 @@ static final class PrintableOption implements Comparable<PrintableOption> {
219216
final String option;
220217
final String description;
221218

222-
protected PrintableOption(String option, String description) {
219+
private PrintableOption(String option, String description) {
223220
this.option = option;
224221
this.description = description;
225222
}
@@ -231,21 +228,12 @@ public int compareTo(PrintableOption o) {
231228
}
232229

233230
private static String optionsTitle(String kind, OptionCategory optionCategory) {
234-
String category;
235-
switch (optionCategory) {
236-
case USER:
237-
category = "User ";
238-
break;
239-
case EXPERT:
240-
category = "Expert ";
241-
break;
242-
case INTERNAL:
243-
category = "Internal ";
244-
break;
245-
default:
246-
category = "";
247-
break;
248-
}
231+
String category = switch (optionCategory) {
232+
case USER -> "User ";
233+
case EXPERT -> "Expert ";
234+
case INTERNAL -> "Internal ";
235+
default -> "";
236+
};
249237
return category + kind + " options:";
250238
}
251239

@@ -279,9 +267,7 @@ private static PrintableOption asPrintableOption(OptionDescriptor descriptor) {
279267
StringBuilder key = new StringBuilder("--");
280268
key.append(descriptor.getName());
281269
Object defaultValue = descriptor.getKey().getDefaultValue();
282-
if (defaultValue instanceof Boolean && defaultValue == Boolean.FALSE) {
283-
// nothing to print
284-
} else {
270+
if (defaultValue != Boolean.FALSE) {
285271
key.append("=<");
286272
key.append(descriptor.getKey().getType().getName());
287273
key.append(">");

0 commit comments

Comments
 (0)