# HG changeset patch # User dbessono # Date 1532442910 -3600 # Tue Jul 24 15:35:10 2018 +0100 # Node ID c72d9d0a39259154e53e9b951c633c04642e1185 # Parent eac2a6c332dc5c591faf3cba61dc396a8f99fed7 7902237: Fixing raw use of parameterized class Reviewed-by: jjg diff --git a/src/com/sun/interview/FileListQuestion.java b/src/com/sun/interview/FileListQuestion.java --- a/src/com/sun/interview/FileListQuestion.java +++ b/src/com/sun/interview/FileListQuestion.java @@ -126,7 +126,7 @@ */ @Override public void setValue(String paths) { - setValue(paths == null ? (File[])null : split(paths)); + setValue(paths == null ? null : split(paths)); } /** diff --git a/src/com/sun/interview/FileQuestion.java b/src/com/sun/interview/FileQuestion.java --- a/src/com/sun/interview/FileQuestion.java +++ b/src/com/sun/interview/FileQuestion.java @@ -131,7 +131,7 @@ * @see #getValue */ public void setValue(String path) { - setValue(path == null ? (File)null : new File(path)); + setValue(path == null ? null : new File(path)); } /** diff --git a/src/com/sun/interview/HelpSetFactory.java b/src/com/sun/interview/HelpSetFactory.java --- a/src/com/sun/interview/HelpSetFactory.java +++ b/src/com/sun/interview/HelpSetFactory.java @@ -47,7 +47,7 @@ * * @throws com.sun.interview.Interview.Fault if something went wrong */ - public Object createHelpSetObject(String name, Class c) throws Interview.Fault; + public Object createHelpSetObject(String name, Class c) throws Interview.Fault; /** * Creates an instance of HelpSet. @@ -78,7 +78,7 @@ static class Default implements HelpSetFactory { private static final Object EMPTY = new Object(); - public Object createHelpSetObject(String name, Class c) throws Fault { + public Object createHelpSetObject(String name, Class c) throws Fault { return EMPTY; } diff --git a/src/com/sun/interview/InterviewSet.java b/src/com/sun/interview/InterviewSet.java --- a/src/com/sun/interview/InterviewSet.java +++ b/src/com/sun/interview/InterviewSet.java @@ -108,7 +108,7 @@ if (dependency == null) throw new NullPointerException(); - Set allDeps = getAllDependencies(dependency); + Set allDeps = getAllDependencies(dependency); if (allDeps != null && allDeps.contains(child)) throw new CycleFault(child, dependency); @@ -131,7 +131,7 @@ if (dependency == null) throw new NullPointerException(); - Set deps = getDependencies(child, false); + Set deps = getDependencies(child, false); if (deps != null) deps.remove(dependency); @@ -153,7 +153,7 @@ return deps; } - private Set getAllDependencies(Interview child) { + private Set getAllDependencies(Interview child) { Set s = new HashSet<>(); getAllDependencies(child, s); return s; @@ -246,8 +246,8 @@ if (o1 == o2) return 0; - for (Iterator iter = children.iterator(); iter.hasNext(); ) { - Object o = iter.next(); + for (Iterator iter = children.iterator(); iter.hasNext(); ) { + Interview o = iter.next(); if (o == o1) return -1; if (o == o2) diff --git a/src/com/sun/interview/JavaHelpFactory.java b/src/com/sun/interview/JavaHelpFactory.java --- a/src/com/sun/interview/JavaHelpFactory.java +++ b/src/com/sun/interview/JavaHelpFactory.java @@ -48,7 +48,7 @@ public JavaHelpFactory() { } - public Object createHelpSetObject(String name, Class c) throws Interview.Fault { + public Object createHelpSetObject(String name, Class c) throws Interview.Fault { ClassLoader cl = c.getClassLoader(); String hsn; String pref = ""; @@ -87,7 +87,7 @@ public Object createHelpID(Object hsObject, String target) { if (hsObject != null) { HelpSet hs = (HelpSet) hsObject; - HashMap m = hs.getCombinedMap(); + HashMap m = hs.getCombinedMap(); if (m != null && !m.isEmpty()) { return HelpID.create(target, hs); } @@ -103,8 +103,8 @@ if (oldHelpSet == null) { // no previously registered helpset // so add in any helpsets for child interviews - for (Iterator iter = interview.getInterviews().iterator(); iter.hasNext(); ) { - Interview i = (Interview) (iter.next()); + for (Iterator iter = interview.getInterviews().iterator(); iter.hasNext(); ) { + Interview i = iter.next(); HelpSet ihs = (HelpSet)i.getHelpSet(); if (ihs != null) newHelpSet.add(ihs); diff --git a/src/com/sun/interview/ListQuestion.java b/src/com/sun/interview/ListQuestion.java --- a/src/com/sun/interview/ListQuestion.java +++ b/src/com/sun/interview/ListQuestion.java @@ -125,9 +125,9 @@ public String getDefaultSummary() { if (defaultSummary == null) { // recycle any default summaries that are no longer required - Vector bodies = question.bodies; + Vector bodies = question.bodies; for (int i = 0; i < bodies.size(); i++) { - Body b = (Body) (bodies.elementAt(i)); + Body b = (bodies.elementAt(i)); if (b.defaultSummary != null && b.getSummary() != null && !b.defaultSummary.equals(b.getSummary())) { @@ -142,7 +142,7 @@ // check s is not the same as any current default summary; // if it is, reset it to null for (int i = 0; i < bodies.size(); i++) { - Body b = (Body) (bodies.elementAt(i)); + Body b = (bodies.elementAt(i)); if (s.equals(b.defaultSummary)) { s = null; break; diff --git a/src/com/sun/interview/Properties2.java b/src/com/sun/interview/Properties2.java --- a/src/com/sun/interview/Properties2.java +++ b/src/com/sun/interview/Properties2.java @@ -71,7 +71,7 @@ } public void load(java.util.Properties source) { - Enumeration e = source.propertyNames(); + Enumeration e = source.propertyNames(); while(e.hasMoreElements()) { Object next = e.nextElement(); put( ((String)next), source.get(next) ); @@ -203,8 +203,8 @@ prnt.write('#'); prnt.println(new Date()); - for (Enumeration e = keys() ; e.hasMoreElements() ;) { - String key = (String)e.nextElement(); + for (Enumeration e = keys() ; e.hasMoreElements() ;) { + String key = e.nextElement(); prnt.print(key); prnt.write('='); @@ -285,7 +285,7 @@ * @see java.util.Enumeration * @see com.sun.interview.Properties2#defaults */ - public Enumeration propertyNames() { + public Enumeration propertyNames() { Hashtable h = new Hashtable<>(); enumerate(h); return h.keys(); @@ -307,8 +307,8 @@ out.println("-- listing properties --"); Hashtable h = new Hashtable<>(); enumerate(h); - for (Enumeration e = h.keys() ; e.hasMoreElements() ;) { - String key = (String)e.nextElement(); + for (Enumeration e = h.keys() ; e.hasMoreElements() ;) { + String key = e.nextElement(); String val = (String)h.get(key); if (val.length() > 40) { val = val.substring(0, 37) + "..."; @@ -325,8 +325,8 @@ if (defaults != null) { defaults.enumerate(h); } - for (Enumeration e = keys() ; e.hasMoreElements() ;) { - String key = (String)e.nextElement(); + for (Enumeration e = keys() ; e.hasMoreElements() ;) { + String key = e.nextElement(); h.put(key, get(key)); } } diff --git a/src/com/sun/interview/PropertiesQuestion.java b/src/com/sun/interview/PropertiesQuestion.java --- a/src/com/sun/interview/PropertiesQuestion.java +++ b/src/com/sun/interview/PropertiesQuestion.java @@ -156,7 +156,7 @@ * @return The set of keys (internal non-i18n value) * @see #setKeys */ - public Enumeration getKeys() { + public Enumeration getKeys() { if (value != null) return value.keys(); else @@ -216,11 +216,8 @@ if (value != null) { String sep = System.getProperty("line.separator"); - Enumeration names = value.propertyNames(); - ArrayList list = Collections.list(names); - Collections.sort(list); - for (Object o : list) { - String key = (String)o; + SortedSet names = new TreeSet<>(value.stringPropertyNames()); + for (String key : names) { result.append(key); result.append("="); result.append(value.getProperty(key)); @@ -320,7 +317,7 @@ // repopulate a J2SE properties object Properties p = new Properties(); - Enumeration e = p2.propertyNames(); + Enumeration e = p2.propertyNames(); while(e.hasMoreElements()) { Object next = e.nextElement(); p.put( next, p2.get(next) ); @@ -411,7 +408,7 @@ * in index one. Null means there are no invalid keys. */ public String[][] getInvalidKeys() { - Enumeration names = value.propertyNames(); + Enumeration names = value.propertyNames(); List badKeys = new ArrayList<>(); List reasons = new ArrayList<>(); @@ -690,7 +687,7 @@ return null; if (keyGroups != null) { - Set keys = keyGroups.keySet(); + Set keys = keyGroups.keySet(); if (keys != null) { String[] gps = getGroups(); Properties copy = (Properties)(value.clone()); @@ -705,12 +702,10 @@ } if (copy.size() > 0) { - Enumeration en = copy.propertyNames(); + Set en = copy.stringPropertyNames(); String[][] ret = new String[copy.size()][2]; int i = 0; - - while (en.hasMoreElements()) { - String key = (String)(en.nextElement()); + for (String key : en) { ret[i][0] = key; ret[i][1] = copy.getProperty(key); i++; @@ -724,7 +719,7 @@ } // no groups, return the entire value set String[][] ret = new String[value.size()][2]; - Enumeration en = value.propertyNames(); + Enumeration en = value.propertyNames(); int i = 0; while (en.hasMoreElements()) { diff --git a/src/com/sun/interview/StringListQuestion.java b/src/com/sun/interview/StringListQuestion.java --- a/src/com/sun/interview/StringListQuestion.java +++ b/src/com/sun/interview/StringListQuestion.java @@ -141,7 +141,7 @@ } public void setValue(String s) { - setValue(s == null ? ((String[]) null) : split(s)); + setValue(s == null ? null : split(s)); } /** diff --git a/src/com/sun/interview/WizPrint.java b/src/com/sun/interview/WizPrint.java --- a/src/com/sun/interview/WizPrint.java +++ b/src/com/sun/interview/WizPrint.java @@ -200,7 +200,7 @@ throw new BadArgs(i18n, "wp.noOutput"); } - Class ic = Class.forName(interviewClassName, true, ClassLoader.getSystemClassLoader()); + Class ic = Class.forName(interviewClassName, true, ClassLoader.getSystemClassLoader()); Interview interview = (Interview)(ic.newInstance()); Question[] questions; @@ -213,8 +213,8 @@ else { // enumerate questions, sort on tag SortedVector v = new SortedVector(); - for (Iterator iter = interview.getQuestions().iterator(); iter.hasNext(); ) { - Question q = (Question) (iter.next()); + for (Iterator iter = interview.getQuestions().iterator(); iter.hasNext(); ) { + Question q = iter.next(); v.insert(q); } questions = new Question[v.size()]; diff --git a/src/com/sun/interview/wizard/ChoiceArrayQuestionRenderer.java b/src/com/sun/interview/wizard/ChoiceArrayQuestionRenderer.java --- a/src/com/sun/interview/wizard/ChoiceArrayQuestionRenderer.java +++ b/src/com/sun/interview/wizard/ChoiceArrayQuestionRenderer.java @@ -134,7 +134,7 @@ } protected class TestTableModel extends AbstractTableModel { - public Class getColumnClass(int c) { + public Class getColumnClass(int c) { return (c == 0 ? Boolean.class : String.class); } diff --git a/src/com/sun/interview/wizard/ChoiceQuestionRenderer.java b/src/com/sun/interview/wizard/ChoiceQuestionRenderer.java --- a/src/com/sun/interview/wizard/ChoiceQuestionRenderer.java +++ b/src/com/sun/interview/wizard/ChoiceQuestionRenderer.java @@ -185,7 +185,7 @@ protected class TestTableModel extends AbstractTableModel { - public Class getColumnClass(int c) { + public Class getColumnClass(int c) { return String.class; } diff --git a/src/com/sun/interview/wizard/EditableList.java b/src/com/sun/interview/wizard/EditableList.java --- a/src/com/sun/interview/wizard/EditableList.java +++ b/src/com/sun/interview/wizard/EditableList.java @@ -120,7 +120,7 @@ * @param c the component type of the array to be returned * @return an array containing the items currently in the list */ - public Object[] getItems(Class c) { + public Object[] getItems(Class c) { Object[] items = (Object[]) (Array.newInstance(c, listModel.size())); listModel.copyInto(items); return items; @@ -281,7 +281,7 @@ protected class Renderer extends DefaultListCellRenderer { - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return super.getListCellRendererComponent(list, getDisplayValue(value), index, diff --git a/src/com/sun/interview/wizard/I18NResourceBundle.java b/src/com/sun/interview/wizard/I18NResourceBundle.java --- a/src/com/sun/interview/wizard/I18NResourceBundle.java +++ b/src/com/sun/interview/wizard/I18NResourceBundle.java @@ -55,7 +55,7 @@ * @param c the class for which to obtain the resource bundle * @return the appropriate resource bundle for the class */ - public static I18NResourceBundle getBundleForClass(Class c) { + public static I18NResourceBundle getBundleForClass(Class c) { String cn = c.getName(); int dot = cn.lastIndexOf('.'); String rn = (dot == -1 ? "i18n" : cn.substring(0, dot) + ".i18n"); diff --git a/src/com/sun/interview/wizard/PathPanel.java b/src/com/sun/interview/wizard/PathPanel.java --- a/src/com/sun/interview/wizard/PathPanel.java +++ b/src/com/sun/interview/wizard/PathPanel.java @@ -168,7 +168,7 @@ setFocusable(false); setLayout(new BorderLayout()); pathList = new PathList(); - list = new JList(pathList); + list = new JList<>(pathList); setInfo(list, "path.list", true); list.setCellRenderer(pathList); KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); @@ -244,9 +244,9 @@ private static final int DOTS_PER_INCH = Toolkit.getDefaultToolkit().getScreenResolution(); private class PathList - extends AbstractListModel + extends AbstractListModel implements ActionListener, AncestorListener, - ListCellRenderer, ListSelectionListener, + ListCellRenderer, ListSelectionListener, MouseListener, Interview.Observer { @@ -285,7 +285,7 @@ for (Object e : currEntries) { if (e instanceof Question && e == q) return true; - else if (e instanceof List && ((List) e).contains(q)) + else if (e instanceof List && ((List) e).contains(q)) return false; } return false; @@ -306,7 +306,7 @@ else if (qe == q) return autoOpened; } - else if (e instanceof List && ((List) e).contains(q)) + else if (e instanceof List && ((List) e).contains(q)) return false; } return false; @@ -408,7 +408,7 @@ } }; - public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) { + public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) { if (o instanceof Question) { Question q = (Question)o; Font f; @@ -508,7 +508,7 @@ // invoked by keyboard "enter" public void actionPerformed(ActionEvent e) { //System.err.println("PP.actionPerformed"); - JList list = (JList)(e.getSource()); + JList list = (JList)(e.getSource()); Object o = list.getSelectedValue(); if (o != null && o instanceof Question) { Question q = (Question)o; @@ -532,7 +532,7 @@ // invoked by mouse selection (or by list.setSelectedXXX ??) public void valueChanged(ListSelectionEvent e) { - JList list = (JList) (e.getSource()); + JList list = (JList) (e.getSource()); Object o = list.getSelectedValue(); if (o == null) return; @@ -554,7 +554,7 @@ } } else if (o instanceof List) { - List l = (List) o; + List l = (List) o; if (l.contains(interview.getCurrentQuestion())) return; @@ -606,7 +606,7 @@ } private boolean isOverSelection(MouseEvent e) { - JList l = (JList) (e.getComponent()); + JList l = (JList) (e.getComponent()); Rectangle r = l.getCellBounds(currIndex, currIndex); return (r.contains(e.getX(), e.getY())); } @@ -659,7 +659,7 @@ currQuestion = q; for (int i = 0; i < currEntries.length; i++) { Object o = currEntries[i]; - if (o == q || (o instanceof List && ((List) o).contains(q))) { + if (o == q || (o instanceof List && ((List) o).contains(q))) { currIndex = i; break; } @@ -754,7 +754,7 @@ for (int i = 0; i < currEntries.length; i++) { Object o = currEntries[i]; if (o == currQuestion - || (o instanceof List && ((List) o).contains(currQuestion))) { + || (o instanceof List && ((List) o).contains(currQuestion))) { currIndex = i; break; } @@ -806,7 +806,7 @@ // auto-expand the final section if it doesn't end in FinalQuestion if (!(last instanceof FinalQuestion) && v.lastElement() instanceof List) { - List l = (List) (v.lastElement()); + List l = (List) (v.lastElement()); v.setSize(v.size() - 1); v.addAll(l); } diff --git a/src/com/sun/interview/wizard/PropertiesQuestionRenderer.java b/src/com/sun/interview/wizard/PropertiesQuestionRenderer.java --- a/src/com/sun/interview/wizard/PropertiesQuestionRenderer.java +++ b/src/com/sun/interview/wizard/PropertiesQuestionRenderer.java @@ -91,8 +91,8 @@ valueSaver = new Runnable() { public void run() { - Set keys = tables.keySet(); - Iterator iter = keys.iterator(); + Set keys = tables.keySet(); + Iterator iter = keys.iterator(); while(iter.hasNext()) { JTable table = tables.get(iter.next()); CellEditor editor = table.getCellEditor(); diff --git a/src/com/sun/interview/wizard/QuestionPanel.java b/src/com/sun/interview/wizard/QuestionPanel.java --- a/src/com/sun/interview/wizard/QuestionPanel.java +++ b/src/com/sun/interview/wizard/QuestionPanel.java @@ -552,9 +552,9 @@ return result; } - private QuestionRenderer getRenderer(Question q, Map rendMap) { - for (Class c = q.getClass(); c != null; c = c.getSuperclass()) { - QuestionRenderer r = (QuestionRenderer) (rendMap.get(c)); + private QuestionRenderer getRenderer(Question q, Map, QuestionRenderer> rendMap) { + for (Class c = q.getClass(); c != null; c = c.getSuperclass()) { + QuestionRenderer r = rendMap.get(c); if (r != null) return r; } diff --git a/src/com/sun/interview/wizard/RenderingUtilities.java b/src/com/sun/interview/wizard/RenderingUtilities.java --- a/src/com/sun/interview/wizard/RenderingUtilities.java +++ b/src/com/sun/interview/wizard/RenderingUtilities.java @@ -75,7 +75,7 @@ private PropertiesQuestion q; public PCE(PropertiesQuestion q) { - cbCE = new PropCellEditor(new JComboBox(), q); + cbCE = new PropCellEditor(new JComboBox(), q); tfCE = new RestrainedCellEditor(new JTextField(), q); this.q = q; } @@ -218,11 +218,11 @@ * for editing. */ public static class PropCellEditor extends DefaultCellEditor { - protected PropCellEditor(JComboBox box) { + protected PropCellEditor(JComboBox box) { super(box); } - PropCellEditor(JComboBox box, PropertiesQuestion q) { + PropCellEditor(JComboBox box, PropertiesQuestion q) { this(box); question = q; } @@ -231,7 +231,7 @@ * For use when this renderer is being used outside the context of * an interview and question. */ - PropCellEditor(JComboBox box, ValueConstraints rules) { + PropCellEditor(JComboBox box, ValueConstraints rules) { this(box); this.rules = rules; } diff --git a/src/com/sun/interview/wizard/SearchDialog.java b/src/com/sun/interview/wizard/SearchDialog.java --- a/src/com/sun/interview/wizard/SearchDialog.java +++ b/src/com/sun/interview/wizard/SearchDialog.java @@ -263,7 +263,7 @@ return b; } - private JComboBox createChoice(final String uiKey, final String[] choiceKeys) { + private JComboBox createChoice(final String uiKey, final String[] choiceKeys) { // create a cache of the presentation string, for use when // rendering, but otherwise, let the JComboBox work in terms of the // choiceKeys @@ -277,7 +277,7 @@ ac.setAccessibleName(i18n.getString(uiKey + ".tip")); choice.setRenderer(new DefaultListCellRenderer() { - public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) { + public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) { Object c = o; for (int i = 0; i < choiceKeys.length; i++) { if (choiceKeys[i] == o) { @@ -329,7 +329,7 @@ private HelpBroker helpBroker; private String helpPrefix; private JTextField textField; - private JComboBox whereChoice; + private JComboBox whereChoice; private JCheckBox caseChk; private JCheckBox wordChk; diff --git a/src/com/sun/interview/wizard/Wizard.java b/src/com/sun/interview/wizard/Wizard.java --- a/src/com/sun/interview/wizard/Wizard.java +++ b/src/com/sun/interview/wizard/Wizard.java @@ -114,7 +114,7 @@ try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); - Class ic = (Class.forName(args[0], true, ClassLoader.getSystemClassLoader())); + Class ic = Class.forName(args[0], true, ClassLoader.getSystemClassLoader()); Interview i = (Interview)(ic.newInstance()); Wizard w = new Wizard(i); w.showInFrame(true); @@ -546,7 +546,7 @@ */ private void perform(String s) { try { - Method m = Wizard.class.getDeclaredMethod(s, new Class[] { }); + Method m = Wizard.class.getDeclaredMethod(s, new Class[] { }); m.invoke(Wizard.this, new Object[] { }); } catch (IllegalAccessException ex) { diff --git a/src/com/sun/javatest/BasicParameters.java b/src/com/sun/javatest/BasicParameters.java --- a/src/com/sun/javatest/BasicParameters.java +++ b/src/com/sun/javatest/BasicParameters.java @@ -800,7 +800,7 @@ return true; } - private static boolean equal(Vector v, TestFilter[] f) { + private static boolean equal(Vector v, TestFilter[] f) { if (f == null || v.size() != f.length) return false; for (int i = 0; i < v.size(); i++) { diff --git a/src/com/sun/javatest/DefaultTestRunner.java b/src/com/sun/javatest/DefaultTestRunner.java --- a/src/com/sun/javatest/DefaultTestRunner.java +++ b/src/com/sun/javatest/DefaultTestRunner.java @@ -42,7 +42,7 @@ */ public class DefaultTestRunner extends TestRunner { - public synchronized boolean runTests(Iterator testIter) + public synchronized boolean runTests(Iterator testIter) throws InterruptedException { this.testIter = testIter; @@ -101,8 +101,7 @@ stopping = true; // stop workers from starting any new tests // interrupt the worker threads - for (Iterator iter = activeThreads.iterator() ; iter.hasNext(); ) { - Thread t = (Thread) (iter.next()); + for (Thread t : activeThreads) { t.interrupt(); } @@ -141,7 +140,7 @@ return null; if (testIter.hasNext()) - return (TestDescription) (testIter.next()); + return (testIter.next()); else { stopping = true; return null; @@ -254,7 +253,7 @@ private static final Integer THROWABLE = new Integer(2); - private Iterator testIter; + private Iterator testIter; private Set activeThreads; private boolean allPassed; private boolean stopping; diff --git a/src/com/sun/javatest/EditJTI.java b/src/com/sun/javatest/EditJTI.java --- a/src/com/sun/javatest/EditJTI.java +++ b/src/com/sun/javatest/EditJTI.java @@ -454,9 +454,9 @@ String interviewClassName = (String) (p.get("INTERVIEW")); try { - Class interviewClass = loader.loadClass(interviewClassName); + Class interviewClass = (Class) loader.loadClass(interviewClassName); - interview = (InterviewParameters)(interviewClass.newInstance()); + interview = interviewClass.newInstance(); } catch (ClassCastException e) { throw new Fault(i18n, "editJTI.invalidInterview", inFile); diff --git a/src/com/sun/javatest/ExcludeList.java b/src/com/sun/javatest/ExcludeList.java --- a/src/com/sun/javatest/ExcludeList.java +++ b/src/com/sun/javatest/ExcludeList.java @@ -383,7 +383,7 @@ */ public void merge(ExcludeList other) { synchronized (table) { - for (Iterator iter = other.getIterator(false); iter.hasNext(); ) { + for (Iterator iter = other.getIterator(false); iter.hasNext(); ) { Entry otherEntry = (Entry) (iter.next()); Key key = new Key(otherEntry.relativeURL); Object o = table.get(key); @@ -527,7 +527,7 @@ * and @link(Entry)[], depending on the group * parameter. */ - public Iterator getIterator(boolean group) { + public Iterator getIterator(boolean group) { if (group) return table.values().iterator(); else { @@ -576,7 +576,7 @@ int maxBugIdWidth = 0; int maxPlatformWidth = 0; SortedSet entries = new TreeSet<>(); - for (Iterator iter = getIterator(false); iter.hasNext(); ) { + for (Iterator iter = getIterator(false); iter.hasNext(); ) { Entry entry = (Entry) (iter.next()); entries.add(entry); if (entry.testCase == null) @@ -936,7 +936,7 @@ /** * An entry in the exclude list. */ - public static final class Entry implements Comparable { + public static final class Entry implements Comparable { /** * Create an ExcludeList entry. * @param u The URL for the test, specified relative to the test suite root. @@ -994,8 +994,7 @@ synopsis = s; } - public int compareTo(Object o) { - Entry e = (Entry) o; + public int compareTo(Entry e) { int n = relativeURL.compareTo(e.relativeURL); if (n == 0) { if (testCase == null && e.testCase == null) diff --git a/src/com/sun/javatest/FileParameters.java b/src/com/sun/javatest/FileParameters.java --- a/src/com/sun/javatest/FileParameters.java +++ b/src/com/sun/javatest/FileParameters.java @@ -309,8 +309,8 @@ envError = i18n.getString("fp.envNotFound", envName); return; } - for (Iterator i = env.elements().iterator(); i.hasNext(); ) { - TestEnvironment.Element entry = (TestEnvironment.Element) (i.next()); + for (Iterator i = env.elements().iterator(); i.hasNext(); ) { + TestEnvironment.Element entry = i.next(); if (entry.value.indexOf("VALUE_NOT_DEFINED") >= 0) { String eText = ( (entry.definedInEnv == null ? "" : "env." + entry.definedInEnv + ".") + diff --git a/src/com/sun/javatest/Harness.java b/src/com/sun/javatest/Harness.java --- a/src/com/sun/javatest/Harness.java +++ b/src/com/sun/javatest/Harness.java @@ -720,12 +720,12 @@ notifier.addObserver(testURLCollector); testsStartTime = System.currentTimeMillis(); try { - ok = r.runTests(new Iterator() { + ok = r.runTests(new Iterator() { public boolean hasNext() { return (stopping ? false : raTestIter.hasNext()); } - public Object next() { - TestResult tr = (TestResult) (raTestIter.next()); + public TestDescription next() { + TestResult tr = raTestIter.next(); try { return tr.getDescription(); } diff --git a/src/com/sun/javatest/HarnessHttpHandler.java b/src/com/sun/javatest/HarnessHttpHandler.java --- a/src/com/sun/javatest/HarnessHttpHandler.java +++ b/src/com/sun/javatest/HarnessHttpHandler.java @@ -221,8 +221,8 @@ String[] pa = new String[0]; - for (Iterator i = env.elements().iterator(); i.hasNext(); ) { - TestEnvironment.Element elem = (TestEnvironment.Element) (i.next()); + for (Iterator i = env.elements().iterator(); i.hasNext(); ) { + TestEnvironment.Element elem = i.next(); // this is stunningly inefficient and should be fixed pa = PropertyArray.put(pa, elem.getKey(), elem.getValue()); } @@ -310,14 +310,14 @@ TestFilter[] filters = params.getFilters(); String[] tests = params.getTests(); - Iterator it = null; + Iterator it = null; if (tests == null || tests.length == 0) it = trt.getIterator(filters); else it = trt.getIterator(params.getTests(), filters); while (it.hasNext()) { - TestResult tr = (TestResult)(it.next()); + TestResult tr = it.next(); out.println(tr.getTestName()); out.println(tr.getStatus().toString()); } // while @@ -544,8 +544,8 @@ buf.append(""); out.println(buf.toString()); - for (Iterator keys = env.keys().iterator(); keys.hasNext(); ) { - String key = (String) (keys.next()); + for (Iterator keys = env.keys().iterator(); keys.hasNext(); ) { + String key = keys.next(); out.println(""); buf.setLength(0); buf.append(""); diff --git a/src/com/sun/javatest/InterviewParameters.java b/src/com/sun/javatest/InterviewParameters.java --- a/src/com/sun/javatest/InterviewParameters.java +++ b/src/com/sun/javatest/InterviewParameters.java @@ -799,7 +799,7 @@ return true; } - private static boolean equal(Vector v, TestFilter[] f) { + private static boolean equal(Vector v, TestFilter[] f) { if (f == null || v.size() != f.length) return false; for (int i = 0; i < v.size(); i++) { diff --git a/src/com/sun/javatest/JavaTestSecurityManager.java b/src/com/sun/javatest/JavaTestSecurityManager.java --- a/src/com/sun/javatest/JavaTestSecurityManager.java +++ b/src/com/sun/javatest/JavaTestSecurityManager.java @@ -154,7 +154,7 @@ // These methods are added for forward-compatibility with JDK1.1 public void checkAwtEventQueueAccess() { } - public void checkMemberAccess(Class clazz, int which) { } + public void checkMemberAccess(Class clazz, int which) { } public void checkMulticast(InetAddress maddr) { } public void checkMulticast(InetAddress maddr, byte ttl) { } public void checkPrintJobAccess() { } diff --git a/src/com/sun/javatest/Keywords.java b/src/com/sun/javatest/Keywords.java --- a/src/com/sun/javatest/Keywords.java +++ b/src/com/sun/javatest/Keywords.java @@ -105,8 +105,8 @@ * @return A Keywords object for the specified type and text. * @throws Keywords.Fault if there are errors in the arguments. */ - public static Keywords create(String type, String text, Set validKeywords) throws Fault { - Set lowerCaseValidKeywords = toLowerCase(validKeywords); + public static Keywords create(String type, String text, Set validKeywords) throws Fault { + Set lowerCaseValidKeywords = toLowerCase(validKeywords); if (text == null) { text = ""; } @@ -191,13 +191,13 @@ */ public abstract boolean accepts(Set s); - private static Set toLowerCase(Set words) { + private static Set toLowerCase(Set words) { if (words == null) return null; boolean allLowerCase = true; - for (Iterator iter = words.iterator(); iter.hasNext() && allLowerCase; ) { - String word = (String) (iter.next()); + for (Iterator iter = words.iterator(); iter.hasNext() && allLowerCase; ) { + String word = iter.next(); allLowerCase &= word.equals(word.toLowerCase()); } @@ -205,8 +205,8 @@ return words; Set s = new HashSet<>(); - for (Iterator iter = words.iterator(); iter.hasNext(); ) { - String word = (String) (iter.next()); + for (Iterator iter = words.iterator(); iter.hasNext(); ) { + String word = iter.next(); s.add(word.toLowerCase()); } @@ -234,7 +234,7 @@ Set keys; String allKwds = ""; // string to be used by toString() - SetKeywords(String[] kwds, Set validKeywords) throws Keywords.Fault { + SetKeywords(String[] kwds, Set validKeywords) throws Keywords.Fault { if (kwds.length == 0) { throw new Keywords.Fault(i18n, "kw.noKeywords"); } @@ -278,7 +278,7 @@ } class AllKeywords extends SetKeywords { - AllKeywords(String[] keys, Set validKeywords) throws Keywords.Fault { + AllKeywords(String[] keys, Set validKeywords) throws Keywords.Fault { super(keys, validKeywords); } @@ -301,7 +301,7 @@ class AnyKeywords extends SetKeywords { - AnyKeywords(String[] keys, Set validKeywords) throws Keywords.Fault { + AnyKeywords(String[] keys, Set validKeywords) throws Keywords.Fault { super(keys, validKeywords); } @@ -328,7 +328,7 @@ //------------------------------------------------------------------------------ class ExprParser { - ExprParser(String text, Set validKeywords) { + ExprParser(String text, Set validKeywords) { this.text = text; this.validKeywords = validKeywords; nextToken(); @@ -437,7 +437,7 @@ protected static boolean allowNumericKeywords = Boolean.getBoolean("javatest.allowNumericKeywords"); private String text; - private Set validKeywords; + private Set validKeywords; private int index; private int token; private String idValue; diff --git a/src/com/sun/javatest/KnownFailuresList.java b/src/com/sun/javatest/KnownFailuresList.java --- a/src/com/sun/javatest/KnownFailuresList.java +++ b/src/com/sun/javatest/KnownFailuresList.java @@ -277,7 +277,7 @@ // flatten the enumeration into a vector, then // enumerate that List v = new ArrayList<>(table.size()); - for (Iterator iter = table.values().iterator(); iter.hasNext(); ) { + for (Iterator iter = table.values().iterator(); iter.hasNext(); ) { Object o = iter.next(); if (o instanceof Entry) v.add((Entry)o); @@ -302,8 +302,8 @@ */ public void merge(KnownFailuresList other) { synchronized (table) { - for (Iterator iter = other.getIterator(false); iter.hasNext(); ) { - Entry otherEntry = (Entry) (iter.next()); + for (Iterator iter = other.getIterator(false); iter.hasNext(); ) { + Entry otherEntry = iter.next(); Key key = new Key(otherEntry.relativeURL); Object o = table.get(key); if (o == null) { @@ -707,7 +707,7 @@ /** * An entry in the exclude list. */ - public static final class Entry implements Comparable { + public static final class Entry implements Comparable { /** * Create an ExcludeList entry. * @param u The URL for the test, specified relative to the test suite root. @@ -732,8 +732,7 @@ notes = s; } - public int compareTo(Object o) { - Entry e = (Entry) o; + public int compareTo(Entry e) { int n = relativeURL.compareTo(e.relativeURL); if (n == 0) { if (testCase == null && e.testCase == null) diff --git a/src/com/sun/javatest/LastRunInfo.java b/src/com/sun/javatest/LastRunInfo.java --- a/src/com/sun/javatest/LastRunInfo.java +++ b/src/com/sun/javatest/LastRunInfo.java @@ -141,8 +141,8 @@ return ""; } StringBuffer sb = new StringBuffer(); - for (Iterator it = list.iterator(); it.hasNext();) { - sb.append((String)it.next()); + for (Iterator it = list.iterator(); it.hasNext();) { + sb.append(it.next()); sb.append(SEP); } diff --git a/src/com/sun/javatest/ResourceLoader.java b/src/com/sun/javatest/ResourceLoader.java --- a/src/com/sun/javatest/ResourceLoader.java +++ b/src/com/sun/javatest/ResourceLoader.java @@ -45,7 +45,7 @@ public class ResourceLoader { - public static Enumeration getResources(String name, Class ownClass) throws IOException { + public static Enumeration getResources(String name, Class ownClass) throws IOException { URL extResource = getExtResource(name, null); if (extResource != null) { Vector r = new Vector<>(); @@ -55,7 +55,7 @@ return ownClass.getClassLoader().getResources(name); } - public static InputStream getResourceAsStream(final String name, final Class ownClass) { + public static InputStream getResourceAsStream(final String name, final Class ownClass) { URL url = getExtResource(name, ownClass); try { if (url != null) { @@ -75,7 +75,7 @@ } } - public static File getResourceFile(String name, Class ownClass) { + public static File getResourceFile(String name, Class ownClass) { File f = getExtResourceFile(name, ownClass); if (f != null) { return f; @@ -101,7 +101,7 @@ return url; } - private static URL getExtResource(String name, Class ownClass) { + private static URL getExtResource(String name, Class ownClass) { URL ret = null; File rf = getExtResourceFile(name, ownClass); if (rf != null) { @@ -114,7 +114,7 @@ return ret; } - private static File getExtResourceFile(String name, Class ownClass) { + private static File getExtResourceFile(String name, Class ownClass) { if (ext != null) { String relName; if (ownClass == null) { @@ -133,7 +133,7 @@ // get from java.lang.Class with minimal changes - private static String resolveName(String name, Class baseClass) { + private static String resolveName(String name, Class baseClass) { if (name == null || baseClass == null) { return name; } diff --git a/src/com/sun/javatest/Script.java b/src/com/sun/javatest/Script.java --- a/src/com/sun/javatest/Script.java +++ b/src/com/sun/javatest/Script.java @@ -1040,7 +1040,7 @@ // says in the environment file: Command testCommand; try { - Class c = (loader == null ? Class.forName(className) : loader.loadClass(className)); + Class c = (loader == null ? Class.forName(className) : loader.loadClass(className)); testCommand = (Command)(c.newInstance()); } catch (ClassCastException e) { diff --git a/src/com/sun/javatest/TRT_HttpHandler.java b/src/com/sun/javatest/TRT_HttpHandler.java --- a/src/com/sun/javatest/TRT_HttpHandler.java +++ b/src/com/sun/javatest/TRT_HttpHandler.java @@ -141,9 +141,9 @@ } else { */ - Iterator it = trt.getIterator(); + Iterator it = trt.getIterator(); while (it.hasNext()) { - TestResult tr = (TestResult)(it.next()); + TestResult tr = it.next(); String url; try { url = tr.getDescription().getRootRelativeURL(); diff --git a/src/com/sun/javatest/TestDescription.java b/src/com/sun/javatest/TestDescription.java --- a/src/com/sun/javatest/TestDescription.java +++ b/src/com/sun/javatest/TestDescription.java @@ -91,7 +91,7 @@ rootRelativePath = rootRelativeFile.replace(File.separatorChar, '/'); Vector v = new Vector<>(0, params.size() * 2); - for (Map.Entry entry : params.entrySet()) { + for (Map.Entry entry : params.entrySet()) { insert(v, (String) entry.getKey(), (String) entry.getValue()); } fields = new String[v.size()]; diff --git a/src/com/sun/javatest/TestEnvContext.java b/src/com/sun/javatest/TestEnvContext.java --- a/src/com/sun/javatest/TestEnvContext.java +++ b/src/com/sun/javatest/TestEnvContext.java @@ -93,7 +93,7 @@ * that will be used to identify the source of the properties in any * environments that are created */ - public TestEnvContext(Map[] tables, String[] tableNames) { + public TestEnvContext(Map[] tables, String[] tableNames) { Vector n = new Vector<>(); Vector> p = new Vector<>(); for (int i = 0; i < tables.length; i++) { @@ -112,7 +112,7 @@ * @param tableName The name that will be used to identify the source * of the properties in any environments that are created. */ - public TestEnvContext(Map table, String tableName) { + public TestEnvContext(Map table, String tableName) { Vector n = new Vector<>(); Vector> p = new Vector<>(); add(p, n, table, tableName); @@ -235,11 +235,11 @@ private void updateEnvTable() { // the tables given to the constructor ... - Map[] tables = propTables; + Map[] tables = propTables; String[] tableNames = propTableNames; // defaults given to TestEnvironment - Map[] defaultTables = TestEnvironment.defaultPropTables; + Map[] defaultTables = TestEnvironment.defaultPropTables; String[] defaultTableNames = TestEnvironment.defaultPropTableNames; // if there are defaults, merge them with the TestEnvContext tables @@ -269,9 +269,9 @@ if (debug) System.err.println("Checking " + tableNames[i] + " for environments..."); - Map table = tables[i]; - for (Iterator ii = table.keySet().iterator(); ii.hasNext(); ) { - String prop = (String) (ii.next()); + Map table = tables[i]; + for (Iterator ii = table.keySet().iterator(); ii.hasNext(); ) { + String prop = (ii.next()); String name = null; if (debug) @@ -285,7 +285,7 @@ } else if (prop.endsWith(DOT_MENU)) { name = prop.substring(ENV_DOT.length(), prop.length() - DOT_MENU.length()); - String value = (String) (table.get(prop)); + String value = (table.get(prop)); if ("false".equals(value)) sortedInsert(menuExcludeVec, name); } @@ -341,7 +341,7 @@ v.addElement(s); } - private Map[] propTables; + private Map[] propTables; private String[] propTableNames; private String[] envNames; private String[] envMenuNames; diff --git a/src/com/sun/javatest/TestEnvironment.java b/src/com/sun/javatest/TestEnvironment.java --- a/src/com/sun/javatest/TestEnvironment.java +++ b/src/com/sun/javatest/TestEnvironment.java @@ -117,7 +117,7 @@ } static String[] defaultPropTableNames = { }; - static Map[] defaultPropTables = { }; + static Map[] defaultPropTables = new Map[0]; /** * Construct an environment for a named group of properties. @@ -130,7 +130,7 @@ * @throws TestEnvironment.Fault if there is an error in the table * */ - public TestEnvironment(String name, Map propTable, String propTableName) + public TestEnvironment(String name, Map propTable, String propTableName) throws Fault { this(name, (new Map[] {propTable}), (new String[] {propTableName})); } @@ -178,14 +178,14 @@ for (int inheritIndex = 0; inheritIndex < inherits.length; inheritIndex++) { String prefix = "env." + inherits[inheritIndex] + "."; for (int propIndex = propTables.length - 1; propIndex >= 0; propIndex--) { - Map propTable = propTables[propIndex]; - for (Iterator i = propTable.keySet().iterator(); i.hasNext(); ) { - String prop = (String) (i.next()); + Map propTable = propTables[propIndex]; + for (Iterator i = propTable.keySet().iterator(); i.hasNext(); ) { + String prop = (i.next()); if (prop.startsWith(prefix)) { String key = prop.substring(prefix.length()); if (!table.containsKey(key)) { Element elem = new Element(key, - (String)(propTable.get(prop)), + (propTable.get(prop)), inherits[inheritIndex], propTableNames[propIndex]); table.put(key, elem); @@ -197,13 +197,13 @@ // finally, add in any top-level names (not beginning with env.) for (int propIndex = propTables.length - 1; propIndex >= 0; propIndex--) { - Map propTable = propTables[propIndex]; - for (Iterator i = propTable.keySet().iterator(); i.hasNext(); ) { - String key = (String) (i.next()); + Map propTable = propTables[propIndex]; + for (Iterator i = propTable.keySet().iterator(); i.hasNext(); ) { + String key = (i.next()); if (!key.startsWith("env.")) { if (!table.containsKey(key)) { Element elem = new Element(key, - (String)(propTable.get(key)), + (propTable.get(key)), null, propTableNames[propIndex]); table.put(key, elem); @@ -558,8 +558,8 @@ * VALUE_NOT_DEFINED. */ public boolean hasUndefinedValues() { - for (Iterator i = elements().iterator(); i.hasNext(); ) { - TestEnvironment.Element entry = (TestEnvironment.Element) (i.next()); + for (Iterator i = elements().iterator(); i.hasNext(); ) { + Element entry = i.next(); if (entry.value.indexOf("VALUE_NOT_DEFINED") >= 0) return true; } @@ -625,7 +625,7 @@ * include the `env.environment-name.' prefix of the corresponding * property names. */ - public Set keys() { + public Set keys() { return table.keySet(); } @@ -637,7 +637,7 @@ * referenced. * @see #resetElementsUsed */ - public Collection elementsUsed() { + public Collection elementsUsed() { return cache.values(); } @@ -655,7 +655,7 @@ * @return An enumeration that yields the various elements, explicit or inherited, * that are available in this environment. */ - public Collection elements() { + public Collection elements() { return table.values(); } diff --git a/src/com/sun/javatest/TestFinder.java b/src/com/sun/javatest/TestFinder.java --- a/src/com/sun/javatest/TestFinder.java +++ b/src/com/sun/javatest/TestFinder.java @@ -515,7 +515,7 @@ System.err.println("Found TestDescription"); System.err.println("--------values----------------------------"); - for (Iterator i = entries.keySet().iterator() ; i.hasNext() ;) { + for (Iterator i = entries.keySet().iterator() ; i.hasNext() ;) { Object key = i.next(); System.err.println(">> " + key + ": " + entries.get(key) ); } diff --git a/src/com/sun/javatest/TestFinderQueue.java b/src/com/sun/javatest/TestFinderQueue.java --- a/src/com/sun/javatest/TestFinderQueue.java +++ b/src/com/sun/javatest/TestFinderQueue.java @@ -186,7 +186,7 @@ // build up the fifo of tests to be used by readNextFile - tests = new Fifo(); + tests = new Fifo<>(); currInitialFile = null; for (int pass = 0; pass < 2; pass++) { @@ -233,7 +233,7 @@ */ public void repeat(TestDescription[] tds) { if (tests == null) - tests = new Fifo(); // for now + tests = new Fifo<>(); // for now for (int i = 0; i < tds.length; i++) { TestDescription td = tds[i]; testDescsFound.insert(td); @@ -258,7 +258,7 @@ // read files until there is a test description available or there // are no more files. - while ((td = (TestDescription)(testDescsFound.remove())) == null) { + while ((td = testDescsFound.remove()) == null) { boolean ok = readNextFile(); if (!ok) return null; @@ -507,7 +507,7 @@ // are there any more tests that have not been read? // check until we find one (just one). while (filesToRead.isEmpty() && !tests.isEmpty()) { - currInitialFile = (File)tests.remove(); + currInitialFile = tests.remove(); foundFile(currInitialFile); } @@ -687,7 +687,7 @@ private TestFinder testFinder; - private Fifo tests; + private Fifo tests; private TestFilter[] filters; private String selectedId; private File rootDir; @@ -697,7 +697,7 @@ private Vector filesToRead = new Vector<>(32, 8); private int fileInsertPosn; - private Fifo testDescsFound = new Fifo(); + private Fifo testDescsFound = new Fifo<>(); private int filesRemainingCount; private int filesDoneCount; private int testsDoneCount; diff --git a/src/com/sun/javatest/TestResult.java b/src/com/sun/javatest/TestResult.java --- a/src/com/sun/javatest/TestResult.java +++ b/src/com/sun/javatest/TestResult.java @@ -950,8 +950,8 @@ throw new IllegalStateException( "This TestResult is no longer mutable!"); } - for (Iterator i = environment.elementsUsed().iterator(); i.hasNext(); ) { - TestEnvironment.Element elem = (TestEnvironment.Element) (i.next()); + for (Iterator i = environment.elementsUsed().iterator(); i.hasNext(); ) { + TestEnvironment.Element elem = i.next(); // this is stunningly inefficient and should be fixed env = PropertyArray.put(env, elem.getKey(), elem.getValue()); } @@ -1301,7 +1301,7 @@ * Get the keys of the properties that this object has stored. * @return the keys of the properties that this object has stored */ - public synchronized Enumeration getPropertyNames() { + public synchronized Enumeration getPropertyNames() { return PropertyArray.enumerate(props); } @@ -1332,7 +1332,7 @@ * recreating data from the results file. * @see #setEnvironment */ - public synchronized Map getEnvironment() throws Fault { + public synchronized Map getEnvironment() throws Fault { if (env == null) { // reconstitute environment // this may result in a Fault, which is okay @@ -1982,10 +1982,10 @@ private static long computeChecksum(TestDescription td) { long cs = 0; - for (Iterator i = td.getParameterKeys(); i.hasNext(); ) { + for (Iterator i = td.getParameterKeys(); i.hasNext(); ) { // don't rely on enumeration in a particular order // so simply add the checksum products together - String key = (String) (i.next()); + String key = (i.next()); cs += computeChecksum(key) * computeChecksum(td.getParameter(key)); } return cs; @@ -2557,14 +2557,14 @@ // if this object is in the list; remove it; // if there are dead weak refs, remove them for (Iterator> iter = shrinkList.iterator(); iter.hasNext(); ) { - WeakReference wref = iter.next(); + WeakReference wref = iter.next(); Object o = wref.get(); if (o == null || o == this) iter.remove(); } while (shrinkList.size() >= maxShrinkListSize) { - WeakReference wref = shrinkList.removeFirst(); - TestResult tr = (TestResult) (wref.get()); + WeakReference wref = shrinkList.removeFirst(); + TestResult tr = wref.get(); if (tr != null) tr.shrink(); } diff --git a/src/com/sun/javatest/TestResultCache.java b/src/com/sun/javatest/TestResultCache.java --- a/src/com/sun/javatest/TestResultCache.java +++ b/src/com/sun/javatest/TestResultCache.java @@ -676,7 +676,7 @@ // it till its empty, even though some tests may even have been added // after the worker woke up TestResult tr; - while ((tr = (TestResult) (testsToWrite.remove())) != null) { + while ((tr = testsToWrite.remove()) != null) { // check if test is in the set we've just read String name = tr.getTestName(); TestResult tr2 = tests.get(name); @@ -694,8 +694,8 @@ lastSerial = (int) ((now >> 16) + (now & 0xffff)); raf.writeInt(lastSerial); - for (Iterator iter = tests.values().iterator(); iter.hasNext(); ) { - tr = (TestResult) (iter.next()); + for (Iterator iter = tests.values().iterator(); iter.hasNext(); ) { + tr = iter.next(); writeCacheEntry(tr); } @@ -714,7 +714,7 @@ int debugCount = 0; raf.seek(lastFileSize); TestResult tr; - while ((tr = (TestResult) (testsToWrite.remove())) != null) { + while ((tr = testsToWrite.remove()) != null) { if (tests != null) { // check if test is in the set we've just read String name = tr.getTestName(); @@ -883,7 +883,7 @@ private boolean compressRequested; private boolean flushRequested; private boolean shutdownRequested; - private Fifo testsToWrite = new Fifo(); + private Fifo testsToWrite = new Fifo<>(); private static final String V1_FILENAME = "ResultCache.jtw"; private static final String V1_LOCKNAME = V1_FILENAME + ".lck"; diff --git a/src/com/sun/javatest/TestResultTable.java b/src/com/sun/javatest/TestResultTable.java --- a/src/com/sun/javatest/TestResultTable.java +++ b/src/com/sun/javatest/TestResultTable.java @@ -703,7 +703,7 @@ * @see #getIterator() * @since 3.0 */ - public Enumeration elements() { + public Enumeration elements() { return getIterator(); } @@ -733,7 +733,7 @@ * @since 3.0 * @see #getIterator() */ - public Enumeration elements(TestFilter[] filters) { + public Enumeration elements(TestFilter[] filters) { return getIterator(filters); } @@ -759,7 +759,7 @@ * @see #getIterator() * @since 3.0 */ - public static Enumeration elements(TreeNode node) { + public static Enumeration elements(TreeNode node) { return getIterator(node); } @@ -796,7 +796,7 @@ * @see #getIterator() * @since 3.0 */ - public static Enumeration elements(TreeNode node, TestFilter filter) { + public static Enumeration elements(TreeNode node, TestFilter filter) { return getIterator(node, filter); } @@ -829,7 +829,7 @@ * @see #getIterator() * @since 3.0 */ - public static Enumeration elements(TreeNode node, TestFilter[] filters) { + public static Enumeration elements(TreeNode node, TestFilter[] filters) { return getIterator(node, filters); } @@ -850,7 +850,7 @@ * @see #getIterator() * @since 3.0 */ - public Enumeration elements(String url, TestFilter[] filters) { + public Enumeration elements(String url, TestFilter[] filters) { if (url == null) return NullEnum.getInstance(); else { @@ -898,7 +898,7 @@ * @see #getIterator() * @since 3.0 */ - public Enumeration elements(File[] tests, TestFilter[] filters) throws Fault { + public Enumeration elements(File[] tests, TestFilter[] filters) throws Fault { return getIterator(tests, filters); } @@ -985,7 +985,7 @@ * @see #getIterator() * @since 3.0 */ - public Enumeration elements(String[] urls, TestFilter[] filters) { + public Enumeration elements(String[] urls, TestFilter[] filters) { return getIterator(urls, filters); } diff --git a/src/com/sun/javatest/TestRunner.java b/src/com/sun/javatest/TestRunner.java --- a/src/com/sun/javatest/TestRunner.java +++ b/src/com/sun/javatest/TestRunner.java @@ -200,7 +200,7 @@ * @return true if and only if all the tests executed successfully and passed * @throws InterruptedException if the test run was interrupted */ - protected abstract boolean runTests(Iterator testIter) throws InterruptedException; + protected abstract boolean runTests(Iterator testIter) throws InterruptedException; /** * This method must be called as each test is started, to notify any diff --git a/src/com/sun/javatest/TestSuite.java b/src/com/sun/javatest/TestSuite.java --- a/src/com/sun/javatest/TestSuite.java +++ b/src/com/sun/javatest/TestSuite.java @@ -216,11 +216,8 @@ File f = new File(canonRootDir, TESTSUITE_JTT); if (isReadableFile(f)) { - try { - Properties p = new Properties(); - InputStream in = new BufferedInputStream(new FileInputStream(f)); - p.load(in); - in.close(); + try (InputStream in = new BufferedInputStream(new FileInputStream(f))) { + Map p = com.sun.javatest.util.Properties.load(in); return open(canonRoot, p); } catch (IOException e) { @@ -233,7 +230,7 @@ File parentDir = canonRootDir.getParentFile(); File parent_jtt = (parentDir == null ? null : new File(parentDir, TESTSUITE_JTT)); if (isReadableFile(ts_html) && (parent_jtt == null || !parent_jtt.exists())) - return open(canonRoot, new HashMap()); + return open(canonRoot, new HashMap()); else throw new NotTestSuiteFault(i18n, "ts.notTestSuiteFile", canonRoot); } @@ -246,7 +243,7 @@ * @return A TestSuite object for the test suite in question. * @throws TestSuite.Fault if any problems occur while opening the test suite */ - private static TestSuite open(File root, Map tsInfo) throws Fault { + private static TestSuite open(File root, Map tsInfo) throws Fault { synchronized (dirMap) { TestSuite ts; @@ -268,8 +265,8 @@ } } - private static TestSuite open0(File root, Map tsInfo) throws Fault { - String[] classPath = StringArray.split((String) (tsInfo.get("classpath"))); + private static TestSuite open0(File root, Map tsInfo) throws Fault { + String[] classPath = StringArray.split(tsInfo.get("classpath")); ClassLoader cl; if (classPath.length == 0) @@ -297,7 +294,7 @@ } } - String[] tsClassAndArgs = StringArray.split((String) (tsInfo.get("testsuite"))); + String[] tsClassAndArgs = StringArray.split(tsInfo.get("testsuite")); TestSuite testSuite; if (tsClassAndArgs.length == 0) @@ -306,8 +303,8 @@ String className = tsClassAndArgs[0]; try { - Class c = loadClass(className, cl); - Class[] tsArgTypes = {File.class, Map.class, ClassLoader.class}; + Class c = loadClass(className, cl); + Class[] tsArgTypes = {File.class, Map.class, ClassLoader.class}; Object[] tsArgs = {root, tsInfo, cl}; testSuite = (TestSuite)(newInstance(c, tsArgTypes, tsArgs)); } @@ -365,12 +362,12 @@ * typically using a class path defined in the test suite properties file. * @throws TestSuite.Fault if a problem occurs while creating this test suite. */ - public TestSuite(File root, Map tsInfo, ClassLoader cl) throws Fault { + public TestSuite(File root, Map tsInfo, ClassLoader cl) throws Fault { this.root = root; this.tsInfo = tsInfo; this.loader = cl; - String kw = (tsInfo == null ? null : (String) (tsInfo.get("keywords"))); + String kw = (tsInfo == null ? null : tsInfo.get("keywords")); keywords = (kw == null ? null : StringArray.split(kw)); } @@ -440,7 +437,7 @@ * @return the directory that contains the tests */ public File getTestsDir() { - String t = (String) (tsInfo == null ? null : tsInfo.get("tests")); + String t = (tsInfo == null ? null : tsInfo.get("tests")); if (t == null || t.length() == 0) { File rootDir = getRootDir(); File testsDir = new File(rootDir, "tests"); @@ -551,7 +548,7 @@ File testsDir = getTestsDir(); // no BTF file; look for a finder=class args... entry - String[] finderCmd = StringArray.split((String) (tsInfo.get("finder"))); + String[] finderCmd = StringArray.split((tsInfo.get("finder"))); String finderClassName; String[] finderArgs = new String[0]; @@ -573,7 +570,7 @@ } // first, try looking for testsuite.jtd - String jtd = (String) (tsInfo.get("testsuite.jtd")); + String jtd = tsInfo.get("testsuite.jtd"); File jtdFile = (jtd == null ? new File(testsDir, "testsuite.jtd") : new File(root, jtd)); if (jtdFile.exists()) { try { @@ -591,7 +588,7 @@ } try { - Class c = loadClass(finderClassName); + Class c = loadClass(finderClassName); TestFinder tf = (TestFinder) (newInstance(c)); // called old deprecated entry till we know no-one cares //tf.init(finderArgs, testsRoot, null, null, tsInfo/*pass in env?*/); @@ -631,7 +628,7 @@ TestFinder tf = null; if (finderClassName != null) { - Class c = loadClass(finderClassName); + Class c = loadClass(finderClassName); tf = (TestFinder) (newInstance(c)); } @@ -697,7 +694,7 @@ if (scriptClass == null) { String[] script = envLookup(scriptEnv, "script"); if (script.length == 0) - script = StringArray.split((String) tsInfo.get("script")); + script = StringArray.split(tsInfo.get("script")); if (script.length > 0) { scriptClass = loadClass(script[0]); if (!Script.class.isAssignableFrom(scriptClass)) { @@ -711,8 +708,8 @@ // for backwards compatibility, // see if KeywordScript is a reasonable default boolean keywordScriptOK = false; - for (Iterator i = scriptEnv.keys().iterator(); i.hasNext() && !keywordScriptOK; ) { - String key = (String)(i.next()); + for (Iterator i = scriptEnv.keys().iterator(); i.hasNext() && !keywordScriptOK; ) { + String key = i.next(); keywordScriptOK = key.startsWith("script."); } if (keywordScriptOK) { @@ -758,7 +755,7 @@ public InterviewParameters createInterview() throws Fault { - String[] classNameAndArgs = StringArray.split((String) (tsInfo.get("interview"))); + String[] classNameAndArgs = StringArray.split((tsInfo.get("interview"))); if (classNameAndArgs == null || classNameAndArgs.length == 0) { try { return new LegacyParameters(this); @@ -775,7 +772,7 @@ System.arraycopy(classNameAndArgs, 1, args, 0, args.length); try { - Class c = loadClass(className); + Class c = loadClass(className); InterviewParameters p = (InterviewParameters) (newInstance(c)); p.init(args); p.setTestSuite(this); @@ -842,7 +839,7 @@ * @see #getName */ public String getID() { - return (tsInfo == null ? null : (String) (tsInfo.get("id"))); + return (tsInfo == null ? null : tsInfo.get("id")); } /** @@ -854,7 +851,7 @@ * @see #getID */ public String getName() { - return (tsInfo == null ? null : (String) (tsInfo.get("name"))); + return (tsInfo == null ? null : tsInfo.get("name")); } /** @@ -867,7 +864,7 @@ public int getEstimatedTestCount() { try { if (tsInfo != null) { - String s = (String) (tsInfo.get("testCount")); + String s = tsInfo.get("testCount"); if (s != null) return Integer.parseInt(s); } @@ -886,7 +883,7 @@ * @return the name of the default exclude list, or null if none specified. */ public File getInitialExcludeList() { - String s = (tsInfo == null ? null : (String) (tsInfo.get("initial.jtx"))); + String s = (tsInfo == null ? null : tsInfo.get("initial.jtx")); if (s == null) return null; @@ -917,7 +914,7 @@ */ public URL getLatestExcludeList() { try { - String s = (tsInfo == null ? null : (String) (tsInfo.get("latest.jtx"))); + String s = (tsInfo == null ? null : tsInfo.get("latest.jtx")); return (s == null ? null : new URL(s)); } catch (MalformedURLException e) { @@ -955,7 +952,7 @@ public String[] getAdditionalDocNames() { return (tsInfo == null ? null - : StringArray.split((String) (tsInfo.get("additionalDocs")))); + : StringArray.split((tsInfo.get("additionalDocs")))); } /** @@ -1010,7 +1007,7 @@ */ public URL getLogo() { try { - String s = (tsInfo == null ? null : (String) (tsInfo.get("logo"))); + String s = (tsInfo == null ? null : tsInfo.get("logo")); return (s == null ? null : new URL(getRootDir().toURL(), s)); } catch (MalformedURLException e) { @@ -1037,7 +1034,7 @@ * @throws TestSuite.Fault if any errors arise while trying to instantiate * the class. */ - protected static Object newInstance(Class c) throws Fault { + protected static Object newInstance(Class c) throws Fault { try { return c.newInstance(); } @@ -1063,7 +1060,7 @@ * @throws TestSuite.Fault if any errors arise while trying to instantiate * the class. */ - protected static Object newInstance(Class c, Class[] argTypes, Object[] args) + protected static Object newInstance(Class c, Class[] argTypes, Object[] args) throws Fault { try { @@ -1087,7 +1084,7 @@ catch (NoSuchMethodException e) { // don't recurse past the use of a single arg constructor if (argTypes.length > 1 && Boolean.getBoolean(FIND_LEGACY_CONSTRUCTOR)) { - return newInstance(c, new Class[] {File.class}, new Object[] {args[0]}); + return newInstance(c, new Class[] {File.class}, new Object[] {args[0]}); } throw new Fault(i18n, "ts.cantFindConstructor", @@ -1101,7 +1098,7 @@ * @return the class that was loaded * @throws TestSuite.Fault if there was a problem loading the specified class */ - public Class loadClass(String className) throws Fault { + public Class loadClass(String className) throws Fault { return loadClass(className, loader); } @@ -1113,7 +1110,7 @@ * @return the class that was loaded * @throws TestSuite.Fault if there was a problem loading the specified class */ - protected static Class loadClass(String className, ClassLoader cl) throws Fault { + protected static Class loadClass(String className, ClassLoader cl) throws Fault { try { if (cl == null) return Class.forName(className); @@ -1169,7 +1166,7 @@ */ boolean isLegacy = false; try { - Method m = sr.getClass().getMethod("getServiceDescriptorFileName", new Class[0]); + Method m = sr.getClass().getMethod("getServiceDescriptorFileName", new Class[0]); if (Modifier.isAbstract(m.getModifiers())) { isLegacy = true; } @@ -1193,11 +1190,11 @@ return serviceReader; } - String servInfo = (String)tsInfo.get("serviceReader"); + String servInfo = tsInfo.get("serviceReader"); if (servInfo != null) { String[] args = servInfo.split(" "); try { - Class c = loadClass(args[0]); + Class c = loadClass(args[0]); serviceReader = (ServiceReader) (newInstance(c)); if (args.length > 1) { // problem with java1.5, which has no Arrays.copyOfRange(); @@ -1227,7 +1224,7 @@ * Get a map containing the test suite data in the .jtt file. * @return a map containing the test suite data in the .jtt file */ - protected Map getTestSuiteInfo() { + protected Map getTestSuiteInfo() { return tsInfo; } @@ -1240,7 +1237,7 @@ if (tsInfo == null) return null; else - return (String) (tsInfo.get(name)); + return (tsInfo.get(name)); } /** @@ -1483,12 +1480,12 @@ private static final String FIND_LEGACY_CONSTRUCTOR = "com.sun.javatest.ts.findLegacyCtor"; private File root; - private Map tsInfo; + private Map tsInfo; private ClassLoader loader; private TestFinder finder; // the following are used by the default impl of createScript - private Class scriptClass; + private Class scriptClass; private String[] scriptArgs; private String[] keywords; diff --git a/src/com/sun/javatest/WorkDirectory.java b/src/com/sun/javatest/WorkDirectory.java --- a/src/com/sun/javatest/WorkDirectory.java +++ b/src/com/sun/javatest/WorkDirectory.java @@ -364,9 +364,9 @@ return false; } - private static void undo(ArrayList undoList) { + private static void undo(ArrayList undoList) { for (int i = undoList.size() - 1; i >= 0; i--) { - File f = (File) (undoList.get(i)); + File f = undoList.get(i); delete(f); } } @@ -445,7 +445,7 @@ try { // try to calculate relocation - String oldWDpath = loadWdInfo(jtData).getProperty(PREV_WD_PATH); + String oldWDpath = loadWdInfo(jtData).get(PREV_WD_PATH); String[] begins = getDiffInPaths(dir.getPath(), oldWDpath); if (begins != null) { if (templateFile.startsWith(begins[1])) { @@ -551,18 +551,18 @@ synchronized (dirMap) { // sync-ed to make dirMap data consistent - WeakReference ref = (WeakReference)(dirMap.get(canonDir)); - wd = (ref == null ? null : (WorkDirectory) (ref.get())); + WeakReference ref = dirMap.get(canonDir); + wd = (ref == null ? null : ref.get()); if (wd != null) return wd; - Properties tsInfo; + Map tsInfo; TestSuite ts; try { tsInfo = loadTestSuiteInfo(jtData); - String root = tsInfo.getProperty(TESTSUITE_ROOT); + String root = tsInfo.get(TESTSUITE_ROOT); if (root == null) throw new BadDirectoryFault(i18n, "wd.noTestSuiteRoot", canonDir); @@ -572,7 +572,7 @@ ts = TestSuite.open(tsr); - String wdID = (tsInfo == null ? null : (String) (tsInfo.get(TESTSUITE_ID))); + String wdID = (tsInfo == null ? null : tsInfo.get(TESTSUITE_ID)); String tsID = ts.getID(); if (!(wdID == null ? "" : wdID).equals(tsID == null ? "" : tsID)) throw new MismatchFault(i18n, "wd.mismatchID", canonDir); @@ -633,19 +633,19 @@ WorkDirectory wd = null; synchronized (dirMap) { - WeakReference ref = (WeakReference)(dirMap.get(canonDir)); + WeakReference ref = dirMap.get(canonDir); if (ref != null) - wd = (WorkDirectory)(ref.get()); + wd = ref.get(); if (wd == null) { - Properties tsInfo; + Map tsInfo; try { tsInfo = loadTestSuiteInfo(jtData); } catch (IOException e) { tsInfo = null; } - String wdID = (tsInfo == null ? null : (String) (tsInfo.get(TESTSUITE_ID))); + String wdID = (tsInfo == null ? null : tsInfo.get(TESTSUITE_ID)); String tsID = testSuite.getID(); if (!(wdID == null ? "" : wdID).equals(tsID == null ? "" : tsID)) throw new MismatchFault(i18n, "wd.mismatchID", canonDir); @@ -668,7 +668,7 @@ * Create a WorkDirectory object for a given directory and testsuite. * The directory is assumed to be valid (exists(), isDirectory(), canRead() etc) */ - private WorkDirectory(File root, TestSuite testSuite, Map tsInfo) { + private WorkDirectory(File root, TestSuite testSuite, Map tsInfo) { if (root == null || testSuite == null) throw new NullPointerException(); this.root = root; @@ -691,7 +691,7 @@ // -- possibly conditionally (don't need to write it in case of normal open) if (tsInfo != null) { - String testC = (String) (tsInfo.get(TESTSUITE_TESTCOUNT)); + String testC = (tsInfo.get(TESTSUITE_TESTCOUNT)); int tc; if (testC == null) tc = -1; @@ -717,7 +717,7 @@ private void doWDinfo(File jtData, TestSuite testSuite) { try { - oldWDpath = loadWdInfo(jtData).getProperty(PREV_WD_PATH); + oldWDpath = loadWdInfo(jtData).get(PREV_WD_PATH); } catch (IOException ex) { oldWDpath = null; } @@ -1184,21 +1184,18 @@ return result; } - private static Properties loadTestSuiteInfo(File jtData) throws FileNotFoundException, IOException { + private static Map loadTestSuiteInfo(File jtData) throws FileNotFoundException, IOException { return loadInfo(jtData, TESTSUITE); } - private static Properties loadWdInfo(File jtData) throws FileNotFoundException, IOException { + private static Map loadWdInfo(File jtData) throws FileNotFoundException, IOException { return loadInfo(jtData, WD_INFO); } - private static Properties loadInfo(File jtData, String name) throws FileNotFoundException, IOException { - File f = new File(jtData, name); - InputStream in = new BufferedInputStream(new FileInputStream(f)); - Properties p = new Properties(); - p.load(in); - in.close(); - return p; + private static Map loadInfo(File jtData, String name) throws FileNotFoundException, IOException { + try (InputStream in = new BufferedInputStream(new FileInputStream(new File(jtData, name)))) { + return com.sun.javatest.util.Properties.load(in); + } } @@ -1254,7 +1251,7 @@ private File jtData; private String logFileName; private LogFile logFile; - private static HashMap dirMap = new HashMap(2); // must be manually synchronized + private static HashMap> dirMap = new HashMap<>(2); // must be manually synchronized public static final String JTDATA = "jtData"; private static final String TESTSUITE = "testsuite"; private static final String WD_INFO = "wdinfo"; diff --git a/src/com/sun/javatest/agent/ActiveAgentPool.java b/src/com/sun/javatest/agent/ActiveAgentPool.java --- a/src/com/sun/javatest/agent/ActiveAgentPool.java +++ b/src/com/sun/javatest/agent/ActiveAgentPool.java @@ -324,8 +324,8 @@ return v.contains(e); } - synchronized Enumeration elements() { - return ((Vector)(v.clone())).elements(); + synchronized Enumeration elements() { + return ((Vector)(v.clone())).elements(); } synchronized void add(final Entry e) { @@ -590,7 +590,7 @@ /** * Get an enumeration of the entries currently in the active agent pool. */ - Enumeration elements() { + Enumeration elements() { return entries.elements(); } diff --git a/src/com/sun/javatest/agent/Agent.java b/src/com/sun/javatest/agent/Agent.java --- a/src/com/sun/javatest/agent/Agent.java +++ b/src/com/sun/javatest/agent/Agent.java @@ -781,7 +781,7 @@ PrintWriter testRef = new PrintWriter(new AgentWriter(REF, this)); try { - Class c; + Class c; ClassLoader cl = null; if (remoteClasses) { cl = getAgentClassLoader(sharedClassLoader); @@ -834,7 +834,7 @@ } } - private Status executeTest(Class c, String[] args, + private Status executeTest(Class c, String[] args, PrintWriter testLog, PrintWriter testRef) throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException { notifier.execTest(connection, tag, c.getName(), args); @@ -842,7 +842,7 @@ return t.run(args, testLog, testRef); } - private Status executeCommand(Class c, String[] args, + private Status executeCommand(Class c, String[] args, PrintWriter testLog, PrintWriter testRef, ClassLoader cl) throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException { @@ -945,7 +945,7 @@ PrintStream err = Deprecated.createPrintStream(new WriterStream(testLog)); try { setSystemStreams(this, out, err); - Method main = c.getDeclaredMethod("main", new Class[] {String[].class}); + Method main = c.getDeclaredMethod("main", new Class[] {String[].class}); main.invoke(null, new Object[] {args}); return Status.passed("OK"); } catch (NoSuchMethodException e) { @@ -1107,16 +1107,16 @@ private ClassLoader getAgentClassLoader(boolean useSharedClassLoader) throws InstantiationException, IllegalAccessException { - Class classLoaderClass; + Class classLoaderClass; try { String s = getClass().getName(); String pkg = s.substring(0, s.lastIndexOf('.')); - classLoaderClass = Class.forName(pkg + ".AgentClassLoader2"); + classLoaderClass = (Class) Class.forName(pkg + ".AgentClassLoader2"); } catch (Throwable t) { classLoaderClass = AgentClassLoader.class; } - Class[] argTypes = {Task.class}; + Class[] argTypes = {Task.class}; if (useSharedClassLoader && factoryMethod == null) { try { factoryMethod = classLoaderClass.getDeclaredMethod("getInstance", argTypes); @@ -1139,7 +1139,7 @@ if (useSharedClassLoader && factoryMethod != null) { return (ClassLoader) factoryMethod.invoke(null, args); } else { - return (ClassLoader) (classLoaderConstructor.newInstance(args)); + return classLoaderConstructor.newInstance(args); } } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); @@ -1162,7 +1162,7 @@ private Integer timeoutValue; } - private static Constructor classLoaderConstructor; + private static Constructor classLoaderConstructor; private static Method factoryMethod = null; } diff --git a/src/com/sun/javatest/agent/AgentApplet.java b/src/com/sun/javatest/agent/AgentApplet.java --- a/src/com/sun/javatest/agent/AgentApplet.java +++ b/src/com/sun/javatest/agent/AgentApplet.java @@ -128,7 +128,7 @@ ModeOptions smo = null; try { - Class serial = Class.forName("com.sun.javatest.agent.SerialPortModeOptions"); + Class serial = Class.forName("com.sun.javatest.agent.SerialPortModeOptions"); smo = (ModeOptions)serial.newInstance(); } catch (Exception e) { System.err.println("There is no support for serial port"); @@ -163,7 +163,7 @@ if (observerClassName != null) { try { - Class observerClass = Class.forName(observerClassName); + Class observerClass = Class.forName(observerClassName); Agent.Observer observer = (Agent.Observer)(observerClass.newInstance()); ap.addObserver(observer); } diff --git a/src/com/sun/javatest/agent/AgentClassLoader.java b/src/com/sun/javatest/agent/AgentClassLoader.java --- a/src/com/sun/javatest/agent/AgentClassLoader.java +++ b/src/com/sun/javatest/agent/AgentClassLoader.java @@ -34,10 +34,10 @@ this.parent = parent; } - public synchronized Class loadClass(String className, boolean resolve) throws ClassNotFoundException { + public synchronized Class loadClass(String className, boolean resolve) throws ClassNotFoundException { // check the cache first - Class c = findLoadedClass(className); + Class c = findLoadedClass(className); // not found in the cache? if (c == null) { diff --git a/src/com/sun/javatest/agent/AgentClassLoader2.java b/src/com/sun/javatest/agent/AgentClassLoader2.java --- a/src/com/sun/javatest/agent/AgentClassLoader2.java +++ b/src/com/sun/javatest/agent/AgentClassLoader2.java @@ -98,8 +98,8 @@ return instance; } - public Class loadClassLocal(String name) throws ClassNotFoundException { - Class target = null; + public Class loadClassLocal(String name) throws ClassNotFoundException { + Class target = null; System.out.println("FORCE REMOTE " + name); try { target = findClass(name); @@ -118,7 +118,7 @@ @Override - public Class findClass(String className) throws ClassNotFoundException { + public Class findClass(String className) throws ClassNotFoundException { if (className != null) { int i = className.lastIndexOf('.'); if (i > 0) { diff --git a/src/com/sun/javatest/agent/AgentFrame.java b/src/com/sun/javatest/agent/AgentFrame.java --- a/src/com/sun/javatest/agent/AgentFrame.java +++ b/src/com/sun/javatest/agent/AgentFrame.java @@ -94,7 +94,7 @@ ModeOptions smo = null; try { - Class serial = Class.forName("com.sun.javatest.agent.SerialPortModeOptions"); + Class serial = Class.forName("com.sun.javatest.agent.SerialPortModeOptions"); smo = (ModeOptions)serial.newInstance(); } catch (Exception e) { System.err.println("There is no support for serial port"); @@ -208,7 +208,7 @@ if (observerClassName != null) { try { - Class observerClass = Class.forName(observerClassName); + Class observerClass = Class.forName(observerClassName); Agent.Observer observer = (Agent.Observer)(observerClass.newInstance()); sf.panel.addObserver(observer); } @@ -261,7 +261,7 @@ sp.start(); try { - Method invokeLater = EventQueue.class.getMethod("invokeLater", new Class[] { Runnable.class }); + Method invokeLater = EventQueue.class.getMethod("invokeLater", new Class[] { Runnable.class }); invokeLater.invoke(null, new Object[] { new Runnable() { public void run() { sf.showCentered(); diff --git a/src/com/sun/javatest/agent/AgentMain.java b/src/com/sun/javatest/agent/AgentMain.java --- a/src/com/sun/javatest/agent/AgentMain.java +++ b/src/com/sun/javatest/agent/AgentMain.java @@ -375,7 +375,7 @@ case ACTIVE: try { Class c = Class.forName(pkg + ".ActiveConnectionFactory"); - Constructor m = c.getConstructor(new Class[] {String.class, int.class}); + Constructor m = c.getConstructor(new Class[] {String.class, int.class}); Object[] args = { activeHost, new Integer(activePort) }; return (ConnectionFactory)(m.newInstance(args)); } @@ -392,7 +392,7 @@ case PASSIVE: try { Class c = Class.forName(pkg + ".PassiveConnectionFactory"); - Constructor m = c.getConstructor(new Class[] {int.class, int.class}); + Constructor m = c.getConstructor(new Class[] {int.class, int.class}); Object[] args = { new Integer(passivePort), new Integer(concurrency + 1) }; return (ConnectionFactory)(m.newInstance(args)); } @@ -413,7 +413,7 @@ case SERIAL: try { Class c = Class.forName(pkg + ".SerialPortConnectionFactory"); - Constructor m = c.getConstructor(new Class[] {String.class, String.class, int.class}); + Constructor m = c.getConstructor(new Class[] {String.class, String.class, int.class}); Object[] args = {serialPort, Agent.productName, new Integer(10*1000)}; return (ConnectionFactory)(m.newInstance(args)); } @@ -460,7 +460,7 @@ if (observerClassName != null) { try { - Class observerClass = Class.forName(observerClassName); + Class observerClass = Class.forName(observerClassName); Agent.Observer observer = (Agent.Observer)(observerClass.newInstance()); agent.addObserver(observer); } @@ -621,7 +621,7 @@ public void completed(Agent agent, Connection c) { } - private Class connectExceptionClass; - private Class unknownHostExceptionClass; + private Class connectExceptionClass; + private Class unknownHostExceptionClass; } } diff --git a/src/com/sun/javatest/agent/AgentManager.java b/src/com/sun/javatest/agent/AgentManager.java --- a/src/com/sun/javatest/agent/AgentManager.java +++ b/src/com/sun/javatest/agent/AgentManager.java @@ -536,8 +536,8 @@ ref.flush(); // might be better not to flush these ... - for (Enumeration e = zips.keys(); e.hasMoreElements(); ) { - File f = (File)(e.nextElement()); + for (Enumeration e = zips.keys(); e.hasMoreElements(); ) { + File f = (e.nextElement()); ZipFile z = zips.get(f); zips.remove(f); z.close(); diff --git a/src/com/sun/javatest/agent/AgentMonitorTool.java b/src/com/sun/javatest/agent/AgentMonitorTool.java --- a/src/com/sun/javatest/agent/AgentMonitorTool.java +++ b/src/com/sun/javatest/agent/AgentMonitorTool.java @@ -192,8 +192,8 @@ // Ensure any existing entries in the pool are displayed // Note there is a slight synchronization window between the call of // elements and that of addObserver. - for (Enumeration e = activeAgentPool.elements(); e.hasMoreElements(); ) { - Connection conn = (Connection)(e.nextElement()); + for (Enumeration e = activeAgentPool.elements(); e.hasMoreElements(); ) { + Connection conn = e.nextElement(); listData.addElement(conn.getName()); } @@ -357,7 +357,7 @@ list.setVisibleRowCount(5); list.setCellRenderer(new DefaultListCellRenderer() { - public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) { + public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) { String name = o.toString(); return super.getListCellRendererComponent(list, name, index, isSelected, cellHasFocus); } diff --git a/src/com/sun/javatest/agent/Map.java b/src/com/sun/javatest/agent/Map.java --- a/src/com/sun/javatest/agent/Map.java +++ b/src/com/sun/javatest/agent/Map.java @@ -62,7 +62,7 @@ public static Map readFile(String name) throws IOException { try { Class c = Class.forName("java.io.FileReader"); // optional API in Jersonal Java - Constructor m = c.getConstructor(new Class[] {String.class}); + Constructor m = c.getConstructor(new Class[] {String.class}); Reader r = (Reader)(m.newInstance(new Object[] {name})); return new Map(r); } diff --git a/src/com/sun/javatest/agent/SerialPortModeOptions.java b/src/com/sun/javatest/agent/SerialPortModeOptions.java --- a/src/com/sun/javatest/agent/SerialPortModeOptions.java +++ b/src/com/sun/javatest/agent/SerialPortModeOptions.java @@ -46,7 +46,7 @@ super("serial port"); try { - Class c = Class.forName(Proxy.class.getName() + "Impl"); + Class c = Class.forName(Proxy.class.getName() + "Impl"); proxy = (Proxy)(c.newInstance()); } catch (Throwable ignore) { @@ -112,7 +112,7 @@ public String[] getPortNames() { try { Vector v = new Vector<>(); - for (Enumeration e = CommPortIdentifier.getPortIdentifiers(); e.hasMoreElements(); ) { + for (Enumeration e = CommPortIdentifier.getPortIdentifiers(); e.hasMoreElements(); ) { CommPortIdentifier p = (CommPortIdentifier)(e.nextElement()); if (p.getPortType() == CommPortIdentifier.PORT_SERIAL) v.addElement(p.getName()); diff --git a/src/com/sun/javatest/audit/Audit.java b/src/com/sun/javatest/audit/Audit.java --- a/src/com/sun/javatest/audit/Audit.java +++ b/src/com/sun/javatest/audit/Audit.java @@ -131,11 +131,10 @@ if (!checkTestCases(tr, excludeList)) badTestCaseTestsV.addElement(tr); - Map trEnv = tr.getEnvironment(); - for (Iterator i = trEnv.entrySet().iterator(); i.hasNext(); ) { - Map.Entry e = (Map.Entry) (i.next()); - String key = (String) (e.getKey()); - String value = (String) (e.getValue()); + Map trEnv = tr.getEnvironment(); + for (Map.Entry e : trEnv.entrySet() ) { + String key = e.getKey(); + String value = e.getValue(); Vector allValuesForKey = envTable.get(key); if (allValuesForKey == null) { allValuesForKey = new Vector<>(); @@ -167,9 +166,9 @@ } } - for (Enumeration e = envTable.keys(); e.hasMoreElements(); ) { - String key = (String)(e.nextElement()); - Vector allValuesForKey = envTable.get(key); + for (Enumeration e = envTable.keys(); e.hasMoreElements(); ) { + String key = e.nextElement(); + Vector allValuesForKey = envTable.get(key); envCounts[allValuesForKey.size() == 1 ? 0 : 1]++; } @@ -252,7 +251,7 @@ * The keys to the table are strings; the values are vectors of strings * containing the various values for that key. */ - public Hashtable getEnvTable() { + public Hashtable> getEnvTable() { return envTable; } @@ -493,14 +492,14 @@ out.print(i18n.getString("adt.envList.title")); SortedSet ss = new TreeSet<>(); - for (Enumeration e = envTable.keys(); e.hasMoreElements(); ) { - String key = (String)(e.nextElement()); + for (Enumeration e = envTable.keys(); e.hasMoreElements(); ) { + String key = (e.nextElement()); ss.add(key); } - for (Iterator iter = ss.iterator(); iter.hasNext(); ) { - String key = (String) (iter.next()); - Vector allValuesForKey = envTable.get(key); + for (Iterator iter = ss.iterator(); iter.hasNext(); ) { + String key = (iter.next()); + Vector allValuesForKey = envTable.get(key); if (allValuesForKey.size() == 1) { if (showAll) out.println(i18n.getString("adt.envKeyValue", @@ -633,11 +632,11 @@ //if (!a.rootRelativeFile.equals(b.rootRelativeFile)) // return false; - Iterator eA = a.getParameterKeys(); - Iterator eB = b.getParameterKeys(); + Iterator eA = a.getParameterKeys(); + Iterator eB = b.getParameterKeys(); while (eA.hasNext() && eB.hasNext()) { - String keyA = (String)eA.next(); - String keyB = (String)eB.next(); + String keyA = eA.next(); + String keyB = eB.next(); if (!keyA.equals(keyB)) { //System.err.println("mismatch " + a.getRootRelativePath() + " a:" + keyA + " b:" + keyB); return false; diff --git a/src/com/sun/javatest/audit/AuditCommandManager.java b/src/com/sun/javatest/audit/AuditCommandManager.java --- a/src/com/sun/javatest/audit/AuditCommandManager.java +++ b/src/com/sun/javatest/audit/AuditCommandManager.java @@ -122,7 +122,7 @@ return "showAudit"; } - ShowAuditCommand(ListIterator argIter) { + ShowAuditCommand(ListIterator argIter) { super(getName()); } diff --git a/src/com/sun/javatest/audit/ListPane.java b/src/com/sun/javatest/audit/ListPane.java --- a/src/com/sun/javatest/audit/ListPane.java +++ b/src/com/sun/javatest/audit/ListPane.java @@ -79,7 +79,7 @@ } private class Renderer extends DefaultListCellRenderer { - public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) { + public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) { String name; if (o instanceof TestResult) { TestResult tr = (TestResult) o; diff --git a/src/com/sun/javatest/batch/ObserverCommand.java b/src/com/sun/javatest/batch/ObserverCommand.java --- a/src/com/sun/javatest/batch/ObserverCommand.java +++ b/src/com/sun/javatest/batch/ObserverCommand.java @@ -92,23 +92,23 @@ public void run(CommandContext ctx) throws Fault { try { - Class oc = loadClass(className); + Class oc = loadClass(className); Harness.Observer o = null; if (classArgs == null || classArgs.length == 0) { o = tryConstructor(oc, - new Class[] { }, + new Class[] { }, new Object[] { }); } else if (classArgs.length == 1) { o = tryConstructor(oc, - new Class[] { String.class }, + new Class[] { String.class }, new Object[] { classArgs[0] }); } if (o == null) o = tryConstructor(oc, - new Class[] { String[].class }, + new Class[] { String[].class }, new Object[] { classArgs }); if (o == null) @@ -130,11 +130,11 @@ } } - private Harness.Observer tryConstructor(Class obsClass, Class[] argTypes, Object[] args) + private Harness.Observer tryConstructor(Class obsClass, Class[] argTypes, Object[] args) throws IllegalAccessException, InstantiationException, InvocationTargetException { try { - Constructor c = obsClass.getConstructor(argTypes); + Constructor c = obsClass.getConstructor(argTypes); return (Harness.Observer) (c.newInstance(args)); } catch (NoSuchMethodException e) { @@ -160,7 +160,7 @@ classLoader = new URLClassLoader(path); } - private Class loadClass(String name) throws ClassNotFoundException { + private Class loadClass(String name) throws ClassNotFoundException { return (classLoader == null ? Class.forName(name) : classLoader.loadClass(name)); } diff --git a/src/com/sun/javatest/batch/RunTestsCommand.java b/src/com/sun/javatest/batch/RunTestsCommand.java --- a/src/com/sun/javatest/batch/RunTestsCommand.java +++ b/src/com/sun/javatest/batch/RunTestsCommand.java @@ -30,6 +30,7 @@ import java.text.DateFormat; import java.util.Date; import java.util.Iterator; +import java.util.ListIterator; import com.sun.javatest.Harness; import com.sun.javatest.Parameters; @@ -68,7 +69,7 @@ super(getName()); } - RunTestsCommand(Iterator argIter) { + RunTestsCommand(ListIterator argIter) { super(getName()); } diff --git a/src/com/sun/javatest/exec/BasicCustomTestFilter.java b/src/com/sun/javatest/exec/BasicCustomTestFilter.java --- a/src/com/sun/javatest/exec/BasicCustomTestFilter.java +++ b/src/com/sun/javatest/exec/BasicCustomTestFilter.java @@ -101,7 +101,7 @@ init(null); } - BasicCustomTestFilter(Map map, ExecModel e, UIFactory uif) { + BasicCustomTestFilter(Map map, ExecModel e, UIFactory uif) { super(map, e); this.uif = uif; init(map); @@ -149,7 +149,7 @@ } @Override - boolean load(Map map) { + boolean load(Map map) { boolean result = super.load(map); activeSettings = new SettingsSnapshot(map); putSettings(activeSettings); @@ -274,7 +274,7 @@ } // ----- PRIVATE ----- - private void init(Map map) { + private void init(Map map) { if (NAME == null) { NAME = uif.getI18NString("basicTf.name"); } @@ -883,7 +883,7 @@ private ButtonGroup keyBtnGrp; private JRadioButton keyAllBtn; private JRadioButton keyMatchBtn; - private JComboBox keywordsChoice; + private JComboBox keywordsChoice; private JTextField keywordsField; private static final String ALL_OF = "allOf"; private static final String ANY_OF = "anyOf"; @@ -907,7 +907,7 @@ // jtx info fields private JTextField jtxMode; - private JList jtxFileList; + private JList jtxFileList; private DefaultListModel jtxFiles; private static String NAME, REASON, DESCRIPTION; @@ -996,7 +996,7 @@ keyString = ""; } - SettingsSnapshot(Map m) { + SettingsSnapshot(Map m) { this(); load(m); } @@ -1068,21 +1068,21 @@ map.put(MAP_KEY_STRING, keyString); } - void load(Map map) { - urlsEnabled = intToBoolean((String) (map.get(MAP_URL_ENABLE))); - keywordsEnabled = intToBoolean((String) (map.get(MAP_KEY_ENABLE))); - statusEnabled = intToBoolean((String) (map.get(MAP_STATUS_ENABLE))); - jtxEnabled = intToBoolean((String) (map.get(MAP_JTX_ENABLE))); - tsfEnabled = intToBoolean((String) (map.get(MAP_TSF_ENABLE))); + void load(Map map) { + urlsEnabled = intToBoolean((map.get(MAP_URL_ENABLE))); + keywordsEnabled = intToBoolean((map.get(MAP_KEY_ENABLE))); + statusEnabled = intToBoolean((map.get(MAP_STATUS_ENABLE))); + jtxEnabled = intToBoolean((map.get(MAP_JTX_ENABLE))); + tsfEnabled = intToBoolean((map.get(MAP_TSF_ENABLE))); for (int i = 0; i < Status.NUM_STATES; i++) { - statusFields[i] = intToBoolean((String) (map.get(MAP_STATUS_PREFIX + i))); + statusFields[i] = intToBoolean((map.get(MAP_STATUS_PREFIX + i))); } // for - initialUrls = StringArray.split((String) (map.get(MAP_URLS))); + initialUrls = StringArray.split((map.get(MAP_URLS))); - keyChoice = (String) (map.get(MAP_KEY_CHOICE)); - keyString = (String) (map.get(MAP_KEY_STRING)); + keyChoice = map.get(MAP_KEY_CHOICE); + keyString = map.get(MAP_KEY_STRING); validate(); } diff --git a/src/com/sun/javatest/exec/CE_KeywordsPane.java b/src/com/sun/javatest/exec/CE_KeywordsPane.java --- a/src/com/sun/javatest/exec/CE_KeywordsPane.java +++ b/src/com/sun/javatest/exec/CE_KeywordsPane.java @@ -398,7 +398,7 @@ private KeywordsParameters keywordsParameters; private MutableKeywordsParameters mutableKeywordsParameters; private JCheckBox selectCheck; - private JComboBox keywordsChoice; + private JComboBox keywordsChoice; private JTextField keywordsField; private JButton keywordBtn; private JPopupMenu keywordPopup; diff --git a/src/com/sun/javatest/exec/ConfigurableTestFilter.java b/src/com/sun/javatest/exec/ConfigurableTestFilter.java --- a/src/com/sun/javatest/exec/ConfigurableTestFilter.java +++ b/src/com/sun/javatest/exec/ConfigurableTestFilter.java @@ -80,7 +80,7 @@ * @throws IllegalStateException If the instance name is not present in the map or * the exec model argument is null. */ - protected ConfigurableTestFilter(Map map, ExecModel e) { + protected ConfigurableTestFilter(Map map, ExecModel e) { if (e == null) throw new IllegalArgumentException(i18n.getString("ctf.nullExec")); @@ -134,8 +134,8 @@ * false if the operation failed. * @throws IllegalStateException If the instance name is not present in the map. */ - boolean load(Map map) { - instanceName = (String)(map.get(INSTANCE_KEY)); + boolean load(Map map) { + instanceName = map.get(INSTANCE_KEY); if (instanceName == null) throw new IllegalStateException(i18n.getString("ctf.mapNoName")); diff --git a/src/com/sun/javatest/exec/ET_FilterHandler.java b/src/com/sun/javatest/exec/ET_FilterHandler.java --- a/src/com/sun/javatest/exec/ET_FilterHandler.java +++ b/src/com/sun/javatest/exec/ET_FilterHandler.java @@ -63,7 +63,7 @@ */ public class ET_FilterHandler implements ET_FilterControl, Session.Observer { ET_FilterHandler(JComponent parent, ExecModel model, Harness h, UIFactory uif, - Map map) { + Map map) { this(parent, model, uif); setHarness(h); restore(map); @@ -160,9 +160,9 @@ return fHandler; } - private TestFilter getDefaultFilter(Map map) { + private TestFilter getDefaultFilter(Map map) { if (map != null) { - String pref = (String)(map.get(ExecTool.ACTIVE_FILTER)); + String pref = (map.get(ExecTool.ACTIVE_FILTER)); // try to use filter indicated in preference for (int i = 0; i < allFilters.size(); i++) { @@ -281,7 +281,7 @@ prefs.save(); } - public void restore(Map m) { + public void restore(Map m) { this.map = m; fHandler.setFilter(getDefaultFilter(m)); } @@ -441,7 +441,7 @@ private ExecModel model; private UIFactory uif; private JComponent parentComponent; - private Map map; // saved desktop map to restore from + private Map map; // saved desktop map to restore from // filters private LastRunFilter ltrFilter; // last test run @@ -513,7 +513,7 @@ return null; } - public void putAll(Map t) { + public void putAll(Map t) { throw new UnsupportedOperationException(); } diff --git a/src/com/sun/javatest/exec/EnvironmentBrowser.java b/src/com/sun/javatest/exec/EnvironmentBrowser.java --- a/src/com/sun/javatest/exec/EnvironmentBrowser.java +++ b/src/com/sun/javatest/exec/EnvironmentBrowser.java @@ -209,15 +209,13 @@ } }; - private class EnvEntryComparator implements Comparator { + private class EnvEntryComparator implements Comparator { EnvEntryComparator(int sortMode, String[] inherits) { this.sortMode = sortMode; this.inherits = inherits; } - public int compare(Object o1, Object o2) { - TestEnvironment.Element e1 = (TestEnvironment.Element)o1; - TestEnvironment.Element e2 = (TestEnvironment.Element)o2; + public int compare(TestEnvironment.Element e1, TestEnvironment.Element e2) { // the following should be a switch statement, but JDK // 1.1.7 can't compile it: doesn't recognize KEY etc as // constants. @@ -276,8 +274,8 @@ if (currEnv == null) elems = null; else { - Collection e = currEnv.elements(); - elems = (TestEnvironment.Element[]) (e.toArray(new TestEnvironment.Element[e.size()])); + Collection e = currEnv.elements(); + elems = e.toArray(new TestEnvironment.Element[e.size()]); Arrays.sort(elems, new EnvEntryComparator(KEY, currEnv.getInherits())); } int newRowCount = getRowCount(); @@ -323,7 +321,7 @@ return headings[columnIndex]; } - public Class getColumnClass(int columnIndex) { + public Class getColumnClass(int columnIndex) { return String.class; } diff --git a/src/com/sun/javatest/exec/ExcludeListBrowser.java b/src/com/sun/javatest/exec/ExcludeListBrowser.java --- a/src/com/sun/javatest/exec/ExcludeListBrowser.java +++ b/src/com/sun/javatest/exec/ExcludeListBrowser.java @@ -299,7 +299,7 @@ }); if (list != null) { - for (Iterator iter = list.getIterator(false); iter.hasNext(); ) { + for (Iterator iter = list.getIterator(false); iter.hasNext(); ) { ExcludeList.Entry ee = (ExcludeList.Entry) (iter.next()); sortedEntries.add(ee); } @@ -317,7 +317,7 @@ // model never changes, so ignore listener } - public Class getColumnClass(int columnIndex) { + public Class getColumnClass(int columnIndex) { // for now, all are strings return String.class; } diff --git a/src/com/sun/javatest/exec/ExecTool.java b/src/com/sun/javatest/exec/ExecTool.java --- a/src/com/sun/javatest/exec/ExecTool.java +++ b/src/com/sun/javatest/exec/ExecTool.java @@ -72,7 +72,6 @@ final List controls = new ArrayList(); JMenuBar menuBar = null; - HashMap map = new HashMap(); private boolean shouldPauseTree; private PageFormat pageFormat; diff --git a/src/com/sun/javatest/exec/ExecToolManager.java b/src/com/sun/javatest/exec/ExecToolManager.java --- a/src/com/sun/javatest/exec/ExecToolManager.java +++ b/src/com/sun/javatest/exec/ExecToolManager.java @@ -430,10 +430,10 @@ } } - private static InterviewParameters getInterview(Map m) throws Interview.Fault { - String tsp = (String) (m.get("testSuite")); - String wdp = (String) (m.get("workDir")); - String cfp = (String) (m.get("config")); + private static InterviewParameters getInterview(Map m) throws Interview.Fault { + String tsp = (m.get("testSuite")); + String wdp = (m.get("workDir")); + String cfp = (m.get("config")); if (isEmpty(tsp) && isEmpty(wdp) && isEmpty(cfp)) return null; @@ -528,7 +528,7 @@ } void showError(String key) { - showError(key, (Object[]) null); + showError(key, null); } void showError(String key, Object arg) { diff --git a/src/com/sun/javatest/exec/FileSystemTableModel.java b/src/com/sun/javatest/exec/FileSystemTableModel.java --- a/src/com/sun/javatest/exec/FileSystemTableModel.java +++ b/src/com/sun/javatest/exec/FileSystemTableModel.java @@ -42,7 +42,7 @@ static protected String[] cNames = {"File Name", "Name", "Description"}; // Types of the columns. - static protected Class[] cTypes = { String.class, + static protected Class[] cTypes = { String.class, String.class, String.class}; private FileTableFilter filter = null; @@ -82,7 +82,7 @@ return cNames[column]; } - public Class getColumnClass(int column) { + public Class getColumnClass(int column) { return cTypes[column]; } diff --git a/src/com/sun/javatest/exec/InterviewEditor.java b/src/com/sun/javatest/exec/InterviewEditor.java --- a/src/com/sun/javatest/exec/InterviewEditor.java +++ b/src/com/sun/javatest/exec/InterviewEditor.java @@ -758,8 +758,8 @@ keys.addAll(aQuestions.keySet()); keys.addAll(bQuestions.keySet()); - for (Iterator iter = keys.iterator(); iter.hasNext(); ) { - String key = (String) (iter.next()); + for (Iterator iter = keys.iterator(); iter.hasNext(); ) { + String key = (iter.next()); Question aq = aQuestions.get(key); Question bq = bQuestions.get(key); if (aq == null || bq == null) { @@ -789,8 +789,8 @@ } } // Checking external values - Set aKeys = a.getPropertyKeys(); - Set bKeys = b.getPropertyKeys(); + Set aKeys = a.getPropertyKeys(); + Set bKeys = b.getPropertyKeys(); if (aKeys == null || bKeys == null) { return aKeys == bKeys; @@ -800,8 +800,8 @@ return false; } - for (Iterator iter = aKeys.iterator(); iter.hasNext(); ) { - String key = (String)iter.next(); + for (Iterator iter = aKeys.iterator(); iter.hasNext(); ) { + String key = iter.next(); if (!bKeys.contains(key)) { return false; } diff --git a/src/com/sun/javatest/exec/JavaTestMenuManager.java b/src/com/sun/javatest/exec/JavaTestMenuManager.java --- a/src/com/sun/javatest/exec/JavaTestMenuManager.java +++ b/src/com/sun/javatest/exec/JavaTestMenuManager.java @@ -67,7 +67,7 @@ if (bank == null) return null; else { - ArrayList al = bank[position]; + ArrayList al = bank[position]; if (al.size() == 0) return null; else { diff --git a/src/com/sun/javatest/exec/LogViewer.java b/src/com/sun/javatest/exec/LogViewer.java --- a/src/com/sun/javatest/exec/LogViewer.java +++ b/src/com/sun/javatest/exec/LogViewer.java @@ -978,7 +978,7 @@ private class CustomRenderer extends JComponent implements ListCellRenderer { public Component getListCellRendererComponent( - JList list, Object value, int index, boolean isSelected, + JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (!(value instanceof JSeparator) && !(value instanceof JCheckBox)) { DefaultListCellRenderer defRend = new DefaultListCellRenderer(); @@ -1135,7 +1135,7 @@ } public void actionPerformed(ActionEvent e) { - JComboBox cb = (JComboBox) e.getSource(); + JComboBox cb = (JComboBox) e.getSource(); Object o = cb.getSelectedItem(); if (o instanceof FilterComboboxItem) { FilterComboboxItem fc = (FilterComboboxItem) o; diff --git a/src/com/sun/javatest/exec/MultiFormatPane.java b/src/com/sun/javatest/exec/MultiFormatPane.java --- a/src/com/sun/javatest/exec/MultiFormatPane.java +++ b/src/com/sun/javatest/exec/MultiFormatPane.java @@ -41,6 +41,7 @@ import java.util.HashMap; import java.util.Iterator; import javax.imageio.ImageIO; +import javax.imageio.ImageReader; import javax.imageio.stream.ImageInputStream; import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.MidiFileFormat; @@ -959,14 +960,14 @@ public static boolean isImageResource(URL url) { String file = url.getFile(); String ext = file.substring(file.lastIndexOf('.')+1); - Iterator iter = ImageIO.getImageReadersBySuffix(ext); + Iterator iter = ImageIO.getImageReadersBySuffix(ext); return iter.hasNext(); } public static boolean isImageFormatSupported(URL url) { try { ImageInputStream iis = ImageIO.createImageInputStream(new File(url.getFile())); - Iterator iter = ImageIO.getImageReaders(iis); + Iterator iter = ImageIO.getImageReaders(iis); if(!iter.hasNext()) return false; } catch (IOException exc) { diff --git a/src/com/sun/javatest/exec/MultiSelectPanel.java b/src/com/sun/javatest/exec/MultiSelectPanel.java --- a/src/com/sun/javatest/exec/MultiSelectPanel.java +++ b/src/com/sun/javatest/exec/MultiSelectPanel.java @@ -91,7 +91,7 @@ setLayout(new GridBagLayout()); setMinimumSize(new Dimension(150, 100)); - listModel = new DefaultListModel(); + listModel = new DefaultListModel<>(); nodeList = uif.createList("ms.nlist", listModel); GridBagConstraints gbc = new GridBagConstraints(); gbc.weightx= 1.0; @@ -167,8 +167,8 @@ private TestTreeModel ttm; private TreePanelModel tpm; - private JList nodeList; - private DefaultListModel listModel; + private JList nodeList; + private DefaultListModel listModel; private Object[] nodes; private UIFactory uif; diff --git a/src/com/sun/javatest/exec/NavigationPane.java b/src/com/sun/javatest/exec/NavigationPane.java --- a/src/com/sun/javatest/exec/NavigationPane.java +++ b/src/com/sun/javatest/exec/NavigationPane.java @@ -304,7 +304,7 @@ sf = new StringFitter(getFontMetrics(getFont())); } - public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) { + public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) { String name = null; if (o instanceof URL) { URL url = (URL) o; diff --git a/src/com/sun/javatest/exec/NewReportDialog.java b/src/com/sun/javatest/exec/NewReportDialog.java --- a/src/com/sun/javatest/exec/NewReportDialog.java +++ b/src/com/sun/javatest/exec/NewReportDialog.java @@ -141,9 +141,9 @@ // --------------------------------------------------------------------------- - void setLastState(Map h) { - String rd = (String) (h.get(REPORT_DIR)); - String filter = (String) (h.get(FILTER)); + void setLastState(Map h) { + String rd = (h.get(REPORT_DIR)); + String filter = (h.get(FILTER)); if (dirField == null) initGUI(); @@ -901,9 +901,9 @@ ArrayList customReps = new ArrayList<>(); if (customBoxes != null && customBoxes.size() > 0) { - Iterator it = customBoxes.keySet().iterator(); + Iterator it = customBoxes.keySet().iterator(); while (it.hasNext()) { - JCheckBox box = (JCheckBox)(it.next()); + JCheckBox box = (it.next()); if (box.isSelected()) { customReps.add(customBoxes.get(box)); } @@ -1096,9 +1096,9 @@ } // validate custom reports - Iterator it = getActiveCustomReports().iterator(); + Iterator it = getActiveCustomReports().iterator(); while (it.hasNext()) { - CustomReport cr = (CustomReport) it.next(); + CustomReport cr = it.next(); String error = cr.validateOptions(); if (error != null) { for (int i = 0; i < listModel.getSize(); i++ ) { @@ -1367,7 +1367,7 @@ * @param p parent Panel * @param cardLayout The CardLayout for options */ - SelectListener(JList lst, JPanel p, CardLayout cardLayout ) { + SelectListener(JList lst, JPanel p, CardLayout cardLayout ) { list = lst; listModel = list.getModel(); lastSelected = listModel.getElementAt(0); @@ -1477,8 +1477,8 @@ } Object lastSelected; - JList list; - ListModel listModel; + JList list; + ListModel listModel; JPanel panel; CardLayout cards; JButton okBtn = null; // should be disable iff all check boxes are off diff --git a/src/com/sun/javatest/exec/ProgressMonitor.java b/src/com/sun/javatest/exec/ProgressMonitor.java --- a/src/com/sun/javatest/exec/ProgressMonitor.java +++ b/src/com/sun/javatest/exec/ProgressMonitor.java @@ -476,7 +476,7 @@ private void initRunningCard() { testListData = new DefaultListModel<>(); - final JList list = uif.createList("pm.runlist", testListData); + final JList list = uif.createList("pm.runlist", testListData); list.setBorder(BorderFactory.createEtchedBorder()); list.setCellRenderer(RenderingUtilities.createTestListRenderer()); list.addMouseListener(new MouseAdapter() { @@ -515,7 +515,6 @@ private JTextField fileField; private DefaultListModel testListData; - private JList testList; private String rootDir; } diff --git a/src/com/sun/javatest/exec/RenderingUtilities.java b/src/com/sun/javatest/exec/RenderingUtilities.java --- a/src/com/sun/javatest/exec/RenderingUtilities.java +++ b/src/com/sun/javatest/exec/RenderingUtilities.java @@ -41,11 +41,11 @@ import com.sun.javatest.util.I18NResourceBundle; class RenderingUtilities { - static ListCellRenderer createTestListRenderer() { + static ListCellRenderer createTestListRenderer() { return new TestCellRenderer(i18n); } - static ListCellRenderer createTRTNodeRenderer() { + static ListCellRenderer createTRTNodeRenderer() { return new TestCellRenderer(i18n); } @@ -63,13 +63,13 @@ /** * Render a list of tests (TestResult objects). */ - static class TestCellRenderer extends JLabel implements ListCellRenderer { + static class TestCellRenderer extends JLabel implements ListCellRenderer { public TestCellRenderer(I18NResourceBundle i18n) { setOpaque(false); this.i18n = i18n; } - public Component getListCellRendererComponent(JList list, + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value == null) // very strange... return this; @@ -107,7 +107,7 @@ return this; } - private void setBasicAttribs(boolean isSelected, JList list) { + private void setBasicAttribs(boolean isSelected, JList list) { // Hopefully safe to share...will help with saving space // This border is to provide space between the text and the // side of the widget, helping readability. @@ -159,7 +159,7 @@ return this; } - private void setColors(boolean isSelected, JList list) { + private void setColors(boolean isSelected, JList list) { if (isSelected) { setOpaque(true); setForeground(list.getSelectionForeground()); diff --git a/src/com/sun/javatest/exec/RunTestsHandler.java b/src/com/sun/javatest/exec/RunTestsHandler.java --- a/src/com/sun/javatest/exec/RunTestsHandler.java +++ b/src/com/sun/javatest/exec/RunTestsHandler.java @@ -285,7 +285,7 @@ for (int i = paths.length; i > 0; i--) model.add(model.getSize(), paths[model.getSize()]); - JList list = uif.createList("rh.confirmList", model); + JList list = uif.createList("rh.confirmList", model); p.add(uif.createScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER); diff --git a/src/com/sun/javatest/exec/TP_DescSubpanel.java b/src/com/sun/javatest/exec/TP_DescSubpanel.java --- a/src/com/sun/javatest/exec/TP_DescSubpanel.java +++ b/src/com/sun/javatest/exec/TP_DescSubpanel.java @@ -54,8 +54,8 @@ return; } - for (Iterator iter = td.getParameterKeys(); iter.hasNext(); ) { - String key = (String)(iter.next()); + for (Iterator iter = td.getParameterKeys(); iter.hasNext(); ) { + String key = (iter.next()); String val = td.getParameter(key); updateEntry(key, val); } diff --git a/src/com/sun/javatest/exec/TP_OutputSubpanel.java b/src/com/sun/javatest/exec/TP_OutputSubpanel.java --- a/src/com/sun/javatest/exec/TP_OutputSubpanel.java +++ b/src/com/sun/javatest/exec/TP_OutputSubpanel.java @@ -700,8 +700,8 @@ } public void valueChanged(ListSelectionEvent e) { - JList l = (JList) (e.getSource()); - TOCEntry entry = (TOCEntry) (l.getSelectedValue()); + JList l = (JList) (e.getSource()); + TOCEntry entry = (l.getSelectedValue()); if (entry == null) return; titleField.setText(entry.getTitle()); @@ -877,7 +877,7 @@ } private class TOCRenderer extends DefaultListCellRenderer { - public Component getListCellRendererComponent(JList list, + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, diff --git a/src/com/sun/javatest/exec/TP_PropertySubpanel.java b/src/com/sun/javatest/exec/TP_PropertySubpanel.java --- a/src/com/sun/javatest/exec/TP_PropertySubpanel.java +++ b/src/com/sun/javatest/exec/TP_PropertySubpanel.java @@ -90,11 +90,10 @@ table.reset(); } - protected void updateEntries(Map map) { - for (Iterator i = map.entrySet().iterator(); i.hasNext(); ) { - Map.Entry e = (Map.Entry) (i.next()); - String key = (String) (e.getKey()); - String val = (String) (e.getValue()); + protected void updateEntries(Map map) { + for (Map.Entry e : map.entrySet()) { + String key = (e.getKey()); + String val = (e.getValue()); if (val != null && !val.trim().isEmpty()) { table.updateEntry(key, val); } @@ -241,8 +240,8 @@ int y = (inScrollPane ? 0 : h); - for (Iterator iter = entries.values().iterator(); iter.hasNext(); ) { - Entry e = (Entry) (iter.next()); + for (Iterator iter = entries.values().iterator(); iter.hasNext(); ) { + Entry e = (iter.next()); // need to take insets into account for value, since we are dealing // with the elemental view inside the valueField Insets vi = e.valueText.getInsets(); @@ -259,8 +258,8 @@ public Dimension getMinimumSize() { //System.err.println("TP_PS.Table: minimumLayoutSize"); int h = (inScrollPane ? 0 : nameLabel.getPreferredSize().height); - for (Iterator iter = entries.values().iterator(); iter.hasNext(); ) { - Entry e = (Entry) (iter.next()); + for (Iterator iter = entries.values().iterator(); iter.hasNext(); ) { + Entry e = (iter.next()); h += e.valueText.getMinimumSize().height; } return new Dimension(maxNameStringWidth + 400, h); @@ -269,8 +268,8 @@ public Dimension getPreferredSize() { //System.err.println("TP_PS.Table: preferredLayoutSize"); int h = (inScrollPane ? 0 : nameLabel.getPreferredSize().height); - for (Iterator iter = entries.values().iterator(); iter.hasNext(); ) { - Entry e = (Entry) (iter.next()); + for (Iterator iter = entries.values().iterator(); iter.hasNext(); ) { + Entry e = (iter.next()); h += e.valueText.getPreferredSize().height; } return new Dimension(maxNameStringWidth + 400, h); diff --git a/src/com/sun/javatest/exec/TP_ResultsSubpanel.java b/src/com/sun/javatest/exec/TP_ResultsSubpanel.java --- a/src/com/sun/javatest/exec/TP_ResultsSubpanel.java +++ b/src/com/sun/javatest/exec/TP_ResultsSubpanel.java @@ -59,9 +59,9 @@ } private void updateEntries() { - for (Enumeration e = subpanelTest.getPropertyNames(); e.hasMoreElements(); ) { + for (Enumeration e = subpanelTest.getPropertyNames(); e.hasMoreElements(); ) { try { - String key = (String)(e.nextElement()); + String key = (e.nextElement()); String val = subpanelTest.getProperty(key); updateEntry(key, val); } diff --git a/src/com/sun/javatest/exec/TT_BasicNode.java b/src/com/sun/javatest/exec/TT_BasicNode.java --- a/src/com/sun/javatest/exec/TT_BasicNode.java +++ b/src/com/sun/javatest/exec/TT_BasicNode.java @@ -51,7 +51,7 @@ this.tn = tn; } // ------- interface methods -------- - public Enumeration children() { + public Enumeration children() { updateNode(); ArrayList copy = null; @@ -60,14 +60,14 @@ copy = new ArrayList<>(children); } - final Iterator it = copy.iterator(); - return new Enumeration() { + final Iterator it = copy.iterator(); + return new Enumeration() { public boolean hasMoreElements() { return it.hasNext(); } - public Object nextElement() { + public TT_TreeNode nextElement() { return it.next(); } }; diff --git a/src/com/sun/javatest/exec/TT_NodeCache.java b/src/com/sun/javatest/exec/TT_NodeCache.java --- a/src/com/sun/javatest/exec/TT_NodeCache.java +++ b/src/com/sun/javatest/exec/TT_NodeCache.java @@ -723,7 +723,7 @@ /** * Determine the index of a particular test in a vector. */ - private int searchList(TestResult target, Vector list) { + private int searchList(TestResult target, Vector list) { int possible = list.indexOf(target); return possible; } diff --git a/src/com/sun/javatest/exec/TT_TestNode.java b/src/com/sun/javatest/exec/TT_TestNode.java --- a/src/com/sun/javatest/exec/TT_TestNode.java +++ b/src/com/sun/javatest/exec/TT_TestNode.java @@ -42,7 +42,7 @@ this.parent = parent; } // ------- interface methods -------- - public Enumeration children() { + public Enumeration children() { throw new UnsupportedOperationException("Not supported."); } diff --git a/src/com/sun/javatest/exec/TestPanel.java b/src/com/sun/javatest/exec/TestPanel.java --- a/src/com/sun/javatest/exec/TestPanel.java +++ b/src/com/sun/javatest/exec/TestPanel.java @@ -170,7 +170,7 @@ // check if there are any environment entries recorded boolean hasEnv; try { - Map map = currTest.getEnvironment(); + Map map = currTest.getEnvironment(); hasEnv = (map != null && map.size() > 0); } catch (TestResult.Fault f) { diff --git a/src/com/sun/javatest/exec/TestTree.java b/src/com/sun/javatest/exec/TestTree.java --- a/src/com/sun/javatest/exec/TestTree.java +++ b/src/com/sun/javatest/exec/TestTree.java @@ -171,10 +171,10 @@ return null; TreePath[] paths = new TreePath[0]; - Enumeration e = getDescendantToggledPaths(new TreePath(currModel.getRoot())); + Enumeration e = getDescendantToggledPaths(new TreePath(currModel.getRoot())); while (e != null && e.hasMoreElements()) { - TreePath tp = (TreePath)(e.nextElement()); + TreePath tp = (e.nextElement()); if (!isVisible(tp)) // if we can't see it, we don't care continue; if (!isExpanded(tp)) // if it's not expanded, we don't need it diff --git a/src/com/sun/javatest/exec/TestTreeModel.java b/src/com/sun/javatest/exec/TestTreeModel.java --- a/src/com/sun/javatest/exec/TestTreeModel.java +++ b/src/com/sun/javatest/exec/TestTreeModel.java @@ -997,7 +997,7 @@ */ void invalidateNodeInfo() { synchronized (htLock) { - Enumeration e = cache.keys(); + Enumeration e = cache.keys(); while (e.hasMoreElements()) { (cache.get(e.nextElement())).invalidate(); } // while @@ -1008,9 +1008,9 @@ } // reprocess any needed nodes - Iterator it = relevantNodes.iterator(); + Iterator it = relevantNodes.iterator(); while (it.hasNext()) { - TT_TreeNode tn = (TT_TreeNode) it.next(); + TT_TreeNode tn = it.next(); if (tn instanceof TT_BasicNode) { getNodeInfo(((TT_BasicNode) tn).getTableNode(), false); } @@ -1337,7 +1337,7 @@ // basically equivalent TT_NodeCache selected = null; int depth = -1; - LinkedList theList = cacheQueue; + LinkedList theList = cacheQueue; boolean notDone = true; int count = 0; @@ -1351,7 +1351,7 @@ } while (notDone) { - TT_NodeCache possible = (TT_NodeCache) (theList.get(count)); + TT_NodeCache possible = (theList.get(count)); int thisDepth = TestResultTable.getObjectPath(possible.getNode()).length; if (thisDepth > depth) { diff --git a/src/com/sun/javatest/exec/TestTreePanel.java b/src/com/sun/javatest/exec/TestTreePanel.java --- a/src/com/sun/javatest/exec/TestTreePanel.java +++ b/src/com/sun/javatest/exec/TestTreePanel.java @@ -1583,7 +1583,7 @@ * @param prefix i18n bundle prefix * @param args Arguments for the user message string, which is prefix.txt. */ - private int showConfirmListDialog(String prefix, Object[] args, ListModel model) { + private int showConfirmListDialog(String prefix, Object[] args, ListModel model) { // resources needed: // prefix.title JPanel p = uif.createPanel("ttp.confirmPanel", false); @@ -1591,7 +1591,7 @@ p.setLayout(new BorderLayout()); p.add(msg, BorderLayout.NORTH); - JList list = uif.createList("treep.nodeList", model); + JList list = uif.createList("treep.nodeList", model); p.add(uif.createScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER); diff --git a/src/com/sun/javatest/finder/BinaryTestWriter.java b/src/com/sun/javatest/finder/BinaryTestWriter.java --- a/src/com/sun/javatest/finder/BinaryTestWriter.java +++ b/src/com/sun/javatest/finder/BinaryTestWriter.java @@ -278,7 +278,7 @@ throw new NullPointerException(); try { - Class c = Class.forName(finder); + Class c = Class.forName(finder); testFinder = (TestFinder) (c.newInstance()); testFinder.init(args, ts, null); } @@ -386,10 +386,8 @@ return null; Arrays.sort(files); - Arrays.sort(tests, new Comparator() { - public int compare(Object o1, Object o2) { - TestDescription td1 = (TestDescription) o1; - TestDescription td2 = (TestDescription) o2; + Arrays.sort(tests, new Comparator() { + public int compare(TestDescription td1, TestDescription td2) { return td1.getRootRelativeURL().compareTo(td2.getRootRelativeURL()); } }); @@ -463,8 +461,8 @@ * Add all the strings used in a test description to the table. */ void add(TestDescription test) { - for (Iterator i = test.getParameterKeys(); i.hasNext(); ) { - String key = (String) (i.next()); + for (Iterator i = test.getParameterKeys(); i.hasNext(); ) { + String key = (i.next()); String param = test.getParameter(key); add(key); add(param); @@ -669,8 +667,8 @@ private void write(TestDescription td, DataOutputStream o) throws IOException { // should consider using load/save here writeInt(o, td.getParameterCount()); - for (Iterator i = td.getParameterKeys(); i.hasNext(); ) { - String key = (String) (i.next()); + for (Iterator i = td.getParameterKeys(); i.hasNext(); ) { + String key = (i.next()); String value = td.getParameter(key); stringTable.writeRef(key, o); stringTable.writeRef(value, o); diff --git a/src/com/sun/javatest/finder/ChameleonTestFinder.java b/src/com/sun/javatest/finder/ChameleonTestFinder.java --- a/src/com/sun/javatest/finder/ChameleonTestFinder.java +++ b/src/com/sun/javatest/finder/ChameleonTestFinder.java @@ -278,7 +278,7 @@ currEntry = null; } - private Object newInstance(Class c) throws Fault { + private Object newInstance(Class c) throws Fault { try { return c.newInstance(); } @@ -292,7 +292,7 @@ } } - private Class loadClass(String className) throws Fault { + private Class loadClass(String className) throws Fault { try { if (loader == null) return Class.forName(className); diff --git a/src/com/sun/javatest/finder/ExpandTestFinder.java b/src/com/sun/javatest/finder/ExpandTestFinder.java --- a/src/com/sun/javatest/finder/ExpandTestFinder.java +++ b/src/com/sun/javatest/finder/ExpandTestFinder.java @@ -110,9 +110,9 @@ expandVars = new HashMap<>(3); expandVarLen = new HashMap<>(3); - for (Iterator i = env.keys().iterator(); i.hasNext(); ) { + for (Iterator i = env.keys().iterator(); i.hasNext(); ) { try { - String n = (String) (i.next()); + String n = (i.next()); if (! n.startsWith("expand.")) continue; diff --git a/src/com/sun/javatest/finder/ReverseTestFinder.java b/src/com/sun/javatest/finder/ReverseTestFinder.java --- a/src/com/sun/javatest/finder/ReverseTestFinder.java +++ b/src/com/sun/javatest/finder/ReverseTestFinder.java @@ -76,7 +76,7 @@ TestEnvironment env) throws Fault { String delegateClassName = args[0]; try { - Class delegateClass = Class.forName(delegateClassName, true, ClassLoader.getSystemClassLoader()); + Class delegateClass = Class.forName(delegateClassName, true, ClassLoader.getSystemClassLoader()); delegate = (TestFinder)(delegateClass.newInstance()); args = shift(args, 1); delegate.init(args, testSuiteRoot, env); diff --git a/src/com/sun/javatest/finder/ShowTests.java b/src/com/sun/javatest/finder/ShowTests.java --- a/src/com/sun/javatest/finder/ShowTests.java +++ b/src/com/sun/javatest/finder/ShowTests.java @@ -223,7 +223,7 @@ TestFinder testFinder; try { - Class c = Class.forName(finder); + Class c = Class.forName(finder); testFinder = (TestFinder) (c.newInstance()); testFinder.init(args, ts, null); } @@ -258,8 +258,8 @@ TestDescription td = tests[i]; out.println(" " + td.getRootRelativeURL()); if (fullTests) { - for (Iterator iter = td.getParameterKeys(); iter.hasNext(); ) { - String key = (String) (iter.next()); + for (Iterator iter = td.getParameterKeys(); iter.hasNext(); ) { + String key = (iter.next()); String value = td.getParameter(key); out.print(" "); out.print(key); diff --git a/src/com/sun/javatest/httpd/PageGenerator.java b/src/com/sun/javatest/httpd/PageGenerator.java --- a/src/com/sun/javatest/httpd/PageGenerator.java +++ b/src/com/sun/javatest/httpd/PageGenerator.java @@ -121,7 +121,7 @@ /** * Prints the contents of any dictionary in a two column table. */ - public static void writeDictionary(PrintWriter out, Dictionary dict, + public static void writeDictionary(PrintWriter out, Dictionary dict, String keyHeader, String valHeader) { // XXX should include HTML filtering of strings @@ -148,7 +148,7 @@ buf.append(""); } else { - Enumeration keys = dict.keys(); + Enumeration keys = dict.keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); out.println(""); diff --git a/src/com/sun/javatest/httpd/RequestHandler.java b/src/com/sun/javatest/httpd/RequestHandler.java --- a/src/com/sun/javatest/httpd/RequestHandler.java +++ b/src/com/sun/javatest/httpd/RequestHandler.java @@ -163,7 +163,6 @@ out.println(""); } - private static Hashtable urlMap; private Socket soc; private PrintWriter out; diff --git a/src/com/sun/javatest/httpd/httpURL.java b/src/com/sun/javatest/httpd/httpURL.java --- a/src/com/sun/javatest/httpd/httpURL.java +++ b/src/com/sun/javatest/httpd/httpURL.java @@ -149,7 +149,7 @@ * Set the key-value pairs encoded in this URL. * Not implemented yet. */ - public void setProperties(Dictionary props) { + public void setProperties(Dictionary props) { } /** diff --git a/src/com/sun/javatest/interview/EnvironmentInterview.java b/src/com/sun/javatest/interview/EnvironmentInterview.java --- a/src/com/sun/javatest/interview/EnvironmentInterview.java +++ b/src/com/sun/javatest/interview/EnvironmentInterview.java @@ -259,9 +259,9 @@ // verify all entries defined cachedEnvError = null; cachedEnvErrorArgs = null; - for (Iterator i = cachedEnv.elements().iterator(); + for (Iterator i = cachedEnv.elements().iterator(); i.hasNext() && cachedEnvError == null; ) { - TestEnvironment.Element entry = (TestEnvironment.Element) (i.next()); + TestEnvironment.Element entry = (i.next()); if (entry.getValue().indexOf("VALUE_NOT_DEFINED") >= 0) { cachedEnv = null; String eText = diff --git a/src/com/sun/javatest/junit/JUnitAnnotationMultiTest.java b/src/com/sun/javatest/junit/JUnitAnnotationMultiTest.java --- a/src/com/sun/javatest/junit/JUnitAnnotationMultiTest.java +++ b/src/com/sun/javatest/junit/JUnitAnnotationMultiTest.java @@ -82,7 +82,7 @@ protected void setup(String executeClass) { try { - Class junitTestCaseClass = getClassLoader().loadClass(executeClass); + Class junitTestCaseClass = getClassLoader().loadClass(executeClass); testCaseClass = junitTestCaseClass; @@ -95,5 +95,5 @@ t.printStackTrace(log); } - protected Class testCaseClass; + protected Class testCaseClass; } diff --git a/src/com/sun/javatest/junit/JUnitAnnotationTestFinder.java b/src/com/sun/javatest/junit/JUnitAnnotationTestFinder.java --- a/src/com/sun/javatest/junit/JUnitAnnotationTestFinder.java +++ b/src/com/sun/javatest/junit/JUnitAnnotationTestFinder.java @@ -153,7 +153,7 @@ */ protected void scanFile(File file) { testMethods = new ArrayList<>(); // new every time we visit a new class - tdValues = new HashMap(); + tdValues = new HashMap<>(); String name = file.getName(); int dot = name.indexOf('.'); diff --git a/src/com/sun/javatest/junit/JUnitBareMultiTest.java b/src/com/sun/javatest/junit/JUnitBareMultiTest.java --- a/src/com/sun/javatest/junit/JUnitBareMultiTest.java +++ b/src/com/sun/javatest/junit/JUnitBareMultiTest.java @@ -63,9 +63,9 @@ if (tests == null) { return Status.failed("No test cases found in test."); } - Iterator iterator = ((Set)tests.entrySet()).iterator(); + Iterator> iterator = tests.entrySet().iterator(); while (iterator.hasNext()) { - Method method = (Method)((Map.Entry)iterator.next()).getValue(); + Method method = iterator.next().getValue(); Status status = null; try { status = invokeTestCase(method); @@ -95,7 +95,7 @@ protected void setup(String executeClass) { TestCase test; try { - Class tc = getClassLoader().loadClass(executeClass); + Class tc = getClassLoader().loadClass(executeClass); String name = tc.getName(); String constructor = tc.getConstructors()[0].toGenericString(); test = (constructor.indexOf("java.lang.String") > -1)? @@ -144,8 +144,8 @@ if(m == null || excludeTestCases.contains(m.getName())){ continue; } - Class[] paramTypes = m.getParameterTypes(); - Class returnType = m.getReturnType(); + Class[] paramTypes = m.getParameterTypes(); + Class returnType = m.getReturnType(); String name = m.getName(); if ((paramTypes.length == 0) && Void.TYPE.isAssignableFrom(returnType) && name.startsWith("test") ) { @@ -161,5 +161,5 @@ protected SortedMap tests; protected String testCases[] = null; - protected Vector excludeTestCases = new Vector(); + protected Vector excludeTestCases = new Vector<>(); } diff --git a/src/com/sun/javatest/junit/JUnitBaseInterview.java b/src/com/sun/javatest/junit/JUnitBaseInterview.java --- a/src/com/sun/javatest/junit/JUnitBaseInterview.java +++ b/src/com/sun/javatest/junit/JUnitBaseInterview.java @@ -53,7 +53,7 @@ public TestEnvironment getEnv() { try { - return new TestEnvironment("junitenv", new HashMap(), "junit"); + return new TestEnvironment("junitenv", new HashMap(), "junit"); } catch (TestEnvironment.Fault f) { f.printStackTrace(); diff --git a/src/com/sun/javatest/junit/JUnitSuperTestFinder.java b/src/com/sun/javatest/junit/JUnitSuperTestFinder.java --- a/src/com/sun/javatest/junit/JUnitSuperTestFinder.java +++ b/src/com/sun/javatest/junit/JUnitSuperTestFinder.java @@ -332,7 +332,7 @@ //----------member variables------------------------------------------------ - protected ArrayList requiredSuperclass = new ArrayList(); + protected ArrayList requiredSuperclass = new ArrayList<>(); protected String initialTag = "test"; protected final MethodFinderVisitor mfv = new MethodFinderVisitor(); protected static final I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(JUnitSuperTestFinder.class); diff --git a/src/com/sun/javatest/junit/JUnitTestFinder.java b/src/com/sun/javatest/junit/JUnitTestFinder.java --- a/src/com/sun/javatest/junit/JUnitTestFinder.java +++ b/src/com/sun/javatest/junit/JUnitTestFinder.java @@ -121,7 +121,7 @@ * A class to read files of a particular extension. * The class must be a subtype of CommentStream */ - public void addExtension(String extn, Class commentStreamClass) { + public void addExtension(String extn, Class commentStreamClass) { if (!extn.startsWith(".")) throw new IllegalArgumentException("extension must begin with `.'"); if (commentStreamClass != null && !CommentStream.class.isAssignableFrom(commentStreamClass)) @@ -135,7 +135,7 @@ * @param extn The extension in question * @return the class previously registered with addExtension */ - public Class getClassForExtension(String extn) { + public Class getClassForExtension(String extn) { return extensionTable.get(extn); } @@ -151,7 +151,7 @@ protected boolean scanClasses = false; protected File currFile; protected Map excludeList = new HashMap<>(); - protected Map extensionTable = new HashMap<>(); + protected Map> extensionTable = new HashMap<>(); protected List testMethods; protected static final String[] excludeNames = { "SCCS", "deleted_files", ".svn" diff --git a/src/com/sun/javatest/junit/JUnitTestRunner.java b/src/com/sun/javatest/junit/JUnitTestRunner.java --- a/src/com/sun/javatest/junit/JUnitTestRunner.java +++ b/src/com/sun/javatest/junit/JUnitTestRunner.java @@ -50,12 +50,12 @@ // by the corresponding TestSuite class. } - protected boolean runTests(Iterator testIter) throws InterruptedException { + protected boolean runTests(Iterator testIter) throws InterruptedException { WorkDirectory wd = getWorkDirectory(); TestDescription td = null; //for (TestDescription td: testIter) { for (; testIter.hasNext() ;) { - td = (TestDescription)(testIter.next()); + td = testIter.next(); TestResult tr = new TestResult(td); TestResult.Section outSection = tr.createSection("Main"); @@ -85,7 +85,7 @@ this.loader = loader; try { - Class c = loader.loadClass("com.sun.javatest.junit.JUnitMultiTest"); + Class c = loader.loadClass("com.sun.javatest.junit.JUnitMultiTest"); } catch (ClassNotFoundException e) { e.printStackTrace(); } diff --git a/src/com/sun/javatest/junit/JUnitTestSuite.java b/src/com/sun/javatest/junit/JUnitTestSuite.java --- a/src/com/sun/javatest/junit/JUnitTestSuite.java +++ b/src/com/sun/javatest/junit/JUnitTestSuite.java @@ -37,7 +37,7 @@ * Basic implementation of a test suite for JUnit tests. */ public class JUnitTestSuite extends TestSuite { - public JUnitTestSuite(File root, Map props, ClassLoader loader) throws TestSuite.Fault { + public JUnitTestSuite(File root, Map props, ClassLoader loader) throws TestSuite.Fault { super(root, props, loader); try { if (getTestsDir() != null) @@ -56,7 +56,7 @@ // will need to add options to test suite to be passed to runner // for ex. - to run setup/teardown, etc... try { - Class c = loadClass("com.sun.javatest.junit.JUnitTestRunner"); + Class c = loadClass("com.sun.javatest.junit.JUnitTestRunner"); JUnitTestRunner tr = (JUnitTestRunner)(c.newInstance()); tr.setClassLoader(getClassLoader()); return tr; diff --git a/src/com/sun/javatest/lib/ExecStdTestSameJVMCmd.java b/src/com/sun/javatest/lib/ExecStdTestSameJVMCmd.java --- a/src/com/sun/javatest/lib/ExecStdTestSameJVMCmd.java +++ b/src/com/sun/javatest/lib/ExecStdTestSameJVMCmd.java @@ -105,7 +105,7 @@ Status status = null; try { - Class c; + Class c; if (loader == null) c = Class.forName(className); else diff --git a/src/com/sun/javatest/lib/JavaCompileCommand.java b/src/com/sun/javatest/lib/JavaCompileCommand.java --- a/src/com/sun/javatest/lib/JavaCompileCommand.java +++ b/src/com/sun/javatest/lib/JavaCompileCommand.java @@ -182,7 +182,7 @@ else loader = new PathClassLoader(classpath); - Class compilerClass; + Class compilerClass; if (compilerClassName != null) { compilerClass = getClass(loader, compilerClassName); if (compilerClass == null) @@ -201,12 +201,12 @@ Object[] compileMethodArgs; Method compileMethod = getMethod(compilerClass, "compile", // JDK1.4+ - new Class[] { String[].class, PrintWriter.class }); + new Class[] { String[].class, PrintWriter.class }); if (compileMethod != null) compileMethodArgs = new Object[] { args, ref }; else { compileMethod = getMethod(compilerClass, "compile", // JDK1.1-3 - new Class[] { String[].class }); + new Class[] { String[].class }); if (compileMethod != null) compileMethodArgs = new Object[] { args }; else @@ -218,12 +218,12 @@ compiler = null; else { Object[] constrArgs; - Constructor constr = getConstructor(compilerClass, // JDK1.1-2 - new Class[] { OutputStream.class, String.class }); + Constructor constr = getConstructor(compilerClass, // JDK1.1-2 + new Class[] { OutputStream.class, String.class }); if (constr != null) constrArgs = new Object[] { new WriterStream(ref), compilerName }; else { - constr = getConstructor(compilerClass, new Class[0]); // JDK1.3 + constr = getConstructor(compilerClass, new Class[0]); // JDK1.3 if (constr != null) constrArgs = new Object[0]; else @@ -265,7 +265,7 @@ } } - private Class getClass(ClassLoader loader, String name) { + private Class getClass(ClassLoader loader, String name) { try { return (loader == null ? Class.forName(name) : loader.loadClass(name)); } @@ -274,7 +274,7 @@ } } - private Constructor getConstructor(Class c, Class[] argTypes) { + private Constructor getConstructor(Class c, Class[] argTypes) { try { return c.getConstructor(argTypes); } @@ -288,7 +288,7 @@ } } - private Method getMethod(Class c, String name, Class[] argTypes) { + private Method getMethod(Class c, String name, Class[] argTypes) { try { return c.getMethod(name, argTypes); } diff --git a/src/com/sun/javatest/lib/KeywordScript.java b/src/com/sun/javatest/lib/KeywordScript.java --- a/src/com/sun/javatest/lib/KeywordScript.java +++ b/src/com/sun/javatest/lib/KeywordScript.java @@ -64,14 +64,14 @@ } // for String prefix = "script."; - Set testKeys = td.getKeywordTable(); + Set testKeys = td.getKeywordTable(); Vector choices = new Vector<>(); // the set of choices Vector matches = new Vector<>(); // the set of matches int wordsMatchingInMatches = 0;// the number of words matching findMatch: - for (Iterator iter = env.keys().iterator(); iter.hasNext(); ) { - String key = (String) (iter.next()); + for (Iterator iter = env.keys().iterator(); iter.hasNext(); ) { + String key = (iter.next()); // if the key does not begin with the `script.' prefix, ignore key if (!key.startsWith(prefix)) @@ -177,7 +177,7 @@ printStrArr(trOut, msgs); try { - Class c = Class.forName(command[0]); + Class c = Class.forName(command[0]); Script script = (Script)c.newInstance(); String[] scriptArgs = new String[command.length - 1]; diff --git a/src/com/sun/javatest/lib/TestCases.java b/src/com/sun/javatest/lib/TestCases.java --- a/src/com/sun/javatest/lib/TestCases.java +++ b/src/com/sun/javatest/lib/TestCases.java @@ -138,15 +138,15 @@ * select and exclude calls that have been made, if any. * @return An enumeration of the test cases. */ - public Enumeration enumerate() { + public Enumeration enumerate() { Vector v = new Vector<>(); if (selectedCases.isEmpty()) { Method[] methods = testClass.getMethods(); for (int i = 0; i < methods.length; i++) { Method m = methods[i]; if (excludedCases.get(m.getName()) == null) { - Class[] paramTypes = m.getParameterTypes(); - Class returnType = m.getReturnType(); + Class[] paramTypes = m.getParameterTypes(); + Class returnType = m.getReturnType(); if ((paramTypes.length == 0) && Status.class.isAssignableFrom(returnType)) v.addElement(m); } @@ -176,7 +176,7 @@ // see if test object provides Status invokeTestCase(Method m) Method invoker; try { - invoker = testClass.getMethod("invokeTestCase", new Class[] {Method.class}); + invoker = testClass.getMethod("invokeTestCase", new Class[] {Method.class}); if (!Status.class.isAssignableFrom(invoker.getReturnType())) invoker = null; } @@ -185,8 +185,8 @@ } MultiStatus ms = new MultiStatus(log); - for (Enumeration e = enumerate(); e.hasMoreElements(); ) { - Method m = (Method)(e.nextElement()); + for (Enumeration e = enumerate(); e.hasMoreElements(); ) { + Method m = (e.nextElement()); Status s; try { if (invoker != null) @@ -271,5 +271,5 @@ private PrintWriter log; private static final Object[] noArgs = { }; - private static final Class[] noArgTypes = { }; + private static final Class[] noArgTypes = { }; } diff --git a/src/com/sun/javatest/logging/LogModel.java b/src/com/sun/javatest/logging/LogModel.java --- a/src/com/sun/javatest/logging/LogModel.java +++ b/src/com/sun/javatest/logging/LogModel.java @@ -427,7 +427,7 @@ private class MessageCache extends LinkedHashMap { - protected boolean removeEldestEntry(Map.Entry eldest) { + protected boolean removeEldestEntry(Map.Entry eldest) { return size() > PAGE_SIZE*2; } } diff --git a/src/com/sun/javatest/mrep/BrowserPane.java b/src/com/sun/javatest/mrep/BrowserPane.java --- a/src/com/sun/javatest/mrep/BrowserPane.java +++ b/src/com/sun/javatest/mrep/BrowserPane.java @@ -562,7 +562,7 @@ //------------------------------------------------------------------------------------ private class Renderer extends DefaultListCellRenderer { - public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) { + public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) { String name = null; if (o instanceof URL) { URL url = (URL) o; diff --git a/src/com/sun/javatest/mrep/ConflictResolutionDialog.java b/src/com/sun/javatest/mrep/ConflictResolutionDialog.java --- a/src/com/sun/javatest/mrep/ConflictResolutionDialog.java +++ b/src/com/sun/javatest/mrep/ConflictResolutionDialog.java @@ -66,7 +66,7 @@ private JButton cancelButton; private DefaultListModel listModel; - private JList list; + private JList list; private int selectedIndex; private boolean bPreferredReport; diff --git a/src/com/sun/javatest/mrep/Merger.java b/src/com/sun/javatest/mrep/Merger.java --- a/src/com/sun/javatest/mrep/Merger.java +++ b/src/com/sun/javatest/mrep/Merger.java @@ -50,11 +50,11 @@ public boolean merge(File[] in, File out, ConflictResolver conflictResolver) throws SAXException, ParserConfigurationException, IOException{ // Maps with statistics - Map[] inputs = new Map[in.length]; + Map[] inputs = new Map[in.length]; // read statistics for (int i = 0; i < in.length; i++) { XMLReportReader reader = new XMLReportReader(); - Map map = reader.readIDs(in[i]); + Map map = reader.readIDs(in[i]); inputs[i] = map; } @@ -65,7 +65,7 @@ List conflicts = new ArrayList<>(); for (int i = 0; i < in.length; i++) { int workdirsInFile = 0; - Iterator it = inputs[i].keySet().iterator(); + Iterator it = inputs[i].keySet().iterator(); Map newMap = new HashMap<>(); while (it.hasNext()) { Object o = it.next(); diff --git a/src/com/sun/javatest/mrep/OptionsPane.java b/src/com/sun/javatest/mrep/OptionsPane.java --- a/src/com/sun/javatest/mrep/OptionsPane.java +++ b/src/com/sun/javatest/mrep/OptionsPane.java @@ -322,7 +322,7 @@ * @param p parent Panel * @param cardLayout The CardLayout for options */ - SelectListener(JList lst, JPanel p, CardLayout cardLayout) { + SelectListener(JList lst, JPanel p, CardLayout cardLayout) { list = lst; listModel = list.getModel(); lastSelected = listModel.getElementAt(0); @@ -344,7 +344,7 @@ public void valueChanged(ListSelectionEvent e) { int index = list.getSelectedIndex(); - JCheckBox box = (JCheckBox) (listModel.getElementAt(index)); + JCheckBox box = (listModel.getElementAt(index)); if (lastSelected != box) { cards.show(panel, box.getName()); @@ -379,7 +379,7 @@ } private void process(final int index) { - JCheckBox box = (JCheckBox) (listModel.getElementAt(index)); + JCheckBox box = (listModel.getElementAt(index)); if (lastSelected == box) { box.doClick(); @@ -396,8 +396,8 @@ } Object lastSelected; - JList list; - ListModel listModel; + JList list; + ListModel listModel; JPanel panel; CardLayout cards; double emptyCBW = new JCheckBox("").getPreferredSize().getWidth() + 2; @@ -469,7 +469,7 @@ } private class CheckBoxListCellRenderer implements ListCellRenderer { - public Component getListCellRendererComponent(JList list, JCheckBox comp, + public Component getListCellRendererComponent(JList list, JCheckBox comp, int index, boolean isSelected, boolean cellHasFocus) { // assert: value is a JCheckBox if (isSelected) { diff --git a/src/com/sun/javatest/mrep/ReportDirChooser.java b/src/com/sun/javatest/mrep/ReportDirChooser.java --- a/src/com/sun/javatest/mrep/ReportDirChooser.java +++ b/src/com/sun/javatest/mrep/ReportDirChooser.java @@ -51,7 +51,7 @@ // be safely loaded, before the JFileChooser starts running its background // thread, exposing a JVM bug in class loading. static { - Class reportClass = Report.class; + Class reportClass = Report.class; } /** diff --git a/src/com/sun/javatest/mrep/XMLReportWriter.java b/src/com/sun/javatest/mrep/XMLReportWriter.java --- a/src/com/sun/javatest/mrep/XMLReportWriter.java +++ b/src/com/sun/javatest/mrep/XMLReportWriter.java @@ -124,7 +124,7 @@ ser.startElement("", "", Scheme.REPORT, atts); } - public void write(File[] file, Map[] map) throws SAXException, + public void write(File[] file, Map[] map) throws SAXException, ParserConfigurationException, IOException { try { ser.startDocument(); @@ -171,9 +171,9 @@ // id -> new_id mapping // url -> new_TestDescr mapping - private Map map; + private Map map; - public CopyHandler(ContentHandler ser, boolean isWorkDir, Map map) { + public CopyHandler(ContentHandler ser, boolean isWorkDir, Map map) { this.ser = ser; if (ser instanceof LexicalHandler) { lh = (LexicalHandler) ser; diff --git a/src/com/sun/javatest/report/ConfigSection.java b/src/com/sun/javatest/report/ConfigSection.java --- a/src/com/sun/javatest/report/ConfigSection.java +++ b/src/com/sun/javatest/report/ConfigSection.java @@ -382,16 +382,16 @@ Set envTable = new TreeSet<>(new StringArrayComparator()); - for (Iterator i = env.elements().iterator(); i.hasNext(); ) { - TestEnvironment.Element envElem = (TestEnvironment.Element) (i.next()); + for (Iterator i = env.elements().iterator(); i.hasNext(); ) { + TestEnvironment.Element envElem = (i.next()); String[] envTableRow = {envElem.getKey(), envElem.getValue()}; envTable.add(envTableRow); } out.startTag(HTMLWriterEx.TABLE); out.writeAttr(HTMLWriterEx.BORDER, 1); - for (Iterator i = envTable.iterator(); i.hasNext(); ) { - String[] envEntry = (String[]) (i.next()); + for (Iterator i = envTable.iterator(); i.hasNext(); ) { + String[] envEntry = (i.next()); out.startTag(HTMLWriterEx.TR); for (int j = 0; j < envEntry.length; j++ ) { @@ -417,7 +417,7 @@ } else { SortedSet sortedEntries = new TreeSet<>(new ExcludeListEntryComparator()); - for (Iterator iter = excludeList.getIterator(false); iter.hasNext(); ) + for (Iterator iter = excludeList.getIterator(false); iter.hasNext(); ) sortedEntries.add((ExcludeList.Entry)iter.next()); out.startTag(HTMLWriterEx.TABLE); @@ -440,8 +440,8 @@ out.endTag(HTMLWriterEx.TH); out.endTag(HTMLWriterEx.TR); - for (Iterator iter = sortedEntries.iterator(); iter.hasNext(); ) { - ExcludeList.Entry e = (ExcludeList.Entry) (iter.next()); + for (Iterator iter = sortedEntries.iterator(); iter.hasNext(); ) { + ExcludeList.Entry e = (iter.next()); out.startTag(HTMLWriterEx.TR); writeTD(out, e.getRelativeURL()); writeTD(out, e.getTestCases()); diff --git a/src/com/sun/javatest/report/KflSorter.java b/src/com/sun/javatest/report/KflSorter.java --- a/src/com/sun/javatest/report/KflSorter.java +++ b/src/com/sun/javatest/report/KflSorter.java @@ -132,7 +132,7 @@ * @param tests * @return Number of comparison problems encountered. */ - synchronized int run(TreeSet[] tests) { + synchronized int run(TreeSet[] tests) { Iterator it = kfl.getIterator(false); int probs = 0; int tcprobs = 0; @@ -422,7 +422,7 @@ private int addListedTestCases(final KnownFailuresList.Entry entry, final String url, final TestResult tr, - Transitions t, TreeSet set) { + Transitions t, TreeSet set) { int problems = 0; String[] tcs = entry.getTestCaseList(); @@ -619,7 +619,7 @@ * based on the KFL. Using this class allows the analysis to be done once * then queried again and again for different purposes. */ - public static class TestDiff implements Comparable { + public static class TestDiff implements Comparable { public TestDiff(String url, TestResult tr, Transitions type) { this.tr = tr; this.url = url; @@ -700,8 +700,7 @@ } @Override - public int compareTo(Object o) { - TestDiff e = (TestDiff) o; + public int compareTo(TestDiff e) { int n = getName().compareTo(e.getName()); /* if (n == 0) { if (testCase == null && e.testCase == null) diff --git a/src/com/sun/javatest/report/ReportSettings.java b/src/com/sun/javatest/report/ReportSettings.java --- a/src/com/sun/javatest/report/ReportSettings.java +++ b/src/com/sun/javatest/report/ReportSettings.java @@ -448,9 +448,9 @@ * * @return Map for data exchange */ - public Map getExchangeData() { + public Map getExchangeData() { if (exchangeData == null) { - exchangeData = new HashMap(); + exchangeData = new HashMap<>(); } return exchangeData; } @@ -465,7 +465,7 @@ for (int i = 0; i < sortedResults.length; i++) { sortedResults[i] = new TreeSet<>(new TestResultsByNameComparator()); } - Iterator iter; + Iterator iter; try { TestFilter[] fs = null; // Note: settings.filter should not really be null, modernized clients @@ -480,7 +480,7 @@ throw new JavaTestError(ReportSettings.i18n.getString("result.testResult.err")); } for (; iter.hasNext();) { - TestResult tr = (TestResult) (iter.next()); + TestResult tr = (iter.next()); Status s = tr.getStatus(); TreeSet list = sortedResults[s == null ? Status.NOT_RUN : s.getType()]; list.add(tr); @@ -530,7 +530,7 @@ File xmlReportFile = null; File tmpXmlReportFile = null; private File[] mif = new File[0]; - private HashMap exchangeData; + private HashMap exchangeData; private InterviewParameters ip; private List customReports = Collections.emptyList(); diff --git a/src/com/sun/javatest/report/ResultSection.java b/src/com/sun/javatest/report/ResultSection.java --- a/src/com/sun/javatest/report/ResultSection.java +++ b/src/com/sun/javatest/report/ResultSection.java @@ -58,7 +58,7 @@ initFiles = settings.getInitialFiles(); lists = sortedResults; - for (TreeSet s: sortedResults) + for (TreeSet s: sortedResults) totalFound += s.size(); /* lists = new TreeSet[Status.NUM_STATES]; @@ -116,7 +116,7 @@ for (int i = 0; i < lists.length; i++ ) { String reportFile = HTMLReport.files[fileCodes[i]]; - TreeSet l = lists[i]; + TreeSet l = lists[i]; int n = l.size(); if (n > 0) { @@ -200,12 +200,12 @@ ReportWriter out = openAuxFile(fileCodes[i], headings[i], i18n); try { - TreeSet list = lists[i]; + TreeSet list = lists[i]; if (list.size() > 0) { boolean inList = false; - for (Iterator iter = list.iterator(); iter.hasNext(); ) { - TestResult e = (TestResult) (iter.next()); + for (Iterator iter = list.iterator(); iter.hasNext(); ) { + TestResult e = (iter.next()); String title; try { TestDescription e_td = e.getDescription(); @@ -247,12 +247,12 @@ ReportWriter out = openAuxFile(groupedFileCodes[i], headings[i], i18n); out.write(i18n.getString("result.groupByStatus")); try { - TreeSet list = lists[i]; + TreeSet list = lists[i]; if (list.size() > 0) { boolean inList = false; String currentHead = null; - for (Iterator iter = list.iterator(); iter.hasNext(); ) { - TestResult e = (TestResult) (iter.next()); + for (Iterator iter = list.iterator(); iter.hasNext(); ) { + TestResult e = (iter.next()); String title; try { TestDescription e_td = e.getDescription(); diff --git a/src/com/sun/javatest/report/StatisticsSection.java b/src/com/sun/javatest/report/StatisticsSection.java --- a/src/com/sun/javatest/report/StatisticsSection.java +++ b/src/com/sun/javatest/report/StatisticsSection.java @@ -142,10 +142,10 @@ } Vector v = new Vector<>(); - for (Iterator iter = keywordTable.entrySet().iterator(); iter.hasNext(); ) { - Map.Entry e = (Map.Entry) (iter.next()); - String k = (String) (e.getKey()); - int[] kv = (int[]) (e.getValue()); + for (Iterator> iter = keywordTable.entrySet().iterator(); iter.hasNext(); ) { + Map.Entry e = (iter.next()); + String k = (e.getKey()); + int[] kv = (e.getValue()); String[] newEntry = new String[ncols]; int c = 0, total = 0; newEntry[c++] = k; diff --git a/src/com/sun/javatest/report/TestResultsByTitleComparator.java b/src/com/sun/javatest/report/TestResultsByTitleComparator.java --- a/src/com/sun/javatest/report/TestResultsByTitleComparator.java +++ b/src/com/sun/javatest/report/TestResultsByTitleComparator.java @@ -30,10 +30,8 @@ import com.sun.javatest.TestResult; -class TestResultsByTitleComparator implements Comparator { - public int compare(Object o1, Object o2) { - TestResult tr1 = (TestResult)o1; - TestResult tr2 = (TestResult)o2; +class TestResultsByTitleComparator implements Comparator { + public int compare(TestResult tr1, TestResult tr2) { return compare(tr1.getTestName(), tr2.getTestName()); } diff --git a/src/com/sun/javatest/report/XMLReport.java b/src/com/sun/javatest/report/XMLReport.java --- a/src/com/sun/javatest/report/XMLReport.java +++ b/src/com/sun/javatest/report/XMLReport.java @@ -144,7 +144,7 @@ maker.sTestResults(); File[] initFiles = sett.getInitialFiles(); - Iterator iter = null; + Iterator iter = null; TestResultTable resultTable = sett.getInterview().getWorkDirectory().getTestResultTable(); try { @@ -154,7 +154,7 @@ iter = resultTable.getIterator(initFiles, new TestFilter[] {sett.getTestFilter()}); } for (; iter.hasNext(); ) { - TestResult tr = (TestResult) (iter.next()); + TestResult tr = (iter.next()); writeResult(maker, tr); } maker.eTestResults(); @@ -203,9 +203,9 @@ String time = testResult.getProperty(TestResult.END); maker.sResultProps(time); - Enumeration en = testResult.getPropertyNames(); + Enumeration en = testResult.getPropertyNames(); while (en.hasMoreElements()) { - String key = (String) en.nextElement(); + String key = en.nextElement(); String val = testResult.getProperty(key); if (!TestResult.END.equals(key)) { maker.makeProperty(key, val); @@ -216,14 +216,14 @@ private void writeEnvironment(final XMLReportMaker maker, final TestResult testResult) throws SAXException { - Iterator keysIt; + Iterator keysIt; try { - Map m = testResult.getEnvironment(); + Map m = testResult.getEnvironment(); keysIt = m.keySet().iterator(); maker.sTestEnvironment(); while (keysIt.hasNext()) { - String key = (String) keysIt.next(); - String val = (String) m.get(key); + String key = keysIt.next(); + String val = m.get(key); maker.makeProperty(key, val); } maker.eTestEnvironment(); @@ -296,8 +296,8 @@ maker.sEnvironment(name, descr); TestEnvironment env = sett.getInterview().getEnv(); if (env != null) { - for (Iterator i = env.elements().iterator(); i.hasNext(); ) { - TestEnvironment.Element envElem = (TestEnvironment.Element) (i.next()); + for (Iterator i = env.elements().iterator(); i.hasNext(); ) { + TestEnvironment.Element envElem = (i.next()); maker.makeProperty(envElem.getKey(), envElem.getValue()); } } diff --git a/src/com/sun/javatest/services/ServiceManager.java b/src/com/sun/javatest/services/ServiceManager.java --- a/src/com/sun/javatest/services/ServiceManager.java +++ b/src/com/sun/javatest/services/ServiceManager.java @@ -290,7 +290,7 @@ if (mode == StartMode.UP_FRONT) { Set active = new TreeSet<>(); try { - Iterator iter = harness.getTestsIterator(null); + Iterator iter = harness.getTestsIterator(null); active = selectActiveServices(iter); } catch (Harness.Fault f) { commonLog.log(Level.SEVERE, f.getMessage()); @@ -367,13 +367,13 @@ this.mode = mode; } - private Set selectActiveServices(Iterator iter) { + private Set selectActiveServices(Iterator iter) { Set active = new TreeSet<>(); Set copy = new HashSet<>(testServiceMap); TestResult tr; TestDescription td; while (!copy.isEmpty() && active.size() < services.size() && - (tr = (TestResult)iter.next()) != null ) { + (tr = iter.next()) != null ) { try { td = tr.getDescription(); HashSet toRemove = new HashSet<>(); diff --git a/src/com/sun/javatest/servlets/ExcludeBrowser.java b/src/com/sun/javatest/servlets/ExcludeBrowser.java --- a/src/com/sun/javatest/servlets/ExcludeBrowser.java +++ b/src/com/sun/javatest/servlets/ExcludeBrowser.java @@ -82,7 +82,7 @@ out.println("Exclude list is empty."); else { out.println(""); - for (Iterator iter = excludeList.getIterator(false); iter.hasNext(); ) { + for (Iterator iter = excludeList.getIterator(false); iter.hasNext(); ) { ExcludeList.Entry entry = (ExcludeList.Entry) (iter.next()); String[] bugIds = entry.getBugIdStrings(); StringBuffer bugIdText = new StringBuffer(); diff --git a/src/com/sun/javatest/servlets/ResultBrowser.java b/src/com/sun/javatest/servlets/ResultBrowser.java --- a/src/com/sun/javatest/servlets/ResultBrowser.java +++ b/src/com/sun/javatest/servlets/ResultBrowser.java @@ -117,8 +117,8 @@ try { TestDescription td = tr.getDescription(); out.println("
"); - for (Iterator iter = td.getParameterKeys(); iter.hasNext(); ) { - String key = (String) (iter.next()); + for (Iterator iter = td.getParameterKeys(); iter.hasNext(); ) { + String key = (iter.next()); String value = td.getParameter(key); if (key.equals("$root") || key.equals("$file") || key.equals("testsuite") || key.equals("file")) out.println("
" + key + "" + filter(value, false) + ""); @@ -151,8 +151,8 @@ out.println("

