提交 808a9fe5 编写于 作者: S smarks
上级 041e7d14
...@@ -183,7 +183,7 @@ class JarFile extends ZipFile { ...@@ -183,7 +183,7 @@ class JarFile extends ZipFile {
} else { } else {
man = new Manifest(super.getInputStream(manEntry)); man = new Manifest(super.getInputStream(manEntry));
} }
manRef = new SoftReference(man); manRef = new SoftReference<>(man);
} }
} }
return man; return man;
...@@ -233,13 +233,13 @@ class JarFile extends ZipFile { ...@@ -233,13 +233,13 @@ class JarFile extends ZipFile {
* Returns an enumeration of the zip file entries. * Returns an enumeration of the zip file entries.
*/ */
public Enumeration<JarEntry> entries() { public Enumeration<JarEntry> entries() {
final Enumeration enum_ = super.entries(); final Enumeration<? extends ZipEntry> enum_ = super.entries();
return new Enumeration<JarEntry>() { return new Enumeration<JarEntry>() {
public boolean hasMoreElements() { public boolean hasMoreElements() {
return enum_.hasMoreElements(); return enum_.hasMoreElements();
} }
public JarFileEntry nextElement() { public JarFileEntry nextElement() {
ZipEntry ze = (ZipEntry)enum_.nextElement(); ZipEntry ze = enum_.nextElement();
return new JarFileEntry(ze); return new JarFileEntry(ze);
} }
}; };
...@@ -608,7 +608,7 @@ class JarFile extends ZipFile { ...@@ -608,7 +608,7 @@ class JarFile extends ZipFile {
} }
// screen out entries which are never signed // screen out entries which are never signed
final Enumeration enum_ = super.entries(); final Enumeration<? extends ZipEntry> enum_ = super.entries();
return new Enumeration<JarEntry>() { return new Enumeration<JarEntry>() {
ZipEntry entry; ZipEntry entry;
...@@ -618,7 +618,7 @@ class JarFile extends ZipFile { ...@@ -618,7 +618,7 @@ class JarFile extends ZipFile {
return true; return true;
} }
while (enum_.hasMoreElements()) { while (enum_.hasMoreElements()) {
ZipEntry ze = (ZipEntry) enum_.nextElement(); ZipEntry ze = enum_.nextElement();
if (JarVerifier.isSigningRelated(ze.getName())) { if (JarVerifier.isSigningRelated(ze.getName())) {
continue; continue;
} }
...@@ -649,7 +649,7 @@ class JarFile extends ZipFile { ...@@ -649,7 +649,7 @@ class JarFile extends ZipFile {
* JAR file has no signed content. Is there a non-signing * JAR file has no signed content. Is there a non-signing
* code source? * code source?
*/ */
Enumeration unsigned = unsignedEntryNames(); Enumeration<String> unsigned = unsignedEntryNames();
if (unsigned.hasMoreElements()) { if (unsigned.hasMoreElements()) {
return new CodeSource[]{JarVerifier.getUnsignedCS(url)}; return new CodeSource[]{JarVerifier.getUnsignedCS(url)};
} else { } else {
...@@ -658,7 +658,7 @@ class JarFile extends ZipFile { ...@@ -658,7 +658,7 @@ class JarFile extends ZipFile {
} }
private Enumeration<String> unsignedEntryNames() { private Enumeration<String> unsignedEntryNames() {
final Enumeration entries = entries(); final Enumeration<JarEntry> entries = entries();
return new Enumeration<String>() { return new Enumeration<String>() {
String name; String name;
...@@ -673,7 +673,7 @@ class JarFile extends ZipFile { ...@@ -673,7 +673,7 @@ class JarFile extends ZipFile {
} }
while (entries.hasMoreElements()) { while (entries.hasMoreElements()) {
String value; String value;
ZipEntry e = (ZipEntry) entries.nextElement(); ZipEntry e = entries.nextElement();
value = e.getName(); value = e.getName();
if (e.isDirectory() || JarVerifier.isSigningRelated(value)) { if (e.isDirectory() || JarVerifier.isSigningRelated(value)) {
continue; continue;
...@@ -726,11 +726,11 @@ class JarFile extends ZipFile { ...@@ -726,11 +726,11 @@ class JarFile extends ZipFile {
} }
} }
List getManifestDigests() { List<Object> getManifestDigests() {
ensureInitialization(); ensureInitialization();
if (jv != null) { if (jv != null) {
return jv.getManifestDigests(); return jv.getManifestDigests();
} }
return new ArrayList(); return new ArrayList<Object>();
} }
} }
...@@ -51,7 +51,7 @@ public class Manifest implements Cloneable { ...@@ -51,7 +51,7 @@ public class Manifest implements Cloneable {
private Attributes attr = new Attributes(); private Attributes attr = new Attributes();
// manifest entries // manifest entries
private Map entries = new HashMap(); private Map<String, Attributes> entries = new HashMap<>();
/** /**
* Constructs a new, empty Manifest. * Constructs a new, empty Manifest.
...@@ -148,11 +148,11 @@ public class Manifest implements Cloneable { ...@@ -148,11 +148,11 @@ public class Manifest implements Cloneable {
// Write out the main attributes for the manifest // Write out the main attributes for the manifest
attr.writeMain(dos); attr.writeMain(dos);
// Now write out the pre-entry attributes // Now write out the pre-entry attributes
Iterator it = entries.entrySet().iterator(); Iterator<Map.Entry<String, Attributes>> it = entries.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry e = (Map.Entry)it.next(); Map.Entry<String, Attributes> e = it.next();
StringBuffer buffer = new StringBuffer("Name: "); StringBuffer buffer = new StringBuffer("Name: ");
String value = (String)e.getKey(); String value = e.getKey();
if (value != null) { if (value != null) {
byte[] vb = value.getBytes("UTF8"); byte[] vb = value.getBytes("UTF8");
value = new String(vb, 0, 0, vb.length); value = new String(vb, 0, 0, vb.length);
...@@ -161,7 +161,7 @@ public class Manifest implements Cloneable { ...@@ -161,7 +161,7 @@ public class Manifest implements Cloneable {
buffer.append("\r\n"); buffer.append("\r\n");
make72Safe(buffer); make72Safe(buffer);
dos.writeBytes(buffer.toString()); dos.writeBytes(buffer.toString());
((Attributes)e.getValue()).write(dos); e.getValue().write(dos);
} }
dos.flush(); dos.flush();
} }
......
...@@ -179,10 +179,10 @@ public class LogManager { ...@@ -179,10 +179,10 @@ public class LogManager {
cname = System.getProperty("java.util.logging.manager"); cname = System.getProperty("java.util.logging.manager");
if (cname != null) { if (cname != null) {
try { try {
Class clz = ClassLoader.getSystemClassLoader().loadClass(cname); Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(cname);
manager = (LogManager) clz.newInstance(); manager = (LogManager) clz.newInstance();
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
Class clz = Thread.currentThread().getContextClassLoader().loadClass(cname); Class<?> clz = Thread.currentThread().getContextClassLoader().loadClass(cname);
manager = (LogManager) clz.newInstance(); manager = (LogManager) clz.newInstance();
} }
} }
...@@ -200,8 +200,8 @@ public class LogManager { ...@@ -200,8 +200,8 @@ public class LogManager {
// Adding the global Logger. Doing so in the Logger.<clinit> // Adding the global Logger. Doing so in the Logger.<clinit>
// would deadlock with the LogManager.<clinit>. // would deadlock with the LogManager.<clinit>.
Logger.global.setLogManager(manager); Logger.getGlobal().setLogManager(manager);
manager.addLogger(Logger.global); manager.addLogger(Logger.getGlobal());
// We don't call readConfiguration() here, as we may be running // We don't call readConfiguration() here, as we may be running
// very early in the JVM startup sequence. Instead readConfiguration // very early in the JVM startup sequence. Instead readConfiguration
...@@ -415,8 +415,8 @@ public class LogManager { ...@@ -415,8 +415,8 @@ public class LogManager {
for (int i = 0; i < names.length; i++) { for (int i = 0; i < names.length; i++) {
String word = names[i]; String word = names[i];
try { try {
Class clz = ClassLoader.getSystemClassLoader().loadClass(word); Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(word);
Handler hdl = (Handler) clz.newInstance(); Handler hdl = (Handler) clz.newInstance();
try { try {
// Check if there is a property defining the // Check if there is a property defining the
// this handler's level. // this handler's level.
...@@ -782,11 +782,11 @@ public class LogManager { ...@@ -782,11 +782,11 @@ public class LogManager {
// responsibility to initialize the logging configuration, by // responsibility to initialize the logging configuration, by
// calling readConfiguration(InputStream) with a suitable stream. // calling readConfiguration(InputStream) with a suitable stream.
try { try {
Class clz = ClassLoader.getSystemClassLoader().loadClass(cname); Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(cname);
clz.newInstance(); clz.newInstance();
return; return;
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
Class clz = Thread.currentThread().getContextClassLoader().loadClass(cname); Class<?> clz = Thread.currentThread().getContextClassLoader().loadClass(cname);
clz.newInstance(); clz.newInstance();
return; return;
} }
...@@ -837,9 +837,9 @@ public class LogManager { ...@@ -837,9 +837,9 @@ public class LogManager {
// the global handlers, if they haven't been initialized yet. // the global handlers, if they haven't been initialized yet.
initializedGlobalHandlers = true; initializedGlobalHandlers = true;
} }
Enumeration enum_ = getLoggerNames(); Enumeration<String> enum_ = getLoggerNames();
while (enum_.hasMoreElements()) { while (enum_.hasMoreElements()) {
String name = (String)enum_.nextElement(); String name = enum_.nextElement();
resetLogger(name); resetLogger(name);
} }
} }
...@@ -926,7 +926,7 @@ public class LogManager { ...@@ -926,7 +926,7 @@ public class LogManager {
for (int i = 0; i < names.length; i++) { for (int i = 0; i < names.length; i++) {
String word = names[i]; String word = names[i];
try { try {
Class clz = ClassLoader.getSystemClassLoader().loadClass(word); Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(word);
clz.newInstance(); clz.newInstance();
} catch (Exception ex) { } catch (Exception ex) {
System.err.println("Can't load config class \"" + word + "\""); System.err.println("Can't load config class \"" + word + "\"");
...@@ -1024,7 +1024,7 @@ public class LogManager { ...@@ -1024,7 +1024,7 @@ public class LogManager {
String val = getProperty(name); String val = getProperty(name);
try { try {
if (val != null) { if (val != null) {
Class clz = ClassLoader.getSystemClassLoader().loadClass(val); Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(val);
return (Filter) clz.newInstance(); return (Filter) clz.newInstance();
} }
} catch (Exception ex) { } catch (Exception ex) {
...@@ -1045,7 +1045,7 @@ public class LogManager { ...@@ -1045,7 +1045,7 @@ public class LogManager {
String val = getProperty(name); String val = getProperty(name);
try { try {
if (val != null) { if (val != null) {
Class clz = ClassLoader.getSystemClassLoader().loadClass(val); Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(val);
return (Formatter) clz.newInstance(); return (Formatter) clz.newInstance();
} }
} catch (Exception ex) { } catch (Exception ex) {
...@@ -1163,7 +1163,7 @@ public class LogManager { ...@@ -1163,7 +1163,7 @@ public class LogManager {
// Private method to be called when the configuration has // Private method to be called when the configuration has
// changed to apply any level settings to any pre-existing loggers. // changed to apply any level settings to any pre-existing loggers.
synchronized private void setLevelsOnExistingLoggers() { synchronized private void setLevelsOnExistingLoggers() {
Enumeration enum_ = props.propertyNames(); Enumeration<?> enum_ = props.propertyNames();
while (enum_.hasMoreElements()) { while (enum_.hasMoreElements()) {
String key = (String)enum_.nextElement(); String key = (String)enum_.nextElement();
if (!key.endsWith(".level")) { if (!key.endsWith(".level")) {
......
...@@ -413,7 +413,7 @@ public abstract class Preferences { ...@@ -413,7 +413,7 @@ public abstract class Preferences {
* @throws IllegalArgumentException if the package has node preferences * @throws IllegalArgumentException if the package has node preferences
* node associated with it. * node associated with it.
*/ */
private static String nodeName(Class c) { private static String nodeName(Class<?> c) {
if (c.isArray()) if (c.isArray())
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Arrays have no associated preferences node."); "Arrays have no associated preferences node.");
......
...@@ -106,7 +106,7 @@ class XmlSupport { ...@@ -106,7 +106,7 @@ class XmlSupport {
xmlRoot.setAttribute("type", (p.isUserNode() ? "user" : "system")); xmlRoot.setAttribute("type", (p.isUserNode() ? "user" : "system"));
// Get bottom-up list of nodes from p to root, excluding root // Get bottom-up list of nodes from p to root, excluding root
List ancestors = new ArrayList(); List<Preferences> ancestors = new ArrayList<>();
for (Preferences kid = p, dad = kid.parent(); dad != null; for (Preferences kid = p, dad = kid.parent(); dad != null;
kid = dad, dad = kid.parent()) { kid = dad, dad = kid.parent()) {
...@@ -116,7 +116,7 @@ class XmlSupport { ...@@ -116,7 +116,7 @@ class XmlSupport {
for (int i=ancestors.size()-1; i >= 0; i--) { for (int i=ancestors.size()-1; i >= 0; i--) {
e.appendChild(doc.createElement("map")); e.appendChild(doc.createElement("map"));
e = (Element) e.appendChild(doc.createElement("node")); e = (Element) e.appendChild(doc.createElement("node"));
e.setAttribute("name", ((Preferences)ancestors.get(i)).name()); e.setAttribute("name", ancestors.get(i).name());
} }
putPreferencesInXml(e, doc, p, subTree); putPreferencesInXml(e, doc, p, subTree);
...@@ -339,17 +339,17 @@ class XmlSupport { ...@@ -339,17 +339,17 @@ class XmlSupport {
* @throws IOException if writing to the specified output stream * @throws IOException if writing to the specified output stream
* results in an <tt>IOException</tt>. * results in an <tt>IOException</tt>.
*/ */
static void exportMap(OutputStream os, Map map) throws IOException { static void exportMap(OutputStream os, Map<String, String> map) throws IOException {
Document doc = createPrefsDoc("map"); Document doc = createPrefsDoc("map");
Element xmlMap = doc.getDocumentElement( ) ; Element xmlMap = doc.getDocumentElement( ) ;
xmlMap.setAttribute("MAP_XML_VERSION", MAP_XML_VERSION); xmlMap.setAttribute("MAP_XML_VERSION", MAP_XML_VERSION);
for (Iterator i = map.entrySet().iterator(); i.hasNext(); ) { for (Iterator<Map.Entry<String, String>> i = map.entrySet().iterator(); i.hasNext(); ) {
Map.Entry e = (Map.Entry) i.next(); Map.Entry<String, String> e = i.next();
Element xe = (Element) Element xe = (Element)
xmlMap.appendChild(doc.createElement("entry")); xmlMap.appendChild(doc.createElement("entry"));
xe.setAttribute("key", (String) e.getKey()); xe.setAttribute("key", e.getKey());
xe.setAttribute("value", (String) e.getValue()); xe.setAttribute("value", e.getValue());
} }
writeDoc(doc, os); writeDoc(doc, os);
...@@ -368,7 +368,7 @@ class XmlSupport { ...@@ -368,7 +368,7 @@ class XmlSupport {
* @throws InvalidPreferencesFormatException Data on input stream does not * @throws InvalidPreferencesFormatException Data on input stream does not
* constitute a valid XML document with the mandated document type. * constitute a valid XML document with the mandated document type.
*/ */
static void importMap(InputStream is, Map m) static void importMap(InputStream is, Map<String, String> m)
throws IOException, InvalidPreferencesFormatException throws IOException, InvalidPreferencesFormatException
{ {
try { try {
......
...@@ -281,6 +281,7 @@ class ZipEntry implements ZipConstants, Cloneable { ...@@ -281,6 +281,7 @@ class ZipEntry implements ZipConstants, Cloneable {
* Converts DOS time to Java time (number of milliseconds since epoch). * Converts DOS time to Java time (number of milliseconds since epoch).
*/ */
private static long dosToJavaTime(long dtime) { private static long dosToJavaTime(long dtime) {
@SuppressWarnings("deprecation") // Use of date constructor.
Date d = new Date((int)(((dtime >> 25) & 0x7f) + 80), Date d = new Date((int)(((dtime >> 25) & 0x7f) + 80),
(int)(((dtime >> 21) & 0x0f) - 1), (int)(((dtime >> 21) & 0x0f) - 1),
(int)((dtime >> 16) & 0x1f), (int)((dtime >> 16) & 0x1f),
...@@ -293,6 +294,7 @@ class ZipEntry implements ZipConstants, Cloneable { ...@@ -293,6 +294,7 @@ class ZipEntry implements ZipConstants, Cloneable {
/* /*
* Converts Java time to DOS time. * Converts Java time to DOS time.
*/ */
@SuppressWarnings("deprecation") // Use of date methods
private static long javaToDosTime(long time) { private static long javaToDosTime(long time) {
Date d = new Date(time); Date d = new Date(time);
int year = d.getYear() + 1900; int year = d.getYear() + 1900;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册