diff options
author | Jiri Vanek <[email protected]> | 2013-12-13 10:47:07 +0100 |
---|---|---|
committer | Jiri Vanek <[email protected]> | 2013-12-13 10:47:07 +0100 |
commit | 25f307d98cb0ba4698318c6a1a4e738ee81f6e55 (patch) | |
tree | e869f4d7ea537ba2d4508f71edbafdccecd0f375 /netx | |
parent | 6256aac59275df0edd0feb4950272aa33573be9f (diff) |
itw itself warning cleanup: fixed rawtypes and unchecks, added braces and Override
After this clean up only "internal proprietary API and may be removed in a future release" warnings remain fro make check. Please keep itw in this way :)
remaining issues:
icedtea-web/netx/net/sourceforge/jnlp/cache/ResourceTracker.java:357: warning: [deprecation] toURL() in File has been deprecated
icedtea-web/netx/net/sourceforge/jnlp/cache/CacheUtil.java:128: warning: [deprecation] toURL() in File has been deprecated
icedtea-web/netx/net/sourceforge/jnlp/runtime/Boot.java:261: warning: [deprecation] toURL() in File has been deprecated
There have been a lot of work around cach x file x url escaping, and as main difference between file.tourl and file.touri.tourl is escapin, I rather left it.
icedtea-web/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java:804: warning: [deprecation] Ref in sun.misc has been deprecated
icedtea-web/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java:121: warning: [deprecation] Ref in sun.misc has been deprecated
What can be done?
icedtea-web/netx/net/sourceforge/jnlp/browser/BrowserAwareProxySelector.java:205: warning: [fallthrough] possible fall-through into case
icedtea-web/netx/net/sourceforge/jnlp/browser/BrowserAwareProxySelector.java:211: warning: [fallthrough] possible fall-through into case
This have to be fixed
Diffstat (limited to 'netx')
28 files changed, 283 insertions, 180 deletions
diff --git a/netx/net/sourceforge/jnlp/JREDesc.java b/netx/net/sourceforge/jnlp/JREDesc.java index 50ee9a3..14736cd 100644 --- a/netx/net/sourceforge/jnlp/JREDesc.java +++ b/netx/net/sourceforge/jnlp/JREDesc.java @@ -30,22 +30,22 @@ import java.util.*; public class JREDesc { /** the platform version or the product version if location is not null */ - private Version version; + final private Version version; /** the location of a JRE product or null */ - private URL location; + final private URL location; /** inital heap size */ - private String initialHeapSize; + final private String initialHeapSize; /** maximum head size */ - private String maximumHeapSize; + final private String maximumHeapSize; /** args to pass to the vm */ - private String vmArgs; + final private String vmArgs; /** list of ResourceDesc objects */ - private List resources; + final private List<ResourcesDesc> resources; /** * Create a JRE descriptor. @@ -59,7 +59,7 @@ public class JREDesc { */ public JREDesc(Version version, URL location, String vmArgs, String initialHeapSize, - String maximumHeapSize, List resources) throws ParseException { + String maximumHeapSize, List<ResourcesDesc> resources) throws ParseException { this.version = version; this.location = location; this.vmArgs = vmArgs; @@ -112,7 +112,7 @@ public class JREDesc { /** * Returns the resources defined for this JRE. */ - public List getResourcesDesc() { + public List<ResourcesDesc> getResourcesDesc() { return resources; } diff --git a/netx/net/sourceforge/jnlp/Launcher.java b/netx/net/sourceforge/jnlp/Launcher.java index fc4eefc..2982b45 100644 --- a/netx/net/sourceforge/jnlp/Launcher.java +++ b/netx/net/sourceforge/jnlp/Launcher.java @@ -44,7 +44,6 @@ import net.sourceforge.jnlp.services.ServiceUtil; import javax.swing.SwingUtilities; import javax.swing.text.html.parser.ParserDelegator; -import net.sourceforge.jnlp.runtime.AppletEnvironment; import net.sourceforge.jnlp.splashscreen.SplashUtils; import net.sourceforge.jnlp.util.logging.OutputController; @@ -92,8 +91,9 @@ public class Launcher { public Launcher() { this(null, null); - if (handler == null) + if (handler == null) { handler = JNLPRuntime.getDefaultLaunchHandler(); + } } /** @@ -105,8 +105,9 @@ public class Launcher { public Launcher(boolean exitOnFailure) { this(null, null); - if (handler == null) + if (handler == null) { handler = JNLPRuntime.getDefaultLaunchHandler(); + } this.exitOnFailure = exitOnFailure; } @@ -141,8 +142,9 @@ public class Launcher { * Sets the update policy used by launched applications. */ public void setUpdatePolicy(UpdatePolicy policy) { - if (policy == null) + if (policy == null) { throw new IllegalArgumentException(R("LNullUpdatePolicy")); + } this.updatePolicy = policy; } @@ -237,12 +239,15 @@ public class Launcher { } } - if (file instanceof PluginBridge && cont != null) + if (file instanceof PluginBridge && cont != null) { tg = new TgThread(file, cont, true); - else if (cont == null) + } + else if (cont == null) { tg = new TgThread(file); - else + } + else { tg = new TgThread(file, cont); + } tg.start(); @@ -253,11 +258,13 @@ public class Launcher { throw launchWarning(new LaunchException(file, ex, R("LSMinor"), R("LCSystem"), R("LThreadInterrupted"), R("LThreadInterruptedInfo"))); } - if (tg.getException() != null) - throw tg.getException(); // passed to handler when first created + if (tg.getException() != null) { + throw tg.getException(); + } // passed to handler when first created - if (handler != null) + if (handler != null) { handler.launchCompleted(tg.getApplication()); + } return tg.getApplication(); } @@ -378,12 +385,15 @@ public class Launcher { public void launchExternal(List<String> vmArgs, JNLPFile file, List<String> javawsArgs) throws LaunchException { List<String> updatedArgs = new LinkedList<String>(javawsArgs); - if (file.getFileLocation() != null) + if (file.getFileLocation() != null) { updatedArgs.add(file.getFileLocation().toString()); - else if (file.getSourceLocation() != null) + } + else if (file.getSourceLocation() != null) { updatedArgs.add(file.getFileLocation().toString()); - else + } + else { launchError(new LaunchException(file, null, R("LSFatal"), R("LCExternalLaunch"), R("LNullLocation"), R("LNullLocationInfo"))); + } launchExternal(vmArgs, updatedArgs); @@ -444,9 +454,7 @@ public class Launcher { */ private JNLPFile fromUrl(URL location) throws LaunchException { try { - JNLPFile file = null; - - file = new JNLPFile(location, parserSettings); + JNLPFile file = new JNLPFile(location, parserSettings); boolean isLocal = false; boolean haveHref = false; @@ -476,8 +484,9 @@ public class Launcher { * from a thread in the application's thread group. */ protected ApplicationInstance launchApplication(JNLPFile file) throws LaunchException { - if (!file.isApplication()) + if (!file.isApplication()) { throw launchError(new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LNotApplication"), R("LNotApplicationInfo"))); + } try { @@ -521,10 +530,11 @@ public class Launcher { } } - if (mainName == null) + if (mainName == null) { throw launchError(new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LCantDetermineMainClass"), R("LCantDetermineMainClassInfo"))); + } Class<?> mainClass = app.getClassLoader().loadClass(mainName); @@ -533,6 +543,7 @@ public class Launcher { SwingUtilities.invokeAndWait(new Runnable() { // dummy method to force Event Dispatch Thread creation + @Override public void run() { } }); @@ -696,17 +707,18 @@ public class Launcher { // appletInstance is needed by ServiceManager when looking up // services. This could potentially be done in applet constructor // so initialize appletInstance before creating applet. - if (cont == null) - appletInstance = new AppletInstance(file, group, loader, null); - else - appletInstance = new AppletInstance(file, group, loader, null, cont); + if (cont == null) { + appletInstance = new AppletInstance(file, group, loader, null); + } else { + appletInstance = new AppletInstance(file, group, loader, null, cont); + } loader.setApplication(appletInstance); // Initialize applet now that ServiceManager has access to its // appletInstance. String appletName = file.getApplet().getMainClass(); - Class appletClass = loader.loadClass(appletName); + Class<?> appletClass = loader.loadClass(appletName); Applet applet = (Applet) appletClass.newInstance(); applet.setStub((AppletStub)cont); // Finish setting up appletInstance. @@ -738,7 +750,7 @@ public class Launcher { } String appletName = file.getApplet().getMainClass(); - Class appletClass = loader.loadClass(appletName); + Class<?> appletClass = loader.loadClass(appletName); Applet applet = (Applet) appletClass.newInstance(); return applet; @@ -772,7 +784,7 @@ public class Launcher { * ThreadGroup has to be created at an earlier point in the applet code. */ protected ThreadGroup createThreadGroup(JNLPFile file) { - ThreadGroup tg = null; + final ThreadGroup tg; if (file instanceof PluginBridge) { tg = Thread.currentThread().getThreadGroup(); @@ -795,8 +807,9 @@ public class Launcher { if (applet != null) { SplashUtils.showErrorCaught(ex, applet); } - if (handler != null) + if (handler != null) { handler.launchError(ex); + } return ex; } @@ -809,10 +822,11 @@ public class Launcher { * @return an exception to throw if the launch should be aborted, or null otherwise */ private LaunchException launchWarning(LaunchException ex) { - if (handler != null) + if (handler != null) { if (!handler.launchWarning(ex)) // no need to destroy the app b/c it hasn't started - return ex; // chose to abort + return ex; + } // chose to abort return null; // chose to continue, or no handler } @@ -863,12 +877,14 @@ public class Launcher { this.isPlugin = isPlugin; } + @Override public void run() { try { // Do not create new AppContext if we're using NetX and icedteaplugin. // The plugin needs an AppContext too, but it has to be created earlier. - if (context && !isPlugin) + if (context && !isPlugin) { SunToolkit.createNewAppContext(); + } doPerApplicationAppContextHacks(); @@ -877,23 +893,28 @@ public class Launcher { JNLPRuntime.setDefaultDownloadIndicator(null); application = getApplet(file, ((PluginBridge)file).codeBaseLookup(), cont); } else { - if (file.isApplication()) + if (file.isApplication()) { application = launchApplication(file); - else if (file.isApplet()) - application = launchApplet(file, true, cont); // enable applet code base - else if (file.isInstaller()) + } + else if (file.isApplet()) { + application = launchApplet(file, true, cont); + } // enable applet code base + else if (file.isInstaller()) { application = launchInstaller(file); - else + } + else { throw launchError(new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LNotLaunchable"), R("LNotLaunchableInfo"))); + } } } catch (LaunchException ex) { OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ex); exception = ex; // Exit if we can't launch the application. - if (exitOnFailure) + if (exitOnFailure) { JNLPRuntime.exit(1); + } } } diff --git a/netx/net/sourceforge/jnlp/Node.java b/netx/net/sourceforge/jnlp/Node.java index f3c95bd..e208852 100644 --- a/netx/net/sourceforge/jnlp/Node.java +++ b/netx/net/sourceforge/jnlp/Node.java @@ -63,13 +63,16 @@ class Node { } Node getFirstChild() { - if (children == null) + if (children == null) { getChildNodes(); + } - if (children.length == 0) + if (children.length == 0) { return null; - else + } + else { return children[0]; + } } Node getNextSibling() { @@ -87,13 +90,15 @@ class Node { if (children == null) { List<Node> list = new ArrayList<Node>(); - for (Enumeration e = xml.enumerateChildren(); e.hasMoreElements();) - list.add(new Node((XMLElement) e.nextElement())); + for (Enumeration<XMLElement> e = xml.enumerateChildren(); e.hasMoreElements();) { + list.add(new Node(e.nextElement())); + } children = list.toArray(new Node[list.size()]); - for (int i = 0; i < children.length - 1; i++) + for (int i = 0; i < children.length - 1; i++) { children[i].next = children[i + 1]; + } } return children; @@ -107,8 +112,9 @@ class Node { if (attributeNames == null) { attributeNames= new ArrayList<String>(); - for (Enumeration e = xml.enumerateAttributeNames(); e.hasMoreElements();) - attributeNames.add(new String((String) e.nextElement())); + for (Enumeration<String> e = xml.enumerateAttributeNames(); e.hasMoreElements();) { + attributeNames.add(new String(e.nextElement())); + } } return attributeNames; @@ -119,12 +125,15 @@ class Node { } String getNodeName() { - if (xml.getName() == null) + if (xml.getName() == null) { return ""; - else + } + else { return xml.getName(); + } } + @Override public String toString() { return getNodeName(); } diff --git a/netx/net/sourceforge/jnlp/Parser.java b/netx/net/sourceforge/jnlp/Parser.java index 4043fa6..e7dcf9d 100644 --- a/netx/net/sourceforge/jnlp/Parser.java +++ b/netx/net/sourceforge/jnlp/Parser.java @@ -345,7 +345,7 @@ class Parser { } String initialHeap = getAttribute(node, "initial-heap-size", null); String maxHeap = getAttribute(node, "max-heap-size", null); - List resources = getResources(node, true); + List<ResourcesDesc> resources = getResources(node, true); // require version attribute getRequiredAttribute(node, "version", null); diff --git a/netx/net/sourceforge/jnlp/PluginBridge.java b/netx/net/sourceforge/jnlp/PluginBridge.java index 7228521..db4f7b2 100644 --- a/netx/net/sourceforge/jnlp/PluginBridge.java +++ b/netx/net/sourceforge/jnlp/PluginBridge.java @@ -324,7 +324,10 @@ public class PluginBridge extends JNLPFile { } catch (MalformedURLException ex) { /* Ignored */ } } else if (launchType.equals(ExtensionDesc.class)) { - return (List<T>) extensionJars; // this list is populated when the PluginBridge is first constructed + // We hope this is a safe list of JarDesc objects + @SuppressWarnings("unchecked") + List<T> castList = (List<T>) extensionJars; // this list is populated when the PluginBridge is first constructed + return castList; } return sharedResources.getResources(launchType); } diff --git a/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java b/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java index c873c4d..78d19cf 100644 --- a/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java +++ b/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java @@ -221,8 +221,11 @@ public enum CacheLRUWrapper { * * @return List of Strings sorted by ascending order. */ + @SuppressWarnings({"unchecked", "rawtypes"}) + //although Properties are pretending to be <object,Object> they are always <String,String> + //bug in jdk? public synchronized List<Entry<String, String>> getLRUSortedEntries() { - ArrayList<Entry<String, String>> entries = new ArrayList(cacheOrder.entrySet()); + List<Entry<String, String>> entries = new ArrayList(cacheOrder.entrySet()); // sort by keys in descending order. Collections.sort(entries, new Comparator<Entry<String, String>>() { @Override diff --git a/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java b/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java index a132864..a4adfd0 100644 --- a/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java +++ b/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java @@ -515,7 +515,7 @@ public final class DeploymentConfiguration { OutputController.getLogger().log("Using System level" + DEPLOYMENT_PROPERTIES + ": " + systemPropertiesFile); Setting<String> mandatory = systemConfiguration.get("deployment.system.config.mandatory"); - systemPropertiesMandatory = Boolean.valueOf(mandatory == null ? null : (String) mandatory.getValue()); + systemPropertiesMandatory = Boolean.valueOf(mandatory == null ? null : mandatory.getValue()); return true; } else { OutputController.getLogger().log("Remote + " + DEPLOYMENT_PROPERTIES + " not supported"); @@ -580,8 +580,8 @@ public final class DeploymentConfiguration { for (String key : currentConfiguration.keySet()) { String oldValue = unchangeableConfiguration.get(key) == null ? null - : (String) unchangeableConfiguration.get(key).getValue(); - String newValue = currentConfiguration.get(key) == null ? null : (String) currentConfiguration + : unchangeableConfiguration.get(key).getValue(); + String newValue = currentConfiguration.get(key) == null ? null : currentConfiguration .get(key).getValue(); if (oldValue == null && newValue == null) { continue; diff --git a/netx/net/sourceforge/jnlp/controlpanel/CachePane.java b/netx/net/sourceforge/jnlp/controlpanel/CachePane.java index d5bb267..25fb12a 100644 --- a/netx/net/sourceforge/jnlp/controlpanel/CachePane.java +++ b/netx/net/sourceforge/jnlp/controlpanel/CachePane.java @@ -110,14 +110,15 @@ public class CachePane extends JPanel { cacheTable = new JTable(model); cacheTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); cacheTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override final public void valueChanged(ListSelectionEvent listSelectionEvent) { // If no row has been selected, disable the delete button, else enable it - if (cacheTable.getSelectionModel().isSelectionEmpty()) - // Disable delete button, since nothing selected + if (cacheTable.getSelectionModel().isSelectionEmpty()) { deleteButton.setEnabled(false); - else - // Enable delete button, since something selected + } + else { deleteButton.setEnabled(true); + } } }); cacheTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN); @@ -126,7 +127,9 @@ public class CachePane extends JPanel { JScrollPane scrollPane = new JScrollPane(cacheTable); TableRowSorter<TableModel> tableSorter = new TableRowSorter<TableModel>(model); - final Comparator comparator = new Comparator<Comparable>() { // General purpose Comparator + final Comparator<Comparable<?>> comparator = new Comparator<Comparable<?>>() { // General purpose Comparator + @Override + @SuppressWarnings("unchecked") public final int compare(final Comparable a, final Comparable b) { return a.compareTo(b); } @@ -258,6 +261,7 @@ public class CachePane extends JPanel { */ private final void invokeLaterDelete() { EventQueue.invokeLater(new Runnable() { + @Override public void run() { try { FileLock fl = null; @@ -278,7 +282,9 @@ public class CachePane extends JPanel { int row = cacheTable.getSelectedRow(); try { - if (fl == null) return; + if (fl == null) { + return; + } int modelRow = cacheTable.convertRowIndexToModel(row); DirectoryNode fileNode = ((DirectoryNode) cacheTable.getModel().getValueAt(modelRow, 0)); if (fileNode.getFile().delete()) { @@ -305,7 +311,9 @@ public class CachePane extends JPanel { OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, exception); } finally { // If nothing selected then keep deleteButton disabled - if (!cacheTable.getSelectionModel().isSelectionEmpty()) deleteButton.setEnabled(true); + if (!cacheTable.getSelectionModel().isSelectionEmpty()) { + deleteButton.setEnabled(true); + } // Enable buttons refreshButton.setEnabled(true); doneButton.setEnabled(true); @@ -344,6 +352,7 @@ public class CachePane extends JPanel { */ final void invokeLaterPopulateTable() { EventQueue.invokeLater(new Runnable() { + @Override public void run() { try { populateTable(); @@ -378,7 +387,9 @@ public class CachePane extends JPanel { NonEditableTableModel tableModel; (tableModel = (NonEditableTableModel)cacheTable.getModel()).setRowCount(0); //Clears the table - for (Object[] v : generateData(root)) tableModel.addRow(v); + for (Object[] v : generateData(root)) { + tableModel.addRow(v); + } } catch (Exception exception) { OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, exception); } finally { diff --git a/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java b/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java index e3fa2db..7a50d68 100644 --- a/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java +++ b/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java @@ -124,7 +124,7 @@ public class ControlPanel extends JFrame { } private JPanel createTopPanel() { - Font currentFont = null; + Font currentFont; JLabel about = new JLabel(R("CPMainDescriptionShort")); currentFont = about.getFont(); about.setFont(currentFont.deriveFont(currentFont.getSize2D() + 2)); @@ -276,10 +276,12 @@ public class ControlPanel extends JFrame { for (SettingsPanel panel : panels) { JPanel p = panel.getPanel(); Dimension d = p.getMinimumSize(); - if (d.height > height) + if (d.height > height) { height = d.height; - if (d.width > width) + } + if (d.width > width) { width = d.width; + } } Dimension dim = new Dimension(width, height); @@ -289,7 +291,7 @@ public class ControlPanel extends JFrame { settingsPanel.add(p, panel.toString()); } - final JList settingsList = new JList(panels); + final JList<SettingsPanel> settingsList = new JList<SettingsPanel>(panels); settingsList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { diff --git a/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java b/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java index 68d34d9..559b4d5 100644 --- a/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java +++ b/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java @@ -139,7 +139,7 @@ public class DebuggingPanel extends NamedBorderPanel implements ItemListener { new ComboItem(Translator.R("DPShowJavawsOnly"), DeploymentConfiguration.CONSOLE_SHOW_JAVAWS) }; JLabel consoleLabel = new JLabel(Translator.R("DPJavaConsole")); - JComboBox consoleComboBox = new JComboBox(); + JComboBox<ComboItem> consoleComboBox = new JComboBox<ComboItem>(); consoleComboBox.setActionCommand(DeploymentConfiguration.KEY_CONSOLE_STARTUP_MODE); // The property this comboBox affects. JPanel consolePanel = new JPanel(); @@ -201,6 +201,7 @@ public class DebuggingPanel extends NamedBorderPanel implements ItemListener { } @Override + @SuppressWarnings("unchecked") public void itemStateChanged(ItemEvent e) { Object o = e.getSource(); @@ -209,7 +210,7 @@ public class DebuggingPanel extends NamedBorderPanel implements ItemListener { JCheckBox jcb = (JCheckBox) o; config.setProperty(jcb.getActionCommand(), String.valueOf(jcb.isSelected())); } else if (o instanceof JComboBox) { - JComboBox jcb = (JComboBox) o; + JComboBox<ComboItem> jcb = (JComboBox) o; ComboItem c = (ComboItem) e.getItem(); config.setProperty(jcb.getActionCommand(), c.getValue()); } diff --git a/netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java b/netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java index 299a4e1..57d9059 100644 --- a/netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java +++ b/netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java @@ -62,7 +62,7 @@ public class DesktopShortcutPanel extends NamedBorderPanel implements ItemListen private void addComponents() { GridBagConstraints c = new GridBagConstraints(); JLabel description = new JLabel("<html>" + Translator.R("CPDesktopIntegrationDescription") + "<hr /></html>"); - JComboBox shortcutComboOptions = new JComboBox(); + JComboBox<ComboItem> shortcutComboOptions = new JComboBox<ComboItem>(); ComboItem[] items = { new ComboItem(Translator.R("DSPNeverCreate"), "NEVER"), new ComboItem(Translator.R("DSPAlwaysAllow"), "ALWAYS"), new ComboItem(Translator.R("DSPAskUser"), "ASK_USER"), @@ -72,8 +72,9 @@ public class DesktopShortcutPanel extends NamedBorderPanel implements ItemListen shortcutComboOptions.setActionCommand("deployment.javaws.shortcut"); // The configuration property this combobox affects. for (int j = 0; j < items.length; j++) { shortcutComboOptions.addItem(items[j]); - if (config.getProperty("deployment.javaws.shortcut").equals(items[j].getValue())) + if (config.getProperty("deployment.javaws.shortcut").equals(items[j].getValue())) { shortcutComboOptions.setSelectedIndex(j); + } } shortcutComboOptions.addItemListener(this); diff --git a/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java b/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java index f42ed08..7519b2f 100644 --- a/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java +++ b/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java @@ -163,7 +163,7 @@ public class TemporaryInternetFilesPanel extends NamedBorderPanel implements Cha new ComboItem("7", "7"), new ComboItem("8", "8"), new ComboItem(Translator.R("TIFPMax"), "9"), }; - JComboBox cbCompression = new JComboBox(compressionOptions); + JComboBox<ComboItem> cbCompression = new JComboBox<ComboItem>(compressionOptions); cbCompression.setSelectedIndex(Integer.parseInt(this.config.getProperty(properties[3]))); cbCompression.addItemListener(new ItemListener() { @Override diff --git a/netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java b/netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java index 1cb38af..727c94c 100644 --- a/netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java +++ b/netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java @@ -39,7 +39,6 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.io.BufferedWriter; @@ -96,9 +95,9 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel { private javax.swing.JButton moveRowDownButton; private javax.swing.JCheckBox askBeforeActionCheckBox; private javax.swing.JCheckBox filterRegexesCheckBox; - private javax.swing.JComboBox mainPolicyComboBox; - private javax.swing.JComboBox deleteTypeComboBox; - private javax.swing.JComboBox viewFilter; + private javax.swing.JComboBox<AppletSecurityLevel> mainPolicyComboBox; + private javax.swing.JComboBox<String> deleteTypeComboBox; + private javax.swing.JComboBox<String> viewFilter; private javax.swing.JLabel globalBehaviourLabel; private javax.swing.JLabel securityLevelLabel; private javax.swing.JScrollPane userTableScrollPane; @@ -117,7 +116,6 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel { private UnsignedAppletActionTableModel currentModel; private String lastDoc; private String lastCode; - private final UnsignedAppletsTrustingListPanel self; /* @@ -151,7 +149,6 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel { } public UnsignedAppletsTrustingListPanel(File globalSettings, File customSettings, DeploymentConfiguration conf) { - self = this; customBackEnd = new UnsignedAppletActionStorageExtendedImpl(customSettings); globalBackEnd = new UnsignedAppletActionStorageExtendedImpl(globalSettings); customModel = new UnsignedAppletActionTableModel(customBackEnd); @@ -252,7 +249,7 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel { userTable = createTbale(customModel); globalTable = createTbale(globalModel); helpButton = new javax.swing.JButton(); - mainPolicyComboBox = new JComboBox(new AppletSecurityLevel[]{ + mainPolicyComboBox = new JComboBox<AppletSecurityLevel>(new AppletSecurityLevel[]{ AppletSecurityLevel.DENY_ALL, AppletSecurityLevel.DENY_UNSIGNED, AppletSecurityLevel.ASK_UNSIGNED, @@ -261,8 +258,8 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel { mainPolicyComboBox.setSelectedItem(AppletSecurityLevel.getDefault()); securityLevelLabel = new javax.swing.JLabel(); globalBehaviourLabel = new javax.swing.JLabel(); - deleteTypeComboBox = new javax.swing.JComboBox(); - viewFilter = new javax.swing.JComboBox(); + deleteTypeComboBox = new javax.swing.JComboBox<String>(); + viewFilter = new javax.swing.JComboBox<String>(); deleteButton = new javax.swing.JButton(); testUrlButton = new javax.swing.JButton(); addRowButton = new javax.swing.JButton(); @@ -338,7 +335,7 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel { globalBehaviourLabel.setText(Translator.R("APPEXTSECguiPanelGlobalBehaviourCaption")); - deleteTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[]{ + deleteTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[]{ Translator.R("APPEXTSECguiPanelDeleteMenuSelected"), Translator.R("APPEXTSECguiPanelDeleteMenuAllA"), Translator.R("APPEXTSECguiPanelDeleteMenuAllN"), @@ -346,7 +343,7 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel { Translator.R("APPEXTSECguiPanelDeleteMenuAlln"), Translator.R("APPEXTSECguiPanelDeleteMenuAllAll")})); - viewFilter.setModel(new javax.swing.DefaultComboBoxModel(new String[]{ + viewFilter.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[]{ Translator.R("APPEXTSECguiPanelShowOnlyPermanent"), Translator.R("APPEXTSECguiPanelShowOnlyTemporal"), Translator.R("APPEXTSECguiPanelShowAll"), @@ -704,7 +701,7 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel { public TableCellEditor getCellEditor(int row, int column) { int columnx = convertColumnIndexToModel(column); if (columnx == 0) { - return new DefaultCellEditor(new JComboBox(new ExecuteUnsignedApplet[]{ExecuteUnsignedApplet.ALWAYS, ExecuteUnsignedApplet.NEVER, ExecuteUnsignedApplet.YES, ExecuteUnsignedApplet.NO})); + return new DefaultCellEditor(new JComboBox<ExecuteUnsignedApplet>(new ExecuteUnsignedApplet[]{ExecuteUnsignedApplet.ALWAYS, ExecuteUnsignedApplet.NEVER, ExecuteUnsignedApplet.YES, ExecuteUnsignedApplet.NO})); } if (columnx == 2) { column = convertColumnIndexToModel(column); @@ -764,7 +761,7 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel { private void removeByBehaviour(ExecuteUnsignedApplet unsignedAppletAction) { UnsignedAppletActionEntry[] items = currentModel.back.toArray(); if (askBeforeActionCheckBox.isSelected()) { - List<UnsignedAppletActionEntry> toBeDeleted = new ArrayList(); + List<UnsignedAppletActionEntry> toBeDeleted = new ArrayList<UnsignedAppletActionEntry>(); for (int i = 0; i < items.length; i++) { UnsignedAppletActionEntry unsignedAppletActionEntry = items[i]; if (unsignedAppletActionEntry.getUnsignedAppletAction() == unsignedAppletAction) { @@ -880,7 +877,7 @@ public class UnsignedAppletsTrustingListPanel extends javax.swing.JPanel { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE && !currentModel.back.isReadOnly()) { - removeSelectedFromTable(table, askBeforeActionCheckBox.isSelected(), (UnsignedAppletActionTableModel) table.getModel(), self); + removeSelectedFromTable(table, askBeforeActionCheckBox.isSelected(), (UnsignedAppletActionTableModel) table.getModel(), UnsignedAppletsTrustingListPanel.this); } } diff --git a/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java b/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java index 17e9d14..d838ac6 100644 --- a/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java +++ b/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java @@ -89,6 +89,7 @@ public class AppletEnvironment implements AppletContext, AppletStub { // may not need this once security manager can close windows // that do not have app code on the stack WindowListener closer = new WindowAdapter() { + @Override public void windowClosing(WindowEvent event) { appletInstance.destroy(); JNLPRuntime.exit(0); @@ -105,8 +106,9 @@ public class AppletEnvironment implements AppletContext, AppletStub { * @throws IllegalStateException */ private void checkDestroyed() { - if (destroyed) + if (destroyed) { throw new IllegalStateException("Illegal applet stub/context access: applet destroyed."); + } } /** @@ -147,18 +149,21 @@ public class AppletEnvironment implements AppletContext, AppletStub { public void startApplet() { checkDestroyed(); - if (appletStarted) + if (appletStarted) { return; + } appletStarted = true; try { AppletDesc appletDesc = file.getApplet(); - if (cont instanceof AppletStub) + if (cont instanceof AppletStub) { applet.setStub((AppletStub) cont); - else + } + else { applet.setStub(this); + } cont.setLayout(new BorderLayout()); cont.add("Center", applet); @@ -176,6 +181,7 @@ public class AppletEnvironment implements AppletContext, AppletStub { try { SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { // do first because some applets need to be displayed before // starting (they use Component.getImage or something) @@ -207,13 +213,15 @@ public class AppletEnvironment implements AppletContext, AppletStub { * Returns the applet if the applet's name is specified, * otherwise return null. */ + @Override public Applet getApplet(String name) { checkDestroyed(); - if (name != null && name.equals(file.getApplet().getName())) + if (name != null && name.equals(file.getApplet().getName())) { return applet; - else + } else { return null; + } } /** @@ -231,6 +239,7 @@ public class AppletEnvironment implements AppletContext, AppletStub { * Returns an enumeration that contains only the applet * from the JNLP file. */ + @Override public Enumeration<Applet> getApplets() { checkDestroyed(); @@ -240,6 +249,7 @@ public class AppletEnvironment implements AppletContext, AppletStub { /** * Returns an audio clip. */ + @Override public AudioClip getAudioClip(URL location) { checkDestroyed(); @@ -254,6 +264,7 @@ public class AppletEnvironment implements AppletContext, AppletStub { /** * Return an image loaded from the specified location. */ + @Override public Image getImage(URL location) { checkDestroyed(); @@ -266,6 +277,7 @@ public class AppletEnvironment implements AppletContext, AppletStub { /** * Not implemented yet. */ + @Override public void showDocument(java.net.URL uRL) { checkDestroyed(); @@ -274,6 +286,7 @@ public class AppletEnvironment implements AppletContext, AppletStub { /** * Not implemented yet. */ + @Override public void showDocument(java.net.URL uRL, java.lang.String str) { checkDestroyed(); @@ -282,6 +295,7 @@ public class AppletEnvironment implements AppletContext, AppletStub { /** * Not implemented yet. */ + @Override public void showStatus(java.lang.String str) { checkDestroyed(); @@ -290,6 +304,7 @@ public class AppletEnvironment implements AppletContext, AppletStub { /** * Required for JRE1.4, but not implemented yet. */ + @Override public void setStream(String key, InputStream stream) { checkDestroyed(); @@ -298,6 +313,7 @@ public class AppletEnvironment implements AppletContext, AppletStub { /** * Required for JRE1.4, but not implemented yet. */ + @Override public InputStream getStream(String key) { checkDestroyed(); @@ -307,6 +323,7 @@ public class AppletEnvironment implements AppletContext, AppletStub { /** * Required for JRE1.4, but not implemented yet. */ + @Override public Iterator<String> getStreamKeys() { checkDestroyed(); @@ -315,6 +332,7 @@ public class AppletEnvironment implements AppletContext, AppletStub { // stub methods + @Override public void appletResize(int width, int height) { checkDestroyed(); @@ -327,18 +345,21 @@ public class AppletEnvironment implements AppletContext, AppletStub { } } + @Override public AppletContext getAppletContext() { checkDestroyed(); return this; } + @Override public URL getCodeBase() { checkDestroyed(); return file.getCodeBase(); } + @Override public URL getDocumentBase() { checkDestroyed(); @@ -347,16 +368,19 @@ public class AppletEnvironment implements AppletContext, AppletStub { // FIXME: Sun's applet code forces all parameters to lower case. // Does Netx's JNLP code do the same, so we can remove the first lookup? + @Override public String getParameter(String name) { checkDestroyed(); - String s = (String) parameters.get(name); - if (s != null) + String s = parameters.get(name); + if (s != null) { return s; + } - return (String) parameters.get(name.toLowerCase()); + return parameters.get(name.toLowerCase()); } + @Override public boolean isActive() { checkDestroyed(); diff --git a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java index 4d38be4..0258840 100644 --- a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java +++ b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java @@ -296,7 +296,7 @@ public class ApplicationInstance { } // then stop - Thread.currentThread().yield(); + Thread.yield(); nthreads = group.enumerate(threads); for (int i = 0; i < nthreads; i++) { OutputController.getLogger().log("Stop thread: " + threads[i]); diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java index 3a50f6c..866c7b1 100644 --- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java +++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java @@ -21,9 +21,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.io.PrintStream; import java.lang.reflect.Constructor; -import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; import java.net.Authenticator; import java.net.ProxySelector; @@ -33,8 +31,6 @@ import java.security.AllPermission; import java.security.KeyStore; import java.security.Policy; import java.security.Security; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; import java.text.MessageFormat; import java.util.List; import java.util.ResourceBundle; @@ -44,8 +40,6 @@ import javax.naming.ConfigurationException; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; -import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.swing.UIManager; @@ -64,7 +58,6 @@ import net.sourceforge.jnlp.config.DeploymentConfiguration; import net.sourceforge.jnlp.security.JNLPAuthenticator; import net.sourceforge.jnlp.security.KeyStores; import net.sourceforge.jnlp.security.SecurityDialogMessageHandler; -import net.sourceforge.jnlp.security.VariableX509TrustManager; import net.sourceforge.jnlp.services.XServiceManagerStub; import net.sourceforge.jnlp.util.FileUtils; import net.sourceforge.jnlp.util.logging.JavaConsole; @@ -462,7 +455,7 @@ public class JNLPRuntime { * * @throws IllegalStateException if caller is not the exit class */ - public static void setExitClass(Class exitClass) { + public static void setExitClass(Class<?> exitClass) { checkExitClass(); security.setExitClass(exitClass); } diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java index dc1989a..762bb91 100644 --- a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java +++ b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java @@ -18,25 +18,19 @@ package net.sourceforge.jnlp.runtime; import static net.sourceforge.jnlp.runtime.Translator.R; -import java.awt.Frame; import java.awt.Window; -import java.lang.ref.WeakReference; import java.net.SocketPermission; -import java.security.AllPermission; import java.security.AccessControlException; import java.security.Permission; -import java.security.SecurityPermission; import javax.swing.JWindow; -import net.sourceforge.jnlp.JNLPFile; import net.sourceforge.jnlp.security.SecurityDialogs.AccessType; import net.sourceforge.jnlp.services.ServiceUtil; import net.sourceforge.jnlp.util.logging.OutputController; import net.sourceforge.jnlp.util.WeakList; import sun.awt.AWTSecurityManager; import sun.awt.AppContext; -import sun.security.util.SecurityConstants; /** * Security manager for JNLP environment. This security manager @@ -118,8 +112,9 @@ class JNLPSecurityManager extends AWTSecurityManager { // not added to any window list when checkTopLevelWindow is // called for it (and not disposed). - if (!JNLPRuntime.isHeadless()) + if (!JNLPRuntime.isHeadless()) { new JWindow().getOwner(); + } mainAppContext = AppContext.getAppContext(); } @@ -137,12 +132,15 @@ class JNLPSecurityManager extends AWTSecurityManager { * true if no exit class is set. */ private boolean isExitClass(Class stack[]) { - if (exitClass == null) + if (exitClass == null) { return true; + } - for (int i = 0; i < stack.length; i++) - if (stack[i] == exitClass) + for (int i = 0; i < stack.length; i++) { + if (stack[i] == exitClass) { return true; + } + } return false; } @@ -154,9 +152,10 @@ class JNLPSecurityManager extends AWTSecurityManager { * @param exitClass the exit class * @throws IllegalStateException if the exit class is already set */ - public void setExitClass(Class exitClass) throws IllegalStateException { - if (this.exitClass != null) + public void setExitClass(Class<?> exitClass) throws IllegalStateException { + if (this.exitClass != null) { throw new IllegalStateException(R("RExitTaken")); + } this.exitClass = exitClass; } @@ -181,8 +180,9 @@ class JNLPSecurityManager extends AWTSecurityManager { weakApplications.remove(i); } - if (w == window) + if (w == window) { return weakApplications.get(i); + } } return null; @@ -204,8 +204,9 @@ class JNLPSecurityManager extends AWTSecurityManager { cl = cl.getParent(); } - if (maxDepth <= 0) + if (maxDepth <= 0) { maxDepth = stack.length; + } // this needs to be tightened up for (int i = 0; i < stack.length && i < maxDepth; i++) { @@ -230,8 +231,9 @@ class JNLPSecurityManager extends AWTSecurityManager { private JNLPClassLoader getJnlpClassLoader(ClassLoader cl) { // Since we want to deal with JNLPClassLoader, extract it if this // is a codebase loader - if (cl instanceof JNLPClassLoader.CodeBaseClassLoader) + if (cl instanceof JNLPClassLoader.CodeBaseClassLoader) { cl = ((JNLPClassLoader.CodeBaseClassLoader) cl).getParentJNLPClassLoader(); + } if (cl instanceof JNLPClassLoader) { JNLPClassLoader loader = (JNLPClassLoader) cl; @@ -245,10 +247,12 @@ class JNLPSecurityManager extends AWTSecurityManager { * Returns the application's thread group if the application can * be determined; otherwise returns super.getThreadGroup() */ + @Override public ThreadGroup getThreadGroup() { ApplicationInstance app = getApplication(); - if (app == null) + if (app == null) { return super.getThreadGroup(); + } return app.getThreadGroup(); } @@ -258,6 +262,7 @@ class JNLPSecurityManager extends AWTSecurityManager { * otherwise return normally. This method always denies * permission to change the security manager or policy. */ + @Override public void checkPermission(Permission perm) { String name = perm.getName(); @@ -267,8 +272,9 @@ class JNLPSecurityManager extends AWTSecurityManager { // OutputController.getLogger().log("Checking permission: " + perm.toString()); if (!JNLPRuntime.isWebstartApplication() && - ("setPolicy".equals(name) || "setSecurityManager".equals(name))) + ("setPolicy".equals(name) || "setSecurityManager".equals(name))) { throw new SecurityException(R("RCantReplaceSM")); + } try { // deny all permissions to stopped applications @@ -337,6 +343,7 @@ class JNLPSecurityManager extends AWTSecurityManager { * warning banner, and adds the window to the list of windows to * be disposed when the calling application exits. */ + @Override public boolean checkTopLevelWindow(Object window) { ApplicationInstance app = getApplication(); @@ -371,22 +378,26 @@ class JNLPSecurityManager extends AWTSecurityManager { * Calls not from Runtime.exit or with no exit class set will * behave normally, and the exit class can always exit the JVM. */ + @Override public void checkExit(int status) { // applets are not allowed to exit, but the plugin main class (primordial loader) is Class stack[] = getClassContext(); if (!exitAllowed) { - for (int i = 0; i < stack.length; i++) - if (stack[i].getClassLoader() != null) + for (int i = 0; i < stack.length; i++) { + if (stack[i].getClassLoader() != null) { throw new AccessControlException("Applets may not call System.exit()"); + } + } } super.checkExit(status); boolean realCall = (stack[1] == Runtime.class); - if (isExitClass(stack)) // either exitClass called or no exitClass set - return; // to Runtime.exit or fake call to see if app has permission + if (isExitClass(stack)) { + return; + } // to Runtime.exit or fake call to see if app has permission // not called from Runtime.exit() if (!realCall) { @@ -446,6 +457,7 @@ class JNLPSecurityManager extends AWTSecurityManager { * @exception SecurityException if the caller does not have * permission to accesss the AWT event queue. */ + @Override public void checkAwtEventQueueAccess() { /* * this is the templace of the code that should allow applets access to diff --git a/netx/net/sourceforge/jnlp/security/CertWarningPane.java b/netx/net/sourceforge/jnlp/security/CertWarningPane.java index dae8030..f2a21d6 100644 --- a/netx/net/sourceforge/jnlp/security/CertWarningPane.java +++ b/netx/net/sourceforge/jnlp/security/CertWarningPane.java @@ -65,7 +65,6 @@ import javax.swing.SwingConstants; import net.sourceforge.jnlp.JNLPFile; import net.sourceforge.jnlp.PluginBridge; -import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.security.KeyStores.Level; import net.sourceforge.jnlp.security.KeyStores.Type; import net.sourceforge.jnlp.security.SecurityDialogs.AccessType; diff --git a/netx/net/sourceforge/jnlp/security/CertsInfoPane.java b/netx/net/sourceforge/jnlp/security/CertsInfoPane.java index d22a590..a6d189f 100644 --- a/netx/net/sourceforge/jnlp/security/CertsInfoPane.java +++ b/netx/net/sourceforge/jnlp/security/CertsInfoPane.java @@ -65,7 +65,6 @@ import javax.swing.tree.TreeSelectionModel; public class CertsInfoPane extends SecurityDialogPanel { private CertPath certPath; - private JList list; protected JTree tree; private JTable table; private JTextArea output; @@ -175,7 +174,7 @@ public class CertsInfoPane extends SecurityDialogPanel { /** * Constructs the GUI components of this panel */ - protected void addComponents() { + private void addComponents() { buildTree(); populateTable(); /** @@ -235,17 +234,21 @@ public class CertsInfoPane extends SecurityDialogPanel { * Copies the currently selected certificate to the system Clipboard. */ private class CopyToClipboardHandler implements ActionListener { + @Override public void actionPerformed(ActionEvent e) { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); int certIndex = 0; DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); - if (node == null) + if (node == null) { return; - if (node.isRoot()) + } + if (node.isRoot()) { certIndex = 0; - else if (node.isLeaf()) + } + else if (node.isLeaf()) { certIndex = 1; + } String[][] cert = certsData.get(certIndex); int rows = cert.length; @@ -268,12 +271,14 @@ public class CertsInfoPane extends SecurityDialogPanel { * Updates the JTable when the JTree selection has changed. */ protected class TreeSelectionHandler implements TreeSelectionListener { + @Override public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); - if (node == null) + if (node == null) { return; + } if (node.isRoot()) { table.setModel(new DefaultTableModel(certsData.get(0), columnNames)); @@ -288,6 +293,7 @@ public class CertsInfoPane extends SecurityDialogPanel { * Updates the JTable when the selection on the list has changed. */ private class ListSelectionHandler implements ListSelectionListener { + @Override public void valueChanged(ListSelectionEvent e) { ListSelectionModel lsm = (ListSelectionModel) e.getSource(); @@ -308,6 +314,7 @@ public class CertsInfoPane extends SecurityDialogPanel { * has changed. */ private class TableSelectionHandler implements ListSelectionListener { + @Override public void valueChanged(ListSelectionEvent e) { ListSelectionModel lsm = (ListSelectionModel) e.getSource(); @@ -329,8 +336,9 @@ public class CertsInfoPane extends SecurityDialogPanel { private String makeFingerprint(byte[] hash) { String fingerprint = ""; for (int i = 0; i < hash.length; i++) { - if (!fingerprint.equals("")) + if (!fingerprint.equals("")) { fingerprint += ":"; + } fingerprint += Integer.toHexString( ((hash[i] & 0xFF) | 0x100)).substring(1, 3); } diff --git a/netx/net/sourceforge/jnlp/security/appletextendedsecurity/impl/UnsignedAppletActionStorageImpl.java b/netx/net/sourceforge/jnlp/security/appletextendedsecurity/impl/UnsignedAppletActionStorageImpl.java index ef5eada..2a5bfd3 100644 --- a/netx/net/sourceforge/jnlp/security/appletextendedsecurity/impl/UnsignedAppletActionStorageImpl.java +++ b/netx/net/sourceforge/jnlp/security/appletextendedsecurity/impl/UnsignedAppletActionStorageImpl.java @@ -151,7 +151,7 @@ public class UnsignedAppletActionStorageImpl extends LockingReaderWriter impleme } public List<UnsignedAppletActionEntry> getMatchingItems(String documentBase, String codeBase, List<String> archives) { - List<UnsignedAppletActionEntry> result = new ArrayList(); + List<UnsignedAppletActionEntry> result = new ArrayList<UnsignedAppletActionEntry>(); lock(); try { readContents(); diff --git a/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java b/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java index 61123d7..71b48aa 100644 --- a/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java +++ b/netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java @@ -108,7 +108,7 @@ public class CertificatePane extends JPanel { JTabbedPane tabbedPane; private final JTable userTable; private final JTable systemTable; - private JComboBox certificateTypeCombo; + private JComboBox<CertificateType> certificateTypeCombo; private KeyStores.Type currentKeyStoreType; private KeyStores.Level currentKeyStoreLevel; @@ -156,7 +156,7 @@ public class CertificatePane extends JPanel { } //create the GUI here. - protected void addComponents() { + private void addComponents() { JPanel main = new JPanel(new BorderLayout()); @@ -165,7 +165,7 @@ public class CertificatePane extends JPanel { JLabel certificateTypeLabel = new JLabel(R("CVCertificateType")); - certificateTypeCombo = new JComboBox(certificateTypes); + certificateTypeCombo = new JComboBox<CertificateType>(certificateTypes); certificateTypeCombo.addActionListener(new CertificateTypeListener()); certificateTypePanel.add(certificateTypeLabel, BorderLayout.LINE_START); @@ -264,8 +264,9 @@ public class CertificatePane extends JPanel { aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { Certificate c = keyStore.getCertificate(aliases.nextElement()); - if (c instanceof X509Certificate) + if (c instanceof X509Certificate) { certs.add((X509Certificate) c); + } } //get the publisher and root information @@ -310,10 +311,12 @@ public class CertificatePane extends JPanel { new Object[]{label, jpf}, R("CVPasswordTitle"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); - if (result == JOptionPane.OK_OPTION) + if (result == JOptionPane.OK_OPTION) { return jpf.getPassword(); - else + } + else { return null; + } } /** Allows storing KeyStores.Types in a JComponent */ @@ -328,6 +331,7 @@ public class CertificatePane extends JPanel { return type; } + @Override public String toString() { return KeyStores.toDisplayableString(null, type); } @@ -336,8 +340,9 @@ public class CertificatePane extends JPanel { /** Invoked when a user selects a different certificate type */ private class CertificateTypeListener implements ActionListener { @Override + @SuppressWarnings("unchecked")//this is just certificateTypeCombo, nothing else public void actionPerformed(ActionEvent e) { - JComboBox source = (JComboBox) e.getSource(); + JComboBox<CertificateType> source = (JComboBox<CertificateType>) e.getSource(); CertificateType type = (CertificateType) source.getSelectedItem(); currentKeyStoreType = type.getType(); repopulateTables(); @@ -372,6 +377,7 @@ public class CertificatePane extends JPanel { } private class ImportButtonListener implements ActionListener { + @Override public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); @@ -412,9 +418,10 @@ public class CertificatePane extends JPanel { } private class ExportButtonListener implements ActionListener { + @Override public void actionPerformed(ActionEvent e) { - JTable table = null; + final JTable table ; if (currentKeyStoreLevel == Level.USER) { table = userTable; } else { @@ -435,8 +442,9 @@ public class CertificatePane extends JPanel { if (alias != null) { if (currentKeyStoreType == KeyStores.Type.CLIENT_CERTS) { char[] password = getPassword(R("CVExportPasswordMessage")); - if (password != null) + if (password != null) { CertificateUtils.dumpPKCS12(alias, chooser.getSelectedFile(), keyStore, password); + } } else { Certificate c = keyStore.getCertificate(alias); PrintStream ps = new PrintStream(chooser.getSelectedFile().getAbsolutePath()); @@ -457,9 +465,10 @@ public class CertificatePane extends JPanel { /** * Removes a certificate from the keyStore and writes changes to disk. */ + @Override public void actionPerformed(ActionEvent e) { - JTable table = null; + final JTable table; if (currentKeyStoreLevel == Level.USER) { table = userTable; } else { @@ -502,9 +511,10 @@ public class CertificatePane extends JPanel { /** * Shows the details of a trusted certificate. */ + @Override public void actionPerformed(ActionEvent e) { - JTable table = null; + final JTable table; if (currentKeyStoreLevel == Level.USER) { table = userTable; } else { diff --git a/netx/net/sourceforge/jnlp/services/ServiceUtil.java b/netx/net/sourceforge/jnlp/services/ServiceUtil.java index 9885138..ec573b0 100644 --- a/netx/net/sourceforge/jnlp/services/ServiceUtil.java +++ b/netx/net/sourceforge/jnlp/services/ServiceUtil.java @@ -155,9 +155,9 @@ public class ServiceUtil { * must be more than extremely careful in the operations they * perform. */ - static Object createPrivilegedProxy(Class iface, final Object receiver) { + static Object createPrivilegedProxy(Class<?> iface, final Object receiver) { return java.lang.reflect.Proxy.newProxyInstance(XServiceManagerStub.class.getClassLoader(), - new Class[] { iface }, + new Class<?>[] { iface }, new PrivilegedHandler(receiver)); } @@ -171,15 +171,19 @@ public class ServiceUtil { this.receiver = receiver; } + @Override public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable { if (JNLPRuntime.isDebug()) { OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "call privileged method: " + method.getName()); - if (args != null) - for (int i = 0; i < args.length; i++) + if (args != null) { + for (int i = 0; i < args.length; i++) { OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, " arg: " + args[i]); + } + } } PrivilegedExceptionAction<Object> invoker = new PrivilegedExceptionAction<Object>() { + @Override public Object run() throws Exception { return method.invoke(receiver, args); } @@ -242,8 +246,9 @@ public class ServiceUtil { if (!shouldPromptUser()) { return false; } - if (app == null) + if (app == null) { app = JNLPRuntime.getApplication(); + } final AccessType tmpType = type; final Object[] tmpExtras = extras; @@ -253,6 +258,7 @@ public class ServiceUtil { //applets, otherwise permissions won't be granted to load icons //from resources.jar. Boolean b = AccessController.doPrivileged(new PrivilegedAction<Boolean>() { + @Override public Boolean run() { boolean b = SecurityDialogs.showAccessWarningDialog(tmpType, tmpApp.getJNLPFile(), tmpExtras); @@ -294,14 +300,15 @@ public class ServiceUtil { public static boolean isSigned(ApplicationInstance app) { - if (app == null) + if (app == null) { app = JNLPRuntime.getApplication(); + } StackTraceElement[] stack = Thread.currentThread().getStackTrace(); for (int i = 0; i < stack.length; i++) { - Class c = null; + Class<?> c = null; try { c = Class.forName(stack[i].getClassName()); diff --git a/netx/net/sourceforge/jnlp/splashscreen/impls/DefaultErrorSplashScreen2012.java b/netx/net/sourceforge/jnlp/splashscreen/impls/DefaultErrorSplashScreen2012.java index a9e38a2..fb55dc4 100644 --- a/netx/net/sourceforge/jnlp/splashscreen/impls/DefaultErrorSplashScreen2012.java +++ b/netx/net/sourceforge/jnlp/splashscreen/impls/DefaultErrorSplashScreen2012.java @@ -46,7 +46,6 @@ import net.sourceforge.jnlp.splashscreen.parts.BasicComponentErrorSplashScreen; public final class DefaultErrorSplashScreen2012 extends BasicComponentErrorSplashScreen { - private final DefaultErrorSplashScreen2012 self; private final ErrorPainter painter; private final DefaultSplashScreens2012Commons commons; @@ -55,22 +54,21 @@ public final class DefaultErrorSplashScreen2012 extends BasicComponentErrorSplas //setSplashHeight(height); //setSplashWidth(width); //to have this in inner classes - self = this; setLoadingException(ex); setSplashReason(splashReason); - painter = new ErrorPainter(self, true); + painter = new ErrorPainter(this, true); addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - if (((ErrorPainter) painter).getErrorCorner() != null - && e.getX() > ((ErrorPainter) painter).getErrorCorner().x - && e.getY() > ((ErrorPainter) painter).getErrorCorner().y) { + if ((painter).getErrorCorner() != null + && e.getX() > (painter).getErrorCorner().x + && e.getY() > (painter).getErrorCorner().y) { raiseExceptionDialog(); } } }); - commons = new DefaultSplashScreens2012Commons(painter, self); + commons = new DefaultSplashScreens2012Commons(painter, this); } @Override diff --git a/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/NatCubic.java b/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/NatCubic.java index 43bda84..8fe3516 100644 --- a/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/NatCubic.java +++ b/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/NatCubic.java @@ -115,7 +115,7 @@ public class NatCubic extends ControlCurve { Cubic[] Y = calcNaturalCubic(pts.npoints - 1, pts.ypoints); /* very crude technique - just break each segment up into steps lines */ Polygon p = new Polygon(); - p.addPoint((int) Math.round(X[0].eval(0)), (int) Math.round(Y[0].eval(0))); + p.addPoint(Math.round(X[0].eval(0)), Math.round(Y[0].eval(0))); for (int i = 0; i < X.length; i++) { for (int j = 1; j <= STEPS; j++) { float u = j / (float) STEPS; diff --git a/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/SplinesDefs.java b/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/SplinesDefs.java index 0f18fe9..c5c165e 100644 --- a/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/SplinesDefs.java +++ b/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/SplinesDefs.java @@ -153,24 +153,24 @@ public class SplinesDefs { return polygonizeControlPoints(mainLeafArray, scalex, scaley); } - static Polygon polygonizeControlPoints(Point[] pp, Double scalex, double scaley) { + static Polygon polygonizeControlPoints(Point[] pp, double scalex, double scaley) { Polygon r = new Polygon(); for (int i = 0; i < pp.length; i++) { Point p = pp[i]; - r.addPoint((int) ((double) p.x * (double) scalex), (int) ((double) p.y * (double) scaley)); + r.addPoint( (int) ((double) p.x * scalex), (int) ((double) p.y * scaley)); } return r; } - public static Polygon getSecondLeaf(Double scalex, double scaley) { + public static Polygon getSecondLeaf(double scalex, double scaley) { return polygonizeControlPoints(smallLeafArray, scalex, scaley); } - public static Polygon getSecondLeafStalk(Double scalex, double scaley) { + public static Polygon getSecondLeafStalk(double scalex, double scaley) { return polygonizeControlPoints(smallLeafStalkArray, scalex, scaley); } - public static Polygon getMainLeafStalk(Double scalex, double scaley) { + public static Polygon getMainLeafStalk(double scalex, double scaley) { return polygonizeControlPoints(mainLeafStalkArray, scalex, scaley); } diff --git a/netx/net/sourceforge/jnlp/util/Reflect.java b/netx/net/sourceforge/jnlp/util/Reflect.java index 6673974..065c843 100644 --- a/netx/net/sourceforge/jnlp/util/Reflect.java +++ b/netx/net/sourceforge/jnlp/util/Reflect.java @@ -16,8 +16,9 @@ package net.sourceforge.jnlp.util; +import java.lang.reflect.Method; import net.sourceforge.jnlp.util.logging.OutputController; -import java.lang.reflect.*; + /** * Provides simply, convenient methods to invoke methods by @@ -75,11 +76,12 @@ public class Reflect { */ public Object invokeStatic(String className, String method, Object args[]) { try { - Class c = Class.forName(className, true, Reflect.class.getClassLoader()); + Class<?> c = Class.forName(className, true, Reflect.class.getClassLoader()); Method m = getMethod(c, method, args); - if (m.isAccessible() != accessible) + if (m.isAccessible() != accessible) { m.setAccessible(accessible); + } return m.invoke(null, args); } catch (Exception ex) { // eat @@ -103,8 +105,9 @@ public class Reflect { public Object invoke(Object object, String method, Object args[]) { try { Method m = getMethod(object.getClass(), method, args); - if (m.isAccessible() != accessible) + if (m.isAccessible() != accessible) { m.setAccessible(accessible); + } return m.invoke(object, args); } catch (Exception ex) { // eat @@ -117,17 +120,18 @@ public class Reflect { * Return the Method matching the specified name and number of * arguments. */ - public Method getMethod(Class type, String method, Object args[]) { + public Method getMethod(Class<?> type, String method, Object args[]) { try { - for (Class c = type; c != null; c = c.getSuperclass()) { + for (Class<?> c = type; c != null; c = c.getSuperclass()) { Method methods[] = c.getMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(method)) { Class parameters[] = methods[i].getParameterTypes(); - if (parameters.length == args.length) + if (parameters.length == args.length) { return methods[i]; + } } } } diff --git a/netx/net/sourceforge/jnlp/util/ui/NonEditableTableModel.java b/netx/net/sourceforge/jnlp/util/ui/NonEditableTableModel.java index 4f2c409..e64a244 100644 --- a/netx/net/sourceforge/jnlp/util/ui/NonEditableTableModel.java +++ b/netx/net/sourceforge/jnlp/util/ui/NonEditableTableModel.java @@ -94,7 +94,7 @@ public class NonEditableTableModel extends DefaultTableModel { * @param rowCount the number of rows the table holds * @see DefaultTableModel#DefaultTableModel(Vector,int) */ - public NonEditableTableModel(final Vector columnNames, final int rowCount) { + public NonEditableTableModel(final Vector<?> columnNames, final int rowCount) { super(columnNames, rowCount); } @@ -106,7 +106,7 @@ public class NonEditableTableModel extends DefaultTableModel { * @param columnNames {@code vector} containing the names of the new columns * @see DefaultTableModel#DefaultTableModel(Vector,Vector) */ - public NonEditableTableModel(final Vector data, final Vector columnNames) { + public NonEditableTableModel(final Vector<?> data, final Vector<?> columnNames) { super(data, columnNames); } diff --git a/netx/net/sourceforge/nanoxml/XMLElement.java b/netx/net/sourceforge/nanoxml/XMLElement.java index dab8056..6a6e8b2 100644 --- a/netx/net/sourceforge/nanoxml/XMLElement.java +++ b/netx/net/sourceforge/nanoxml/XMLElement.java @@ -372,7 +372,7 @@ public class XMLElement { * </ul></dd></dl> * */ - public Enumeration enumerateAttributeNames() { + public Enumeration<String> enumerateAttributeNames() { return this.attributes.keys(); } @@ -384,7 +384,7 @@ public class XMLElement { * </ul></dd></dl> * */ - public Enumeration enumerateChildren() { + public Enumeration<XMLElement> enumerateChildren() { return this.children.elements(); } |