7092375: Security Libraries don't build with javac -Werror
Summary: Changes to security related java and make files to remove warnings
Reviewed-by: xuelei
Contributed-by: kurchi.subhra.hazra@oracle.com
--- a/jdk/make/java/security/Makefile Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/make/java/security/Makefile Wed Sep 28 15:10:02 2011 -0700
@@ -26,8 +26,8 @@
BUILDDIR = ../..
PACKAGE = java.security
PRODUCT = sun
-JAVAC_MAX_WARNINGS = false
-JAVAC_LINT_OPTIONS = -Xlint:all,-deprecation
+JAVAC_MAX_WARNINGS = true
+JAVAC_LINT_OPTIONS = -Xlint:all
JAVAC_WARNINGS_FATAL = true
include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/javax/Makefile Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/make/javax/Makefile Wed Sep 28 15:10:02 2011 -0700
@@ -30,7 +30,7 @@
BUILDDIR = ..
include $(BUILDDIR)/common/Defs.gmk
-SUBDIRS = others
+SUBDIRS = others security
SUBDIRS_management = management
--- a/jdk/make/javax/others/Makefile Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/make/javax/others/Makefile Wed Sep 28 15:10:02 2011 -0700
@@ -38,10 +38,6 @@
com/sun/naming/internal \
javax/net \
javax/script \
- javax/security/auth \
- javax/security/cert \
- javax/security/sasl \
- javax/smartcardio \
javax/tools \
javax/xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/javax/security/Makefile Wed Sep 28 15:10:02 2011 -0700
@@ -0,0 +1,49 @@
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#
+# Makefile for building javax (security classes)
+#
+
+BUILDDIR = ../..
+JAVAC_MAX_WARNINGS = true
+JAVAC_WARNINGS_FATAL = true
+
+include $(BUILDDIR)/common/Defs.gmk
+
+#
+# Files to compile
+#
+AUTO_FILES_JAVA_DIRS = \
+ javax/security/auth \
+ javax/security/cert \
+ javax/security/sasl \
+ javax/smartcardio
+
+#
+# Rules
+#
+include $(BUILDDIR)/common/Classes.gmk
+
--- a/jdk/make/org/ietf/jgss/Makefile Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/make/org/ietf/jgss/Makefile Wed Sep 28 15:10:02 2011 -0700
@@ -26,6 +26,8 @@
BUILDDIR = ../../..
PACKAGE = org.ietf.jgss
PRODUCT = sun
+JAVAC_MAX_WARNINGS = true
+JAVAC_WARNINGS_FATAL = true
include $(BUILDDIR)/common/Defs.gmk
#
--- a/jdk/make/sun/security/other/Makefile Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/make/sun/security/other/Makefile Wed Sep 28 15:10:02 2011 -0700
@@ -26,7 +26,7 @@
BUILDDIR = ../../..
PACKAGE = sun.security.other
PRODUCT = sun
-JAVAC_MAX_WARNINGS=false
+JAVAC_MAX_WARNINGS=true
JAVAC_LINT_OPTIONS=-Xlint:all,-deprecation
JAVAC_WARNINGS_FATAL=true
include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/src/share/classes/java/security/Signature.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/java/security/Signature.java Wed Sep 28 15:10:02 2011 -0700
@@ -899,6 +899,7 @@
* and its original parent (Object).
*/
+ @SuppressWarnings("deprecation")
private static class Delegate extends Signature {
// The provider implementation (delegate)
@@ -1203,6 +1204,7 @@
}
// adapter for RSA/ECB/PKCS1Padding ciphers
+ @SuppressWarnings("deprecation")
private static class CipherAdapter extends SignatureSpi {
private final Cipher cipher;
--- a/jdk/src/share/classes/javax/security/auth/PrivateCredentialPermission.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/javax/security/auth/PrivateCredentialPermission.java Wed Sep 28 15:10:02 2011 -0700
@@ -117,7 +117,7 @@
* The set contains elements of type,
* <code>PrivateCredentialPermission.CredOwner</code>.
*/
- private Set principals; // ignored - kept around for compatibility
+ private Set<Principal> principals; // ignored - kept around for compatibility
private transient CredOwner[] credOwners;
/**
--- a/jdk/src/share/classes/javax/security/auth/Subject.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/javax/security/auth/Subject.java Wed Sep 28 15:10:02 2011 -0700
@@ -1291,6 +1291,7 @@
oos.writeFields();
}
+ @SuppressWarnings("unchecked")
private void readObject(ObjectInputStream ois)
throws IOException, ClassNotFoundException
{
@@ -1329,6 +1330,7 @@
}
}
+ @SuppressWarnings("unchecked") /*To suppress warning from line 1374*/
private void populateSet() {
final Iterator<?> iterator;
switch(which) {
--- a/jdk/src/share/classes/javax/security/auth/SubjectDomainCombiner.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/javax/security/auth/SubjectDomainCombiner.java Wed Sep 28 15:10:02 2011 -0700
@@ -56,6 +56,7 @@
sun.security.util.Debug.getInstance("combiner",
"\t[SubjectDomainCombiner]");
+ @SuppressWarnings("deprecation")
// Note: check only at classloading time, not dynamically during combine()
private static final boolean useJavaxPolicy =
javax.security.auth.Policy.isCustomPolicySet(debug);
@@ -300,6 +301,7 @@
if (!allowCaching) {
java.security.AccessController.doPrivileged
(new PrivilegedAction<Void>() {
+ @SuppressWarnings("deprecation")
public Void run() {
// Call refresh only caching is disallowed
javax.security.auth.Policy.getPolicy().refresh();
@@ -308,6 +310,7 @@
});
}
+
int cLen = (currentDomains == null ? 0 : currentDomains.length);
int aLen = (assignedDomains == null ? 0 : assignedDomains.length);
@@ -348,13 +351,13 @@
// get the original perms
Permissions perms = new Permissions();
PermissionCollection coll = pd.getPermissions();
- java.util.Enumeration e;
+ java.util.Enumeration<Permission> e;
if (coll != null) {
synchronized (coll) {
e = coll.elements();
while (e.hasMoreElements()) {
Permission newPerm =
- (Permission)e.nextElement();
+ e.nextElement();
perms.add(newPerm);
}
}
@@ -367,6 +370,7 @@
PermissionCollection newPerms =
java.security.AccessController.doPrivileged
(new PrivilegedAction<PermissionCollection>() {
+ @SuppressWarnings("deprecation")
public PermissionCollection run() {
return
javax.security.auth.Policy.getPolicy().getPermissions
@@ -379,7 +383,7 @@
synchronized (newPerms) {
e = newPerms.elements();
while (e.hasMoreElements()) {
- Permission newPerm = (Permission)e.nextElement();
+ Permission newPerm = e.nextElement();
if (!perms.implies(newPerm)) {
perms.add(newPerm);
if (debug != null)
--- a/jdk/src/share/classes/javax/security/auth/kerberos/DelegationPermission.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/javax/security/auth/kerberos/DelegationPermission.java Wed Sep 28 15:10:02 2011 -0700
@@ -375,6 +375,7 @@
/*
* Reads in a Vector of DelegationPermissions and saves them in the perms field.
*/
+ @SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
// Don't call defaultReadObject()
--- a/jdk/src/share/classes/javax/security/auth/kerberos/ServicePermission.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/javax/security/auth/kerberos/ServicePermission.java Wed Sep 28 15:10:02 2011 -0700
@@ -583,6 +583,7 @@
/*
* Reads in a Vector of ServicePermissions and saves them in the perms field.
*/
+ @SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
// Don't call defaultReadObject()
--- a/jdk/src/share/classes/javax/security/auth/login/LoginContext.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/javax/security/auth/login/LoginContext.java Wed Sep 28 15:10:02 2011 -0700
@@ -214,14 +214,14 @@
private boolean subjectProvided = false;
private boolean loginSucceeded = false;
private CallbackHandler callbackHandler;
- private Map state = new HashMap();
+ private Map<String,?> state = new HashMap<String,Object>();
private Configuration config;
private boolean configProvided = false;
private AccessControlContext creatorAcc = null;
private ModuleInfo[] moduleStack;
private ClassLoader contextClassLoader = null;
- private static final Class[] PARAMS = { };
+ private static final Class<?>[] PARAMS = { };
// state saved in the event a user-specified asynchronous exception
// was specified and thrown
@@ -306,7 +306,7 @@
(DEFAULT_HANDLER);
if (defaultHandler == null || defaultHandler.length() == 0)
return null;
- Class c = Class.forName(defaultHandler,
+ Class<?> c = Class.forName(defaultHandler,
true,
finalLoader);
return (CallbackHandler)c.newInstance();
@@ -743,12 +743,12 @@
} else {
// instantiate the LoginModule
- Class c = Class.forName
+ Class<?> c = Class.forName
(moduleStack[i].entry.getLoginModuleName(),
true,
contextClassLoader);
- Constructor constructor = c.getConstructor(PARAMS);
+ Constructor<?> constructor = c.getConstructor(PARAMS);
Object[] args = { };
// allow any object to be a LoginModule
--- a/jdk/src/share/classes/javax/security/auth/x500/X500Principal.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/javax/security/auth/x500/X500Principal.java Wed Sep 28 15:10:02 2011 -0700
@@ -118,7 +118,7 @@
* is improperly specified
*/
public X500Principal(String name) {
- this(name, (Map<String, String>) Collections.EMPTY_MAP);
+ this(name, Collections.<String, String>emptyMap());
}
/**
--- a/jdk/src/share/classes/javax/security/cert/CertificateEncodingException.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/javax/security/cert/CertificateEncodingException.java Wed Sep 28 15:10:02 2011 -0700
@@ -41,6 +41,7 @@
*/
public class CertificateEncodingException extends CertificateException {
+ private static final long serialVersionUID = -8187642723048403470L;
/**
* Constructs a CertificateEncodingException with no detail message. A
* detail message is a String that describes this particular
--- a/jdk/src/share/classes/javax/security/cert/CertificateException.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/javax/security/cert/CertificateException.java Wed Sep 28 15:10:02 2011 -0700
@@ -41,6 +41,7 @@
*/
public class CertificateException extends Exception {
+ private static final long serialVersionUID = -5757213374030785290L;
/**
* Constructs a certificate exception with no detail message. A detail
* message is a String that describes this particular exception.
--- a/jdk/src/share/classes/javax/security/cert/CertificateExpiredException.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/javax/security/cert/CertificateExpiredException.java Wed Sep 28 15:10:02 2011 -0700
@@ -43,6 +43,7 @@
*/
public class CertificateExpiredException extends CertificateException {
+ private static final long serialVersionUID = 5091601212177261883L;
/**
* Constructs a CertificateExpiredException with no detail message. A
* detail message is a String that describes this particular
--- a/jdk/src/share/classes/javax/security/cert/CertificateNotYetValidException.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/javax/security/cert/CertificateNotYetValidException.java Wed Sep 28 15:10:02 2011 -0700
@@ -43,6 +43,7 @@
*/
public class CertificateNotYetValidException extends CertificateException {
+ private static final long serialVersionUID = -8976172474266822818L;
/**
* Constructs a CertificateNotYetValidException with no detail message. A
* detail message is a String that describes this particular
--- a/jdk/src/share/classes/javax/security/cert/CertificateParsingException.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/javax/security/cert/CertificateParsingException.java Wed Sep 28 15:10:02 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,8 @@
*/
public class CertificateParsingException extends CertificateException {
+ private static final long serialVersionUID = -8449352422951136229L;
+
/**
* Constructs a CertificateParsingException with no detail message. A
* detail message is a String that describes this particular
--- a/jdk/src/share/classes/javax/security/cert/X509Certificate.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/javax/security/cert/X509Certificate.java Wed Sep 28 15:10:02 2011 -0700
@@ -219,11 +219,11 @@
className = "com.sun.security.cert.internal.x509.X509V1CertImpl";
}
try {
- Class[] params = null;
+ Class<?>[] params = null;
if (value instanceof InputStream) {
- params = new Class[] { InputStream.class };
+ params = new Class<?>[] { InputStream.class };
} else if (value instanceof byte[]) {
- params = new Class[] { value.getClass() };
+ params = new Class<?>[] { value.getClass() };
} else
throw new CertificateException("Unsupported argument type");
Class<?> certClass = Class.forName(className);
--- a/jdk/src/share/classes/javax/security/sasl/Sasl.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/javax/security/sasl/Sasl.java Wed Sep 28 15:10:02 2011 -0700
@@ -395,7 +395,7 @@
* will be thrown.
*/
ClassLoader cl = p.getClass().getClassLoader();
- Class implClass;
+ Class<?> implClass;
implClass = Class.forName(className, true, cl);
return implClass.newInstance();
} catch (ClassNotFoundException e) {
@@ -576,7 +576,7 @@
classes.clear();
// Check the keys for each provider.
- for (Enumeration e = providers[i].keys(); e.hasMoreElements(); ) {
+ for (Enumeration<Object> e = providers[i].keys(); e.hasMoreElements(); ) {
String currentKey = (String)e.nextElement();
if (currentKey.startsWith(serviceName)) {
// We should skip the currentKey if it contains a
--- a/jdk/src/share/classes/javax/smartcardio/TerminalFactory.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/javax/smartcardio/TerminalFactory.java Wed Sep 28 15:10:02 2011 -0700
@@ -113,7 +113,7 @@
type = "PC/SC";
Provider sun = Security.getProvider("SunPCSC");
if (sun == null) {
- Class clazz = Class.forName("sun.security.smartcardio.SunPCSC");
+ Class<?> clazz = Class.forName("sun.security.smartcardio.SunPCSC");
sun = (Provider)clazz.newInstance();
}
factory = TerminalFactory.getInstance(type, null, sun);
@@ -131,6 +131,8 @@
}
private static final class NoneProvider extends Provider {
+
+ private static final long serialVersionUID = 2745808869881593918L;
final static Provider INSTANCE = new NoneProvider();
private NoneProvider() {
super("None", 1.0d, "none");
--- a/jdk/src/share/classes/sun/security/ec/ECPublicKeyImpl.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/sun/security/ec/ECPublicKeyImpl.java Wed Sep 28 15:10:02 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -51,6 +51,7 @@
* Construct a key from its components. Used by the
* ECKeyFactory and SunPKCS11.
*/
+ @SuppressWarnings("deprecation")
public ECPublicKeyImpl(ECPoint w, ECParameterSpec params)
throws InvalidKeyException {
this.w = w;
@@ -85,6 +86,7 @@
// Internal API to get the encoded point. Currently used by SunPKCS11.
// This may change/go away depending on what we do with the public API.
+ @SuppressWarnings("deprecation")
public byte[] getEncodedPublicValue() {
return key.clone();
}
@@ -92,6 +94,7 @@
/**
* Parse the key. Called by X509Key.
*/
+ @SuppressWarnings("deprecation")
protected void parseKeyBits() throws InvalidKeyException {
try {
AlgorithmParameters algParams = this.algid.getParameters();
--- a/jdk/src/share/classes/sun/security/validator/PKIXValidator.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/sun/security/validator/PKIXValidator.java Wed Sep 28 15:10:02 2011 -0700
@@ -327,6 +327,7 @@
* Set the check date (for debugging).
*/
private void setDate(PKIXBuilderParameters params) {
+ @SuppressWarnings("deprecation")
Date date = validationDate;
if (date != null) {
params.setDate(date);
--- a/jdk/src/share/classes/sun/security/validator/SimpleValidator.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/sun/security/validator/SimpleValidator.java Wed Sep 28 15:10:02 2011 -0700
@@ -131,6 +131,7 @@
// make sure chain includes a trusted cert
chain = buildTrustedChain(chain);
+ @SuppressWarnings("deprecation")
Date date = validationDate;
if (date == null) {
date = new Date();
--- a/jdk/src/share/classes/sun/security/x509/X509CertImpl.java Tue Oct 11 12:06:46 2011 +0100
+++ b/jdk/src/share/classes/sun/security/x509/X509CertImpl.java Wed Sep 28 15:10:02 2011 -0700
@@ -1323,7 +1323,7 @@
for (Extension ex : exts.getAllExtensions()) {
ObjectIdentifier inCertOID = ex.getExtensionId();
- if (inCertOID.equals(findOID)) {
+ if (inCertOID.equals((Object)findOID)) {
certExt = ex;
break;
}