Test Result properties

"); try { out.println(""); - for (Enumeration e = tr.getPropertyNames(); e.hasMoreElements(); ) { - String key = (String)(e.nextElement()); + for (Enumeration e = tr.getPropertyNames(); e.hasMoreElements(); ) { + String key = (e.nextElement()); out.println("
" + key + "" + filter(tr.getProperty(key), true)); } } @@ -167,16 +167,16 @@ // test environment out.println("

Test Environment

"); try { - Map env = tr.getEnvironment(); + Map env = tr.getEnvironment(); if (env.size() == 0) { out.println("
No environment details found"); } else { out.println(""); - for (Iterator i = env.entrySet().iterator(); i.hasNext(); ) { - Map.Entry e = (Map.Entry) (i.next()); - String key = (String) (e.getKey()); - String value = (String) (e.getValue()); + for (Iterator> i = env.entrySet().iterator(); i.hasNext(); ) { + Map.Entry e = (i.next()); + String key = (e.getKey()); + String value = (e.getValue()); out.println("
" + key + "" + filter(value, true)); } out.println("
"); diff --git a/src/com/sun/javatest/tool/Command.java b/src/com/sun/javatest/tool/Command.java --- a/src/com/sun/javatest/tool/Command.java +++ b/src/com/sun/javatest/tool/Command.java @@ -130,7 +130,7 @@ * entry from the argument array. * @param argIter the iterator from which teh argument was obtained */ - protected void putbackArg(ListIterator argIter) { + protected void putbackArg(ListIterator argIter) { argIter.previous(); args.remove(args.size() - 1); } diff --git a/src/com/sun/javatest/tool/ConfigManager.java b/src/com/sun/javatest/tool/ConfigManager.java --- a/src/com/sun/javatest/tool/ConfigManager.java +++ b/src/com/sun/javatest/tool/ConfigManager.java @@ -211,7 +211,6 @@ return new OpenCommand(file); } - private static Map commandFactory; private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(ConfigManager.class); //-------------------------------------------------------------------------- @@ -879,10 +878,10 @@ InterviewParameters p = getConfig(ctx); Question[] path = p.getPath(); if (file != null) { - Map values = loadFile(file); + Map values = loadFile(file); for (int i = 0; i < path.length; i++) { Question q = path[i]; - String v = (String) (values.get(q.getTag())); + String v = (values.get(q.getTag())); if (v != null) { setValue(q, v); path = p.getPath(); @@ -967,12 +966,10 @@ return (sb.toString()); } - private Map loadFile(File file) throws Fault { + private Map loadFile(File file) throws Fault { try (FileInputStream fis = new FileInputStream(file); InputStream in = new BufferedInputStream(fis)) { - Properties props = new Properties(); - props.load(in); - return props; + return com.sun.javatest.util.Properties.load(in); } catch (FileNotFoundException e) { throw new Fault(i18n, "cnfg.set.cantFindFile", file); @@ -1022,19 +1019,19 @@ public void run(CommandContext ctx) throws Fault { InterviewParameters p = getConfig(ctx); if (file != null) { - Map values = loadFile(file); - Set keys = values.keySet(); - Iterator it = keys.iterator(); + Map values = loadFile(file); + Set keys = values.keySet(); + Iterator it = keys.iterator(); String name = null; for (int i = 0; it.hasNext(); i++) { - name = (String)(it.next()); + name = it.next(); /* could do it this way to reject unknown props String v = p.retrieveProperty(name); if (v != null) { p.storeProperty(name, (String)(values.get(name))); } */ - p.storeProperty(name, (String)(values.get(name))); + p.storeProperty(name, (values.get(name))); } } else { @@ -1042,12 +1039,10 @@ } } - private Map loadFile(File file) throws Fault { + private Map loadFile(File file) throws Fault { try (FileInputStream fis = new FileInputStream(file); InputStream in = new BufferedInputStream(fis)) { - Properties props = new Properties(); - props.load(in); - return props; + return com.sun.javatest.util.Properties.load(in); } catch (FileNotFoundException e) { throw new Fault(i18n, "cnfg.set.cantFindFile", file); diff --git a/src/com/sun/javatest/tool/DeskView.java b/src/com/sun/javatest/tool/DeskView.java --- a/src/com/sun/javatest/tool/DeskView.java +++ b/src/com/sun/javatest/tool/DeskView.java @@ -664,12 +664,12 @@ * @param m the map in which the information is to be recorded * @see #saveBounds */ - protected static void restoreBounds(Component c, Map m) { + protected static void restoreBounds(Component c, Map m) { try { - String xs = (String) (m.get("x")); - String ys = (String) (m.get("y")); - String ws = (String) (m.get("w")); - String hs = (String) (m.get("h")); + String xs = (m.get("x")); + String ys = (m.get("y")); + String ws = (m.get("w")); + String hs = (m.get("h")); if (xs != null && ys != null && ws != null && hs != null) { Rectangle restored = new Rectangle(Integer.parseInt(xs), Integer.parseInt(ys), @@ -791,14 +791,14 @@ } // for - List fileHistory = desktop.getFileHistory(); + List fileHistory = desktop.getFileHistory(); // if (!fileHistory.isEmpty()) { JMenu hm = uif.createMenu("dt.file.recentwd"); if (!fileHistory.isEmpty()) { int n = 0; - for (Iterator i = fileHistory.iterator(); i.hasNext(); ) { - Desktop.FileHistoryEntry h = (Desktop.FileHistoryEntry) (i.next()); + for (Iterator i = fileHistory.iterator(); i.hasNext(); ) { + Desktop.FileHistoryEntry h = (i.next()); if (!h.file.exists()) continue; String s = uif.getI18NString("dt.file.historyX.mit", diff --git a/src/com/sun/javatest/tool/Desktop.java b/src/com/sun/javatest/tool/Desktop.java --- a/src/com/sun/javatest/tool/Desktop.java +++ b/src/com/sun/javatest/tool/Desktop.java @@ -167,14 +167,14 @@ break; case CommandContext.METAL_LAF: try { - Class nimbusClass = Class.forName("javax.swing.plaf.metal.MetalLookAndFeel"); + Class nimbusClass = Class.forName("javax.swing.plaf.metal.MetalLookAndFeel"); UIManager.setLookAndFeel((LookAndFeel) nimbusClass.newInstance()); } catch (Throwable e) { } break; case CommandContext.NIMBUS_LAF: try { - Class nimbusClass = Class.forName("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); + Class nimbusClass = Class.forName("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); UIManager.setLookAndFeel((LookAndFeel) nimbusClass.newInstance()); } catch (Throwable e) { } @@ -399,7 +399,7 @@ // this is to avoid a class dependency to exec package, which is // normally not allowed in this package Method m = mgr.getClass().getMethod("startTool", - new Class[] { InterviewParameters.class} ); + new Class[] { InterviewParameters.class} ); return (Tool) m.invoke(mgr, new Object[] { ip }); } @@ -449,7 +449,7 @@ * @param c the class of the desired tool manager. * @return a tool manager of the desired type, or null if none found */ - public ToolManager getToolManager(Class c) { + public ToolManager getToolManager(Class c) { for (int i = 0; i < toolManagers.length; i++) { ToolManager m = toolManagers[i]; if (c.isInstance(m)) @@ -522,7 +522,7 @@ * @return a list of the current entries on the file history associated with this desktop * @see #addToFileHistory */ - List getFileHistory() + List getFileHistory() { return fileHistory; } @@ -1438,9 +1438,9 @@ try { ManagerLoader ml = new ManagerLoader(ToolManager.class, System.err); - ml.setManagerConstructorArgs(new Class[] { Desktop.class }, new Object[] { this }); - Set s = ml.loadManagers(TOOLMGRLIST); - toolManagers = (ToolManager[]) (s.toArray(new ToolManager[s.size()])); + ml.setManagerConstructorArgs(new Class[] { Desktop.class }, new Object[] { this }); + Set s = ml.loadManagers(TOOLMGRLIST); + toolManagers = s.toArray(new ToolManager[s.size()]); } catch (IOException e) { throw new JavaTestError(uif.getI18NResourceBundle(), diff --git a/src/com/sun/javatest/tool/DesktopManager.java b/src/com/sun/javatest/tool/DesktopManager.java --- a/src/com/sun/javatest/tool/DesktopManager.java +++ b/src/com/sun/javatest/tool/DesktopManager.java @@ -111,7 +111,7 @@ private static class SetLafCommand extends Command { - private SetLafCommand(ListIterator argIter, CommandContext ctx) throws Fault { + private SetLafCommand(ListIterator argIter, CommandContext ctx) throws Fault { super("laf"); if (!argIter.hasNext()) { @@ -120,7 +120,7 @@ int laf; - String lafName = (String) argIter.next(); + String lafName = argIter.next(); if ("nimbus".equalsIgnoreCase(lafName)) { laf = CommandContext.NIMBUS_LAF; } else if ("metal".equalsIgnoreCase(lafName)) { diff --git a/src/com/sun/javatest/tool/DesktopPrefsPane.java b/src/com/sun/javatest/tool/DesktopPrefsPane.java --- a/src/com/sun/javatest/tool/DesktopPrefsPane.java +++ b/src/com/sun/javatest/tool/DesktopPrefsPane.java @@ -33,16 +33,8 @@ import java.awt.event.ActionListener; import java.util.Enumeration; import java.util.Map; +import javax.swing.*; import javax.swing.plaf.basic.BasicComboBoxRenderer; -import javax.swing.Box; -import javax.swing.ButtonGroup; -import javax.swing.ButtonModel; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JRadioButton; /** * Preferences for the desktop itself. @@ -80,7 +72,7 @@ if (styleName == null) styleName = Desktop.styleNames[desktop.getStyle()]; - for (Enumeration e = styleGrp.getElements(); e.hasMoreElements(); ) { + for (Enumeration e = styleGrp.getElements(); e.hasMoreElements(); ) { JRadioButton rb = (JRadioButton)e.nextElement(); if (rb.getActionCommand().equals(styleName)) { rb.setSelected(true); diff --git a/src/com/sun/javatest/tool/EditableList.java b/src/com/sun/javatest/tool/EditableList.java --- a/src/com/sun/javatest/tool/EditableList.java +++ b/src/com/sun/javatest/tool/EditableList.java @@ -158,7 +158,7 @@ * @return an array containing the items currently in the list * @see #setItems */ - public Object[] getItems(Class c) { + public Object[] getItems(Class c) { Object[] items = (Object[]) (Array.newInstance(c, listModel.size())); listModel.copyInto(items); return items; @@ -336,7 +336,7 @@ private class Renderer extends DefaultListCellRenderer { - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return super.getListCellRendererComponent(list, getDisplayValue(value), index, diff --git a/src/com/sun/javatest/tool/FileHistory.java b/src/com/sun/javatest/tool/FileHistory.java --- a/src/com/sun/javatest/tool/FileHistory.java +++ b/src/com/sun/javatest/tool/FileHistory.java @@ -93,10 +93,10 @@ return null; // let's find in the cache work dir corresponding to the path - Iterator it = cache.keySet().iterator(); + Iterator it = cache.keySet().iterator(); WorkDirectory wd = null; while (it.hasNext()) { - WorkDirectory tempWD = ((WorkDirectory)it.next()); + WorkDirectory tempWD = it.next(); if (tempWD.getRoot().equals(wdFile)) { wd = tempWD; break; diff --git a/src/com/sun/javatest/tool/FocusMonitor.java b/src/com/sun/javatest/tool/FocusMonitor.java --- a/src/com/sun/javatest/tool/FocusMonitor.java +++ b/src/com/sun/javatest/tool/FocusMonitor.java @@ -26,15 +26,7 @@ */ package com.sun.javatest.tool; -import java.awt.Color; -import java.awt.Component; -import java.awt.Container; -import java.awt.FocusTraversalPolicy; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.KeyboardFocusManager; -import java.awt.Window; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; @@ -398,9 +390,9 @@ if (c == null) return null; - Set s = c.getFocusTraversalKeys(mode); + Set s = c.getFocusTraversalKeys(mode); StringBuffer sb = new StringBuffer(); - for (Iterator iter = s.iterator(); iter.hasNext(); ) { + for (Iterator iter = s.iterator(); iter.hasNext(); ) { if (sb.length() > 0) sb.append(", "); sb.append(iter.next()); diff --git a/src/com/sun/javatest/tool/HelpExternalLink.java b/src/com/sun/javatest/tool/HelpExternalLink.java --- a/src/com/sun/javatest/tool/HelpExternalLink.java +++ b/src/com/sun/javatest/tool/HelpExternalLink.java @@ -74,7 +74,7 @@ } else if (os.startsWith("Mac OS")) { Class fileMgr = Class.forName("com.apple.eio.FileManager"); Method openURL = fileMgr.getDeclaredMethod("openURL", - new Class[]{String.class}); + new Class[]{String.class}); openURL.invoke(null, new Object[]{url}); } else { String[] commands = { diff --git a/src/com/sun/javatest/tool/HelpManager.java b/src/com/sun/javatest/tool/HelpManager.java --- a/src/com/sun/javatest/tool/HelpManager.java +++ b/src/com/sun/javatest/tool/HelpManager.java @@ -176,8 +176,8 @@ tm.put(n.getName(), n); } - for (Iterator iter = tm.values().iterator(); iter.hasNext(); ) { - commandHelpTree.addNode((HelpTree.Node) (iter.next())); + for (Iterator iter = tm.values().iterator(); iter.hasNext(); ) { + commandHelpTree.addNode((iter.next())); } // now add file types diff --git a/src/com/sun/javatest/tool/HelpMenu.java b/src/com/sun/javatest/tool/HelpMenu.java --- a/src/com/sun/javatest/tool/HelpMenu.java +++ b/src/com/sun/javatest/tool/HelpMenu.java @@ -118,8 +118,8 @@ // for the active test suites, add any available help sets to the menu // e.g. those specified in the testsuite.jtt int count = 0; - for (Iterator iter = loadedTestSuites.iterator(); iter.hasNext(); ) { - TestSuite ts = (TestSuite) (iter.next()); + for (Iterator iter = loadedTestSuites.iterator(); iter.hasNext(); ) { + TestSuite ts = (iter.next()); JMenuItem[] menuItems = getMenuItems(ts, count); if (menuItems != null && menuItems.length > 0) { for (int i = 0; i < menuItems.length; i++) { diff --git a/src/com/sun/javatest/tool/ManagerLoader.java b/src/com/sun/javatest/tool/ManagerLoader.java --- a/src/com/sun/javatest/tool/ManagerLoader.java +++ b/src/com/sun/javatest/tool/ManagerLoader.java @@ -47,16 +47,16 @@ class ManagerLoader { - ManagerLoader(Class managerClass, PrintStream log) { + ManagerLoader(Class managerClass, PrintStream log) { setManagerClass(managerClass); setLog(log); } - void setManagerClass(Class managerClass) { + void setManagerClass(Class managerClass) { this.managerClass = managerClass; } - void setManagerConstructorArgs(Class[] argTypes, Object[] args) { + void setManagerConstructorArgs(Class[] argTypes, Object[] args) { constrArgTypes = argTypes; constrArgs = args; } @@ -69,12 +69,12 @@ throws IOException { - Enumeration e = ResourceLoader.getResources(resourceName, getClass()); + Enumeration e = ResourceLoader.getResources(resourceName, getClass()); Set mgrs = new HashSet<>(); URLClassLoader altLoader = null; while (e.hasMoreElements()) { - URL entry = (URL)(e.nextElement()); + URL entry = e.nextElement(); try { BufferedReader in = new BufferedReader(new InputStreamReader(entry.openStream())); String line; @@ -156,7 +156,7 @@ } try { - Class c = Class.forName(className, true, cl); + Class c = Class.forName(className, true, cl); Object mgr = newInstance(c); if (managerClass.isInstance(mgr)) { return mgr; @@ -180,7 +180,7 @@ } try { - Constructor constr = c.getConstructor(constrArgTypes); + Constructor constr = c.getConstructor(constrArgTypes); return constr.newInstance(constrArgs); } catch (InvocationTargetException e) { @@ -241,8 +241,8 @@ } private Class managerClass; - private Constructor constr; - private Class[] constrArgTypes; + private Constructor constr; + private Class[] constrArgTypes; private Object[] constrArgs; private PrintStream log; diff --git a/src/com/sun/javatest/tool/PreferencesPane.java b/src/com/sun/javatest/tool/PreferencesPane.java --- a/src/com/sun/javatest/tool/PreferencesPane.java +++ b/src/com/sun/javatest/tool/PreferencesPane.java @@ -494,7 +494,7 @@ return oldValue; } - public void putAll(Map m) { + public void putAll(Map m) { throw new UnsupportedOperationException(); } diff --git a/src/com/sun/javatest/tool/TabDeskView.java b/src/com/sun/javatest/tool/TabDeskView.java --- a/src/com/sun/javatest/tool/TabDeskView.java +++ b/src/com/sun/javatest/tool/TabDeskView.java @@ -83,10 +83,10 @@ // perhaps would be nice to have getTools(Comparator) and have it return a sorted // array of tools - Arrays.sort(tools, new Comparator() { - public int compare(Object o1, Object o2) { - Long l1 = new Long(((Tool)o1).getCreationTime()); - Long l2 = new Long(((Tool)o2).getCreationTime()); + Arrays.sort(tools, new Comparator() { + public int compare(Tool o1, Tool o2) { + Long l1 = new Long(o1.getCreationTime()); + Long l2 = new Long(o2.getCreationTime()); return (l1.compareTo(l2)); } }); diff --git a/src/com/sun/javatest/tool/ToolAction.java b/src/com/sun/javatest/tool/ToolAction.java --- a/src/com/sun/javatest/tool/ToolAction.java +++ b/src/com/sun/javatest/tool/ToolAction.java @@ -193,7 +193,7 @@ } public synchronized void removePropertyChangeListener(PropertyChangeListener listener) { - WeakReference[] l = listeners; + WeakReference[] l = listeners; int size = l.length; for (int i = size - 1; i >= 0; i--) { if (l[i].get() == listener) @@ -208,10 +208,10 @@ private void firePropertyChangeEvent(String name, Object oldVal, Object newVal) { PropertyChangeEvent ev = null; // lazy create event if needed - WeakReference[] l = listeners; + WeakReference[] l = listeners; if (l.length > 0) { for (int i = l.length - 1; i >= 0; i--) { - PropertyChangeListener pcl = (PropertyChangeListener) (l[i].get()); + PropertyChangeListener pcl = (l[i].get()); if (pcl != null) { if (ev == null) ev = new PropertyChangeEvent(this, name, oldVal, newVal); @@ -239,5 +239,5 @@ private Map misc; private boolean enabled = true; - private WeakReference[] listeners = new WeakReference[0]; + private WeakReference[] listeners = new WeakReference[0]; } diff --git a/src/com/sun/javatest/tool/UIFactory.java b/src/com/sun/javatest/tool/UIFactory.java --- a/src/com/sun/javatest/tool/UIFactory.java +++ b/src/com/sun/javatest/tool/UIFactory.java @@ -412,7 +412,7 @@ * @param c the class used to determine the i18n properties * @param helpBroker the help broker to be used when creating help buttons */ - public UIFactory(Class c, HelpBroker helpBroker) { + public UIFactory(Class c, HelpBroker helpBroker) { this(c, null, helpBroker); } @@ -437,7 +437,7 @@ * @param p the parent component to be used for any dialogs that are created * @param helpBroker the help broker to be used when creating help buttons */ - public UIFactory(Class c, Component p, HelpBroker helpBroker) { + public UIFactory(Class c, Component p, HelpBroker helpBroker) { this.helpBroker = helpBroker; clientClass = c; parent = p; @@ -1161,7 +1161,7 @@ * @return the choice item that was created * @see #createLiteralChoice */ - public JComboBox createChoice(final String uiKey, final String[] choiceKeys) { + public JComboBox createChoice(final String uiKey, final String[] choiceKeys) { return createChoice(uiKey, choiceKeys, false); } @@ -1206,7 +1206,7 @@ } choice.setRenderer(new DefaultListCellRenderer() { - public Component getListCellRendererComponent(JList list, Object o, int index, + public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) { Object c = o; for (int i = 0; i < choiceKeys.length; i++) { @@ -1232,7 +1232,7 @@ * @param uiKey the base name of the resources to be used for the menu * @return the choice component that was created */ - public JComboBox createChoice(String uiKey) { + public JComboBox createChoice(String uiKey) { return createChoice(uiKey, false); } @@ -1245,8 +1245,8 @@ * @return the choice component that was created * @see #createChoice(String) */ - public JComboBox createChoice(String uiKey, boolean editable) { - return createChoice(uiKey, editable, (JLabel) null); + public JComboBox createChoice(String uiKey, boolean editable) { + return createChoice(uiKey, editable, null); } /** @@ -3552,7 +3552,7 @@ } }; - private Class clientClass; + private Class clientClass; private Component parent; private I18NResourceBundle i18n; private HelpBroker helpBroker; @@ -3571,9 +3571,9 @@ */ public static class UIFactoryExt extends UIFactory { private I18NResourceBundle i18n_alt; - private Class altClass; - - public UIFactoryExt(UIFactory uif, Class altClass) { + private Class altClass; + + public UIFactoryExt(UIFactory uif, Class altClass) { super(uif.clientClass, uif.parent, uif.helpBroker); i18n_alt = I18NResourceBundle.getBundleForClass(altClass); this.altClass = altClass; diff --git a/src/com/sun/javatest/tool/VerboseCommand.java b/src/com/sun/javatest/tool/VerboseCommand.java --- a/src/com/sun/javatest/tool/VerboseCommand.java +++ b/src/com/sun/javatest/tool/VerboseCommand.java @@ -122,10 +122,9 @@ } public void run(CommandContext ctx) throws Fault { - for (Iterator iter = optionValues.entrySet().iterator(); iter.hasNext(); ) { - Map.Entry e = (Map.Entry) (iter.next()); - String name = (String) (e.getKey()); - boolean value = ((Boolean) (e.getValue())).booleanValue(); + for (Map.Entry e : optionValues.entrySet()) { + String name = (e.getKey()); + boolean value = e.getValue().booleanValue(); if (name.equalsIgnoreCase(MAX)) ctx.setVerboseMax(value); else if (name.equalsIgnoreCase(QUIET)) @@ -142,8 +141,8 @@ HelpTree.Node[] nodes = new HelpTree.Node[allOptions.size()]; int i = 0; - for (Iterator iter = allOptions.values().iterator(); iter.hasNext(); ) - nodes[i++] = (HelpTree.Node) (iter.next()); + for (Iterator iter = allOptions.values().iterator(); iter.hasNext(); ) + nodes[i++] = iter.next(); return new HelpTree.Node(i18n, "verb", nodes); } diff --git a/src/com/sun/javatest/tool/jthelp/JTHelpBroker.java b/src/com/sun/javatest/tool/jthelp/JTHelpBroker.java --- a/src/com/sun/javatest/tool/jthelp/JTHelpBroker.java +++ b/src/com/sun/javatest/tool/jthelp/JTHelpBroker.java @@ -129,11 +129,11 @@ File helpVersion = new File(destDir, HELP_VERSION_NAME); JarFile jar = new JarFile(jarFile); - Enumeration enumEntries = jar.entries(); + Enumeration enumEntries = jar.entries(); int total = 0; while (enumEntries.hasMoreElements()) { - JarEntry file = (JarEntry) enumEntries.nextElement(); + JarEntry file = enumEntries.nextElement(); if (isHelpFile(file)) { total++; } @@ -150,7 +150,7 @@ enumEntries = jar.entries(); while (enumEntries.hasMoreElements()) { - JarEntry file = (JarEntry) enumEntries.nextElement(); + JarEntry file = enumEntries.nextElement(); File f = new java.io.File(destDir + java.io.File.separator + file.getName()); if (isHelpFile(file)) { f.getParentFile().mkdirs(); diff --git a/src/com/sun/javatest/tool/jthelp/JTHelpProgressBar.java b/src/com/sun/javatest/tool/jthelp/JTHelpProgressBar.java --- a/src/com/sun/javatest/tool/jthelp/JTHelpProgressBar.java +++ b/src/com/sun/javatest/tool/jthelp/JTHelpProgressBar.java @@ -36,13 +36,13 @@ public class JTHelpProgressBar extends Component implements PropertyChangeListener { private JProgressBar progressBar; - private SwingWorker task; + private SwingWorker task; private JDialog frame; private JPanel ŅontentPane; private UIFactory uif; - public JTHelpProgressBar(SwingWorker progressTask) { + public JTHelpProgressBar(SwingWorker progressTask) { uif = new UIFactory(this, null); task = progressTask; diff --git a/src/com/sun/javatest/util/Debug.java b/src/com/sun/javatest/util/Debug.java --- a/src/com/sun/javatest/util/Debug.java +++ b/src/com/sun/javatest/util/Debug.java @@ -132,7 +132,7 @@ * a return value of zero. * @return the debugging setting for the specified class */ - public static boolean getBoolean(Class c) { + public static boolean getBoolean(Class c) { init(false); if (!masterSwitch) @@ -156,7 +156,7 @@ * of just the classname. * @return the debugging setting for the specified class */ - public static boolean getBoolean(Class c, String suffix) { + public static boolean getBoolean(Class c, String suffix) { init(false); if (!masterSwitch) @@ -200,7 +200,7 @@ * @return the debugging setting for the given class, or 0 if no class * was specified */ - public static int getInt(Class c) { + public static int getInt(Class c) { init(false); if (!masterSwitch || c == null) @@ -224,7 +224,7 @@ * null will result in a lookup of just the classname. * @return the debugging setting for the class */ - public static int getInt(Class c, String suffix) { + public static int getInt(Class c, String suffix) { init(false); if (!masterSwitch || c == null) @@ -317,7 +317,7 @@ return; } - Enumeration keys = props.propertyNames(); + Enumeration keys = props.propertyNames(); dProps = new Properties(); wildProps = new WildcardProperties(); @@ -348,7 +348,7 @@ * * @param c Must not be null. */ - private static String getName(Class c) { + private static String getName(Class c) { // null checking skipped String name = c.getName(); @@ -455,7 +455,7 @@ String lowerKey = key.toLowerCase(); String target = trimTarget(lowerKey); - Enumeration keys = propertyNames(); + Enumeration keys = propertyNames(); while (keys.hasMoreElements()) { String k = (String)(keys.nextElement()); String lowerK = k.toLowerCase(); diff --git a/src/com/sun/javatest/util/DirectoryClassLoader.java b/src/com/sun/javatest/util/DirectoryClassLoader.java --- a/src/com/sun/javatest/util/DirectoryClassLoader.java +++ b/src/com/sun/javatest/util/DirectoryClassLoader.java @@ -73,7 +73,7 @@ * @return the class that was loaded * @throws ClassNotFoundException if the class was not found. */ - protected Class loadClass(String name, boolean resolve) + protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { // check the cache first @@ -173,7 +173,7 @@ //----------internal methods------------------------------------------------ - private synchronized Class locateClass(String name) + private synchronized Class locateClass(String name) throws ClassNotFoundException { //This check is currently necessary; we just // check the cache at the one call site, but that was not diff --git a/src/com/sun/javatest/util/DynamicArray.java b/src/com/sun/javatest/util/DynamicArray.java --- a/src/com/sun/javatest/util/DynamicArray.java +++ b/src/com/sun/javatest/util/DynamicArray.java @@ -107,7 +107,7 @@ if (array2 == null) return array1; - Class type = array1.getClass().getComponentType(); + Class type = array1.getClass().getComponentType(); int size = array1.length + array2.length; T[] newArray = (T[]) Array.newInstance(type, size); System.arraycopy(array1, 0, newArray, 0, array1.length); @@ -261,7 +261,7 @@ * @param arr The array to examine. * @return The class of objects that the given array can hold. */ - protected static Class getArrayClass(Object[] arr) { + protected static Class getArrayClass(Object[] arr) { if(arr != null) { return arr.getClass().getComponentType(); } else { diff --git a/src/com/sun/javatest/util/Fifo.java b/src/com/sun/javatest/util/Fifo.java --- a/src/com/sun/javatest/util/Fifo.java +++ b/src/com/sun/javatest/util/Fifo.java @@ -31,7 +31,7 @@ * A simple variable length first-in first-out queue. */ -public class Fifo +public class Fifo { /** * Create a buffer with a default initial size. @@ -48,7 +48,7 @@ */ public Fifo(int initialSlots) { bufSize = initialSlots; - buf = new Object[bufSize]; + buf = (E[]) new Object[bufSize]; insertSlot = 0; removeSlot = 0; entries = 0; @@ -78,13 +78,13 @@ * * @param obj The object to be inserted. It must not be null. */ - public synchronized void insert(Object obj) { + public synchronized void insert(E obj) { if (obj == null) throw new NullPointerException(); if (entries == bufSize) { int newBufSize = 2 * bufSize; - Object[] newBuf = new Object[newBufSize]; + E[] newBuf = (E[]) new Object[newBufSize]; int saveEntries = entries; for (int i = 0; entries > 0; i++) { newBuf[i] = remove(); @@ -107,11 +107,11 @@ * @return The next object in line to be removed, if one is available, * or null if none are available. */ - public synchronized Object remove() { + public synchronized E remove() { if (entries == 0) return null; - Object o = buf[removeSlot]; + E o = buf[removeSlot]; buf[removeSlot] = null; removeSlot = (removeSlot + 1) % bufSize; entries--; @@ -135,7 +135,7 @@ private final static int defaultInitialSlots = 16; - private Object[] buf; // The circular array to hold the entries + private E[] buf; // The circular array to hold the entries private int bufSize; // The size of the array: buf.length private int insertSlot; // The next slot to store an entry private int removeSlot; // The next slot from which to remove an entry diff --git a/src/com/sun/javatest/util/FileInfoCache.java b/src/com/sun/javatest/util/FileInfoCache.java --- a/src/com/sun/javatest/util/FileInfoCache.java +++ b/src/com/sun/javatest/util/FileInfoCache.java @@ -38,7 +38,7 @@ // we can't use generics in util package but this is actually Map private Map map = Collections.synchronizedMap( new LinkedHashMap() { - protected boolean removeEldestEntry(Map.Entry eldest) { + protected boolean removeEldestEntry(Map.Entry eldest) { return size() > SIZE; } }); diff --git a/src/com/sun/javatest/util/HelpTree.java b/src/com/sun/javatest/util/HelpTree.java --- a/src/com/sun/javatest/util/HelpTree.java +++ b/src/com/sun/javatest/util/HelpTree.java @@ -168,17 +168,17 @@ this(node, null); } - private Selection(Map map) { + private Selection(Map map) { this(null, map); } - private Selection(Node node, Map map) { + private Selection(Node node, Map map) { this.node = node; this.map = map; } private Node node; - private Map map; + private Map map; } /** @@ -413,12 +413,12 @@ return nodeComparator; } - private void write(WrapWriter out, Map m) throws IOException { + private void write(WrapWriter out, Map m) throws IOException { int margin = out.getLeftMargin(); - for (Iterator iter = m.entrySet().iterator(); iter.hasNext(); ) { - Map.Entry e = (Map.Entry) (iter.next()); - Node node = (Node) (e.getKey()); - Selection s = (Selection) (e.getValue()); + for (Iterator> iter = m.entrySet().iterator(); iter.hasNext(); ) { + Map.Entry e = iter.next(); + Node node = (e.getKey()); + Selection s = (e.getValue()); if (s.map == null) write(out, node); else { diff --git a/src/com/sun/javatest/util/I18NResourceBundle.java b/src/com/sun/javatest/util/I18NResourceBundle.java --- a/src/com/sun/javatest/util/I18NResourceBundle.java +++ b/src/com/sun/javatest/util/I18NResourceBundle.java @@ -49,7 +49,7 @@ * @param c the class for which to obtain the resource bundle * @return the appropriate resource bundle for the class */ - public static I18NResourceBundle getBundleForClass(Class c) { + public static I18NResourceBundle getBundleForClass(Class c) { String cn = c.getName(); int dot = cn.lastIndexOf('.'); String rn = (dot == -1 ? "i18n" : cn.substring(0, dot) + ".i18n"); diff --git a/src/com/sun/javatest/util/OrderedTwoWayTable.java b/src/com/sun/javatest/util/OrderedTwoWayTable.java --- a/src/com/sun/javatest/util/OrderedTwoWayTable.java +++ b/src/com/sun/javatest/util/OrderedTwoWayTable.java @@ -121,7 +121,7 @@ * @param target the object to search for * @return the index of the target in the vector, or -1 if not found */ - protected int findIndex(Vector data, Object target) { + protected int findIndex(Vector data, Object target) { for (int i = 0; i < data.size(); i++) if (data.elementAt(i) == target) return i; diff --git a/src/com/sun/javatest/util/PathClassLoader.java b/src/com/sun/javatest/util/PathClassLoader.java --- a/src/com/sun/javatest/util/PathClassLoader.java +++ b/src/com/sun/javatest/util/PathClassLoader.java @@ -92,7 +92,7 @@ * @return the class that was loaded * @throws ClassNotFoundException if the class was not found. */ - protected Class loadClass(String name, boolean resolve) + protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { Class cl = classes.get(name); @@ -113,7 +113,7 @@ } - private synchronized Class locateClass(String name) + private synchronized Class locateClass(String name) throws ClassNotFoundException { //System.err.println("locateClass: " + name); Class c = classes.get(name); @@ -135,7 +135,7 @@ throw new ClassNotFoundException(name); } - private Class locateClassInDir(String name, File dir) + private Class locateClassInDir(String name, File dir) throws ClassNotFoundException { //System.err.println("locateClassInDir: " + name + " " + dir); String cname = name.replace('.', '/') + ".class"; @@ -149,7 +149,7 @@ } } - private Class locateClassInJar(String name, File jarFile) + private Class locateClassInJar(String name, File jarFile) throws ClassNotFoundException { //System.err.println("locateClassInJar: " + name + " " + jarFile); String cname = name.replace('.', '/') + ".class"; @@ -170,7 +170,7 @@ } } - private Class readClass(String name, InputStream in, int size) throws IOException { + private Class readClass(String name, InputStream in, int size) throws IOException { byte[] data = new byte[size]; try { for (int total = 0; total < size; ) { diff --git a/src/com/sun/javatest/util/PrefixMap.java b/src/com/sun/javatest/util/PrefixMap.java --- a/src/com/sun/javatest/util/PrefixMap.java +++ b/src/com/sun/javatest/util/PrefixMap.java @@ -145,8 +145,8 @@ public int size() { int n = 0; - for (Iterator i = map.keySet().iterator(); i.hasNext(); ) { - String key = (String) (i.next()); + for (Iterator i = map.keySet().iterator(); i.hasNext(); ) { + String key = (i.next()); if (key.startsWith(prefix)) n++; } diff --git a/src/com/sun/javatest/util/Properties.java b/src/com/sun/javatest/util/Properties.java --- a/src/com/sun/javatest/util/Properties.java +++ b/src/com/sun/javatest/util/Properties.java @@ -536,7 +536,7 @@ * @see com.sun.javatest.util.Properties#defaults * @since JDK1.0 */ - public Enumeration propertyNames() { + public Enumeration propertyNames() { Hashtable h = new Hashtable<>(); enumerate(h); return h.keys(); @@ -587,8 +587,8 @@ if (defaults != null) { defaults.enumerate(h); } - for (Enumeration e = keys() ; e.hasMoreElements() ;) { - String key = (String)e.nextElement(); + for (Enumeration e = keys() ; e.hasMoreElements() ;) { + String key = e.nextElement(); h.put(key, get(key)); } } diff --git a/src/com/sun/javatest/util/PropertyArray.java b/src/com/sun/javatest/util/PropertyArray.java --- a/src/com/sun/javatest/util/PropertyArray.java +++ b/src/com/sun/javatest/util/PropertyArray.java @@ -227,7 +227,7 @@ * @return an array that does not contain the named property */ public static String[] remove(String[] data, String key) { - Vector vec = copyOutOf(data); + Vector vec = copyOutOf(data); int lower = 0; int upper = vec.size() - 2; int mid = 0; @@ -239,7 +239,7 @@ } // goes at the end - String last = (String)vec.elementAt(upper); + String last = vec.elementAt(upper); int cmp = key.compareTo(last); if (cmp > 0) { return data; @@ -248,7 +248,7 @@ while (lower <= upper) { // in next line, take care to ensure that mid is always even mid = lower + ((upper - lower) / 4) * 2; - String e = (String)(vec.elementAt(mid)); + String e = (vec.elementAt(mid)); cmp = key.compareTo(e); if (cmp < 0) { upper = mid - 2; @@ -259,7 +259,7 @@ else { // strings equal, zap key and value vec.removeElementAt(mid); - old = (String)(vec.elementAt(mid)); + old = vec.elementAt(mid); vec.removeElementAt(mid); break; } @@ -373,15 +373,15 @@ * @param props an array of sequential name value properties * @return an enumeration of the properties in the array */ - public static Enumeration enumerate(final String[] props) { - return new Enumeration() { + public static Enumeration enumerate(final String[] props) { + return new Enumeration() { int pos = 0; public boolean hasMoreElements() { return (props != null && pos < props.length); } - public Object nextElement() { + public String nextElement() { if (props == null || pos >= props.length) { return null; } diff --git a/src/com/sun/javatest/util/ReadAheadIterator.java b/src/com/sun/javatest/util/ReadAheadIterator.java --- a/src/com/sun/javatest/util/ReadAheadIterator.java +++ b/src/com/sun/javatest/util/ReadAheadIterator.java @@ -26,6 +26,8 @@ */ package com.sun.javatest.util; +import com.sun.javatest.TestResult; + import java.util.Iterator; /** @@ -33,7 +35,7 @@ * performance reasons or to help find out the number of items returned by an * iterator before accessing them. */ -public class ReadAheadIterator implements Iterator +public class ReadAheadIterator implements Iterator { /** * A constant indicating that no read ahead is required. @@ -61,7 +63,7 @@ * @see #LIMITED * @see #FULL */ - public ReadAheadIterator(Iterator source, int mode) { + public ReadAheadIterator(Iterator source, int mode) { this(source, mode, DEFAULT_LIMITED_READAHEAD); } @@ -76,7 +78,7 @@ * @see #LIMITED * @see #FULL */ - public ReadAheadIterator(Iterator source, int mode, int amount) { + public ReadAheadIterator(Iterator source, int mode, int amount) { this.source = source; setMode(mode, amount); } @@ -173,9 +175,9 @@ || (worker == null ? source.hasNext() : sourceHasNext)); } - public synchronized Object next() { + public synchronized TestResult next() { // see if there are items in the read ahead queue - Object result = queue.remove(); + TestResult result = queue.remove(); if (result == null) { // queue is empty: check whether to read source directly, or rely on the worker thread @@ -256,7 +258,7 @@ // sourceHasNext is true, which means there is another item // to be read, so read it, and also check whether there is // another item after that - Object srcNext = source.next(); + TestResult srcNext = source.next(); boolean srcHasNext = source.hasNext(); // get the lock to update the queue and sourceHasNext; @@ -296,7 +298,7 @@ /** * The queue to hold the items that have been read from the underlying source iterator. */ - private final Fifo queue = new Fifo(); + private final Fifo queue = new Fifo<>(); /** * The underlying source iterator. If the worker thread is running, it alone @@ -304,7 +306,7 @@ * along with everything else. * @see #worker */ - private final Iterator source; + private final Iterator source; /** * A value indicating whether the underlying source iterator has more values to be read. diff --git a/src/com/sun/javatest/util/SortedProperties.java b/src/com/sun/javatest/util/SortedProperties.java --- a/src/com/sun/javatest/util/SortedProperties.java +++ b/src/com/sun/javatest/util/SortedProperties.java @@ -41,11 +41,11 @@ // override Keys() to return a sorted set public Enumeration keys() { Set s = new TreeSet<>(); // ordered - for (Enumeration e = super.keys(); e.hasMoreElements(); ) { + for (Enumeration e = super.keys(); e.hasMoreElements(); ) { s.add(e.nextElement()); } - final Iterator iter = s.iterator(); + final Iterator iter = s.iterator(); return new Enumeration() { public boolean hasMoreElements() { return iter.hasNext(); diff --git a/src/com/sun/jct/utils/glossarygen/Main.java b/src/com/sun/jct/utils/glossarygen/Main.java --- a/src/com/sun/jct/utils/glossarygen/Main.java +++ b/src/com/sun/jct/utils/glossarygen/Main.java @@ -273,8 +273,8 @@ char currLetter = 0; - for (Iterator iter = glossary.values().iterator(); iter.hasNext(); ) { - Entry e = (Entry) (iter.next()); + for (Iterator iter = glossary.values().iterator(); iter.hasNext(); ) { + Entry e = (iter.next()); if (!e.matches(keyword)) continue; @@ -1007,7 +1007,7 @@ private File file; private String head1; private String text; - private Set keywords; + private Set keywords; private Reader in; private Writer out; diff --git a/src/com/sun/jct/utils/indexgen/Main.java b/src/com/sun/jct/utils/indexgen/Main.java --- a/src/com/sun/jct/utils/indexgen/Main.java +++ b/src/com/sun/jct/utils/indexgen/Main.java @@ -521,8 +521,8 @@ char currLetter = 0; - for (Iterator iter = root.iterator(); iter.hasNext(); ) { - Node node = (Node) (iter.next()); + for (Iterator iter = root.iterator(); iter.hasNext(); ) { + Node node = (iter.next()); String name = node.getName(); char initial = Character.toUpperCase(name.charAt(0)); if (Character.isLetter(initial) && initial != currLetter) { @@ -597,8 +597,8 @@ } if (node.getChildCount() > 0) { - for (Iterator iter = node.iterator(); iter.hasNext(); ) { - Node child = (Node) (iter.next()); + for (Iterator iter = node.iterator(); iter.hasNext(); ) { + Node child = (iter.next()); write(xmlOut, mapOut, htmlOut, child, depth + 1); } diff --git a/src/com/sun/jct/utils/mapmerge/Main.java b/src/com/sun/jct/utils/mapmerge/Main.java --- a/src/com/sun/jct/utils/mapmerge/Main.java +++ b/src/com/sun/jct/utils/mapmerge/Main.java @@ -136,8 +136,8 @@ } public void execute() { - for (Iterator iter = fileSets.iterator(); iter.hasNext(); ) { - FileSet fs = (FileSet) iter.next(); + for (Iterator iter = fileSets.iterator(); iter.hasNext(); ) { + FileSet fs = iter.next(); FileScanner s = fs.getDirectoryScanner(getProject()); m.addFiles(s.getBasedir(), s.getIncludedFiles()); } @@ -184,17 +184,17 @@ out.println(""); int maxLen = 0; - for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) { - Map.Entry e = (Map.Entry) (iter.next()); - String target = (String) (e.getKey()); - String url = (String) (e.getValue()); + for (Iterator> iter = map.entrySet().iterator(); iter.hasNext(); ) { + Map.Entry e = iter.next(); + String target = e.getKey(); + String url = e.getValue(); maxLen = Math.max(maxLen, target.length()); } - for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) { - Map.Entry e = (Map.Entry) (iter.next()); - String target = (String) (e.getKey()); - String url = (String) (e.getValue()); + for (Iterator> iter = map.entrySet().iterator(); iter.hasNext(); ) { + Map.Entry e = iter.next(); + String target = e.getKey(); + String url = e.getValue(); out.print("