Skip to content

Commit 4825967

Browse files
committed
Deleting code using @IgnoreJRERequirement for Java 5 compatibility.
1 parent 24052ea commit 4825967

11 files changed

+10
-95
lines changed

cli/src/main/java/hudson/cli/CLI.java

-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import hudson.remoting.RemoteOutputStream;
3333
import hudson.remoting.SocketInputStream;
3434
import hudson.remoting.SocketOutputStream;
35-
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
3635

3736
import javax.crypto.SecretKey;
3837
import javax.crypto.spec.SecretKeySpec;
@@ -592,20 +591,14 @@ private static boolean isPemEncrypted(File f) throws IOException{
592591
return pemString.contains("4,ENCRYPTED");
593592
}
594593

595-
@SuppressWarnings("Since15")
596-
@IgnoreJRERequirement
597594
private static String askForPasswd(String filePath){
598-
try {
599595
Console cons = System.console();
600596
String passwd = null;
601597
if (cons != null){
602598
char[] p = cons.readPassword("%s", "Enter passphrase for "+filePath+":");
603599
passwd = String.valueOf(p);
604600
}
605601
return passwd;
606-
} catch (LinkageError e) {
607-
throw new Error("Your private key is encrypted, but we need Java6 to ask you password safely",e);
608-
}
609602
}
610603

611604
/**

core/src/main/java/hudson/Functions.java

+3-11
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@
140140
import org.apache.commons.jexl.parser.ASTSizeFunction;
141141
import org.apache.commons.jexl.util.Introspector;
142142
import org.apache.commons.lang.StringUtils;
143-
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
144143
import org.jvnet.tiger_types.Types;
145144
import org.kohsuke.stapler.Ancestor;
146145
import org.kohsuke.stapler.Stapler;
@@ -1126,7 +1125,6 @@ public static Map<Thread,StackTraceElement[]> dumpAllThreads() {
11261125
return sorted;
11271126
}
11281127

1129-
@IgnoreJRERequirement
11301128
public static ThreadInfo[] getThreadInfos() {
11311129
ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
11321130
return mbean.dumpAllThreads(mbean.isObjectMonitorUsageSupported(),mbean.isSynchronizerUsageSupported());
@@ -1190,20 +1188,14 @@ public int compare(Thread a, Thread b) {
11901188
}
11911189

11921190
/**
1193-
* Are we running on JRE6 or above?
1191+
* @deprecated Now always true.
11941192
*/
1195-
@IgnoreJRERequirement
1193+
@Deprecated
11961194
public static boolean isMustangOrAbove() {
1197-
try {
1198-
System.console();
1199-
return true;
1200-
} catch(LinkageError e) {
1201-
return false;
1202-
}
1195+
return true;
12031196
}
12041197

