Skip to content

Commit 5725a93

Browse files
author
Andrey Turbanov
committed
8293879: Remove unnecessary castings in jdk.hotspot.agent
Reviewed-by: lmesnik, cjplummer
1 parent ab7f58a commit 5725a93

File tree

75 files changed

+253
-261
lines changed

Some content is hidden

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

75 files changed

+253
-261
lines changed

src/jdk.hotspot.agent/share/classes/com/sun/java/swing/action/ActionManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2022, 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
@@ -60,7 +60,7 @@ protected void addAction(String cmdname, Action action)
6060

6161
public Action getAction(String key)
6262
{
63-
return (Action)actions.get(key);
63+
return actions.get(key);
6464
}
6565

6666
public DelegateAction getDelegateAction(String name)

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void add(String s, ArrayList<String> t) {
197197
add(w[i], t);
198198
}
199199
}
200-
tokens = (String[])t.toArray(new String[0]);
200+
tokens = t.toArray(new String[0]);
201201
i = 0;
202202
length = tokens.length;
203203

@@ -768,7 +768,7 @@ public int compare(Object o1, Object o2) {
768768
});
769769
for (int i = 0; i < keys.length; i++) {
770770
out.print(" ");
771-
out.println(((Command)commands.get(keys[i])).usage);
771+
out.println(commands.get(keys[i]).usage);
772772
}
773773
}
774774
}
@@ -1085,7 +1085,7 @@ public void doit(Tokens t) {
10851085
n = n.getSuperclass();
10861086
}
10871087
while (!pending.isEmpty()) {
1088-
n = (Type)pending.pop();
1088+
n = pending.pop();
10891089
dumpType(n);
10901090
emitted.add(n.getName());
10911091
}
@@ -1481,7 +1481,7 @@ public void doit(Tokens t) {
14811481
n = n.getSuperclass();
14821482
}
14831483
while (!pending.isEmpty()) {
1484-
n = (Type)pending.pop();
1484+
n = pending.pop();
14851485
dumpType(n);
14861486
emitted.add(n.getName());
14871487
}
@@ -1986,7 +1986,7 @@ public void visit(Klass k) {
19861986
private boolean doEcho = false;
19871987

19881988
private Command findCommand(String key) {
1989-
return (Command)commands.get(key);
1989+
return commands.get(key);
19901990
}
19911991

19921992
public void printPrompt() {
@@ -2082,17 +2082,17 @@ public void executeCommand(String ln, boolean putInHistory) {
20822082

20832083
String cmd = m.group(2);
20842084
if (cmd.equals("!!")) {
2085-
result.append((String)history.get(history.size() - 1));
2085+
result.append(history.get(history.size() - 1));
20862086
} else if (cmd.equals("!!-")) {
2087-
Tokens item = new Tokens((String)history.get(history.size() - 1));
2087+
Tokens item = new Tokens(history.get(history.size() - 1));
20882088
item.trim(1);
20892089
result.append(item.join(" "));
20902090
} else if (cmd.equals("!*")) {
2091-
Tokens item = new Tokens((String)history.get(history.size() - 1));
2091+
Tokens item = new Tokens(history.get(history.size() - 1));
20922092
item.nextToken();
20932093
result.append(item.join(" "));
20942094
} else if (cmd.equals("!$")) {
2095-
Tokens item = new Tokens((String)history.get(history.size() - 1));
2095+
Tokens item = new Tokens(history.get(history.size() - 1));
20962096
result.append(item.at(item.countTokens() - 1));
20972097
} else {
20982098
String tail = cmd.substring(1);
@@ -2115,13 +2115,13 @@ public void executeCommand(String ln, boolean putInHistory) {
21152115
if (index > size) {
21162116
err.println("No such history item");
21172117
} else {
2118-
result.append((String)history.get(index));
2118+
result.append(history.get(index));
21192119
}
21202120
break;
21212121
}
21222122
default: {
21232123
for (int i = history.size() - 1; i >= 0; i--) {
2124-
String s = (String)history.get(i);
2124+
String s = history.get(i);
21252125
if (s.startsWith(tail)) {
21262126
result.append(s);
21272127
break; // only capture the most recent match in the history

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ public void run() {
956956
}
957957

958958
// Add signal information to annotation if necessary
959-
SignalInfo sigInfo = (SignalInfo) interruptedFrameMap.get(curFrame);
959+
SignalInfo sigInfo = interruptedFrameMap.get(curFrame);
960960
if (sigInfo != null) {
961961
// This frame took a signal and we need to report it.
962962
anno = anno + "\n*** INTERRUPTED BY SIGNAL " + sigInfo.sigNum +
@@ -1778,7 +1778,7 @@ private static JavaVFrame getLastJavaVFrame(JavaThread cur) {
17781778
if (vf.isJavaFrame()) {
17791779
return (JavaVFrame) vf;
17801780
}
1781-
return (JavaVFrame) vf.javaSender();
1781+
return vf.javaSender();
17821782
}
17831783

17841784
// Internal routine for debugging

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotAgent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ private void connectRemoteDebugger() throws DebuggerException {
488488
RemoteDebugger remote =
489489
(RemoteDebugger) RMIHelper.lookup(debugServerID);
490490
debugger = new RemoteDebuggerClient(remote);
491-
machDesc = ((RemoteDebuggerClient) debugger).getMachineDescription();
491+
machDesc = debugger.getMachineDescription();
492492
os = debugger.getOS();
493493
setupJVMLibNames(os);
494494
cpu = debugger.getCPU();

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ci/ciInstanceKlass.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2022, 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
@@ -96,7 +96,7 @@ public void dumpReplayData(PrintStream out) {
9696
sub = sub.getNextSiblingKlass();
9797
}
9898

99-
final int length = (int) cp.getLength();
99+
final int length = cp.getLength();
100100
out.print("ciInstanceKlass " + name() + " " + (isLinked() ? 1 : 0) + " " + (isInitialized() ? 1 : 0) + " " + length);
101101
for (int index = 1; index < length; index++) {
102102
out.print(" " + cp.getTags().at(index));

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public int getOSREntryBCI() {
229229
}
230230

231231
public NMethod getOSRLink() {
232-
return (NMethod) VMObjectFactory.newObject(NMethod.class, osrLinkField.getValue(addr));
232+
return VMObjectFactory.newObject(NMethod.class, osrLinkField.getValue(addr));
233233
}
234234

235235
// MethodHandle
@@ -463,9 +463,9 @@ public void dumpReplayData(PrintStream out) {
463463
if (h.get(meta) != null) continue;
464464
h.put(meta, meta);
465465
if (meta instanceof InstanceKlass) {
466-
((InstanceKlass)meta).dumpReplayData(out);
466+
meta.dumpReplayData(out);
467467
} else if (meta instanceof Method) {
468-
((Method)meta).dumpReplayData(out);
468+
meta.dumpReplayData(out);
469469
MethodData mdo = ((Method)meta).getMethodData();
470470
if (mdo != null) {
471471
mdo.dumpReplayData(out);
@@ -481,7 +481,7 @@ public void dumpReplayData(PrintStream out) {
481481
}
482482
}
483483
if (h.get(method.getMethodHolder()) == null) {
484-
((InstanceKlass)method.getMethodHolder()).dumpReplayData(out);
484+
method.getMethodHolder().dumpReplayData(out);
485485
}
486486
Klass holder = method.getMethodHolder();
487487
out.println("compile " + holder.getName().asString() + " " +

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/ObjectValue.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2009, 2022, 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
@@ -50,7 +50,7 @@ public ObjectValue(int id) {
5050
public int id() { return id; }
5151
public ScopeValue getKlass() { return klass; }
5252
public List<ScopeValue> getFieldsValue() { return fieldsValue; }
53-
public ScopeValue getFieldAt(int i) { return (ScopeValue)fieldsValue.get(i); }
53+
public ScopeValue getFieldAt(int i) { return fieldsValue.get(i); }
5454
public int fieldsSize() { return fieldsValue.size(); }
5555

5656
// Field "value" is always NULL here since it is used
@@ -82,11 +82,11 @@ public void printOn(PrintStream tty) {
8282

8383
void printFieldsOn(PrintStream tty) {
8484
if (fieldsValue.size() > 0) {
85-
((ScopeValue)fieldsValue.get(0)).printOn(tty);
85+
fieldsValue.get(0).printOn(tty);
8686
}
8787
for (int i = 1; i < fieldsValue.size(); i++) {
8888
tty.print(", ");
89-
((ScopeValue)fieldsValue.get(i)).printOn(tty);
89+
fieldsValue.get(i).printOn(tty);
9090
}
9191
}
9292

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/VMRegImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2006, 2022, 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
@@ -53,7 +53,7 @@ private static void initialize(TypeDataBase db) {
5353
Type type = db.lookupType("VMRegImpl");
5454
AddressField stack0Field = type.getAddressField("stack0");
5555
stack0Addr = stack0Field.getValue();
56-
stack0Val = (int) stack0Addr.hashCode();
56+
stack0Val = stack0Addr.hashCode();
5757
stack0 = new VMReg(stack0Val);
5858
regNameField = type.getAddressField("regName[0]");
5959
stackSlotSize = db.lookupIntConstant("VMRegImpl::stack_slot_size");

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/compiler/ImmutableOopMapSet.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2022, 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
@@ -92,8 +92,8 @@ private static void initialize(TypeDataBase db) {
9292
if (!VM.getVM().isCore()) {
9393
REG_COUNT = db.lookupIntConstant("REG_COUNT").intValue();
9494
if (VM.getVM().isServerCompiler()) {
95-
SAVED_ON_ENTRY_REG_COUNT = (int) db.lookupIntConstant("SAVED_ON_ENTRY_REG_COUNT").intValue();
96-
C_SAVED_ON_ENTRY_REG_COUNT = (int) db.lookupIntConstant("C_SAVED_ON_ENTRY_REG_COUNT").intValue();
95+
SAVED_ON_ENTRY_REG_COUNT = db.lookupIntConstant("SAVED_ON_ENTRY_REG_COUNT").intValue();
96+
C_SAVED_ON_ENTRY_REG_COUNT = db.lookupIntConstant("C_SAVED_ON_ENTRY_REG_COUNT").intValue();
9797
}
9898
}
9999
}

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicBlockSym.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2022, 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
@@ -59,7 +59,7 @@ public int getNumLocals() {
5959
}
6060

6161
public LocalSym getLocal(int i) {
62-
return (LocalSym) locals.get(i);
62+
return locals.get(i);
6363
}
6464

6565
public void addLocal(LocalSym local) {

0 commit comments

Comments
 (0)