diff --git a/core/src/main/java/hudson/EnvVars.java b/core/src/main/java/hudson/EnvVars.java index 39a3edd5f13c819e82460b50663d001d1c022653..8f8c49124adc5e3921f86e1de2fbd7e487e33fa4 100644 --- a/core/src/main/java/hudson/EnvVars.java +++ b/core/src/main/java/hudson/EnvVars.java @@ -17,6 +17,7 @@ public class EnvVars { public static final Map masterEnvVars; static { + @SuppressWarnings("unchecked") // Ant does not use JDK 5 Vector envs = Execute.getProcEnvironment(); Map m = new HashMap(); for (String e : envs) { diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index 119e845c4e250f9f3c92f33c58cd083286896f3a..5a3a5b76aac9102df472370034b768eef5b8f8d1 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -62,7 +62,8 @@ public class Functions { } public static RunUrl decompose(StaplerRequest req) { - List ancestors = (List) req.getAncestors(); + @SuppressWarnings("unchecked") // pre-JDK 5 API? + List ancestors = req.getAncestors(); for (Ancestor anc : ancestors) { if(anc.getObject() instanceof Run) { // bingo @@ -139,11 +140,11 @@ public class Functions { } public static Map getSystemProperties() { - return new TreeMap(System.getProperties()); + return new TreeMap(System.getProperties()); } public static Map getEnvVars() { - return new TreeMap(EnvVars.masterEnvVars); + return new TreeMap(EnvVars.masterEnvVars); } public static boolean isWindows() { diff --git a/core/src/main/java/hudson/Launcher.java b/core/src/main/java/hudson/Launcher.java index de07eb6871ba4bf242a4fe9cfb1f16cb5acda9eb..2c31475e763161364b8b09f6cdcbd80e2e042cae 100644 --- a/core/src/main/java/hudson/Launcher.java +++ b/core/src/main/java/hudson/Launcher.java @@ -36,15 +36,15 @@ public class Launcher { this.listener = listener; } - public final Proc launch(String cmd, Map env, OutputStream out, FilePath workDir) throws IOException { + public final Proc launch(String cmd, Map env, OutputStream out, FilePath workDir) throws IOException { return launch(cmd,Util.mapToEnv(env),out,workDir); } - public final Proc launch(String[] cmd, Map env, OutputStream out, FilePath workDir) throws IOException { + public final Proc launch(String[] cmd, Map env, OutputStream out, FilePath workDir) throws IOException { return launch(cmd,Util.mapToEnv(env),out,workDir); } - public final Proc launch(String[] cmd,Map env, InputStream in, OutputStream out) throws IOException { + public final Proc launch(String[] cmd, Map env, InputStream in, OutputStream out) throws IOException { return launch(cmd,Util.mapToEnv(env),in,out); } diff --git a/core/src/main/java/hudson/Plugin.java b/core/src/main/java/hudson/Plugin.java index cafe25995dfe8ab399eead32fcf312e0a8173c6b..60ed8a0f57a7350b8c4f80715b5df15944819226 100644 --- a/core/src/main/java/hudson/Plugin.java +++ b/core/src/main/java/hudson/Plugin.java @@ -1,10 +1,5 @@ package hudson; -import hudson.model.Hudson; -import hudson.scm.SCM; -import hudson.tasks.Builder; -import hudson.tasks.Publisher; -import hudson.triggers.Trigger; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; diff --git a/core/src/main/java/hudson/Proc.java b/core/src/main/java/hudson/Proc.java index 25d4f4dd313ef0119516a03cfa5221f5b324301b..54d3f8abaca53e384270cf3ac62a28464a4675ab 100644 --- a/core/src/main/java/hudson/Proc.java +++ b/core/src/main/java/hudson/Proc.java @@ -20,11 +20,11 @@ public final class Proc { private final Process proc; private final Thread t1,t2; - public Proc(String cmd,Map env, OutputStream out, File workDir) throws IOException { + public Proc(String cmd, Map env, OutputStream out, File workDir) throws IOException { this(cmd,Util.mapToEnv(env),out,workDir); } - public Proc(String[] cmd,Map env,InputStream in, OutputStream out) throws IOException { + public Proc(String[] cmd, Map env,InputStream in, OutputStream out) throws IOException { this(cmd,Util.mapToEnv(env),in,out); } diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index e57d2c20329a76856a88887e7f36eeaffab097b0..5eac1fb20bbb8d1b8872b3828b8e79fb3e29bd6d 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -17,7 +17,6 @@ import java.util.Map; import java.util.ResourceBundle; import java.util.StringTokenizer; import java.util.SimpleTimeZone; -import java.util.Map.Entry; import java.util.logging.Logger; import java.util.logging.Level; import java.util.regex.Matcher; @@ -187,12 +186,12 @@ public class Util { return a; } - public static String[] mapToEnv(Map m) { + public static String[] mapToEnv(Map m) { String[] r = new String[m.size()]; int idx=0; - for (final Map.Entry e : m.entrySet()) { - r[idx++] = e.getKey().toString() + '=' + e.getValue().toString(); + for (final Map.Entry e : m.entrySet()) { + r[idx++] = e.getKey() + '=' + e.getValue(); } return r; } diff --git a/core/src/main/java/hudson/XmlFile.java b/core/src/main/java/hudson/XmlFile.java index 797866caeed891cb5b9db91d405d50fdf1f357fd..1ec525456fd1cdf8245488d85c6dddd44506442c 100644 --- a/core/src/main/java/hudson/XmlFile.java +++ b/core/src/main/java/hudson/XmlFile.java @@ -2,13 +2,11 @@ package hudson; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.converters.ConversionException; -import com.thoughtworks.xstream.converters.Converter; import com.thoughtworks.xstream.io.StreamException; import com.thoughtworks.xstream.io.xml.XppReader; import hudson.util.AtomicFileWriter; import hudson.util.IOException2; import hudson.util.XStream2; -import hudson.model.Descriptor; import java.io.BufferedReader; import java.io.File; diff --git a/core/src/main/java/hudson/model/Actionable.java b/core/src/main/java/hudson/model/Actionable.java index 41e60961cd02c4c2b0d160c17212d4d98f255f24..a8eff4a6a849a2b126911a03238172c608d4a84e 100644 --- a/core/src/main/java/hudson/model/Actionable.java +++ b/core/src/main/java/hudson/model/Actionable.java @@ -36,8 +36,11 @@ public abstract class Actionable extends AbstractModelObject { public T getAction(Class type) { for (Action a : getActions()) { - if(type.isInstance(a)) - return (T)a; // type.cast() not available in JDK 1.4 + if (type.isInstance(a)) { + @SuppressWarnings("unchecked") // type.cast() not available in JDK 1.4; XXX doesn't retro* emulate it? + T _a = (T) a; + return _a; + } } return null; } diff --git a/core/src/main/java/hudson/model/Build.java b/core/src/main/java/hudson/model/Build.java index b303a16f52da9fd53b614bc3d888e1e52c7ca1e9..2e335617008f3875746cd087b896ca7fe1e3bd17 100644 --- a/core/src/main/java/hudson/model/Build.java +++ b/core/src/main/java/hudson/model/Build.java @@ -240,10 +240,10 @@ public final class Build extends Run implements Runnable { * Gets the changes in the dependency between the given build and this build. */ public Map getDependencyChanges(Build from) { - if(from==null) return Collections.EMPTY_MAP; // make it easy to call this from views + if(from==null) return Collections.emptyMap(); // make it easy to call this from views FingerprintAction n = this.getAction(FingerprintAction.class); FingerprintAction o = from.getAction(FingerprintAction.class); - if(n==null || o==null) return Collections.EMPTY_MAP; + if(n==null || o==null) return Collections.emptyMap(); Map ndep = n.getDependencies(); Map odep = o.getDependencies(); diff --git a/core/src/main/java/hudson/model/Descriptor.java b/core/src/main/java/hudson/model/Descriptor.java index 32c67e6b6b432bfbb8cb647d878d9ba8d2830f9b..b39b53ed6839e82c1112c7fbcc506f1caf02d26b 100644 --- a/core/src/main/java/hudson/model/Descriptor.java +++ b/core/src/main/java/hudson/model/Descriptor.java @@ -1,7 +1,6 @@ package hudson.model; import hudson.XmlFile; -import hudson.scm.CVSSCM; import org.kohsuke.stapler.StaplerRequest; import javax.servlet.http.HttpServletRequest; @@ -61,6 +60,7 @@ public abstract class Descriptor> { * * @deprecated */ + @Deprecated private transient Map properties; /** @@ -113,6 +113,7 @@ public abstract class Descriptor> { * @deprecated * As of 1.64. Use {@link #configure(StaplerRequest)}. */ + @Deprecated public boolean configure( HttpServletRequest req ) throws FormException { return true; } @@ -162,7 +163,9 @@ public abstract class Descriptor> { Object o = file.unmarshal(this); if(o instanceof Map) { // legacy format - convert((Map)o); + @SuppressWarnings("unchecked") + Map _o = (Map) o; + convert(_o); save(); // convert to the new format } } catch (IOException e) { diff --git a/core/src/main/java/hudson/model/Hudson.java b/core/src/main/java/hudson/model/Hudson.java index f7dccf4f27ba5d418ba147b04f65c4a5b74449a3..70033f9fd432e845058012139131d74eeb16cc45 100644 --- a/core/src/main/java/hudson/model/Hudson.java +++ b/core/src/main/java/hudson/model/Hudson.java @@ -161,10 +161,11 @@ public final class Hudson extends JobCollection implements Node { } /** - * If you are calling it o Hudson something is wrong. + * If you are calling this on Hudson something is wrong. * * @deprecated */ + @Deprecated public String getNodeName() { return ""; } @@ -339,6 +340,7 @@ public final class Hudson extends JobCollection implements Node { * @deprecated * why are you calling a method that always return true? */ + @Deprecated public boolean containsJob(Job job) { return true; } @@ -939,6 +941,7 @@ public final class Hudson extends JobCollection implements Node { ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory()); // Parse the request + @SuppressWarnings("unchecked") // pre-generics lib List items = upload.parseRequest(req); rsp.sendRedirect2(req.getContextPath()+"/fingerprint/"+ @@ -1161,7 +1164,7 @@ public final class Hudson extends JobCollection implements Node { /** * Live view of recent {@link LogRecord}s produced by Hudson. */ - public static List logRecords = Collections.EMPTY_LIST; // initialized to dummy value to avoid NPE + public static List logRecords = Collections.emptyList(); // initialized to dummy value to avoid NPE /** * Thread-safe reusable {@link XStream}. diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java index 7724e4ffab76cff4e403ad5117efba7b022e53d6..10df6dbb14b777e6329d24d32e1e5cc816bf53f0 100644 --- a/core/src/main/java/hudson/model/Job.java +++ b/core/src/main/java/hudson/model/Job.java @@ -34,7 +34,6 @@ import java.awt.Color; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Comparator; import java.util.List; import java.util.SortedMap; import java.util.Collections; @@ -310,6 +309,7 @@ public abstract class Job, RunT extends Run,R extends Run> exten * @deprecated * This is not a valid operation for {@link Job}s. */ + @Deprecated public Job newInstance(StaplerRequest req) throws FormException { throw new UnsupportedOperationException(); } diff --git a/core/src/main/java/hudson/model/Jobs.java b/core/src/main/java/hudson/model/Jobs.java index c1509ea1ddca9f72823e2ddb172666202c19508a..49035fe2e3aa2691e6f26d2c1818b8ee0e494b95 100644 --- a/core/src/main/java/hudson/model/Jobs.java +++ b/core/src/main/java/hudson/model/Jobs.java @@ -11,13 +11,14 @@ public class Jobs { /** * List of all installed job types. */ - public static final List JOBS = (List)Descriptor.toList( + @SuppressWarnings("unchecked") // two typing problems here! + public static final List> JOBS = (List)Descriptor.toList( Project.DESCRIPTOR, ExternalJob.DESCRIPTOR ); public static JobDescriptor getDescriptor(String displayName) { - for (JobDescriptor job : JOBS) { + for (JobDescriptor job : JOBS) { if(job.getDisplayName().equals(displayName)) return job; } diff --git a/core/src/main/java/hudson/model/Project.java b/core/src/main/java/hudson/model/Project.java index 79fc0e2f3a3c5e98b6fd2367000fdc470d156dec..35ac596308150e43e578e4d6545c534b33d288a1 100644 --- a/core/src/main/java/hudson/model/Project.java +++ b/core/src/main/java/hudson/model/Project.java @@ -516,7 +516,7 @@ public class Project extends Job { */ public void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { - Set upstream = Collections.EMPTY_SET; + Set upstream = Collections.emptySet(); synchronized(this) { try { @@ -711,6 +711,7 @@ public class Project extends Job { * @deprecated * left for legacy config file compatibility */ + @Deprecated private transient String slave; private static final String FAILURE_ONLY_COOKIE = "TestResultAction_failureOnly"; diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index 5a0172e6538d8aa6a4083a9c65f19ed9f2897707..bafb21938eebc15f4e572b136e994a3f2e54b47f 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -7,7 +7,6 @@ import hudson.ExtensionPoint; import hudson.Util; import hudson.XmlFile; import hudson.FeedAdapter; -import hudson.tasks.BuildStep; import hudson.tasks.LogRotator; import hudson.tasks.test.AbstractTestResultAction; import hudson.util.CharSpool; @@ -459,6 +458,10 @@ public abstract class Run ,RunT extends Run env = createEnvVarMap(true); int r = launcher.launch(cmd.toCommandArray(),env,out,dir).join(); if(r!=0) @@ -52,8 +51,8 @@ abstract class AbstractCVSFamilySCM implements SCM { * false to indicate that the map should contain complete map. * This is to invoke {@link Proc} directly. */ - protected final Map createEnvVarMap(boolean overrideOnly) { - Map env = new HashMap(); + protected final Map createEnvVarMap(boolean overrideOnly) { + Map env = new HashMap(); if(!overrideOnly) env.putAll(EnvVars.masterEnvVars); buildEnvVars(env); diff --git a/core/src/main/java/hudson/scm/CVSSCM.java b/core/src/main/java/hudson/scm/CVSSCM.java index c1a670c29f46f306026d6b904fbabb5131f4a6ea..6dd366ffc7386683e878aa48027255248a264371 100644 --- a/core/src/main/java/hudson/scm/CVSSCM.java +++ b/core/src/main/java/hudson/scm/CVSSCM.java @@ -28,7 +28,6 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.BufferedReader; import java.io.ByteArrayInputStream; @@ -274,6 +273,7 @@ public class CVSSCM extends AbstractCVSFamilySCM { parseUpdateOutput("",baos, changedFileNames); } else { + @SuppressWarnings("unchecked") // StringTokenizer oddly has the wrong type Set moduleNames = new TreeSet(Collections.list(new StringTokenizer(module))); // Add in any existing CVS dirs, in case project checked out its own. File[] subdirs = workspace.getLocal().listFiles(); diff --git a/core/src/main/java/hudson/scm/ChangeLogSet.java b/core/src/main/java/hudson/scm/ChangeLogSet.java index 5bc840a8b4a2ef06421d523d480389a8ffa15514..edb49b26e376fe359170ae4e1d3312aaf6f8a9a3 100644 --- a/core/src/main/java/hudson/scm/ChangeLogSet.java +++ b/core/src/main/java/hudson/scm/ChangeLogSet.java @@ -21,7 +21,7 @@ public abstract class ChangeLogSet implements Iter /** * Constant instance that represents no changes. */ - public static final ChangeLogSet EMPTY = new CVSChangeLogSet(Collections.EMPTY_LIST); + public static final ChangeLogSet EMPTY = new CVSChangeLogSet(Collections.emptyList()); public static abstract class Entry { diff --git a/core/src/main/java/hudson/scm/NullChangeLogParser.java b/core/src/main/java/hudson/scm/NullChangeLogParser.java index 8e600050a9117058aed49005b7ae923bfbc73d48..881b6869b86ecd9b44a946e10eb19622cc85ade9 100644 --- a/core/src/main/java/hudson/scm/NullChangeLogParser.java +++ b/core/src/main/java/hudson/scm/NullChangeLogParser.java @@ -11,7 +11,7 @@ import java.io.IOException; * @author Kohsuke Kawaguchi */ public class NullChangeLogParser extends ChangeLogParser { - public ChangeLogSet parse(Build build, File changelogFile) throws IOException, SAXException { + public ChangeLogSet parse(Build build, File changelogFile) throws IOException, SAXException { return ChangeLogSet.EMPTY; } } diff --git a/core/src/main/java/hudson/scm/SCMS.java b/core/src/main/java/hudson/scm/SCMS.java index a0024ec052ebf9e86193cf5a3d94ca107f5d4cbb..faa2e8fea53cbbdd0e996b2da4619a6969f91854 100644 --- a/core/src/main/java/hudson/scm/SCMS.java +++ b/core/src/main/java/hudson/scm/SCMS.java @@ -11,6 +11,7 @@ public class SCMS { /** * List of all installed SCMs. */ + @SuppressWarnings("unchecked") // generic array creation public static final List> SCMS = Descriptor.toList(NullSCM.DESCRIPTOR,CVSSCM.DESCRIPTOR,SubversionSCM.DESCRIPTOR); } diff --git a/core/src/main/java/hudson/scm/SubversionSCM.java b/core/src/main/java/hudson/scm/SubversionSCM.java index d5fbddbd49bd5620a26274d0d538c4b13653c79d..cab19d97fea8e9174fe8790fdb50ab1ce2a026b6 100644 --- a/core/src/main/java/hudson/scm/SubversionSCM.java +++ b/core/src/main/java/hudson/scm/SubversionSCM.java @@ -17,7 +17,6 @@ import org.kohsuke.stapler.StaplerResponse; import org.xml.sax.SAXException; import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.ByteArrayInputStream; @@ -115,7 +114,7 @@ public class SubversionSCM extends AbstractCVSFamilySCM { Map previousRevisions = parseRevisionFile(build.getPreviousBuild()); Map thisRevisions = parseRevisionFile(build); - Map env = createEnvVarMap(true); + Map env = createEnvVarMap(true); for( String module : getModuleDirNames() ) { Integer prevRev = previousRevisions.get(module); diff --git a/core/src/main/java/hudson/tasks/Mailer.java b/core/src/main/java/hudson/tasks/Mailer.java index 33be60a60f992762a09a67aa07f244fc631b8c67..4ec6802e5d7adf1773007f807cd0db1e9bc9d990 100644 --- a/core/src/main/java/hudson/tasks/Mailer.java +++ b/core/src/main/java/hudson/tasks/Mailer.java @@ -22,7 +22,6 @@ import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; -import javax.servlet.http.HttpServletRequest; import java.io.File; import java.io.IOException; import java.io.PrintWriter;