Skip to content

Commit 49230e9

Browse files
authored
8349687: Some more tidying of Nashorn codebase (#25)
1 parent 3990e64 commit 49230e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+151
-179
lines changed

src/org.openjdk.nashorn.shell/share/classes/org/openjdk/nashorn/tools/jjs/Console.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class Console implements AutoCloseable {
9696
in.getHistory().add(line.toString());
9797
}
9898
}
99-
Runtime.getRuntime().addShutdownHook(new Thread((Runnable)this::saveHistory));
99+
Runtime.getRuntime().addShutdownHook(new Thread(this::saveHistory));
100100
bind(DOCUMENTATION_SHORTCUT, ()->showDocumentation(docHelper));
101101
}
102102

src/org.openjdk.nashorn.shell/share/classes/org/openjdk/nashorn/tools/jjs/HistoryObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private void print() {
182182

183183
private Object iterate(final JSObject func) {
184184
for (History.Entry e : hist) {
185-
if (JSType.toBoolean(func.call(this, e.line().toString()))) {
185+
if (JSType.toBoolean(func.call(this, e.line()))) {
186186
break; // return true from callback to skip iteration
187187
}
188188
}

src/org.openjdk.nashorn.shell/share/classes/org/openjdk/nashorn/tools/jjs/JavacPackagesHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static boolean isAvailable() {
8888
fm.setLocation(StandardLocation.CLASS_PATH, getFiles(classPath));
8989
} else {
9090
// no classpath set. Make sure that it is empty and not any default like "."
91-
fm.setLocation(StandardLocation.CLASS_PATH, Collections.<File>emptyList());
91+
fm.setLocation(StandardLocation.CLASS_PATH, Collections.emptyList());
9292
}
9393
} else {
9494
// javac is not available - caller should have checked!

src/org.openjdk.nashorn.shell/share/classes/org/openjdk/nashorn/tools/jjs/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ private void evalImpl(final Context context, final Global global, final String s
289289
}
290290
}
291291

292-
private static String JAVADOC_BASE = "https://docs.oracle.com/javase/%d/docs/api/";
292+
private static final String JAVADOC_BASE = "https://docs.oracle.com/javase/%d/docs/api/";
293293
private static void openBrowserForJavadoc(ScriptFunction browse, String relativeUrl) {
294294
try {
295295
final URI uri = new URI(String.format(JAVADOC_BASE, Runtime.version().feature()) + relativeUrl);

src/org.openjdk.nashorn.shell/share/classes/org/openjdk/nashorn/tools/jjs/PackagesHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ final List<String> getPackageProperties(final String pkg) {
9090
if (Main.DEBUG) {
9191
exp.printStackTrace();
9292
}
93-
return Collections.<String>emptyList();
93+
return Collections.emptyList();
9494
}
9595
}
9696

src/org.openjdk.nashorn.shell/share/classes/org/openjdk/nashorn/tools/jjs/PropertiesHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ List<String> getProperties(final Object obj) {
9090
if (pkgsHelper != null) {
9191
return pkgsHelper.getPackageProperties(((NativeJavaPackage)obj).getName());
9292
} else {
93-
return Collections.<String>emptyList();
93+
return Collections.emptyList();
9494
}
9595
}
9696

src/org.openjdk.nashorn/share/classes/org/openjdk/nashorn/api/tree/YieldTreeImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public ExpressionTree getExpression() {
5050

5151
@Override
5252
public boolean isStar() {
53-
return ((UnaryNode) node).isTokenType(TokenType.YIELD_STAR);
53+
return node.isTokenType(TokenType.YIELD_STAR);
5454
}
5555

5656
@Override

src/org.openjdk.nashorn/share/classes/org/openjdk/nashorn/internal/codegen/ClassEmitter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ static String disassemble(final byte[] bytecode) {
430430
cr.accept(tcv, 0);
431431
}
432432

433-
return new String(baos.toByteArray());
433+
return baos.toString();
434434
}
435435

436436
/**

src/org.openjdk.nashorn/share/classes/org/openjdk/nashorn/internal/codegen/CodeGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3047,7 +3047,7 @@ public boolean enterSwitchNode(final SwitchNode switchNode) {
30473047
}
30483048
// TABLESWITCH needs (range + 3) 32-bit values; LOOKUPSWITCH needs ((size * 2) + 2). Choose the one with
30493049
// smaller representation, favor TABLESWITCH when they're equal size.
3050-
if (range + 1 <= (size * 2)) {
3050+
if (range + 1 <= (size * 2L)) {
30513051
final Label[] table = new Label[(int)range];
30523052
Arrays.fill(table, defaultLabel);
30533053
for (int i = 0; i < size; i++) {

src/org.openjdk.nashorn/share/classes/org/openjdk/nashorn/internal/codegen/CompilerConstants.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,25 +193,25 @@ public enum CompilerConstants {
193193
private final Class<?> type;
194194
private final int slot;
195195

196-
private CompilerConstants() {
196+
CompilerConstants() {
197197
this.symbolName = name();
198198
this.type = null;
199199
this.slot = -1;
200200
}
201201

202-
private CompilerConstants(final String symbolName) {
202+
CompilerConstants(final String symbolName) {
203203
this(symbolName, -1);
204204
}
205205

206-
private CompilerConstants(final String symbolName, final int slot) {
206+
CompilerConstants(final String symbolName, final int slot) {
207207
this(symbolName, null, slot);
208208
}
209209

210-
private CompilerConstants(final String symbolName, final Class<?> type) {
210+
CompilerConstants(final String symbolName, final Class<?> type) {
211211
this(symbolName, type, -1);
212212
}
213213

214-
private CompilerConstants(final String symbolName, final Class<?> type, final int slot) {
214+
CompilerConstants(final String symbolName, final Class<?> type, final int slot) {
215215
this.symbolName = symbolName;
216216
this.type = type;
217217
this.slot = slot;

0 commit comments

Comments
 (0)