12051198
// ThreadInfo.toString() truncates the stack trace by first 8, so needed my own version
1206-
@IgnoreJRERequirement
12071199
public static String dumpThreadInfo(ThreadInfo ti, ThreadGroupMap map) {
12081200
String grp = map.getThreadGroup(ti);
12091201
StringBuilder sb = new StringBuilder("\"" + ti.getThreadName() + "\"" +

core/src/main/java/hudson/Util.java

+4-18
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import org.apache.tools.ant.types.FileSet;
4343
import jnr.posix.FileStat;
4444
import jnr.posix.POSIX;
45-
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
4645

4746
import javax.crypto.SecretKey;
4847
import javax.crypto.spec.SecretKeySpec;
@@ -259,16 +258,11 @@ public static void deleteFile(File f) throws IOException {
259258
/**
260259
* Makes the given file writable by any means possible.
261260
*/
262-
@IgnoreJRERequirement
263261
private static void makeWritable(File f) {
264-
// try JDK6-way of doing it.
265-
try {
266-
if (f.setWritable(true)) {
267-
return;
268-
}
269-
} catch (NoSuchMethodError e) {
270-
// not JDK6
262+
if (f.setWritable(true)) {
263+
return;
271264
}
265+
// TODO do we still need to try anything else?
272266

273267
// try chmod. this becomes no-op if this is not Unix.
274268
try {
@@ -1378,17 +1372,9 @@ private static int _indexOf(String s, char ch) {
13781372
* Loads a key/value pair string as {@link Properties}
13791373
* @since 1.392
13801374
*/
1381-
@IgnoreJRERequirement
13821375
public static Properties loadProperties(String properties) throws IOException {
13831376
Properties p = new Properties();
1384-
try {
1385-
p.load(new StringReader(properties));
1386-
} catch (NoSuchMethodError e) {
1387-
// load(Reader) method is only available on JDK6.
1388-
// this fall back version doesn't work correctly with non-ASCII characters,
1389-
// but there's no other easy ways out it seems.
1390-
p.load(new ByteArrayInputStream(properties.getBytes()));
1391-
}
1377+
p.load(new StringReader(properties));
13921378
return p;
13931379
}
13941380

core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageChecker.java

-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import hudson.Extension;
2727
import jenkins.model.Jenkins;
2828
import hudson.model.PeriodicWork;
29-
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
3029

3130
import java.util.logging.Logger;
3231

@@ -42,9 +41,7 @@ public long getRecurrencePeriod() {
4241
return HOUR;
4342
}
4443

45-
@IgnoreJRERequirement
4644
protected void doRun() {
47-
try {
4845
long free = Jenkins.getInstance().getRootDir().getUsableSpace();
4946
long total = Jenkins.getInstance().getRootDir().getTotalSpace();
5047
if(free<=0 || total<=0) {
@@ -61,11 +58,6 @@ protected void doRun() {
6158
// it's AND and not OR so that small Hudson home won't get a warning,
6259
// and similarly, if you have a 1TB disk, you don't get a warning when you still have 100GB to go.
6360
HudsonHomeDiskUsageMonitor.get().activated = (total/free>10 && free< FREE_SPACE_THRESHOLD);
64-
} catch (LinkageError _) {
65-
// pre Mustang
66-
LOGGER.info("Not on JDK6. Cannot monitor JENKINS_HOME disk usage");
67-
cancel();
68-
}
6961
}
7062

7163
private static final Logger LOGGER = Logger.getLogger(HudsonHomeDiskUsageChecker.class.getName());

core/src/main/java/hudson/node_monitors/DiskSpaceMonitor.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import hudson.Extension;
2727
import hudson.FilePath;
28-
import hudson.Functions;
2928
import hudson.model.Computer;
3029
import hudson.remoting.Callable;
3130
import jenkins.model.Jenkins;
@@ -76,7 +75,6 @@ protected Callable<DiskSpace, IOException> createCallable(Computer c) {
7675

7776
@Extension
7877
public static DiskSpaceMonitorDescriptor install() {
79-
if(Functions.isMustangOrAbove()) return DESCRIPTOR;
80-
return null;
78+
return DESCRIPTOR;
8179
}
8280
}

core/src/main/java/hudson/node_monitors/DiskSpaceMonitorDescriptor.java

-8
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@
2424
package hudson.node_monitors;
2525

2626
import hudson.FilePath.FileCallable;
27-
import hudson.model.Computer;
2827
import hudson.remoting.VirtualChannel;
2928
import hudson.Util;
3029
import hudson.slaves.OfflineCause;
3130
import hudson.node_monitors.DiskSpaceMonitorDescriptor.DiskSpace;
32-
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
3331

3432
import java.io.File;
3533
import java.io.IOException;
@@ -161,16 +159,10 @@ public static DiskSpace parse(String size) throws ParseException {
161159

162160
protected static final class GetUsableSpace implements FileCallable<DiskSpace> {
163161
public GetUsableSpace() {}
164-
@IgnoreJRERequirement
165162
public DiskSpace invoke(File f, VirtualChannel channel) throws IOException {
166-
try {
167163
long s = f.getUsableSpace();
168164
if(s<=0) return null;
169165
return new DiskSpace(f.getCanonicalPath(), s);
170-
} catch (LinkageError e) {
171-
// pre-mustang
172-
return null;
173-
}
174166
}
175167
private static final long serialVersionUID = 1L;
176168
}

core/src/main/java/hudson/node_monitors/TemporarySpaceMonitor.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@
2626
import hudson.Extension;
2727
import hudson.FilePath;
2828
import hudson.FilePath.FileCallable;
29-
import hudson.Functions;
3029
import hudson.model.Computer;
3130
import hudson.remoting.Callable;
3231
import jenkins.model.Jenkins;
3332
import hudson.node_monitors.DiskSpaceMonitorDescriptor.DiskSpace;
3433
import hudson.remoting.VirtualChannel;
35-
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
3634
import org.kohsuke.stapler.DataBoundConstructor;
3735

3836
import java.io.File;
@@ -78,24 +76,17 @@ protected Callable<DiskSpace,IOException> createCallable(Computer c) {
7876

7977
@Extension
8078
public static DiskSpaceMonitorDescriptor install() {
81-
if(Functions.isMustangOrAbove()) return DESCRIPTOR;
82-
return null;
79+
return DESCRIPTOR;
8380
}
8481

8582
protected static final class GetTempSpace implements FileCallable<DiskSpace> {
86-
@IgnoreJRERequirement
8783
public DiskSpace invoke(File f, VirtualChannel channel) throws IOException {
88-
try {
8984
// if the disk is really filled up we can't even create a single file,
9085
// so calling File.createTempFile and figuring out the directory won't reliably work.
9186
f = new File(System.getProperty("java.io.tmpdir"));
9287
long s = f.getUsableSpace();
9388
if(s<=0) return null;
9489
return new DiskSpace(f.getCanonicalPath(), s);
95-
} catch (LinkageError e) {
96-
// pre-mustang
97-
return null;
98-
}
9990
}
10091
private static final long serialVersionUID = 1L;
10192
}

core/src/main/java/hudson/security/AbstractPasswordBasedSecurityRealm.java

-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.acegisecurity.userdetails.UserDetails;
1616
import org.acegisecurity.userdetails.UserDetailsService;
1717
import org.acegisecurity.userdetails.UsernameNotFoundException;
18-
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
1918
import org.kohsuke.args4j.Option;
2019
import org.springframework.dao.DataAccessException;
2120
import org.springframework.web.context.WebApplicationContext;
@@ -141,7 +140,6 @@ protected UserDetails retrieveUser(String username, UsernamePasswordAuthenticati
141140
* Asks for the password.
142141
*/
143142
private static class InteractivelyAskForPassword implements Callable<String,IOException> {
144-
@IgnoreJRERequirement
145143
public String call() throws IOException {
146144
Console console = System.console();
147145
if (console == null) return null; // no terminal

core/src/main/java/hudson/tools/ZipExtractionInstaller.java

+1-15
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@
3030
import hudson.ProxyConfiguration;
3131
import hudson.Util;
3232
import hudson.Functions;
33-
import hudson.os.PosixAPI;
3433
import hudson.model.Node;
3534
import hudson.model.TaskListener;
3635
import hudson.remoting.VirtualChannel;
3736
import hudson.util.FormValidation;
38-
import hudson.util.jna.GNUCLibrary;
3937

4038
import java.io.File;
4139
import java.io.IOException;
@@ -45,7 +43,6 @@
4543
import java.net.URLConnection;
4644
import org.kohsuke.stapler.DataBoundConstructor;
4745
import org.kohsuke.stapler.QueryParameter;
48-
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
4946

5047
/**
5148
* Installs a tool into the Hudson working area by downloading and unpacking a ZIP file.
@@ -126,20 +123,9 @@ public Void invoke(File d, VirtualChannel channel) throws IOException {
126123
process(d);
127124
return null;
128125
}
129-
@IgnoreJRERequirement
130126
private void process(File f) {
131127
if (f.isFile()) {
132-
if(Functions.isMustangOrAbove())
133-
f.setExecutable(true, false);
134-
else {
135-
try {
136-
GNUCLibrary.LIBC.chmod(f.getAbsolutePath(),0755);
137-
} catch (LinkageError e) {
138-
// if JNA is unavailable, fall back.
139-
// we still prefer to try JNA first as PosixAPI supports even smaller platforms.
140-
PosixAPI.jnr().chmod(f.getAbsolutePath(),0755);
141-
}
142-
}
128+
f.setExecutable(true, false);
143129
} else {
144130
File[] kids = f.listFiles();
145131
if (kids != null) {

core/src/main/java/hudson/util/RemotingDiagnostics.java

-11
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,10 @@ public static Future<Map<String,String>> getThreadDumpAsync(VirtualChannel chann
9292
private static final class GetThreadDump implements Callable<Map<String,String>,RuntimeException> {
9393
public Map<String,String> call() {
9494
Map<String,String> r = new LinkedHashMap<String,String>();
95-
try {
9695
ThreadInfo[] data = Functions.getThreadInfos();
9796
Functions.ThreadGroupMap map = Functions.sortThreadsAndGetGroupMap(data);
9897
for (ThreadInfo ti : data)
9998
r.put(ti.getThreadName(),Functions.dumpThreadInfo(ti,map));
100-
} catch (LinkageError _) {
101-
// not in JDK6. fall back to JDK5
102-
r.clear();
103-
for (Map.Entry<Thread,StackTraceElement[]> t : Functions.dumpAllThreads().entrySet()) {
104-
StringBuilder buf = new StringBuilder();
105-
for (StackTraceElement e : t.getValue())
106-
buf.append(e).append('\n');
107-
r.put(t.getKey().getName(),buf.toString());
108-
}
109-
}
11099
return r;
111100
}
112101
private static final long serialVersionUID = 1L;

core/src/main/java/jenkins/PluginSubtypeMarker.java

-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
package jenkins;
2525

2626
import hudson.Plugin;
27-
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
2827
import org.kohsuke.MetaInfServices;
2928

3029
import javax.annotation.processing.AbstractProcessor;
@@ -58,7 +57,6 @@
5857
@SupportedSourceVersion(SourceVersion.RELEASE_6)
5958
@SupportedAnnotationTypes("*")
6059
@MetaInfServices(Processor.class)
61-
@IgnoreJRERequirement
6260
@SuppressWarnings({"Since15"})
6361
public class PluginSubtypeMarker extends AbstractProcessor {
6462
@Override

0 commit comments

Comments
 (0)