diff --git a/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/action/ActionManager.java b/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/action/ActionManager.java index 7da5b6534ca..28e02aacd3f 100644 --- a/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/action/ActionManager.java +++ b/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/action/ActionManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ public abstract class ActionManager protected ActionManager() { - actions = new HashMap(); + actions = new HashMap<>(); addActions(); } @@ -93,7 +93,7 @@ public void setActionEnabled(String name, boolean enabled) action.setEnabled(enabled); } - private HashMap actions; + private HashMap actions; private static ActionUtilities utilities = new ActionUtilities(); private static ActionManager manager; diff --git a/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/ui/CommonUI.java b/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/ui/CommonUI.java index a1c8127f475..fcdbb88138c 100644 --- a/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/ui/CommonUI.java +++ b/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/ui/CommonUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -176,30 +176,30 @@ public static JCheckBox createCheckBox(String text) return createCheckBox(text, -1, null, false); } - public static JComboBox createComboBox(Object items[], ActionListener listener, boolean editable) + public static JComboBox createComboBox(Object items[], ActionListener listener, boolean editable) { - JComboBox comboBox = new JComboBox(items); + JComboBox comboBox = new JComboBox<>(items); if(listener != null) comboBox.addActionListener(listener); comboBox.setEditable(editable); return comboBox; } - public static JComboBox createComboBox(Object items[], boolean editable) + public static JComboBox createComboBox(Object items[], boolean editable) { return createComboBox(items, null, editable); } - public static JComboBox createComboBox(Vector items, ActionListener listener, boolean editable) + public static JComboBox createComboBox(Vector items, ActionListener listener, boolean editable) { - JComboBox comboBox = new JComboBox(items); + JComboBox comboBox = new JComboBox<>(items); if(listener != null) comboBox.addActionListener(listener); comboBox.setEditable(editable); return comboBox; } - public static JComboBox createComboBox(Vector items, boolean editable) + public static JComboBox createComboBox(Vector items, boolean editable) { return createComboBox(items, null, editable); } diff --git a/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/ui/TabsDlg.java b/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/ui/TabsDlg.java index 7bab624a4c2..5d5adae81d0 100644 --- a/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/ui/TabsDlg.java +++ b/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/ui/TabsDlg.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -127,7 +127,7 @@ public static void main(String args[]) JPanel p4 = new JPanel(); p4.add(new JButton("Four")); p4.setName("Four"); - Vector panels = new Vector(); + Vector panels = new Vector<>(); panels.addElement(p1); panels.addElement(p2); panels.addElement(p3); diff --git a/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/ui/WizardDlg.java b/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/ui/WizardDlg.java index c9cb7c9196f..b6ff7fb3996 100644 --- a/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/ui/WizardDlg.java +++ b/src/jdk.hotspot.agent/share/classes/com/sun/java/swing/ui/WizardDlg.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -178,7 +178,7 @@ public static void main(String args[]) p3.add(new JButton("Three")); JPanel p4 = new JPanel(); p4.add(new JButton("Four")); - Vector panels = new Vector(); + Vector panels = new Vector<>(); panels.addElement(p1); panels.addElement(p2); panels.addElement(p3); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java index 71ae64f146e..b9d09609549 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java @@ -128,7 +128,7 @@ public boolean canInclude(InstanceKlass kls) { } public static class NonBootFilter implements ClassFilter { - private HashMap emitted = new HashMap(); + private HashMap emitted = new HashMap<>(); public boolean canInclude(InstanceKlass kls) { if (kls.getClassLoader() == null) return false; if (emitted.get(kls.getName()) != null) { @@ -156,7 +156,7 @@ String[] splitWhitespace(String cmd) { return t; } - void add(String s, ArrayList t) { + void add(String s, ArrayList t) { if (s.length() > 0) { t.add(s); } @@ -167,7 +167,7 @@ void add(String s, ArrayList t) { // check for quoting int quote = cmd.indexOf('"'); - ArrayList t = new ArrayList(); + ArrayList t = new ArrayList<>(); if (quote != -1) { while (cmd.length() > 0) { if (quote != -1) { @@ -682,7 +682,7 @@ public void doit(Tokens t) { } else if (tokens == 0) { out.println("Available commands:"); Object[] keys = commands.keySet().toArray(); - Arrays.sort(keys, new Comparator() { + Arrays.sort(keys, new Comparator<>() { public int compare(Object o1, Object o2) { return o1.toString().compareTo(o2.toString()); } @@ -993,8 +993,8 @@ public void doit(Tokens t) { // be read back. Iterator i = agent.getTypeDataBase().getTypes(); // Make sure the types are emitted in an order than can be read back in - HashSet emitted = new HashSet(); - Stack pending = new Stack(); + HashSet emitted = new HashSet<>(); + Stack pending = new Stack<>(); while (i.hasNext()) { Type n = (Type)i.next(); if (emitted.contains(n.getName())) { @@ -1389,8 +1389,8 @@ public void doit(Tokens t) { } else { Iterator i = agent.getTypeDataBase().getTypes(); // Make sure the types are emitted in an order than can be read back in - HashSet emitted = new HashSet(); - Stack pending = new Stack(); + HashSet emitted = new HashSet<>(); + Stack pending = new Stack<>(); while (i.hasNext()) { Type n = (Type)i.next(); if (emitted.contains(n.getName())) { @@ -1640,7 +1640,7 @@ public void doit(Tokens t) { if (t.countTokens() != 0) { usage(); } else { - ArrayList nmethods = new ArrayList(); + ArrayList nmethods = new ArrayList<>(); Threads threads = VM.getVM().getThreads(); HTMLGenerator gen = new HTMLGenerator(false); for (int i = 0; i < threads.getNumberOfThreads(); i++) { @@ -1832,8 +1832,8 @@ public void visit(Klass k) { }; private boolean verboseExceptions = false; - private ArrayList history = new ArrayList(); - private HashMap commands = new HashMap(); + private ArrayList history = new ArrayList<>(); + private HashMap commands = new HashMap<>(); private boolean doEcho = false; private Command findCommand(String key) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java index 30811504b88..68c74d90d43 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,10 +66,8 @@ public static void main(String[] args) { private boolean attached; private boolean argError; private JFrame frame; - /** List */ - private java.util.List attachMenuItems; - /** List */ - private java.util.List detachMenuItems; + private java.util.List attachMenuItems; + private java.util.List detachMenuItems; private JMenu toolsMenu; private JMenuItem showDbgConsoleMenuItem; private JMenuItem computeRevPtrsMenuItem; @@ -155,8 +153,8 @@ public void run() { agent = new HotSpotAgent(); workerThread = new WorkerThread(); - attachMenuItems = new java.util.ArrayList(); - detachMenuItems = new java.util.ArrayList(); + attachMenuItems = new java.util.ArrayList<>(); + detachMenuItems = new java.util.ArrayList<>(); JMenuBar menuBar = new JMenuBar(); @@ -875,7 +873,7 @@ public void run() { // frames in a table and one which finds Java frames and if they // are in the table indicates that they were interrupted by a signal. - Map interruptedFrameMap = new HashMap(); + Map interruptedFrameMap = new HashMap<>(); { sun.jvm.hotspot.runtime.Frame tmpFrame = thread.getCurrentFrameGuess(); RegisterMap tmpMap = thread.newRegisterMap(false); @@ -1845,9 +1843,9 @@ private String formatMessage(String message, int charsPerLine) { return buf.toString(); } - private void setMenuItemsEnabled(java.util.List items, boolean enabled) { - for (Iterator iter = items.iterator(); iter.hasNext(); ) { - ((JMenuItem) iter.next()).setEnabled(enabled); + private void setMenuItemsEnabled(java.util.List items, boolean enabled) { + for (Iterator iter = items.iterator(); iter.hasNext(); ) { + iter.next().setEnabled(enabled); } } } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotAgent.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotAgent.java index 7533b7072cc..b5547c3c455 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotAgent.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotAgent.java @@ -483,7 +483,7 @@ private void setupDebuggerExisting() { private void setupDebuggerAlternate(String alternateName) { try { - Class c = Class.forName(alternateName); + Class c = Class.forName(alternateName); Constructor cons = c.getConstructor(); debugger = (JVMDebugger) cons.newInstance(); attachDebugger(); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ci/ciObjectFactory.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ci/ciObjectFactory.java index 7f97400085b..bdaf3bd0b50 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ci/ciObjectFactory.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ci/ciObjectFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,13 +63,13 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeExc public static ciObject get(Address addr) { if (addr == null) return null; - return (ciObject)ciObjectConstructor.instantiateWrapperFor(addr); + return ciObjectConstructor.instantiateWrapperFor(addr); } public static ciMetadata getMetadata(Address addr) { if (addr == null) return null; - return (ciMetadata)ciMetadataConstructor.instantiateWrapperFor(addr); + return ciMetadataConstructor.instantiateWrapperFor(addr); } public GrowableArray objects() { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeCache.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeCache.java index 454d2fdc51f..33009b5502e 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeCache.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,8 +49,8 @@ private static synchronized void initialize(TypeDataBase db) { // Get array of CodeHeaps // Note: CodeHeap may be subclassed with optional private heap mechanisms. Type codeHeapType = db.lookupType("CodeHeap"); - VirtualBaseConstructor heapConstructor = - new VirtualBaseConstructor(db, codeHeapType, "sun.jvm.hotspot.memory", CodeHeap.class); + VirtualBaseConstructor heapConstructor = + new VirtualBaseConstructor<>(db, codeHeapType, "sun.jvm.hotspot.memory", CodeHeap.class); AddressField heapsField = type.getAddressField("_heaps"); heapArray = GrowableArray.create(heapsField.getValue(), heapConstructor); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/DebugInfoReadStream.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/DebugInfoReadStream.java index 7083b0e697e..0ab2bbdc608 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/DebugInfoReadStream.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/DebugInfoReadStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ public class DebugInfoReadStream extends CompressedReadStream { private NMethod code; private int InvocationEntryBCI; - private List objectPool; // ArrayList + private List objectPool; public DebugInfoReadStream(NMethod code, int offset) { super(code.scopesDataBegin(), offset); @@ -43,7 +43,7 @@ public DebugInfoReadStream(NMethod code, int offset) { this.objectPool = null; } - public DebugInfoReadStream(NMethod code, int offset, List objectPool) { + public DebugInfoReadStream(NMethod code, int offset, List objectPool) { super(code.scopesDataBegin(), offset); InvocationEntryBCI = VM.getVM().getInvocationEntryBCI(); this.code = code; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java index a5a98222b43..ab117511805 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -416,8 +416,8 @@ public ScopeDesc getScopeDescNearDbg(Address pc) { return new ScopeDesc(this, pd.getScopeDecodeOffset(), pd.getObjDecodeOffset(), pd.getReexecute()); } - public Map/**/ getSafepoints() { - Map safepoints = new HashMap(); // Map + public Map getSafepoints() { + Map safepoints = new HashMap<>(); sun.jvm.hotspot.debugger.Address p = null; for (p = scopesPCsBegin(); p.lessThan(scopesPCsEnd()); p = p.addOffsetTo(pcDescSize)) { @@ -474,7 +474,7 @@ public String getName() { } public void dumpReplayData(PrintStream out) { - HashMap h = new HashMap(); + HashMap h = new HashMap<>(); for (int i = 1; i < getMetadataLength(); i++) { Metadata meta = Metadata.instantiateWrapperFor(getMetadataAt(i)); System.err.println(meta); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/ObjectValue.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/ObjectValue.java index a11beaf4167..1175f5fe4ee 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/ObjectValue.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/ObjectValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,9 +33,9 @@ /** An ObjectValue describes an object eliminated by escape analysis. */ public class ObjectValue extends ScopeValue { - private int id; - private ScopeValue klass; - private List fieldsValue; // ArrayList + private int id; + private ScopeValue klass; + private List fieldsValue; // Field "boolean visited" is not implemented here since // it is used only a during debug info creation. @@ -43,13 +43,13 @@ public class ObjectValue extends ScopeValue { public ObjectValue(int id) { this.id = id; klass = null; - fieldsValue = new ArrayList(); + fieldsValue = new ArrayList<>(); } public boolean isObject() { return true; } public int id() { return id; } public ScopeValue getKlass() { return klass; } - public List getFieldsValue() { return fieldsValue; } + public List getFieldsValue() { return fieldsValue; } public ScopeValue getFieldAt(int i) { return (ScopeValue)fieldsValue.get(i); } public int fieldsSize() { return fieldsValue.size(); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/ScopeDesc.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/ScopeDesc.java index 7edfdb9db9b..af8f6b5b0a3 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/ScopeDesc.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/ScopeDesc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,9 +49,9 @@ public class ScopeDesc { private int expressionsDecodeOffset; private int monitorsDecodeOffset; /** Scalar replaced bjects pool */ - private List objects; // ArrayList + private List objects; - private ScopeDesc(NMethod code, int decodeOffset, List objects, boolean reexecute) { + private ScopeDesc(NMethod code, int decodeOffset, List objects, boolean reexecute) { this.code = code; this.decodeOffset = decodeOffset; this.objects = objects; @@ -93,22 +93,22 @@ public ScopeDesc(NMethod code, int decodeOffset, int objectDecodeOffset, boolean public boolean getReexecute() { return reexecute;} /** Returns a List<ScopeValue> */ - public List getLocals() { + public List getLocals() { return decodeScopeValues(localsDecodeOffset); } /** Returns a List<ScopeValue> */ - public List getExpressions() { + public List getExpressions() { return decodeScopeValues(expressionsDecodeOffset); } /** Returns a List<MonitorValue> */ - public List getMonitors() { + public List getMonitors() { return decodeMonitorValues(monitorsDecodeOffset); } /** Returns a List<ObjectValue> */ - public List getObjects() { + public List getObjects() { return objects; } @@ -166,13 +166,13 @@ private DebugInfoReadStream streamAt(int decodeOffset) { } /** Returns a List<ScopeValue> or null if no values were present */ - private List decodeScopeValues(int decodeOffset) { + private List decodeScopeValues(int decodeOffset) { if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { return null; } DebugInfoReadStream stream = streamAt(decodeOffset); int length = stream.readInt(); - List res = new ArrayList(length); + List res = new ArrayList<>(length); for (int i = 0; i < length; i++) { res.add(ScopeValue.readFrom(stream)); } @@ -180,13 +180,13 @@ private List decodeScopeValues(int decodeOffset) { } /** Returns a List<MonitorValue> or null if no values were present */ - private List decodeMonitorValues(int decodeOffset) { + private List decodeMonitorValues(int decodeOffset) { if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { return null; } DebugInfoReadStream stream = streamAt(decodeOffset); int length = stream.readInt(); - List res = new ArrayList(length); + List res = new ArrayList<>(length); for (int i = 0; i < length; i++) { res.add(new MonitorValue(stream)); } @@ -194,11 +194,11 @@ private List decodeMonitorValues(int decodeOffset) { } /** Returns a List<ObjectValue> or null if no values were present */ - private List decodeObjectValues(int decodeOffset) { + private List decodeObjectValues(int decodeOffset) { if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { return null; } - List res = new ArrayList(); + List res = new ArrayList<>(); DebugInfoReadStream stream = new DebugInfoReadStream(code, decodeOffset, res); int length = stream.readInt(); for (int i = 0; i < length; i++) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/StubQueue.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/StubQueue.java index 245797bd31a..8464204ea52 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/StubQueue.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/StubQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ public class StubQueue extends VMObject { // The type of the contained stubs (i.e., InterpreterCodelet, // ICStub). Must be a subclass of type Stub. - private Class stubType; + private Class stubType; static { VM.registerVMInitializedObserver(new Observer() { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/Debugger.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/Debugger.java index 405c82cbb02..90f79a55485 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/Debugger.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/Debugger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ public interface Debugger extends SymbolLookup, ThreadAccess { /** Provide a snapshot of the list of currently-running processes in the form of a List of ProcessInfo objects. Must only be called if hasProcessList(), above, returns true. */ - public List getProcessList() throws DebuggerException; + public List getProcessList() throws DebuggerException; /** If an error occurs during attachment (i.e., "no such process"), the thrown DebuggerException will contain a description of the diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/BsdCDebugger.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/BsdCDebugger.java index addcf0569c8..198e930efb9 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/BsdCDebugger.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/BsdCDebugger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,11 +41,11 @@ class BsdCDebugger implements CDebugger { this.dbg = dbg; } - public List getThreadList() throws DebuggerException { + public List getThreadList() throws DebuggerException { return dbg.getThreadList(); } - public List/**/ getLoadObjectList() throws DebuggerException { + public List getLoadObjectList() throws DebuggerException { return dbg.getLoadObjectList(); } @@ -53,7 +53,7 @@ public LoadObject loadObjectContainingPC(Address pc) throws DebuggerException { if (pc == null) { return null; } - List objs = getLoadObjectList(); + List objs = getLoadObjectList(); Object[] arr = objs.toArray(); // load objects are sorted by base address, do binary search int mid = -1; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebugger.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebugger.java index d7576d8ba07..8fe3d11f7f4 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebugger.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebugger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,8 +54,8 @@ public long readCInteger(long address, long numBytes, boolean isUnsigned public Address newAddress(long value) throws DebuggerException; // For BsdCDebugger - public List getThreadList(); - public List getLoadObjectList(); + public List getThreadList(); + public List getLoadObjectList(); public ClosestSymbol lookup(long address); // NOTE: this interface implicitly contains the following methods: diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebuggerLocal.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebuggerLocal.java index c065bba050d..91c561d0abf 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebuggerLocal.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebuggerLocal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ import sun.jvm.hotspot.debugger.MachineDescription; import sun.jvm.hotspot.debugger.NotInHeapException; import sun.jvm.hotspot.debugger.OopHandle; +import sun.jvm.hotspot.debugger.ProcessInfo; import sun.jvm.hotspot.debugger.ReadResult; import sun.jvm.hotspot.debugger.ThreadProxy; import sun.jvm.hotspot.debugger.UnalignedAddressException; @@ -75,8 +76,8 @@ public class BsdDebuggerLocal extends DebuggerBase implements BsdDebugger { private BsdCDebugger cdbg; // threadList and loadObjectList are filled by attach0 method - private List threadList; - private List loadObjectList; + private List threadList; + private List loadObjectList; // called by native method lookupByAddress0 private ClosestSymbol createClosestSymbol(String name, long offset) { @@ -230,7 +231,7 @@ public boolean hasProcessList() throws DebuggerException { } /** From the Debugger interface via JVMDebugger */ - public List getProcessList() throws DebuggerException { + public List getProcessList() throws DebuggerException { throw new DebuggerException("getProcessList not implemented yet"); } @@ -266,8 +267,8 @@ private void findABIVersion() throws DebuggerException { /** From the Debugger interface via JVMDebugger */ public synchronized void attach(int processID) throws DebuggerException { checkAttached(); - threadList = new ArrayList(); - loadObjectList = new ArrayList(); + threadList = new ArrayList<>(); + loadObjectList = new ArrayList<>(); class AttachTask implements WorkerThreadTask { int pid; public void doit(BsdDebuggerLocal debugger) { @@ -286,8 +287,8 @@ public void doit(BsdDebuggerLocal debugger) { /** From the Debugger interface via JVMDebugger */ public synchronized void attach(String execName, String coreName) { checkAttached(); - threadList = new ArrayList(); - loadObjectList = new ArrayList(); + threadList = new ArrayList<>(); + loadObjectList = new ArrayList<>(); attach0(execName, coreName); attached = true; isCore = true; @@ -536,13 +537,13 @@ public Address newAddress(long value) { } /** From the BsdCDebugger interface */ - public List/**/ getThreadList() { + public List getThreadList() { requireAttach(); return threadList; } /** From the BsdCDebugger interface */ - public List/**/ getLoadObjectList() { + public List getLoadObjectList() { requireAttach(); return loadObjectList; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/CDebugger.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/CDebugger.java index f251c860c54..88226d81014 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/CDebugger.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/CDebugger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,13 +35,13 @@ public interface CDebugger { ThreadProxy objects. Do not mutate this list. Throws DebuggerException if the target process is not suspended (via ProcessControl) or if the fetch failed for some other reason. */ - public List/**/ getThreadList() throws DebuggerException; + public List getThreadList() throws DebuggerException; /** Return a list of LoadObjects in the target process. Do not mutate this list. Throws DebuggerException if the target process is not suspended (via ProcessControl) or if the fetch failed for some other reason. */ - public List/**/ getLoadObjectList() throws DebuggerException; + public List getLoadObjectList() throws DebuggerException; /** Fetch the loadobject containing the current program counter. Returns null if the PC was outside the ranges of all loadobjects diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/LoadObjectComparator.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/LoadObjectComparator.java index 8a4a845d843..ce3c9a7137d 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/LoadObjectComparator.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/LoadObjectComparator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,10 +29,8 @@ // a comparator used to sort LoadObjects by base address -public class LoadObjectComparator implements Comparator { - public int compare(Object o1, Object o2) { - LoadObject lo1 = (LoadObject) o1; - LoadObject lo2 = (LoadObject) o2; +public class LoadObjectComparator implements Comparator { + public int compare(LoadObject lo1, LoadObject lo2) { Address base1 = lo1.getBase(); Address base2 = lo2.getBase(); long diff = base1.minus(base2); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/TemplateType.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/TemplateType.java index a7353b71c31..fab78894820 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/TemplateType.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/TemplateType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,5 +29,5 @@ public interface TemplateType extends Type { public int getNumTemplateArguments(); public Type instantiate(Type[] arguments); - public Type instantiate(List/**/ arguments); + public Type instantiate(List arguments); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicBlockSym.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicBlockSym.java index 8d0edb19dc3..22dfe0955ae 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicBlockSym.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicBlockSym.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ public class BasicBlockSym extends BasicSym implements BlockSym { private long length; private Address addr; - private List locals; + private List locals; /** Creates a new BlockSym. Parent can be null. */ public BasicBlockSym(BlockSym parent, long length, Address addr, String name) { @@ -64,7 +64,7 @@ public LocalSym getLocal(int i) { public void addLocal(LocalSym local) { if (locals == null) { - locals = new ArrayList(); + locals = new ArrayList<>(); } locals.add(local); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicCDebugInfoDataBase.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicCDebugInfoDataBase.java index 6fb9b69d589..ccc6e3bdaf8 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicCDebugInfoDataBase.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicCDebugInfoDataBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,27 +43,27 @@ public class BasicCDebugInfoDataBase implements CDebugInfoDataBase { /////////// // Used only during construction - private Map lazyTypeMap; + private Map lazyTypeMap; // Used during construction and at run time for iteration - private List types; + private List types; // Used only during runtime - private Map nameToTypeMap; + private Map nameToTypeMap; ///////////// // Symbols // ///////////// // Used only during construction - private Map lazySymMap; + private Map lazySymMap; // List of blocks in increasing order by starting address. These can // then be binary searched. - private List blocks; + private List blocks; // Name-to-global symbol table - private Map nameToSymMap; + private Map nameToSymMap; ////////////////// // Line numbers // @@ -85,13 +85,13 @@ public void beginConstruction() { state = CONSTRUCTION_STATE; // Types - lazyTypeMap = new HashMap(); - types = new ArrayList(); + lazyTypeMap = new HashMap<>(); + types = new ArrayList<>(); // Symbols - lazySymMap = new HashMap(); - blocks = new ArrayList(); - nameToSymMap = new HashMap(); + lazySymMap = new HashMap<>(); + blocks = new ArrayList<>(); + nameToSymMap = new HashMap<>(); // Line numbers lineNumbers = new BasicLineNumberMapping(); @@ -119,7 +119,7 @@ public void resolve(ResolveListener listener) { // Go through all types in lazyTypeMap and types. // Resolve all LazyTypes. resolveLazyMap(listener); - for (ListIterator iter = types.listIterator(); iter.hasNext(); ) { + for (ListIterator iter = types.listIterator(); iter.hasNext(); ) { BasicType t = (BasicType) iter.next(); BasicType t2 = (BasicType) t.resolveTypes(this, listener); if (t != t2) { @@ -137,10 +137,8 @@ public void resolve(ResolveListener listener) { // Sort blocks in ascending order of starting address (but do not // change ordering among blocks with the same starting address) - Collections.sort(blocks, new Comparator() { - public int compare(Object o1, Object o2) { - BlockSym b1 = (BlockSym) o1; - BlockSym b2 = (BlockSym) o2; + Collections.sort(blocks, new Comparator<>() { + public int compare(BlockSym b1, BlockSym b2) { Address a1 = b1.getAddress(); Address a2 = b2.getAddress(); if (AddressOps.lt(a1, a2)) { return -1; } @@ -157,11 +155,11 @@ public void endConstruction() { Assert.that(state == RESOLVED_STATE, "wrong state"); } // Move all types to type list - for (Iterator iter = lazyTypeMap.values().iterator(); iter.hasNext(); ) { + for (Iterator iter = lazyTypeMap.values().iterator(); iter.hasNext(); ) { types.add(iter.next()); } // Build name-to-type map - nameToTypeMap = new HashMap(); + nameToTypeMap = new HashMap<>(); for (Iterator iter = types.iterator(); iter.hasNext(); ) { Type t = (Type) iter.next(); if (!t.isConst() && !t.isVolatile()) { @@ -337,8 +335,8 @@ public Sym resolveSym(Sym containingSymbol, Sym targetSym, ResolveListener liste } private void resolveLazyMap(ResolveListener listener) { - for (Iterator iter = lazyTypeMap.entrySet().iterator(); iter.hasNext(); ) { - Map.Entry entry = (Map.Entry) iter.next(); + for (Iterator> iter = lazyTypeMap.entrySet().iterator(); iter.hasNext(); ) { + Map.Entry entry = iter.next(); BasicType t = (BasicType) entry.getValue(); BasicType t2 = (BasicType) t.resolveTypes(this, listener); if (t2 != t) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicCompoundType.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicCompoundType.java index 4463a7ec0f9..af7d6ad6a64 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicCompoundType.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicCompoundType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,8 +31,8 @@ public class BasicCompoundType extends BasicType implements CompoundType { private CompoundTypeKind kind; - private List baseClasses; - private List fields; + private List baseClasses; + private List fields; public BasicCompoundType(String name, int size, CompoundTypeKind kind) { this(name, size, kind, 0); @@ -57,7 +57,7 @@ public BaseClass getBaseClass(int i) { public void addBaseClass(BaseClass b) { if (baseClasses == null) { - baseClasses = new ArrayList(); + baseClasses = new ArrayList<>(); } baseClasses.add(b); } @@ -71,7 +71,7 @@ public Field getField(int i) { public void addField(Field f) { if (fields == null) { - fields = new ArrayList(); + fields = new ArrayList<>(); } fields.add(f); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicEnumType.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicEnumType.java index 050ec03c1c9..500d4b68bda 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicEnumType.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicEnumType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ private static class Enum { String getName() { return name; } long getValue() { return value; } } - private List/**/ enums; + private List enums; /** Underlying type of enum must be an integer type (or as yet unresolved) */ @@ -70,7 +70,7 @@ public boolean isUnsigned() { public void addEnum(String name, long val) { if (enums == null) { - enums = new ArrayList(); + enums = new ArrayList<>(); } enums.add(new Enum(name, val)); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicFunctionType.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicFunctionType.java index 9147d188b35..de59375bd9f 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicFunctionType.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicFunctionType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ public class BasicFunctionType extends BasicType implements FunctionType { private Type returnType; - private List argumentTypes; + private List argumentTypes; public BasicFunctionType(String name, int size, Type returnType) { this(name, size, returnType, 0); @@ -51,7 +51,7 @@ public Type getArgumentType(int i) { } public void addArgumentType(Type t) { if (argumentTypes == null) { - argumentTypes = new ArrayList(); + argumentTypes = new ArrayList<>(); } argumentTypes.add(t); } @@ -60,8 +60,8 @@ Type resolveTypes(BasicCDebugInfoDataBase db, ResolveListener listener) { super.resolveTypes(db, listener); returnType = db.resolveType(this, returnType, listener, "resolving function return type"); if (argumentTypes != null) { - for (ListIterator iter = argumentTypes.listIterator(); iter.hasNext(); ) { - iter.set(db.resolveType(this, (Type) iter.next(), listener, "resolving function argument types")); + for (ListIterator iter = argumentTypes.listIterator(); iter.hasNext(); ) { + iter.set(db.resolveType(this, iter.next(), listener, "resolving function argument types")); } } return this; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicLineNumberMapping.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicLineNumberMapping.java index 214494f9d1f..b9d2ac73361 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicLineNumberMapping.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicLineNumberMapping.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ import sun.jvm.hotspot.utilities.AddressOps; public class BasicLineNumberMapping { - private List infoList; + private List infoList; public BasicLineNumberMapping() { } @@ -41,7 +41,7 @@ a very loose approximation (i.e., the end of the given DLL) if recomputeEndPCs() will recompute them if needed. */ public void addLineNumberInfo(BasicLineNumberInfo info) { if (infoList == null) { - infoList = new ArrayList(); + infoList = new ArrayList<>(); } infoList.add(info); } @@ -50,10 +50,8 @@ public void addLineNumberInfo(BasicLineNumberInfo info) { counter. This must be done before any queries are made. */ public void sort() { if (infoList == null) return; - Collections.sort(infoList, new Comparator() { - public int compare(Object o1, Object o2) { - BasicLineNumberInfo l1 = (BasicLineNumberInfo) o1; - BasicLineNumberInfo l2 = (BasicLineNumberInfo) o2; + Collections.sort(infoList, new Comparator<>() { + public int compare(BasicLineNumberInfo l1, BasicLineNumberInfo l2) { Address a1 = l1.getStartPC(); Address a2 = l2.getStartPC(); if (AddressOps.lt(a1, a2)) { return -1; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicType.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicType.java index 01ccb8de4a5..b34ac083087 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicType.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ public abstract class BasicType implements Type, CVAttributes { private int size; private int cvAttributes; // Types keep a list of const/volatile qualified variants of themselves - private List cvVariants; + private List cvVariants; protected BasicType(String name, int size) { this(name, size, 0); @@ -83,8 +83,8 @@ protected BasicType(String name, int size, int cvAttributes) { Type resolveTypes(BasicCDebugInfoDataBase db, ResolveListener listener) { if (cvVariants != null) { - for (ListIterator iter = cvVariants.listIterator(); iter.hasNext(); ) { - iter.set(db.resolveType(this, (BasicType) iter.next(), listener, "resolving const/var variants")); + for (ListIterator iter = cvVariants.listIterator(); iter.hasNext(); ) { + iter.set(db.resolveType(this, iter.next(), listener, "resolving const/var variants")); } } return this; @@ -110,7 +110,7 @@ public String toString() { protected abstract Type createCVVariant(int cvAttributes); protected Type findCVVariant(int cvAttributes) { if (cvVariants != null) { - for (Iterator iter = cvVariants.iterator(); iter.hasNext(); ) { + for (Iterator iter = cvVariants.iterator(); iter.hasNext(); ) { BasicType t = (BasicType) iter.next(); if (t.getCVAttributes() == cvAttributes) return t; } @@ -119,7 +119,7 @@ protected Type findCVVariant(int cvAttributes) { } protected void addCVVariant(Type t) { if (cvVariants == null) { - cvVariants = new ArrayList(); + cvVariants = new ArrayList<>(); } cvVariants.add(t); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/dummy/DummyDebugger.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/dummy/DummyDebugger.java index 627d3a6d3c7..b64e41af076 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/dummy/DummyDebugger.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/dummy/DummyDebugger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public boolean hasProcessList() throws DebuggerException { return false; } - public List getProcessList() throws DebuggerException { + public List getProcessList() throws DebuggerException { return null; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java index e44972f796f..ea062622ed9 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java @@ -49,11 +49,11 @@ class LinuxCDebugger implements CDebugger { this.dbg = dbg; } - public List getThreadList() throws DebuggerException { + public List getThreadList() throws DebuggerException { return dbg.getThreadList(); } - public List/**/ getLoadObjectList() throws DebuggerException { + public List getLoadObjectList() throws DebuggerException { return dbg.getLoadObjectList(); } @@ -65,7 +65,7 @@ public LoadObject loadObjectContainingPC(Address pc) throws DebuggerException { /* Typically we have about ten loaded objects here. So no reason to do sort/binary search here. Linear search gives us acceptable performance.*/ - List objs = getLoadObjectList(); + List objs = getLoadObjectList(); for (int i = 0; i < objs.size(); i++) { LoadObject ob = (LoadObject) objs.get(i); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebugger.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebugger.java index d12532c37f7..f991855e92f 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebugger.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebugger.java @@ -55,8 +55,8 @@ public long readCInteger(long address, long numBytes, boolean isUnsigned public Address findLibPtrByAddress(Address pc); // For LinuxCDebugger - public List getThreadList(); - public List getLoadObjectList(); + public List getThreadList(); + public List getLoadObjectList(); public ClosestSymbol lookup(long address); public String demangle(String sym); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebuggerLocal.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebuggerLocal.java index f1183e5a80b..4b857e51c58 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebuggerLocal.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebuggerLocal.java @@ -43,6 +43,7 @@ import sun.jvm.hotspot.debugger.MachineDescription; import sun.jvm.hotspot.debugger.NotInHeapException; import sun.jvm.hotspot.debugger.OopHandle; +import sun.jvm.hotspot.debugger.ProcessInfo; import sun.jvm.hotspot.debugger.ReadResult; import sun.jvm.hotspot.debugger.ThreadProxy; import sun.jvm.hotspot.debugger.UnalignedAddressException; @@ -77,8 +78,8 @@ public class LinuxDebuggerLocal extends DebuggerBase implements LinuxDebugger { private LinuxCDebugger cdbg; // threadList and loadObjectList are filled by attach0 method - private List threadList; - private List loadObjectList; + private List threadList; + private List loadObjectList; // PID namespace support // It maps the LWPID in the host to the LWPID in the container. @@ -248,7 +249,7 @@ public boolean hasProcessList() throws DebuggerException { } /** From the Debugger interface via JVMDebugger */ - public List getProcessList() throws DebuggerException { + public List getProcessList() throws DebuggerException { throw new DebuggerException("getProcessList not implemented yet"); } @@ -317,8 +318,8 @@ private void fillNSpidMap(Path proc) { /** From the Debugger interface via JVMDebugger */ public synchronized void attach(int processID) throws DebuggerException { checkAttached(); - threadList = new ArrayList(); - loadObjectList = new ArrayList(); + threadList = new ArrayList<>(); + loadObjectList = new ArrayList<>(); Path proc = Paths.get("/proc", Integer.toString(processID)); int NSpid = getNamespacePID(Paths.get(proc.toString(), "status")); @@ -349,8 +350,8 @@ public void doit(LinuxDebuggerLocal debugger) { /** From the Debugger interface via JVMDebugger */ public synchronized void attach(String execName, String coreName) { checkAttached(); - threadList = new ArrayList(); - loadObjectList = new ArrayList(); + threadList = new ArrayList<>(); + loadObjectList = new ArrayList<>(); attach0(execName, coreName); attached = true; isCore = true; @@ -593,13 +594,13 @@ public Address newAddress(long value) { } /** From the LinuxCDebugger interface */ - public List/**/ getThreadList() { + public List getThreadList() { requireAttach(); return threadList; } /** From the LinuxCDebugger interface */ - public List/**/ getLoadObjectList() { + public List getLoadObjectList() { requireAttach(); return loadObjectList; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/ProcCDebugger.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/ProcCDebugger.java index 93c7592afa2..9a6d2dd1aea 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/ProcCDebugger.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/ProcCDebugger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,11 +37,11 @@ class ProcCDebugger implements CDebugger { this.dbg = dbg; } - public List getThreadList() throws DebuggerException { + public List getThreadList() throws DebuggerException { return dbg.getThreadList(); } - public List/**/ getLoadObjectList() throws DebuggerException { + public List getLoadObjectList() throws DebuggerException { return dbg.getLoadObjectList(); } @@ -49,7 +49,7 @@ public LoadObject loadObjectContainingPC(Address pc) throws DebuggerException { if (pc == null) { return null; } - List objs = getLoadObjectList(); + List objs = getLoadObjectList(); Object[] arr = objs.toArray(); // load objects are sorted by base address, do binary search int mid = -1; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/ProcDebugger.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/ProcDebugger.java index 9fbdbe9c33f..01ebcf186af 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/ProcDebugger.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/ProcDebugger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,8 +55,8 @@ public long readCInteger(long address, long numBytes, boolean isUnsigned public Address newAddress(long value) throws DebuggerException; // for ProcCDebugger, ProcCFrame and SharedObject - public List getThreadList() throws DebuggerException; - public List getLoadObjectList() throws DebuggerException; + public List getThreadList() throws DebuggerException; + public List getLoadObjectList() throws DebuggerException; public CFrame topFrameForThread(ThreadProxy thread) throws DebuggerException; public ClosestSymbol lookup(long address) throws DebuggerException; public String demangle(String name); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/ProcDebuggerLocal.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/ProcDebuggerLocal.java index 74e957d94b8..e331b5fdc35 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/ProcDebuggerLocal.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/ProcDebuggerLocal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -134,7 +134,7 @@ public boolean hasProcessList() throws DebuggerException { return false; } - public List getProcessList() throws DebuggerException { + public List getProcessList() throws DebuggerException { throw new DebuggerException("Not yet supported"); } @@ -153,7 +153,7 @@ public synchronized void attach(int processID) throws DebuggerException { (String executableName, String coreFileName) throws DebuggerException { checkAttached(); isCore = true; - topFrameCache = new HashMap(); + topFrameCache = new HashMap<>(); attach0(executableName, coreFileName); attached = true; suspended = true; @@ -439,13 +439,13 @@ public Address newAddress(long value) { } /** From the ProcDebugger interface */ - public synchronized List getThreadList() throws DebuggerException { + public synchronized List getThreadList() throws DebuggerException { requireAttach(); - List res = null; + List res = null; if (isCore && (threadListCache != null)) { res = threadListCache; } else { - res = new ArrayList(); + res = new ArrayList<>(); fillThreadList0(res); if (isCore) { threadListCache = res; @@ -455,7 +455,7 @@ public synchronized List getThreadList() throws DebuggerException { } /** From the ProcDebugger interface */ - public synchronized List getLoadObjectList() throws DebuggerException { + public synchronized List getLoadObjectList() throws DebuggerException { requireAttach(); if (!suspended) { throw new DebuggerException("Process not suspended"); @@ -505,16 +505,16 @@ public String demangle(String name) { // private void updateLoadObjectCache() { - List res = new ArrayList(); - nameToDsoMap = new HashMap(); + List res = new ArrayList<>(); + nameToDsoMap = new HashMap<>(); fillLoadObjectList0(res); loadObjectCache = sortLoadObjects(res); } // sort load objects by base address - private static List sortLoadObjects(List in) { + private static List sortLoadObjects(List in) { // sort the list by base address - Object[] arr = in.toArray(); + LoadObject[] arr = in.toArray(new LoadObject[0]); Arrays.sort(arr, loadObjectComparator); return Arrays.asList(arr); } @@ -614,7 +614,7 @@ private void resetNativePointers() { // threads, stacks private native long[] getThreadIntegerRegisterSet0(long tid) throws DebuggerException; - private native void fillThreadList0(List l) throws DebuggerException; + private native void fillThreadList0(List l) throws DebuggerException; // fills stack frame list given reg set of the top frame and top frame private native ProcCFrame fillCFrameList0(long[] regs) throws DebuggerException; @@ -629,7 +629,7 @@ private ProcCFrame createSenderFrame(ProcCFrame f, long pc, long fp) { } // shared objects - private native void fillLoadObjectList0(List l) throws DebuggerException; + private native void fillLoadObjectList0(List l) throws DebuggerException; // helper called by fillLoadObjectList0 private LoadObject createLoadObject(String fileName, long textsize, long base) { @@ -689,10 +689,10 @@ private ClosestSymbol createClosestSymbol(String name, long offset) { // Symbol lookup support // This is a map of library names to DSOs - private Map nameToDsoMap; // Map + private Map nameToDsoMap; // C/C++ debugging support - private List/**/ loadObjects; + private List loadObjects; private CDebugger cdbg; // ProcessControl support @@ -722,7 +722,7 @@ private ClosestSymbol createClosestSymbol(String name, long offset) { // for core files, we cache load object list, thread list, top frames etc. // for processes we cache load object list and sync. it during suspend. - private List threadListCache; - private List loadObjectCache; - private Map topFrameCache; // Map + private List threadListCache; + private List loadObjectCache; + private Map topFrameCache; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java index b6253f6d63d..0387672f85f 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -139,7 +139,7 @@ public boolean hasProcessList() throws DebuggerException { } /** Unimplemented in this class (remote remoteDebugger should already be attached) */ - public List getProcessList() throws DebuggerException { + public List getProcessList() throws DebuggerException { throw new DebuggerException("Should not be called on RemoteDebuggerClient"); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/win32/coff/COFFFileParser.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/win32/coff/COFFFileParser.java index d29a626598b..ad9c58fdd0e 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/win32/coff/COFFFileParser.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/win32/coff/COFFFileParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1427,14 +1427,14 @@ class DebugVC50SSSegNameImpl extends DebugVC50SubsectionImpl implements DebugVC5 names = new MemoizedObject() { public Object computeValue() { int i = 0; - List data = new ArrayList(); + List data = new ArrayList<>(); while (i < size) { String s = readCString(); data.add(s); i += s.length(); } String[] res = new String[data.size()]; - res = (String[]) data.toArray(res); + res = data.toArray(res); return res; } }; @@ -3775,10 +3775,8 @@ String get(int i) { /** This version takes an absolute offset in the file */ String getAtOffset(int offset) { int i = Arrays.binarySearch(strings, new COFFString(null, offset), - new Comparator() { - public int compare(Object o1, Object o2) { - COFFString s1 = (COFFString) o1; - COFFString s2 = (COFFString) o2; + new Comparator<>() { + public int compare(COFFString s1, COFFString s2) { if (s1.offset == s2.offset) { return 0; } else if (s1.offset < s2.offset) { @@ -3905,14 +3903,14 @@ float readFloat() throws COFFException { } String readCString() throws COFFException { - List data = new ArrayList(); + List data = new ArrayList<>(); byte b = 0; while ((b = readByte()) != 0) { - data.add(new Byte(b)); + data.add(b); } byte[] bytes = new byte[data.size()]; for (int i = 0; i < data.size(); i++) { - bytes[i] = ((Byte) data.get(i)).byteValue(); + bytes[i] = (data.get(i)).byteValue(); } try { return new String(bytes, US_ASCII); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugInfoBuilder.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugInfoBuilder.java index 387b7517fdd..445bb268d64 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugInfoBuilder.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugInfoBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,13 +48,13 @@ class WindbgCDebugInfoBuilder private DebugVC50SSSegMap segMap; // Canonicalization of primitive types - private Map primIndexToTypeMap; + private Map primIndexToTypeMap; // Global unnamed enumeration // (FIXME: must figure out how to handle nested type descriptions) private BasicEnumType unnamedEnum; - private Stack blockStack; + private Stack blockStack; private int endsToSkip; private static final int POINTER_SIZE = 4; @@ -72,8 +72,8 @@ CDebugInfoDataBase buildDataBase(String dllName, Address base) { segMap = getSegMap(); - primIndexToTypeMap = new HashMap(); - blockStack = new Stack(); + primIndexToTypeMap = new HashMap<>(); + blockStack = new Stack<>(); endsToSkip = 0; db = new BasicCDebugInfoDataBase(); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java index ce219b986af..5d6b58fa085 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,11 +44,11 @@ class WindbgCDebugger implements CDebugger { this.dbg = dbg; } - public List getThreadList() throws DebuggerException { + public List getThreadList() throws DebuggerException { return dbg.getThreadList(); } - public List/**/ getLoadObjectList() throws DebuggerException{ + public List getLoadObjectList() throws DebuggerException{ return dbg.getLoadObjectList(); } @@ -58,7 +58,7 @@ public LoadObject loadObjectContainingPC(Address pc) throws DebuggerException { if (pc == null) { return null; } - List objs = getLoadObjectList(); + List objs = getLoadObjectList(); for (Iterator iter = objs.iterator(); iter.hasNext(); ) { LoadObject obj = (LoadObject) iter.next(); if (AddressOps.lte(obj.getBase(), pc) && (pc.minus(obj.getBase()) < obj.getSize())) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebugger.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebugger.java index 81825c67d06..e32f8d92583 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebugger.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebugger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,11 +60,11 @@ public long readCInteger(long address, long numBytes, boolean isUnsigned public long getThreadIdFromSysId(long sysId) throws DebuggerException; // Support for the CDebugger interface. Retrieves the thread list of // the target process as a List of ThreadProxy objects. - public List/**/ getThreadList() throws DebuggerException; + public List getThreadList() throws DebuggerException; // Support for the CDebugger interface. Retrieves a List of the // loadobjects in the target process. - public List/**/ getLoadObjectList() throws DebuggerException; + public List getLoadObjectList() throws DebuggerException; // NOTE: this interface implicitly contains the following methods: // From the Debugger interface via JVMDebugger diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java index 4536f215485..ff3b949d602 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,15 +59,15 @@ public class WindbgDebuggerLocal extends DebuggerBase implements WindbgDebugger // Symbol lookup support // This is a map of library names to DLLs - private Map nameToDllMap; + private Map nameToDllMap; // C/C++ debugging support - private List/**/ loadObjects; + private List loadObjects; private CDebugger cdbg; // thread access - private Map threadIntegerRegisterSet; - private List threadList; + private Map threadIntegerRegisterSet; + private List threadList; // windbg native interface pointers @@ -137,7 +137,7 @@ public boolean hasProcessList() throws DebuggerException { } /** From the Debugger interface via JVMDebugger */ - public List getProcessList() throws DebuggerException { + public List getProcessList() throws DebuggerException { return null; } @@ -158,7 +158,7 @@ public synchronized void attach(String executableName, String coreFileName) thro isCore = true; } - public List getLoadObjectList() { + public List getLoadObjectList() { requireAttach(); return loadObjects; } @@ -354,7 +354,7 @@ public synchronized long[] getThreadIntegerRegisterSet(long threadId) return (long[]) threadIntegerRegisterSet.get(new Long(threadId)); } - public synchronized List getThreadList() throws DebuggerException { + public synchronized List getThreadList() throws DebuggerException { requireAttach(); return threadList; } @@ -438,10 +438,10 @@ private void requireAttach() { private void attachInit() { checkAttached(); - loadObjects = new ArrayList(); - nameToDllMap = new HashMap(); - threadIntegerRegisterSet = new HashMap(); - threadList = new ArrayList(); + loadObjects = new ArrayList<>(); + nameToDllMap = new HashMap<>(); + threadIntegerRegisterSet = new HashMap<>(); + threadList = new ArrayList<>(); } private void resetNativePointers() { @@ -539,7 +539,7 @@ public void writeBytesToProcess(long address, long numBytes, byte[] data) String dbgengPath = null; String dbghelpPath = null; String saprocPath = null; - List searchList = new ArrayList(); + List searchList = new ArrayList<>(); boolean loadLibraryDEBUG = System.getProperty("sun.jvm.hotspot.loadLibrary.DEBUG") != null; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/interpreter/BytecodeDisassembler.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/interpreter/BytecodeDisassembler.java index 82b6fe34961..dcadb5f9988 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/interpreter/BytecodeDisassembler.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/interpreter/BytecodeDisassembler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ public class BytecodeDisassembler { private Method method; - private static Map bytecode2Class = new HashMap(); // Map + private static Map bytecode2Class = new HashMap<>(); private static void addBytecodeClass(int bytecode, Class clazz) { bytecode2Class.put(new Integer(bytecode), clazz); @@ -116,7 +116,7 @@ public void decode(BytecodeVisitor visitor) { // look for special Bytecode class int bci = stream.bci(); int hotspotcode = method.getBytecodeOrBPAt(bci); - Class clazz = getBytecodeClass(javacode); + Class clazz = getBytecodeClass(javacode); if (clazz == null) { // check for fast_(i|a)_access_0 clazz = getBytecodeClass(hotspotcode); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/interpreter/OopMapForCacheEntry.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/interpreter/OopMapForCacheEntry.java index dfe3b3aeba6..1a36aeb7106 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/interpreter/OopMapForCacheEntry.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/interpreter/OopMapForCacheEntry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,7 +65,7 @@ public void fillStackmapForOpcodes(BytecodeStream bcs, } } - public void fillInitVars(List/**/ initVars) { + public void fillInitVars(List initVars) { // Do nothing } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Dictionary.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Dictionary.java index 5957f65bcc9..54da4cfc956 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Dictionary.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Dictionary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ public Dictionary(Address addr) { // this is overriden here so that Hashtable.bucket will return // object of DictionaryEntry.class - protected Class getHashtableEntryClass() { + protected Class getHashtableEntryClass() { return DictionaryEntry.class; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java index 391bdf782cb..4f357dbb715 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ import sun.jvm.hotspot.oops.Oop; import sun.jvm.hotspot.runtime.BasicType; import sun.jvm.hotspot.runtime.VM; +import sun.jvm.hotspot.runtime.VMObject; import sun.jvm.hotspot.runtime.VirtualConstructor; import sun.jvm.hotspot.types.AddressField; import sun.jvm.hotspot.types.CIntegerField; @@ -70,7 +71,7 @@ private static boolean typeExists(TypeDataBase db, String type) { return true; } - private static void addHeapTypeIfInDB(TypeDataBase db, Class heapClass) { + private static void addHeapTypeIfInDB(TypeDataBase db, Class heapClass) { String heapName = heapClass.getSimpleName(); if (typeExists(db, heapName)) { heapConstructor.addMapping(heapName, heapClass); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CellTypeStateList.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CellTypeStateList.java index f5ae279fb82..19ebdd1a830 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CellTypeStateList.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CellTypeStateList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ /** Auxiliary class for GenerateOopMap */ public class CellTypeStateList { public CellTypeStateList(int size) { - list = new ArrayList(size); + list = new ArrayList<>(size); for (int i = 0; i < size; i++) { list.add(i, CellTypeState.makeBottom()); } @@ -40,7 +40,7 @@ public int size() { } public CellTypeState get(int i) { - return (CellTypeState) list.get(i); + return list.get(i); } public CellTypeStateList subList(int fromIndex, int toIndex) { @@ -48,8 +48,8 @@ public CellTypeStateList subList(int fromIndex, int toIndex) { } //---------------------------------------------------------------------- - private List list; - private CellTypeStateList(List list) { + private List list; + private CellTypeStateList(List list) { this.list = list; } } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstantPool.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstantPool.java index 1e1adaf6aa7..c7988a44cb4 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstantPool.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstantPool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -539,7 +539,7 @@ public void iterateFields(MetadataVisitor visitor) { public void writeBytes(OutputStream os) throws IOException { // Map between any modified UTF-8 and it's constant pool index. - Map utf8ToIndex = new HashMap(); + Map utf8ToIndex = new HashMap<>(); DataOutputStream dos = new DataOutputStream(os); U1Array tags = getTags(); int len = (int)getLength(); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/GenerateOopMap.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/GenerateOopMap.java index 5ada7683219..0fe3d25f838 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/GenerateOopMap.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/GenerateOopMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -168,19 +168,19 @@ int computeForReturntype(CellTypeStateList effect) { static class RetTableEntry { private static int _init_nof_jsrs; // Default size of jsrs list private int _target_bci; // Target PC address of jump (bytecode index) - private List/**/ _jsrs; // List of return addresses (bytecode index) + private List _jsrs; // List of return addresses (bytecode index) private RetTableEntry _next; // Link to next entry RetTableEntry(int target, RetTableEntry next) { _target_bci = target; - _jsrs = new ArrayList(_init_nof_jsrs); + _jsrs = new ArrayList<>(_init_nof_jsrs); _next = next; } // Query int targetBci() { return _target_bci; } int nofJsrs() { return _jsrs.size(); } - int jsrs(int i) { return ((Integer) _jsrs.get(i)).intValue(); } + int jsrs(int i) { return _jsrs.get(i).intValue(); } // Update entry void addJsr (int return_bci) { _jsrs.add(new Integer(return_bci)); } @@ -1926,11 +1926,11 @@ void reportResult () { } // Initvars - List/**/ _init_vars; + List _init_vars; void initializeVars () { for (int k = 0; k < _init_vars.size(); k++) - _state.get(((Integer) _init_vars.get(k)).intValue()).set(CellTypeState.makeSlotRef(k)); + _state.get((_init_vars.get(k)).intValue()).set(CellTypeState.makeSlotRef(k)); } void addToRefInitSet (int localNo) { @@ -2155,7 +2155,7 @@ public void computeMap() { _max_stack = (int) method().getMaxStack(); _has_exceptions = (method().hasExceptionTable()); _nof_refval_conflicts = 0; - _init_vars = new ArrayList(5); // There are seldom more than 5 init_vars + _init_vars = new ArrayList<>(5); // There are seldom more than 5 init_vars _report_result = false; _report_result_for_send = false; _report_for_exit_bci = -1; @@ -2314,5 +2314,5 @@ public void fillStackmapForOpcodes (BytecodeStream bcs, CellTypeStateList vars, CellTypeStateList stack, int stackTop) { throw new RuntimeException("ShouldNotReachHere"); } - public void fillInitVars (List/**/ init_vars) { throw new RuntimeException("ShouldNotReachHere"); } + public void fillInitVars (List init_vars) { throw new RuntimeException("ShouldNotReachHere"); } } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java index 9c504b2765e..11b16f8a8a8 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -682,14 +682,14 @@ public static class StaticField { public Field[] getStaticFields() { U2Array fields = getFields(); int length = getJavaFieldsCount(); - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); for (int index = 0; index < length; index++) { Field f = newField(index); if (f.isStatic()) { result.add(f); } } - return (Field[])result.toArray(new Field[result.size()]); + return result.toArray(new Field[result.size()]); } public void iterateNonStaticFields(OopVisitor visitor, Oop obj) { @@ -784,11 +784,11 @@ public Field getFieldByIndex(int fieldIndex) { Inherited fields are not included. Return an empty list if there are no fields declared in this class. Only designed for use in a debugging system. */ - public List getImmediateFields() { + public List getImmediateFields() { // A list of Fields for each field declared in this class/interface, // not including inherited fields. int length = getJavaFieldsCount(); - List immediateFields = new ArrayList(length); + List immediateFields = new ArrayList<>(length); for (int index = 0; index < length; index++) { immediateFields.add(getFieldByIndex(index)); } @@ -802,10 +802,10 @@ public List getImmediateFields() { the same name. Return an empty list if there are no fields. Only designed for use in a debugging system. */ - public List getAllFields() { + public List getAllFields() { // Contains a Field for each field in this class, including immediate // fields and inherited fields. - List allFields = getImmediateFields(); + List allFields = getImmediateFields(); // transitiveInterfaces contains all interfaces implemented // by this class and its superclass chain with no duplicates. @@ -838,13 +838,13 @@ public List getAllFields() { Return an empty list if there are none, or if this isn't a class/ interface. */ - public List getImmediateMethods() { + public List getImmediateMethods() { // Contains a Method for each method declared in this class/interface // not including inherited methods. MethodArray methods = getMethods(); int length = methods.length(); - Object[] tmp = new Object[length]; + Method[] tmp = new Method[length]; IntArray methodOrdering = getMethodOrdering(); if (methodOrdering.length() != length) { @@ -865,13 +865,13 @@ public List getImmediateMethods() { /** Return a List containing an SA InstanceKlass for each interface named in this class's 'implements' clause. */ - public List getDirectImplementedInterfaces() { + public List getDirectImplementedInterfaces() { // Contains an InstanceKlass for each interface in this classes // 'implements' clause. KlassArray interfaces = getLocalInterfaces(); int length = interfaces.length(); - List directImplementedInterfaces = new ArrayList(length); + List directImplementedInterfaces = new ArrayList<>(length); for (int index = 0; index < length; index ++) { directImplementedInterfaces.add(interfaces.getAt(index)); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java index 94fc713abd1..c2c1f7c7439 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -133,7 +133,7 @@ public void iterateObjectsOfKlass(HeapVisitor visitor, final Klass k) { extremely low level (stepping word-by-word) to provide the ability to do very low-level debugging */ public void iterateRaw(RawHeapVisitor visitor) { - List liveRegions = collectLiveRegions(); + List
liveRegions = collectLiveRegions(); // Summarize size long totalSize = 0; @@ -223,7 +223,7 @@ public boolean canInclude(Oop obj) { }); } - private void iterateLiveRegions(List liveRegions, HeapVisitor visitor, ObjectFilter of) { + private void iterateLiveRegions(List
liveRegions, HeapVisitor visitor, ObjectFilter of) { // Summarize size long totalSize = 0; for (int i = 0; i < liveRegions.size(); i += 2) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHistogram.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHistogram.java index 173e36027ee..c0bbaef504d 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHistogram.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHistogram.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,16 +29,16 @@ public class ObjectHistogram implements HeapVisitor { - public ObjectHistogram() { map = new HashMap(); } + public ObjectHistogram() { map = new HashMap<>(); } - private HashMap map; + private HashMap map; public void prologue(long size) {} public boolean doObj(Oop obj) { Klass klass = obj.getKlass(); if (!map.containsKey(klass)) map.put(klass, new ObjectHistogramElement(klass)); - ((ObjectHistogramElement) map.get(klass)).updateWith(obj); + map.get(klass).updateWith(obj); return false; } @@ -46,13 +46,13 @@ public void epilogue() {} /** Call this after the iteration is complete to obtain the ObjectHistogramElements in descending order of total heap size - consumed in the form of a List. */ - public List getElements() { - List list = new ArrayList(); + consumed. */ + public List getElements() { + List list = new ArrayList<>(); list.addAll(map.values()); - Collections.sort(list, new Comparator() { - public int compare(Object o1, Object o2) { - return ((ObjectHistogramElement) o1).compare((ObjectHistogramElement) o2); + Collections.sort(list, new Comparator<>() { + public int compare(ObjectHistogramElement o1, ObjectHistogramElement o2) { + return o1.compare(o2); } }); return list; @@ -61,14 +61,14 @@ public int compare(Object o1, Object o2) { public void print() { printOn(System.out); } public void printOn(PrintStream tty) { - List list = getElements(); + List list = getElements(); ObjectHistogramElement.titleOn(tty); - Iterator iterator = list.listIterator(); + Iterator iterator = list.listIterator(); int num=0; int totalCount=0; int totalSize=0; while (iterator.hasNext()) { - ObjectHistogramElement el = (ObjectHistogramElement) iterator.next(); + ObjectHistogramElement el = iterator.next(); num++; totalCount+=el.getCount(); totalSize+=el.getSize(); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallTypeData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallTypeData.java index d7ad5d993ec..483d0d54ee2 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallTypeData.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallTypeData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ // A VirtualCallTypeData is used to access profiling information about // a virtual call for which we collect type information about // arguments and return value. -public class VirtualCallTypeData extends VirtualCallData implements CallTypeDataInterface { +public class VirtualCallTypeData extends VirtualCallData implements CallTypeDataInterface { final TypeStackSlotEntries args; final ReturnTypeEntry ret; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/opto/InlineTree.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/opto/InlineTree.java index 53f024183a8..1607b58cc71 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/opto/InlineTree.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/opto/InlineTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,7 +55,7 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeExc private static AddressField callerTreeField; private static AddressField subtreesField; - private static StaticBaseConstructor inlineTreeConstructor = new StaticBaseConstructor(InlineTree.class); + private static StaticBaseConstructor inlineTreeConstructor = new StaticBaseConstructor<>(InlineTree.class); public InlineTree(Address addr) { super(addr); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/opto/Node.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/opto/Node.java index a4f56d5da36..7cab51ea9d9 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/opto/Node.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/opto/Node.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeExc nodeType = db.lookupType("Node"); - virtualConstructor = new VirtualBaseConstructor(db, nodeType, "sun.jvm.hotspot.opto", Node.class); + virtualConstructor = new VirtualBaseConstructor<>(db, nodeType, "sun.jvm.hotspot.opto", Node.class); } private static CIntField outmaxField; @@ -64,11 +64,11 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeExc private static AddressField outField; private static AddressField inField; - private static VirtualBaseConstructor virtualConstructor; + private static VirtualBaseConstructor virtualConstructor; private static Type nodeType; - static HashMap nodes = new HashMap(); + static HashMap nodes = new HashMap<>(); static HashMap constructors = new HashMap(); @@ -78,7 +78,7 @@ static abstract class Instantiator { static public Node create(Address addr) { if (addr == null) return null; - Node result = (Node)nodes.get(addr); + Node result = nodes.get(addr); if (result == null) { result = (Node)virtualConstructor.instantiateWrapperFor(addr); nodes.put(addr, result); @@ -133,9 +133,9 @@ public Node in(int i) { return _in[i]; } - public ArrayList collect(int d, boolean onlyCtrl) { + public ArrayList collect(int d, boolean onlyCtrl) { int depth = Math.abs(d); - ArrayList nstack = new ArrayList(); + ArrayList nstack = new ArrayList<>(); BitSet set = new BitSet(); nstack.add(this); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java index 8e9f67a2cd4..5d732032407 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -95,7 +95,7 @@ public Method getMethod() { public StackValueCollection getLocals() { if (getScope() == null) return new StackValueCollection(); - List scvList = getScope().getLocals(); + List scvList = getScope().getLocals(); if (scvList == null) return new StackValueCollection(); @@ -104,7 +104,7 @@ public StackValueCollection getLocals() { int length = scvList.size(); StackValueCollection result = new StackValueCollection(length); for( int i = 0; i < length; i++ ) - result.add( createStackValue((ScopeValue) scvList.get(i)) ); + result.add( createStackValue(scvList.get(i)) ); return result; } @@ -112,7 +112,7 @@ public StackValueCollection getLocals() { public StackValueCollection getExpressions() { if (getScope() == null) return new StackValueCollection(); - List scvList = getScope().getExpressions(); + List scvList = getScope().getExpressions(); if (scvList == null) return new StackValueCollection(); @@ -121,23 +121,22 @@ public StackValueCollection getExpressions() { int length = scvList.size(); StackValueCollection result = new StackValueCollection(length); for( int i = 0; i < length; i++ ) - result.add( createStackValue((ScopeValue) scvList.get(i)) ); + result.add( createStackValue(scvList.get(i)) ); return result; } - /** Returns List */ public List getMonitors() { if (getScope() == null) { return new ArrayList<>(); } - List monitors = getScope().getMonitors(); + List monitors = getScope().getMonitors(); if (monitors == null) { return new ArrayList<>(); } List result = new ArrayList<>(monitors.size()); for (int i = 0; i < monitors.size(); i++) { - MonitorValue mv = (MonitorValue) monitors.get(i); + MonitorValue mv = monitors.get(i); ScopeValue ov = mv.owner(); StackValue ownerSV = createStackValue(ov); // it is an oop if (ov.isObject()) { // The owner object was scalar replaced diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ConcurrentLocksPrinter.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ConcurrentLocksPrinter.java index cdeabf2cb97..ba22ab6fa5d 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ConcurrentLocksPrinter.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ConcurrentLocksPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,20 +30,20 @@ import sun.jvm.hotspot.oops.*; public class ConcurrentLocksPrinter { - private Map locksMap = new HashMap(); // > + private Map> locksMap = new HashMap<>(); public ConcurrentLocksPrinter() { fillLocks(); } public void print(JavaThread jthread, PrintStream tty) { - List locks = (List) locksMap.get(jthread); + List locks = locksMap.get(jthread); tty.println("Locked ownable synchronizers:"); if (locks == null || locks.isEmpty()) { tty.println(" - None"); } else { - for (Iterator itr = locks.iterator(); itr.hasNext();) { - Oop oop = (Oop) itr.next(); + for (Iterator itr = locks.iterator(); itr.hasNext();) { + Oop oop = itr.next(); tty.println(" - <" + oop.getHandle() + ">, (a " + oop.getKlass().getName().asString() + ")"); } @@ -71,9 +71,9 @@ private void fillLocks() { public boolean doObj(Oop oop) { JavaThread thread = getOwnerThread(oop); if (thread != null) { - List locks = (List) locksMap.get(thread); + List locks = locksMap.get(thread); if (locks == null) { - locks = new LinkedList(); + locks = new LinkedList<>(); locksMap.put(thread, locks); } locks.add(oop); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/DeadlockDetector.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/DeadlockDetector.java index 68f7ac26f1f..07b4933ad9b 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/DeadlockDetector.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/DeadlockDetector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -142,10 +142,10 @@ public static void print(PrintStream tty, boolean concurrentLocks) { //-- Internals only below this point private static Threads threads; private static ObjectHeap heap; - private static HashMap threadTable; + private static HashMap threadTable; private static void createThreadTable() { - threadTable = new HashMap(); + threadTable = new HashMap<>(); Threads threads = VM.getVM().getThreads(); for (int i = 0; i < threads.getNumberOfThreads(); i++) { JavaThread cur = threads.getJavaThreadAt(i); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/StackValueCollection.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/StackValueCollection.java index 39b12e2489a..ce7a1e5057a 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/StackValueCollection.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/StackValueCollection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,10 +30,10 @@ import sun.jvm.hotspot.types.*; public class StackValueCollection { - private List list; + private List list; - public StackValueCollection() { list = new ArrayList(); } - public StackValueCollection(int length) { list = new ArrayList(length); } + public StackValueCollection() { list = new ArrayList<>(); } + public StackValueCollection(int length) { list = new ArrayList<>(length); } public void add(StackValue val) { list.add(val); } public int size() { return list.size(); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java index b823561617d..a22157eb7ea 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -235,8 +235,8 @@ public JavaThread owningThreadFromMonitor(ObjectMonitor monitor) { // refer to Threads::get_pending_threads // Get list of Java threads that are waiting to enter the specified monitor. - public List getPendingThreads(ObjectMonitor monitor) { - List pendingThreads = new ArrayList(); + public List getPendingThreads(ObjectMonitor monitor) { + List pendingThreads = new ArrayList<>(); for (int i = 0; i < getNumberOfThreads(); i++) { JavaThread thread = getJavaThreadAt(i); if (thread.isCompilerThread() || thread.isCodeCacheSweeperThread()) { @@ -251,8 +251,8 @@ public List getPendingThreads(ObjectMonitor monitor) { } // Get list of Java threads that have called Object.wait on the specified monitor. - public List getWaitingThreads(ObjectMonitor monitor) { - List pendingThreads = new ArrayList(); + public List getWaitingThreads(ObjectMonitor monitor) { + List pendingThreads = new ArrayList<>(); for (int i = 0; i < getNumberOfThreads(); i++) { JavaThread thread = getJavaThreadAt(i); ObjectMonitor waiting = thread.getCurrentWaitingMonitor(); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java index d097b1e4332..f187a2c150a 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,9 +67,9 @@ be notified whenever the VM is initialized (or re-initialized). To public class VM { private static VM soleInstance; - private static List vmInitializedObservers = new ArrayList(); - private List vmResumedObservers = new ArrayList(); - private List vmSuspendedObservers = new ArrayList(); + private static List vmInitializedObservers = new ArrayList<>(); + private List vmResumedObservers = new ArrayList<>(); + private List vmSuspendedObservers = new ArrayList<>(); private TypeDataBase db; private boolean isBigEndian; /** This is only present if in a debugging system */ @@ -134,7 +134,7 @@ public class VM { private String vmInternalInfo; private Flag[] commandLineFlags; - private Map flagsMap; + private Map flagsMap; private static Type intType; private static Type uintType; @@ -998,7 +998,7 @@ public Flag[] getCommandLineFlags() { public Flag getCommandLineFlag(String name) { if (flagsMap == null) { - flagsMap = new HashMap(); + flagsMap = new HashMap<>(); Flag[] flags = getCommandLineFlags(); for (int i = 0; i < flags.length; i++) { flagsMap.put(flags[i].getName(), flags[i]); @@ -1035,10 +1035,8 @@ private void readCommandLineFlags() { } // sort flags by name - Arrays.sort(commandLineFlags, new Comparator() { - public int compare(Object o1, Object o2) { - Flag f1 = (Flag) o1; - Flag f2 = (Flag) o2; + Arrays.sort(commandLineFlags, new Comparator<>() { + public int compare(Flag f1, Flag f2) { return f1.getName().compareTo(f2.getName()); } }); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VirtualBaseConstructor.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VirtualBaseConstructor.java index bc24fa77d8d..1252c422a50 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VirtualBaseConstructor.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VirtualBaseConstructor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,13 +38,13 @@ public class VirtualBaseConstructor extends InstanceConstructor { private TypeDataBase db; - private HashMap map; // Map + private Map> map; private Type baseType; private Class unknownTypeHandler; public VirtualBaseConstructor(TypeDataBase db, Type baseType, String packageName, Class unknownTypeHandler) { this.db = (HotSpotTypeDataBase)db; - map = new HashMap(); + map = new HashMap<>(); this.baseType = baseType; this.unknownTypeHandler = unknownTypeHandler; if (packageName != null) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java index 41b90f0a94e..c3a42dad828 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,7 +71,7 @@ private static class ClassData { private static class LoaderData { long numClasses; long classSize; - List classDetail = new ArrayList(); // List + List classDetail = new ArrayList<>(); } public void run() { @@ -81,7 +81,7 @@ public void run() { private void printClassLoaderStatistics() { final PrintStream out = System.out; final PrintStream err = System.err; - final Map loaderMap = new HashMap(); + final Map loaderMap = new HashMap<>(); // loader data for bootstrap class loader final LoaderData bootstrapLoaderData = new LoaderData(); if (verbose) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java index 3f5c55a46d6..354cc4cf777 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -106,7 +106,7 @@ public void doOop(OopField field, boolean isVMField) { OopField nextField = (OopField) k.findField("next", "Ljava/lang/ref/Reference;"); - HashMap map = new HashMap(); + HashMap map = new HashMap<>(); for (;;) { Oop referent = referentField.getValue(head); @@ -114,7 +114,7 @@ public void doOop(OopField field, boolean isVMField) { if (!map.containsKey(klass)) { map.put(klass, new ObjectHistogramElement(klass)); } - ((ObjectHistogramElement)map.get(klass)).updateWith(referent); + map.get(klass).updateWith(referent); Oop next = nextField.getValue(head); if (next == null || next.equals(head)) break; @@ -124,11 +124,11 @@ public void doOop(OopField field, boolean isVMField) { /* * Sort results - decending order by total size */ - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); list.addAll(map.values()); - Collections.sort(list, new Comparator() { - public int compare(Object o1, Object o2) { - return ((ObjectHistogramElement)o1).compare((ObjectHistogramElement)o2); + Collections.sort(list, new Comparator<>() { + public int compare(ObjectHistogramElement o1, ObjectHistogramElement o2) { + return o1.compare(o2); } }); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java index 7fec70f3200..12697f3719d 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ public String getName() { public void run() { CollectedHeap heap = VM.getVM().getUniverse().heap(); VM.Flag[] flags = VM.getVM().getCommandLineFlags(); - Map flagMap = new HashMap(); + Map flagMap = new HashMap<>(); if (flags == null) { System.out.println("WARNING: command line flags are not available"); } else { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java index 1670e812d78..d6b8eb6a0fa 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java @@ -61,9 +61,9 @@ public void run(PrintStream out, Debugger dbg) { CDebugger cdbg = dbg.getCDebugger(); if (cdbg != null) { - List l = cdbg.getLoadObjectList(); - for (Iterator itr = l.iterator() ; itr.hasNext();) { - LoadObject lo = (LoadObject) itr.next(); + List l = cdbg.getLoadObjectList(); + for (Iterator itr = l.iterator() ; itr.hasNext();) { + LoadObject lo = itr.next(); out.print(lo.getBase() + "\t"); out.print(lo.getSize()/1024 + "K\t"); out.println(lo.getName()); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java index ecc3071bce1..b0c79289742 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java @@ -79,10 +79,10 @@ public void run(PrintStream out, Debugger dbg) { out.println("can't print deadlock information: " + exp.getMessage()); } - List l = cdbg.getThreadList(); + List l = cdbg.getThreadList(); final boolean cdbgCanDemangle = cdbg.canDemangle(); - for (Iterator itr = l.iterator() ; itr.hasNext();) { - ThreadProxy th = (ThreadProxy) itr.next(); + for (Iterator itr = l.iterator() ; itr.hasNext();) { + ThreadProxy th = itr.next(); try { CFrame f = cdbg.topFrameForThread(th); out.print("----------------- "); @@ -199,20 +199,20 @@ public static void main(String[] args) throws Exception { } // -- Internals only below this point - private Map jframeCache; // Map - private Map proxyToThread; // Map + private Map jframeCache; + private Map proxyToThread; private PrintStream out; private boolean verbose; private boolean concurrentLocks; private void initJFrameCache() { // cache frames for subsequent reference - jframeCache = new HashMap(); - proxyToThread = new HashMap(); + jframeCache = new HashMap<>(); + proxyToThread = new HashMap<>(); Threads threads = VM.getVM().getThreads(); for (int i = 0; i < threads.getNumberOfThreads(); i++) { JavaThread cur = threads.getJavaThreadAt(i); - List tmp = new ArrayList(10); + List tmp = new ArrayList<>(10); try { for (JavaVFrame vf = cur.getLastJavaVFrameDbg(); vf != null; vf = vf.javaSender()) { tmp.add(vf); @@ -239,7 +239,7 @@ private String[] getJavaNames(ThreadProxy th, Address fp) { } JavaVFrame[] jvframes = (JavaVFrame[]) jframeCache.get(th); if (jvframes == null) return null; // not a java thread - List names = new ArrayList(10); + List names = new ArrayList<>(10); for (int fCount = 0; fCount < jvframes.length; fCount++) { JavaVFrame vf = jvframes[fCount]; Frame f = vf.getFrame(); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/ByteCodeRewriter.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/ByteCodeRewriter.java index 0c5202f9c5f..88b15695cf3 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/ByteCodeRewriter.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/ByteCodeRewriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,9 +47,9 @@ public class ByteCodeRewriter public static final boolean DEBUG; static { - String debug = (String) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + String debug = AccessController.doPrivileged( + new PrivilegedAction<>() { + public String run() { return System.getProperty("sun.jvm.hotspot.tools.jcore.ByteCodeRewriter.DEBUG"); } } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/ClassDump.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/ClassDump.java index e47816a5c66..2cdbd71b414 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/ClassDump.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/ClassDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,7 +82,7 @@ public void run() { String filterClassName = System.getProperty("sun.jvm.hotspot.tools.jcore.filter", "sun.jvm.hotspot.tools.jcore.PackageNameFilter"); try { - Class filterClass = Class.forName(filterClassName); + Class filterClass = Class.forName(filterClassName); if (pkgList == null) { classFilter = (ClassFilter) filterClass.newInstance(); } else { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/PackageNameFilter.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/PackageNameFilter.java index e0312ff5a4d..a2156d02bc6 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/PackageNameFilter.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/PackageNameFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ public class PackageNameFilter implements ClassFilter { - public Object[] pkgList; + public String[] pkgList; public PackageNameFilter() { // give comma separated list of package names to include @@ -39,11 +39,11 @@ public PackageNameFilter() { public PackageNameFilter(String pattern) { try { StringTokenizer st = new StringTokenizer(pattern, ","); - List l = new LinkedList(); + List l = new LinkedList<>(); while (st.hasMoreTokens()) { l.add(st.nextToken()); } - pkgList = l.toArray(); + pkgList = l.toArray(new String[0]); } catch (Exception exp) { exp.printStackTrace(); } @@ -59,7 +59,7 @@ public boolean canInclude(InstanceKlass kls) { return true; String klassName = kls.getName().asString().replace('/', '.'); for (int i=0; i < len; i++) - if (klassName.startsWith((String) pkgList[i] )) return true; + if (klassName.startsWith(pkgList[i] )) return true; return false; } } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/types/basic/BasicType.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/types/basic/BasicType.java index c8a31953eba..0facd328135 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/types/basic/BasicType.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/types/basic/BasicType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,8 +51,8 @@ public class BasicType implements Type { private boolean isOopType; // These are only the fields defined in this class, not any of this // class's superclasses. - private Map nameToFieldMap = new HashMap(); - private List fieldList = new LinkedList(); + private Map nameToFieldMap = new HashMap<>(); + private List fieldList = new LinkedList<>(); // Superclass, or null if none. Primitive types do not have any // inheritance relationship. private Type superclass; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java index 88529c1a388..d9d88ea511a 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,11 +50,11 @@ public class BasicTypeDataBase implements TypeDataBase { private MachineDescription machDesc; private VtblAccess vtblAccess; /** Maps strings to Type objects. This does not contain the primitive types. */ - private Map nameToTypeMap = new HashMap(); + private Map nameToTypeMap = new HashMap<>(); /** Maps strings to Integers, used for enums, etc. */ - private Map nameToIntConstantMap = new HashMap(); + private Map nameToIntConstantMap = new HashMap<>(); /** Maps strings to Longs, used for 32/64-bit constants, etc. */ - private Map nameToLongConstantMap = new HashMap(); + private Map nameToLongConstantMap = new HashMap<>(); /** Primitive types. */ private Type jbooleanType; private Type jbyteType; @@ -156,10 +156,10 @@ public long getOopSize() { return VM.getVM().getOopSize(); } - HashMap typeToVtbl = new HashMap(); + Map typeToVtbl = new HashMap<>(); private Address vtblForType(Type type) { - Address vtblAddr = (Address)typeToVtbl.get(type); + Address vtblAddr = typeToVtbl.get(type); if (vtblAddr == null) { vtblAddr = vtblAccess.getVtblForType(type); if (vtblAddr != null) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/types/basic/BasicVtblAccess.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/types/basic/BasicVtblAccess.java index 8f15852b91d..621449f9215 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/types/basic/BasicVtblAccess.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/types/basic/BasicVtblAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ public abstract class BasicVtblAccess implements VtblAccess { protected SymbolLookup symbolLookup; protected String[] dllNames; - private Map typeToVtblMap = new HashMap(); + private Map typeToVtblMap = new HashMap<>(); public BasicVtblAccess(SymbolLookup symbolLookup, String[] dllNames) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/AnnotatedMemoryPanel.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/AnnotatedMemoryPanel.java index a7ad6c53a3f..86405409973 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/AnnotatedMemoryPanel.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/AnnotatedMemoryPanel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,7 +55,7 @@ public class AnnotatedMemoryPanel extends JPanel { // Type of this is an IntervalTree indexed by Interval
and // with user data of type Annotation private IntervalTree annotations = - new IntervalTree(new Comparator() { + new IntervalTree(new Comparator<>() { public int compare(Object o1, Object o2) { Address a1 = (Address) o1; Address a2 = (Address) o2; @@ -82,7 +82,7 @@ public int compare(Object o1, Object o2) { // This contains the list of currently-visible IntervalNodes, in // sorted order by their low endpoint, in the form of a // List. These annotations have already been laid out. - private java.util.List visibleAnnotations; + private java.util.List visibleAnnotations; // Darker colors than defaults for better readability private static Color[] colors = { new Color(0.0f, 0.0f, 0.6f), // blue @@ -201,7 +201,7 @@ public synchronized void paintComponent(Graphics g) { // FIXME: it would be nice to have a more static layout; that is, // if something scrolls off the bottom of the screen, other // annotations still visible shouldn't change position - java.util.List va = + java.util.List va = annotations.findAllNodesIntersecting(new Interval(startAddr.addOffsetTo(-addressSize), endAddr.addOffsetTo(2 * addressSize))); @@ -214,12 +214,12 @@ public synchronized void paintComponent(Graphics g) { ((Graphics2D) g).setStroke(stroke); } - Stack drawStack = new Stack(); + Stack drawStack = new Stack<>(); layoutAnnotations(va, g, curTextX, startAddr, lineHeight); - for (Iterator iter = visibleAnnotations.iterator(); iter.hasNext(); ) { - Annotation anno = (Annotation) iter.next(); + for (Iterator iter = visibleAnnotations.iterator(); iter.hasNext(); ) { + Annotation anno = iter.next(); Interval interval = anno.getInterval(); if (!drawStack.empty()) { @@ -293,7 +293,7 @@ private void init(Debugger debugger, boolean is64Bit, BigInteger addrValue, BigI setLayout(new BorderLayout()); setupScrollBar(addrValue, addrLow, addrHigh); add(scrollBar, BorderLayout.EAST); - visibleAnnotations = new ArrayList(); + visibleAnnotations = new ArrayList<>(); setBackground(Color.white); addHierarchyBoundsListener(new HierarchyBoundsListener() { public void ancestorMoved(HierarchyEvent e) { @@ -438,8 +438,8 @@ private String addressToString(Address a) { /** Scrolls the visible annotations by the given Y amount */ private void scrollAnnotations(int y) { - for (Iterator iter = visibleAnnotations.iterator(); iter.hasNext(); ) { - Annotation anno = (Annotation) iter.next(); + for (Iterator iter = visibleAnnotations.iterator(); iter.hasNext(); ) { + Annotation anno = iter.next(); anno.setY(anno.getY() + y); } } @@ -448,7 +448,7 @@ private void scrollAnnotations(int y) { a List) and lays them out given the current visible position and the already-visible annotations. Does not perturb the layouts of the currently-visible annotations. */ - private void layoutAnnotations(java.util.List va, + private void layoutAnnotations(java.util.List va, Graphics g, int x, Address startAddr, @@ -490,15 +490,15 @@ private void layoutAnnotations(java.util.List va, // visibleAnnotations list. This reduces the amount of work we do. int searchIndex = 0; // The new set of annotations - java.util.List newAnnos = new ArrayList(); + java.util.List newAnnos = new ArrayList<>(); - for (Iterator iter = va.iterator(); iter.hasNext(); ) { + for (Iterator iter = va.iterator(); iter.hasNext(); ) { Annotation anno = (Annotation) ((IntervalNode) iter.next()).getData(); // Search forward for this one boolean found = false; for (int i = searchIndex; i < visibleAnnotations.size(); i++) { - Annotation el = (Annotation) visibleAnnotations.get(i); + Annotation el = visibleAnnotations.get(i); // See whether we can abort the search unsuccessfully because // we went forward too far if (el.getLowAddress().greaterThan(anno.getLowAddress())) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/Annotation.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/Annotation.java index 853512d64dd..89e5af52966 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/Annotation.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/Annotation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,10 +38,8 @@ public class Annotation { private Interval interval; - // List - private java.util.List strings; - // List - private java.util.List heights; + private java.util.List strings; + private java.util.List heights; private Color baseColor; private int width; private int height; @@ -53,8 +51,8 @@ public class Annotation { public Annotation(Address lowAddress, Address highAddress, String s) { - strings = new ArrayList(); - heights = new ArrayList(); + strings = new ArrayList<>(); + heights = new ArrayList<>(); for (StringTokenizer tok = new StringTokenizer(s, "\n"); tok.hasMoreTokens(); ) { strings.add(tok.nextToken()); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/FindInHeapPanel.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/FindInHeapPanel.java index 8b0c5ff07d0..94a535072de 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/FindInHeapPanel.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/FindInHeapPanel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,7 +49,7 @@ public class FindInHeapPanel extends JPanel { private HistoryComboBox addressField; private JButton findButton; private JTextArea textArea; - private ArrayList updates; + private ArrayList updates; private double lastFrac; static final double minUpdateFraction = 0.05; @@ -79,7 +79,7 @@ public void prologue(long used) { iterated = 0; lastFrac = 0; error = false; - updates = new ArrayList(); + updates = new ArrayList<>(); } public void visitAddress(Address addr) { @@ -197,7 +197,7 @@ private synchronized void updateResultWindow() { while (i.hasNext()) { textArea.append((String)i.next()); } - updates = new ArrayList();; + updates = new ArrayList<>();; } pendingUpdate = false; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/HighPrecisionJScrollBar.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/HighPrecisionJScrollBar.java index e37446a16a4..b78b763202d 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/HighPrecisionJScrollBar.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/HighPrecisionJScrollBar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ public class HighPrecisionJScrollBar extends JScrollBar { private static final int BIG_RANGE = 10000; // Do we need to scale HP values up/down to fit in 0..BIG_RANGE-1? private boolean down; - private java.util.List changeListeners = new ArrayList(); + private java.util.List changeListeners = new ArrayList<>(); // Number of digits after decimal point to use when scaling between // high and low precision private static final int SCALE = 20; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/HistoryComboBox.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/HistoryComboBox.java index 13313486d9e..5dc7a865991 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/HistoryComboBox.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/HistoryComboBox.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ /** Provides an editable text field with history. */ -public class HistoryComboBox extends JComboBox { +public class HistoryComboBox extends JComboBox { static final int HISTORY_LENGTH = 15; public HistoryComboBox() { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/JavaThreadsPanel.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/JavaThreadsPanel.java index b5b5a60ce70..1197d6f0322 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/JavaThreadsPanel.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/JavaThreadsPanel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ public class JavaThreadsPanel extends SAPanel implements ActionListener { private JavaThreadsTableModel dataModel; private StatusBar statusBar; private JTable threadTable; - private java.util.List cachedThreads = new ArrayList(); + private java.util.List cachedThreads = new ArrayList<>(); private static AddressField crashThread; @@ -265,9 +265,9 @@ public JavaThreadsColumnModel() { private class JavaThreadsTableModel extends AbstractTableModel { private String[] columnNames = { "OS Thread ID", "Java Thread Name" }; - private java.util.List elements; + private java.util.List elements; - public JavaThreadsTableModel(java.util.List threads) { + public JavaThreadsTableModel(java.util.List threads) { this.elements = threads; } @@ -303,16 +303,16 @@ public JavaThread getJavaThread(int index) { } private CachedThread getRow(int row) { - return (CachedThread)elements.get(row); + return elements.get(row); } private String threadIDAt(int index) { - return ((CachedThread) cachedThreads.get(index)).getThreadID(); + return cachedThreads.get(index).getThreadID(); } private String threadNameAt(int index) { try { - return ((CachedThread) cachedThreads.get(index)).getThreadName(); + return cachedThreads.get(index).getThreadName(); } catch (AddressException e) { return ""; } catch (NullPointerException e) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/ObjectHistogramPanel.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/ObjectHistogramPanel.java index 8c3688a9066..cae0673155c 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/ObjectHistogramPanel.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/ObjectHistogramPanel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,7 @@ public class ObjectHistogramPanel extends JPanel implements ActionListener { private ObjectHistogramToolBar toolbar; private StatusBar statusBar; private JTable table; - private java.util.List listeners; + private java.util.List listeners; public ObjectHistogramPanel(ObjectHistogram histo) { dataModel = new ObjectHistogramTableModel(histo); @@ -263,7 +263,7 @@ public interface Listener { public void addPanelListener(Listener listener) { if (listeners == null) { - listeners = new ArrayList(); + listeners = new ArrayList<>(); } listeners.add(listener); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/ProcessListPanel.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/ProcessListPanel.java index b5eba57d6d8..ed70903a7dd 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/ProcessListPanel.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/ProcessListPanel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ public class ProcessListPanel extends JPanel { private Debugger dbg; private AbstractTableModel dataModel; - private java.util.List els; + private java.util.List els; private boolean sortByName = true; private boolean sortReversed = false; private javax.swing.Timer timer; @@ -149,7 +149,7 @@ public synchronized void update() { if (!dbg.hasProcessList()) { throw new RuntimeException("ProcessListPanel requires that debugger supports getProcessList()"); } - java.util.List newEls = dbg.getProcessList(); + java.util.List newEls = dbg.getProcessList(); sort(newEls); if (table != null) { // Keep the current selection if possible @@ -176,24 +176,24 @@ public synchronized ProcessInfo getSelectedProcess() { if (i < 0) { return null; } - return (ProcessInfo) els.get(i); + return els.get(i); } - private synchronized void sort(java.util.List els) { - Comparator c; + private synchronized void sort(java.util.List els) { + Comparator c; if (sortByName) { - c = new Comparator() { - public int compare(Object o1, Object o2) { + c = new Comparator<>() { + public int compare(ProcessInfo o1, ProcessInfo o2) { int scale = (sortReversed ? -1 : 1); - return scale * ((ProcessInfo) o1).getName().compareToIgnoreCase(((ProcessInfo) o2).getName()); + return scale * o1.getName().compareToIgnoreCase(o2.getName()); } }; } else { - c = new Comparator() { - public int compare(Object o1, Object o2) { + c = new Comparator<>() { + public int compare(ProcessInfo o1, ProcessInfo o2) { int scale = (sortReversed ? -1 : 1); - int pid1 = ((ProcessInfo) o1).getPid(); - int pid2 = ((ProcessInfo) o2).getPid(); + int pid1 = o1.getPid(); + int pid2 = o2.getPid(); int ret; if (pid1 < pid2) ret = -1; else if (pid1 == pid2) ret = 0; @@ -216,13 +216,13 @@ public void actionPerformed(ActionEvent e) { return timer; } - private synchronized int getPid(java.util.List els, int index) { - return ((ProcessInfo) els.get(index)).getPid(); + private synchronized int getPid(java.util.List els, int index) { + return els.get(index).getPid(); } - private synchronized int findPid(java.util.List els, int pid) { + private synchronized int findPid(java.util.List els, int pid) { for (int i = 0; i < els.size(); i++) { - ProcessInfo info = (ProcessInfo) els.get(i); + ProcessInfo info = els.get(i); if (info.getPid() == pid) { return i; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/SAPanel.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/SAPanel.java index 9bc7e4b4e48..1e555f57171 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/SAPanel.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/SAPanel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ * in to different containing frameworks (HSDB). */ public class SAPanel extends JPanel { - protected List listeners = new ArrayList(); + protected List listeners = new ArrayList<>(); public SAPanel() { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/SourceCodePanel.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/SourceCodePanel.java index 29cf53580b7..429b7594157 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/SourceCodePanel.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/SourceCodePanel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ public class SourceCodePanel extends JPanel { private static Icon breakpoint; // State private int highlightedLine = -1; - private Set/**/ breakpoints = new HashSet(); // Zero-based lines internally + private Set breakpoints = new HashSet<>(); // Zero-based lines internally // Parent Editor container and EditorCommands object for setting breakpoints private EditorCommands comm; private Editor parent; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java index 796b6f80364..0d8f6a54e3d 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1067,21 +1067,21 @@ protected void genScope(Formatter buf, Formatter tabs, ScopeDesc sd) { buf.append(Integer.toString(line)); } - List locals = sd.getLocals(); + List locals = sd.getLocals(); if (locals != null) { buf.br(); buf.append(tabs); buf.append(genHTMLForLocals(sd, locals)); } - List expressions = sd.getExpressions(); + List expressions = sd.getExpressions(); if (expressions != null) { buf.br(); buf.append(tabs); buf.append(genHTMLForExpressions(sd, expressions)); } - List monitors = sd.getMonitors(); + List monitors = sd.getMonitors(); if (monitors != null) { buf.br(); buf.append(tabs); @@ -1097,14 +1097,14 @@ protected void genScObjInfo(Formatter buf, Formatter tabs, ScopeDesc sd) { return; } - List objects = sd.getObjects(); + List objects = sd.getObjects(); if (objects == null) { return; } int length = objects.size(); for (int i = 0; i < length; i++) { buf.append(tabs); - ObjectValue ov = (ObjectValue)objects.get(i); + ObjectValue ov = objects.get(i); buf.append("ScObj" + i); ScopeValue sv = ov.getKlass(); if (Assert.ASSERTS_ENABLED) { @@ -1352,12 +1352,12 @@ private String scopeValueAsString(ScopeDesc sd, ScopeValue sv) { return buf.toString(); } - protected String genHTMLForScopeValues(ScopeDesc sd, boolean locals, List values) { + protected String genHTMLForScopeValues(ScopeDesc sd, boolean locals, List values) { int length = values.size(); Formatter buf = new Formatter(genHTML); buf.append(locals? "locals " : "expressions "); for (int i = 0; i < length; i++) { - ScopeValue sv = (ScopeValue) values.get(i); + ScopeValue sv = values.get(i); if (sv == null) { continue; } @@ -1387,20 +1387,20 @@ protected String genHTMLForScopeValues(ScopeDesc sd, boolean locals, List values return buf.toString(); } - protected String genHTMLForLocals(ScopeDesc sd, List locals) { + protected String genHTMLForLocals(ScopeDesc sd, List locals) { return genHTMLForScopeValues(sd, true, locals); } - protected String genHTMLForExpressions(ScopeDesc sd, List expressions) { + protected String genHTMLForExpressions(ScopeDesc sd, List expressions) { return genHTMLForScopeValues(sd, false, expressions); } - protected String genHTMLForMonitors(ScopeDesc sd, List monitors) { + protected String genHTMLForMonitors(ScopeDesc sd, List monitors) { int length = monitors.size(); Formatter buf = new Formatter(genHTML); buf.append("monitors "); for (int i = 0; i < length; i++) { - MonitorValue mv = (MonitorValue) monitors.get(i); + MonitorValue mv = monitors.get(i); if (mv == null) { continue; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/CTypeTreeNodeAdapter.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/CTypeTreeNodeAdapter.java index b7da2eeac57..37428af33c1 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/CTypeTreeNodeAdapter.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/CTypeTreeNodeAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ public class CTypeTreeNodeAdapter extends FieldTreeNodeAdapter { final private Type type; private CTypeFieldIdentifier[] fields = null; - private void collectFields(Type type, ArrayList list, boolean statics, boolean recurse) { + private void collectFields(Type type, ArrayList list, boolean statics, boolean recurse) { Type supertype = type.getSuperclass(); if (supertype != null && recurse) { collectFields(supertype, list, statics, recurse); @@ -57,9 +57,9 @@ private void collectFields(Type type, ArrayList list, boolean statics, boolean r private CTypeFieldIdentifier[] getFields() { if (fields == null) { - ArrayList f = new ArrayList(); + ArrayList f = new ArrayList<>(); collectFields(type, f, false, true); - fields = (CTypeFieldIdentifier[]) f.toArray(new CTypeFieldIdentifier[0]); + fields = f.toArray(new CTypeFieldIdentifier[0]); } return fields; } @@ -97,20 +97,20 @@ public CTypeTreeNodeAdapter(Type t) { super(null, false); type = t; addr = null; - ArrayList statics = new ArrayList(); + ArrayList statics = new ArrayList<>(); collectFields(type, statics, true, false); - fields = (CTypeFieldIdentifier[])statics.toArray(new CTypeFieldIdentifier[0]); + fields = statics.toArray(new CTypeFieldIdentifier[0]); } public CTypeTreeNodeAdapter(Iterator types) { super(null, false); addr = null; type = null; - ArrayList statics = new ArrayList(); + ArrayList statics = new ArrayList<>(); while (types.hasNext()) { collectFields((Type)types.next(), statics, true, false); } - fields = (CTypeFieldIdentifier[])statics.toArray(new CTypeFieldIdentifier[0]); + fields = statics.toArray(new CTypeFieldIdentifier[0]); } public int getChildCount() { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/RevPtrsTreeNodeAdapter.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/RevPtrsTreeNodeAdapter.java index fc1a56822d5..40db60433be 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/RevPtrsTreeNodeAdapter.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/RevPtrsTreeNodeAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ public class RevPtrsTreeNodeAdapter extends FieldTreeNodeAdapter { private static FieldIdentifier fid = new NamedFieldIdentifier("_revPtrs"); - private List children; + private List children; public RevPtrsTreeNodeAdapter(Oop oop) { this(oop, false); @@ -52,7 +52,7 @@ public int getChildCount() { } public SimpleTreeNode getChild(int index) { - LivenessPathElement lpe = (LivenessPathElement)children.get(index); + LivenessPathElement lpe = children.get(index); IndexableFieldIdentifier ifid = new IndexableFieldIdentifier(index); Oop oop = lpe.getObj(); if (oop != null) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/SimpleTreeGroupNode.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/SimpleTreeGroupNode.java index f5e56e3fef6..ce9b9e3004b 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/SimpleTreeGroupNode.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/SimpleTreeGroupNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,10 +30,10 @@ of graph */ public class SimpleTreeGroupNode implements SimpleTreeNode { - private List children; + private List children; public SimpleTreeGroupNode() { - children = new ArrayList(); + children = new ArrayList<>(); } public int getChildCount() { return children.size(); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/SimpleTreeModel.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/SimpleTreeModel.java index b8ddaa653f0..f9c45d4bdd9 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/SimpleTreeModel.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/tree/SimpleTreeModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,8 +45,7 @@ public class SimpleTreeModel implements TreeModel { public String getValue() { return toString(); } }; private SimpleTreeNode root = singletonNullRoot; - /** List */ - private List listeners = new ArrayList(); + private List listeners = new ArrayList<>(); public void setRoot(SimpleTreeNode node) { if (node != null) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/BasicHashtable.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/BasicHashtable.java index 5b7cfc571eb..39a70d45d7c 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/BasicHashtable.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/BasicHashtable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,13 +63,13 @@ protected BasicHashtableEntry bucket(int i) { } Address tmp = bucketsField.getValue(addr); tmp = tmp.addOffsetTo(i * bucketSize); - HashtableBucket bucket = (HashtableBucket) VMObjectFactory.newObject( + HashtableBucket bucket = VMObjectFactory.newObject( HashtableBucket.class, tmp); return bucket.getEntry(getHashtableEntryClass()); } // derived class may return Class - protected Class getHashtableEntryClass() { + protected Class getHashtableEntryClass() { return BasicHashtableEntry.class; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/CStringUtilities.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/CStringUtilities.java index 68c631a4e11..5146c1609c7 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/CStringUtilities.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/CStringUtilities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,7 @@ public static String getString(Address addr, Charset charset) { return null; } - List data = new ArrayList(); + List data = new ArrayList<>(); byte val = 0; long i = 0; do { @@ -73,7 +73,7 @@ public static String getString(Address addr, Charset charset) { // Convert to byte[] and from there to String byte[] bytes = new byte[data.size()]; for (i = 0; i < data.size(); ++i) { - bytes[(int) i] = ((Byte) data.get((int) i)).byteValue(); + bytes[(int) i] = data.get((int) i).byteValue(); } // FIXME: When we switch to use JDK 6 to build SA, // we can change the following to just return: diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/FindObjectByType.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/FindObjectByType.java index 1bb091e89e5..63c643e7710 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/FindObjectByType.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/FindObjectByType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,14 +30,14 @@ public class FindObjectByType implements HeapVisitor { private Klass type; - private List results = new ArrayList(); + private List results = new ArrayList<>(); public FindObjectByType(Klass type) { this.type = type; } /** Returns a List of Oops */ - public List getResults() { + public List getResults() { return results; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/Hashtable.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/Hashtable.java index f4146e4b0b8..894043a175a 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/Hashtable.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/Hashtable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,8 +44,7 @@ private static synchronized void initialize(TypeDataBase db) { Type type = db.lookupType("IntptrHashtable"); } - // derived class may return Class - protected Class getHashtableEntryClass() { + protected Class getHashtableEntryClass() { return HashtableEntry.class; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HashtableBucket.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HashtableBucket.java index d86ee992ef0..2a3ff4e1a1b 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HashtableBucket.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HashtableBucket.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,10 +46,10 @@ private static synchronized void initialize(TypeDataBase db) { // Field private static AddressField entryField; - // Accessor - accepts Class - public BasicHashtableEntry getEntry(Class clazz) { + // Accessor + public BasicHashtableEntry getEntry(Class clazz) { Address tmp = entryField.getValue(addr); - return (BasicHashtableEntry) VMObjectFactory.newObject(clazz, tmp); + return VMObjectFactory.newObject(clazz, tmp); } public BasicHashtableEntry entry() { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java index dbb95d392b4..c558e59140c 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -101,7 +101,7 @@ protected void writeHeapHeader() throws IOException { } protected void writeObjectHeader(Oop oop) throws IOException { - refFields = new ArrayList(); + refFields = new ArrayList<>(); isArray = oop.isArray(); // generate an edge for instanceof relation @@ -403,7 +403,7 @@ private void writeVMInfo() throws IOException { private static final String ENCODING = "UTF-8"; // reference fields of currently visited object - private List/**/ refFields; + private List refFields; // are we writing an array now? private boolean isArray; private PrintWriter out; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java index 44aa868414f..d16aacd7a64 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -637,7 +637,7 @@ private void writeClassDumpRecord(Klass k) throws IOException { // two reserved id fields writeObjectID(null); writeObjectID(null); - List fields = getInstanceFields(ik); + List fields = getInstanceFields(ik); int instSize = getSizeForFields(fields); classDataCache.put(ik, new ClassData(instSize, fields)); out.writeInt(instSize); @@ -646,12 +646,12 @@ private void writeClassDumpRecord(Klass k) throws IOException { // output number of cp entries as zero. out.writeShort((short) 0); - List declaredFields = ik.getImmediateFields(); - List staticFields = new ArrayList(); - List instanceFields = new ArrayList(); - Iterator itr = null; + List declaredFields = ik.getImmediateFields(); + List staticFields = new ArrayList<>(); + List instanceFields = new ArrayList<>(); + Iterator itr = null; for (itr = declaredFields.iterator(); itr.hasNext();) { - Field field = (Field) itr.next(); + Field field = itr.next(); if (field.isStatic()) { staticFields.add(field); } else { @@ -955,22 +955,22 @@ protected void writeInstance(Instance instance) throws IOException { if (Assert.ASSERTS_ENABLED) { Assert.that(cd != null, "can not get class data for " + klass.getName().asString() + klass.getAddress()); } - List fields = cd.fields; + List fields = cd.fields; int size = cd.instSize; out.writeInt(size); - for (Iterator itr = fields.iterator(); itr.hasNext();) { - writeField((Field) itr.next(), instance); + for (Iterator itr = fields.iterator(); itr.hasNext();) { + writeField(itr.next(), instance); } } //-- Internals only below this point - private void writeFieldDescriptors(List fields, InstanceKlass ik) + private void writeFieldDescriptors(List fields, InstanceKlass ik) throws IOException { // ik == null for instance fields. out.writeShort((short) fields.size()); - for (Iterator itr = fields.iterator(); itr.hasNext();) { - Field field = (Field) itr.next(); + for (Iterator itr = fields.iterator(); itr.hasNext();) { + Field field = itr.next(); Symbol name = field.getName(); writeSymbolID(name); char typeCode = (char) field.getSignature().getByteAt(0); @@ -1069,9 +1069,9 @@ private void writeClassSymbols(Klass k) throws IOException { writeSymbol(k.getName()); if (k instanceof InstanceKlass) { InstanceKlass ik = (InstanceKlass) k; - List declaredFields = ik.getImmediateFields(); - for (Iterator itr = declaredFields.iterator(); itr.hasNext();) { - Field field = (Field) itr.next(); + List declaredFields = ik.getImmediateFields(); + for (Iterator itr = declaredFields.iterator(); itr.hasNext();) { + Field field = itr.next(); writeSymbol(field.getName()); } } @@ -1174,13 +1174,13 @@ private long getAddressValue(Address addr) { } // get all declared as well as inherited (directly/indirectly) fields - private static List/**/ getInstanceFields(InstanceKlass ik) { + private static List getInstanceFields(InstanceKlass ik) { InstanceKlass klass = ik; - List res = new ArrayList(); + List res = new ArrayList<>(); while (klass != null) { - List curFields = klass.getImmediateFields(); - for (Iterator itr = curFields.iterator(); itr.hasNext();) { - Field f = (Field) itr.next(); + List curFields = klass.getImmediateFields(); + for (Iterator itr = curFields.iterator(); itr.hasNext();) { + Field f = itr.next(); if (! f.isStatic()) { res.add(f); } @@ -1193,10 +1193,10 @@ private long getAddressValue(Address addr) { // get size in bytes (in stream) required for given fields. Note // that this is not the same as object size in heap. The size in // heap will include size of padding/alignment bytes as well. - private int getSizeForFields(List fields) { + private int getSizeForFields(List fields) { int size = 0; - for (Iterator itr = fields.iterator(); itr.hasNext();) { - Field field = (Field) itr.next(); + for (Iterator itr = fields.iterator(); itr.hasNext();) { + Field field = itr.next(); char typeCode = (char) field.getSignature().getByteAt(0); switch (typeCode) { case JVM_SIGNATURE_BOOLEAN: @@ -1265,13 +1265,13 @@ private int getSizeForFields(List fields) { private static class ClassData { int instSize; - List fields; + List fields; - ClassData(int instSize, List fields) { + ClassData(int instSize, List fields) { this.instSize = instSize; this.fields = fields; } } - private Map classDataCache = new HashMap(); // + private Map classDataCache = new HashMap<>(); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/Interval.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/Interval.java index 1f2700c47c7..022124ef06d 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/Interval.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/Interval.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ public Object getHighEndpoint() { /** This takes the Interval to compare against as well as a Comparator which will be applied to the low and high endpoints of the given intervals. */ - public boolean overlaps(Interval arg, Comparator endpointComparator) { + public boolean overlaps(Interval arg, Comparator endpointComparator) { return overlaps(arg.getLowEndpoint(), arg.getHighEndpoint(), endpointComparator); } @@ -61,7 +61,7 @@ public boolean overlaps(Interval arg, Comparator endpointComparator) { different data structures */ public boolean overlaps(Object otherLowEndpoint, Object otherHighEndpoint, - Comparator endpointComparator) { + Comparator endpointComparator) { if (endpointComparator.compare(highEndpoint, otherLowEndpoint) <= 0) { return false; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/IntervalNode.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/IntervalNode.java index 59071140289..f3ac16db2dd 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/IntervalNode.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/IntervalNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,11 +30,11 @@ public class IntervalNode extends RBNode { private Interval interval; - private Comparator endpointComparator; + private Comparator endpointComparator; private Object minEndpoint; private Object maxEndpoint; - public IntervalNode(Interval interval, Comparator endpointComparator, Object data) { + public IntervalNode(Interval interval, Comparator endpointComparator, Object data) { super(data); this.interval = interval; this.endpointComparator = endpointComparator; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/IntervalTree.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/IntervalTree.java index c2e23151537..eb98c0d2940 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/IntervalTree.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/IntervalTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,12 +32,12 @@ import java.util.List; public class IntervalTree extends RBTree { - private Comparator endpointComparator; + private Comparator endpointComparator; /** This constructor takes only one comparator: one which operates upon the endpoints of the Intervals this tree will store. It constructs an internal "interval comparator" out of this one. */ - public IntervalTree(Comparator endpointComparator) { + public IntervalTree(Comparator endpointComparator) { super(new IntervalComparator(endpointComparator)); this.endpointComparator = endpointComparator; } @@ -51,8 +51,8 @@ public void insert(Interval interval, Object data) { intervals were intersected by the given query interval. It is guaranteed that these nodes will be returned sorted by increasing low endpoint. */ - public List findAllNodesIntersecting(Interval interval) { - List retList = new ArrayList(); + public List findAllNodesIntersecting(Interval interval) { + List retList = new ArrayList<>(); searchForIntersectingNodesFrom((IntervalNode) getRoot(), interval, retList); return retList; } @@ -108,10 +108,10 @@ private void verifyFromNode(RBNode node) { verifyFromNode(node.getRight()); } - static class IntervalComparator implements Comparator { - private Comparator endpointComparator; + static class IntervalComparator implements Comparator { + private Comparator endpointComparator; - public IntervalComparator(Comparator endpointComparator) { + public IntervalComparator(Comparator endpointComparator) { this.endpointComparator = endpointComparator; } @@ -124,7 +124,7 @@ public int compare(Object o1, Object o2) { private void searchForIntersectingNodesFrom(IntervalNode node, Interval interval, - List resultList) { + List resultList) { if (node == null) { return; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/LivenessAnalysis.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/LivenessAnalysis.java index a69f88f5a3c..7c1443afd04 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/LivenessAnalysis.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/LivenessAnalysis.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,12 +83,12 @@ private static LivenessPathList computeAllLivenessPaths(Oop target, boolean trim // HashSet of Oops acting as a bit mask indicating which ones have // already been traversed - Set/**/ visitedOops = new HashSet/**/(); + Set visitedOops = new HashSet<>(); // IdentityHashMap of LivenessElements acting as a bit mask // indicating which roots have already been traversed - Map/**/ visitedRoots = - new IdentityHashMap/**/(); + Map visitedRoots = + new IdentityHashMap<>(); visitedOops.add(target); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/LivenessPath.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/LivenessPath.java index a7a0815718b..da10daacb91 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/LivenessPath.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/LivenessPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ it alive. Elements of the path are (object, field) pairs, where public class LivenessPath { LivenessPath() { - stack = new Stack(); + stack = new Stack<>(); } /** Number of elements in the path */ @@ -104,5 +104,5 @@ LivenessPath copy() { //--------------------------------------------------------------------------- // Internals only below this point // - private Stack stack; + private Stack stack; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/LivenessPathList.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/LivenessPathList.java index 7ebd3f9412c..9d399e0bbe5 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/LivenessPathList.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/LivenessPathList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ public class LivenessPathList { public LivenessPathList() { - list = new ArrayList(); + list = new ArrayList<>(); } public int size() { @@ -49,5 +49,5 @@ void remove(LivenessPath path) { list.remove(path); } - private ArrayList list; + private ArrayList list; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/MessageQueueBackend.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/MessageQueueBackend.java index 753bb1da43f..010b0700d41 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/MessageQueueBackend.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/MessageQueueBackend.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,8 +36,8 @@ public class MessageQueueBackend { private MessageQueueImpl rightLeftQueue; public MessageQueueBackend() { - LinkedList leftRightPipe = new LinkedList(); - LinkedList rightLeftPipe = new LinkedList(); + LinkedList leftRightPipe = new LinkedList<>(); + LinkedList rightLeftPipe = new LinkedList<>(); leftRightQueue = new MessageQueueImpl(rightLeftPipe, leftRightPipe); rightLeftQueue = new MessageQueueImpl(leftRightPipe, rightLeftPipe); } @@ -53,10 +53,10 @@ public MessageQueue getSecondQueue() { } private class MessageQueueImpl implements MessageQueue { - private LinkedList readList; - private LinkedList writeList; + private LinkedList readList; + private LinkedList writeList; - public MessageQueueImpl(LinkedList listToReadFrom, LinkedList listToWriteTo) { + public MessageQueueImpl(LinkedList listToReadFrom, LinkedList listToWriteTo) { readList = listToReadFrom; writeList = listToWriteTo; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ObjectReader.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ObjectReader.java index feb5c47849a..3587598b44a 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ObjectReader.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ObjectReader.java @@ -78,8 +78,8 @@ public class ObjectReader { public ObjectReader(ClassLoader cl) { this.cl = cl; - this.oopToObjMap = new HashMap(); - this.fieldMap = new HashMap(); + this.oopToObjMap = new HashMap<>(); + this.fieldMap = new HashMap<>(); } public ObjectReader() { @@ -168,7 +168,7 @@ protected String javaUtilProperties() { return javaUtilProperties; } - private void setHashtableEntry(java.util.Hashtable p, Oop oop) { + private void setHashtableEntry(java.util.Hashtable p, Oop oop) { InstanceKlass ik = (InstanceKlass)oop.getKlass(); OopField keyField = (OopField)ik.findField("key", "Ljava/lang/Object;"); OopField valueField = (OopField)ik.findField("value", "Ljava/lang/Object;"); @@ -229,7 +229,7 @@ protected Object getHashtable(Instance oop) { debugPrintln("Could not find field of [Ljava/util/Hashtable$Entry;"); return null; } - java.util.Hashtable table = new java.util.Hashtable(); + java.util.Hashtable table = new java.util.Hashtable<>(); ObjArray kvs = (ObjArray)tableField.getValue(oop); long size = kvs.getLength(); debugPrintln("Hashtable$Entry Size = " + size); @@ -653,7 +653,7 @@ public java.lang.reflect.Method readMethod(sun.jvm.hotspot.oops.Method m) throws NoSuchMethodException, ClassNotFoundException { java.lang.reflect.Method result = (java.lang.reflect.Method) getFromObjTable(m); if (result == null) { - Class clz = readClass((InstanceKlass)m.getMethodHolder()); + Class clz = readClass(m.getMethodHolder()); String name = m.getName().asString(); Class[] paramTypes = getParamTypes(m.getSignature()); result = clz.getMethod(name, paramTypes); @@ -666,7 +666,7 @@ public java.lang.reflect.Constructor readConstructor(sun.jvm.hotspot.oops.Method throws NoSuchMethodException, ClassNotFoundException { java.lang.reflect.Constructor result = (java.lang.reflect.Constructor) getFromObjTable(m); if (result == null) { - Class clz = readClass((InstanceKlass)m.getMethodHolder()); + Class clz = readClass(m.getMethodHolder()); String name = m.getName().asString(); Class[] paramTypes = getParamTypes(m.getSignature()); result = clz.getDeclaredConstructor(paramTypes); @@ -693,8 +693,8 @@ public java.lang.reflect.Field readField(sun.jvm.hotspot.oops.Field f) } protected final ClassLoader cl; - protected Map oopToObjMap; // Map - protected Map fieldMap; // Map + protected Map oopToObjMap; + protected Map fieldMap; protected void putIntoObjTable(Oop oop, Object obj) { oopToObjMap.put(oop, obj); @@ -713,7 +713,7 @@ protected Object getFromObjTable(Metadata oop) { } protected class SignatureParser extends SignatureIterator { - protected Vector tmp = new Vector(); // Vector + protected Vector> tmp = new Vector<>(); public SignatureParser(Symbol s) { super(s); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/RBTree.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/RBTree.java index 5aa447bb0a6..1a15f138746 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/RBTree.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/RBTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,12 +57,12 @@ right children (see CLR, section 15.2).

public class RBTree { private RBNode root; - private Comparator comparator; + private Comparator comparator; protected static final boolean DEBUGGING = true; protected static final boolean VERBOSE = true; protected static final boolean REALLY_VERBOSE = false; - public RBTree(Comparator comparator) { + public RBTree(Comparator comparator) { this.comparator = comparator; } @@ -534,7 +534,7 @@ public static void main(String[] args) { int treeSize = 10000; int maxVal = treeSize; System.err.println("Building tree..."); - RBTree tree = new RBTree(new Comparator() { + RBTree tree = new RBTree(new Comparator<>() { public int compare(Object o1, Object o2) { Integer i1 = (Integer) o1; Integer i2 = (Integer) o2; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ReversePtrs.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ReversePtrs.java index d2d2b7c166a..08af6d1dd63 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ReversePtrs.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ReversePtrs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,22 +30,22 @@ /** ReversePtrs hashtable. */ public class ReversePtrs { - private HashMap rp; + private HashMap> rp; public ReversePtrs() { - rp = new HashMap(); + rp = new HashMap<>(); } public void put(LivenessPathElement from, Oop to) { if (to == null) return; - ArrayList al = (ArrayList) rp.get((Object) to); - if (al == null) al = new ArrayList(); + ArrayList al = rp.get(to); + if (al == null) al = new ArrayList<>(); // Inserting at the beginning is a hack to change the reported // paths from LivenessAnalysis to look more like they used to; // otherwise paths through the Finalizer queue to popular objects // seem to be preferred - al.add(0, (Object) from); - rp.put((Object) to, (Object) al); + al.add(0, from); + rp.put(to, al); } /** Returns an ArrayList of the incoming references to this Oop if @@ -53,7 +53,7 @@ public void put(LivenessPathElement from, Oop to) { ReversePtrsAnalysis. Currently not all roots are scanned so this result is frequently inaccurate for JVM-internal objects, but is usually correct for Java-level objects. */ - public ArrayList/**/ get(Oop obj) { - return (ArrayList) rp.get((Object)obj); + public ArrayList get(Oop obj) { + return rp.get(obj); } } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ReversePtrsAnalysis.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ReversePtrsAnalysis.java index 49613525bca..34e67140b58 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ReversePtrsAnalysis.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ReversePtrsAnalysis.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -206,7 +206,7 @@ private void markAndTraverse(final Oop obj) { // Root of work list for objects to be visited. A simple // stack for saving new objects to be analyzed. - final Stack workList = new Stack(); + final Stack workList = new Stack<>(); // Next object to be visited. Oop next = obj; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/StreamMonitor.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/StreamMonitor.java index d7f4ddc5bf8..648df6e4234 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/StreamMonitor.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/StreamMonitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,8 +37,8 @@ public class StreamMonitor implements Runnable { private String waitString; private boolean waitStringSeen; - private List triggers = new LinkedList(); - private List triggersSeen = new LinkedList(); + private List triggers = new LinkedList<>(); + private List triggersSeen = new LinkedList<>(); private String prefixString; private boolean printContents; @@ -145,9 +145,9 @@ public boolean removeTrigger(String[] strs) { values of the triggers seen since the last call to getTriggersSeen. If there were no triggers seen, returns an empty list; does not return null. */ - public synchronized List getTriggersSeen() { - List tmpList = triggersSeen; - triggersSeen = new LinkedList(); + public synchronized List getTriggersSeen() { + List tmpList = triggersSeen; + triggersSeen = new LinkedList<>(); return tmpList; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/SystemDictionaryHelper.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/SystemDictionaryHelper.java index d69a54ac4ef..0aaf98294ad 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/SystemDictionaryHelper.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/SystemDictionaryHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ public static synchronized InstanceKlass[] getAllInstanceKlasses() { return klasses; } - final Vector tmp = new Vector(); + final Vector tmp = new Vector<>(); ClassLoaderDataGraph cldg = VM.getVM().getClassLoaderDataGraph(); cldg.classesDo(new ClassLoaderDataGraph.ClassVisitor() { public void visit(Klass k) { @@ -66,10 +66,8 @@ public void visit(Klass k) { Object[] tmpArray = tmp.toArray(); klasses = new InstanceKlass[tmpArray.length]; System.arraycopy(tmpArray, 0, klasses, 0, tmpArray.length); - Arrays.sort(klasses, new Comparator() { - public int compare(Object o1, Object o2) { - InstanceKlass k1 = (InstanceKlass) o1; - InstanceKlass k2 = (InstanceKlass) o2; + Arrays.sort(klasses, new Comparator<>() { + public int compare(InstanceKlass k1, InstanceKlass k2) { Symbol s1 = k1.getName(); Symbol s2 = k2.getName(); return s1.asString().compareTo(s2.asString()); @@ -83,7 +81,7 @@ public static InstanceKlass[] findInstanceKlasses(String namePart) { namePart = namePart.replace('.', '/'); InstanceKlass[] tmpKlasses = getAllInstanceKlasses(); - Vector tmp = new Vector(); + Vector tmp = new Vector<>(); for (int i = 0; i < tmpKlasses.length; i++) { String name = tmpKlasses[i].getName().asString(); if (name.indexOf(namePart) != -1) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFactoryImpl.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFactoryImpl.java index 82e88e9dda8..8615ab4e1c6 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFactoryImpl.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFactoryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ public JSJavaObject newJSJavaObject(Oop oop) { } } if (res != null) { - om.put(oop, new SoftReference(res)); + om.put(oop, new SoftReference<>(res)); } return res; } @@ -60,7 +60,7 @@ public JSJavaKlass newJSJavaKlass(Klass klass) { res = new JSJavaTypeArrayKlass((TypeArrayKlass) klass, this); } if (res != null) { - om.put(klass, new SoftReference(res)); + om.put(klass, new SoftReference<>(res)); } return res; } @@ -68,7 +68,7 @@ public JSJavaKlass newJSJavaKlass(Klass klass) { public JSJavaMethod newJSJavaMethod(Method method) { JSJavaMethod res = new JSJavaMethod(method, this); if (res != null) { - om.put(method, new SoftReference(res)); + om.put(method, new SoftReference<>(res)); } return res; } @@ -190,8 +190,7 @@ private JSJavaObject newJavaInstance(Instance instance) { return res; } - // Map> - private Map om = new HashMap(); + private Map> om = new HashMap<>(); private String javaLangString; private String javaLangThread; private String javaLangClass; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaField.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaField.java index 4a9a5fb7911..1561bf6b543 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaField.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaField.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -131,7 +131,7 @@ private JSJavaObject getFieldHolder() { return factory.newJSJavaKlass(field.getFieldHolder()).getJSJavaClass(); } - private static Map fields = new HashMap(); + private static Map fields = new HashMap<>(); private static void addField(String name, int fieldId) { fields.put(name, new Integer(fieldId)); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFrame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFrame.java index 99a489d837d..b59009a6719 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFrame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -100,7 +100,7 @@ public String toString() { } //-- Internals only below this point - private static Map fields = new HashMap(); + private static Map fields = new HashMap<>(); private static void addField(String name, int fieldId) { fields.put(name, new Integer(fieldId)); } @@ -139,7 +139,7 @@ private int getLineNumber() { private synchronized JSMap getLocals() { if (localsCache == null) { - Map map = new HashMap(); + Map map = new HashMap<>(); localsCache = factory.newJSMap(map); StackValueCollection values = jvf.getLocals(); Method method = jvf.getMethod(); @@ -150,7 +150,7 @@ private synchronized JSMap getLocals() { LocalVariableTableElement[] localVars = method.getLocalVariableTable(); int bci = getBCI(); - List visibleVars = new ArrayList(0); + List visibleVars = new ArrayList<>(0); for (int i = 0; i < localVars.length; i++) { LocalVariableTableElement cur = localVars[i]; int startBCI = cur.getStartBCI(); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaHeap.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaHeap.java index 053ddbce4b4..b7f2c3c7495 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaHeap.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -223,7 +223,7 @@ public String toString() { } //-- Internals only below this point - private static Map fields = new HashMap(); + private static Map fields = new HashMap<>(); private static void addField(String name, int fieldId) { fields.put(name, new Integer(fieldId)); } @@ -239,7 +239,7 @@ private static int getFieldID(String name) { addField("forEachObject", FIELD_FOR_EACH_OBJECT); addField("forEachClass", FIELD_FOR_EACH_CLASS); try { - Class myClass = JSJavaHeap.class; + Class myClass = JSJavaHeap.class; forEachObjectMethod = myClass.getMethod("forEachObject", new Class[] { Object[].class }); forEachClassMethod = myClass.getMethod("forEachClass", diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java index 069a40326a2..fa6d7b8d2fa 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,8 +52,8 @@ public class JSJavaInstanceKlass extends JSJavaKlass { public JSJavaInstanceKlass(InstanceKlass kls, JSJavaFactory fac) { super(kls, fac); - this.instanceFields = new HashMap(); - this.staticFields = new HashMap(); + this.instanceFields = new HashMap<>(); + this.staticFields = new HashMap<>(); } public final InstanceKlass getInstanceKlass() { @@ -159,9 +159,9 @@ public String[] getInstanceFieldNames() { if (instanceFieldNames == null) { InstanceKlass current = getInstanceKlass(); while (current != null) { - List tmp = current.getImmediateFields(); - for (Iterator itr = tmp.iterator(); itr.hasNext();) { - Field fld = (Field) itr.next(); + List tmp = current.getImmediateFields(); + for (Iterator itr = tmp.iterator(); itr.hasNext();) { + Field fld = itr.next(); if (!fld.isStatic()) { String name = fld.getID().getName(); if (instanceFields.get(name) == null) { @@ -190,9 +190,9 @@ public boolean hasInstanceField(String name) { public String[] getStaticFieldNames() { if (staticFieldNames == null) { InstanceKlass current = getInstanceKlass(); - List tmp = current.getImmediateFields(); - for (Iterator itr = tmp.iterator(); itr.hasNext();) { - Field fld = (Field) itr.next(); + List tmp = current.getImmediateFields(); + for (Iterator itr = tmp.iterator(); itr.hasNext();) { + Field fld = itr.next(); if (fld.isStatic()) { staticFields.put(fld.getID().getName(), fld); } @@ -214,7 +214,7 @@ public boolean hasStaticField(String name) { } //-- Intenals only below this point - private static Map fields = new HashMap(); + private static Map fields = new HashMap<>(); private static void addField(String name, int fieldId) { fields.put(name, new Integer(fieldId)); } @@ -313,9 +313,9 @@ private Field findInstanceField(String name) { } else { InstanceKlass current = getInstanceKlass(); while (current != null) { - List tmp = current.getImmediateFields(); - for (Iterator itr = tmp.iterator(); itr.hasNext();) { - fld = (Field) itr.next(); + List tmp = current.getImmediateFields(); + for (Iterator itr = tmp.iterator(); itr.hasNext();) { + fld = itr.next(); if (fld.getID().getName().equals(name) && !fld.isStatic()) { instanceFields.put(name, fld); return fld; @@ -338,9 +338,9 @@ private Field findStaticField(String name) { // Direct/indirect super classes and interfaces // are not included in search. InstanceKlass current = getInstanceKlass(); - List tmp = current.getImmediateFields(); - for (Iterator itr = tmp.iterator(); itr.hasNext();) { - fld = (Field) itr.next(); + List tmp = current.getImmediateFields(); + for (Iterator itr = tmp.iterator(); itr.hasNext();) { + fld = itr.next(); if (fld.getID().getName().equals(name) && fld.isStatic()) { staticFields.put(name, fld); return fld; @@ -353,10 +353,10 @@ private Field findStaticField(String name) { private JSList getInterfaces() { InstanceKlass ik = getInstanceKlass(); - List intfs = ik.getDirectImplementedInterfaces(); - List res = new ArrayList(0); - for (Iterator itr = intfs.iterator(); itr.hasNext();) { - Klass k = (Klass) itr.next(); + List intfs = ik.getDirectImplementedInterfaces(); + List res = new ArrayList<>(0); + for (Iterator itr = intfs.iterator(); itr.hasNext();) { + Klass k = itr.next(); res.add(k.getJavaMirror()); } return factory.newJSList(res); @@ -364,7 +364,7 @@ private JSList getInterfaces() { private JSMap getStatics() { String[] names = getStaticFieldNames(); - Map map = new HashMap(); + Map map = new HashMap<>(); for (int i=0; i < names.length; i++) { try { map.put(names[i], getStaticFieldValue(names[i])); @@ -373,8 +373,8 @@ private JSMap getStatics() { return factory.newJSMap(map); } - private Map instanceFields; - private Map staticFields; + private Map instanceFields; + private Map staticFields; private String[] instanceFieldNames; private String[] staticFieldNames; private AccessFlags accFlags; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaKlass.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaKlass.java index 25f3ded4051..420ad4b5b99 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaKlass.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaKlass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,7 +81,7 @@ public String[] getMetaClassFieldNames() { public abstract boolean isArray(); //-- Internals only below this point - private static Map fields = new HashMap(); + private static Map fields = new HashMap<>(); private static void addField(String name, int fieldId) { fields.put(name, new Integer(fieldId)); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaMethod.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaMethod.java index 8ff09a3b16c..33e60f77a2a 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaMethod.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -135,7 +135,7 @@ private JSJavaObject getMethodHolder() { return factory.newJSJavaKlass(k).getJSJavaClass(); } - private static Map fields = new HashMap(); + private static Map fields = new HashMap<>(); private static void addField(String name, int fieldId) { fields.put(name, new Integer(fieldId)); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaThread.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaThread.java index 7c79afa4f05..09a512dfafd 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaThread.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaThread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -97,7 +97,7 @@ private String getName() { private synchronized JSList getFrames() { if (framesCache == null) { - final List list = new ArrayList(0); + final List list = new ArrayList<>(0); if (jthread != null) { JavaVFrame jvf = jthread.getLastJavaVFrameDbg(); while (jvf != null) { @@ -112,9 +112,9 @@ private synchronized JSList getFrames() { private synchronized JSList getOwnedMonitors() { if (monitorsCache == null) { - final List ownedMonitors = new ArrayList(0); + final List ownedMonitors = new ArrayList<>(0); if (jthread != null) { - List lockedObjects = new ArrayList(); // List + List lockedObjects = new ArrayList<>(); ObjectMonitor waitingMonitor = jthread.getCurrentWaitingMonitor(); OopHandle waitingObj = null; @@ -132,9 +132,9 @@ private synchronized JSList getOwnedMonitors() { JavaVFrame frame = jthread.getLastJavaVFrameDbg(); while (frame != null) { - List frameMonitors = frame.getMonitors(); // List - for (Iterator miItr = frameMonitors.iterator(); miItr.hasNext(); ) { - MonitorInfo mi = (MonitorInfo) miItr.next(); + List frameMonitors = frame.getMonitors(); + for (Iterator miItr = frameMonitors.iterator(); miItr.hasNext(); ) { + MonitorInfo mi = miItr.next(); if (mi.eliminated() && frame.isCompiledFrame()) { continue; // skip eliminated monitor diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaVM.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaVM.java index 7d374970713..dd9f55d4ba6 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaVM.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaVM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -119,7 +119,7 @@ public String toString() { } //-- Internals only below this point - private static Map fields = new HashMap(); + private static Map fields = new HashMap<>(); private static void addField(String name, int fieldId) { fields.put(name, new Integer(fieldId)); } @@ -152,7 +152,7 @@ private long getVMBit() { private synchronized JSMap getFlags() { if (flagsCache == null) { VM.Flag[] flags = vm.getCommandLineFlags(); - Map map = new HashMap(); + Map map = new HashMap<>(); if (flags != null) { for (int f = 0; f < flags.length; f++) { VM.Flag flag = flags[f]; @@ -174,7 +174,7 @@ private synchronized JSJavaHeap getHeap() { private synchronized JSMap getSysProps() { if (sysPropsCache == null) { Properties props = vm.getSystemProperties(); - Map map = new HashMap(); + Map map = new HashMap<>(); if (props != null) { Enumeration e = props.propertyNames(); while (e.hasMoreElements()) { @@ -189,7 +189,7 @@ private synchronized JSMap getSysProps() { private synchronized JSList getThreads() { if (threadsCache == null) { - List threadsList = new ArrayList(0); + List threadsList = new ArrayList<>(0); threadsCache = factory.newJSList(threadsList); Threads threads = VM.getVM().getThreads(); for (int i = 0; i < threads.getNumberOfThreads(); i++) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/MapScriptObject.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/MapScriptObject.java index 4912a13ea3f..67b3e93ec51 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/MapScriptObject.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/MapScriptObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,13 +38,13 @@ */ public class MapScriptObject implements ScriptObject { // map to store the properties - private Map map; + private Map map; public MapScriptObject() { - this(new HashMap()); + this(new HashMap<>()); } - public MapScriptObject(Map map) { + public MapScriptObject(Map map) { // make it synchronized this.map = Collections.synchronizedMap(map); }