提交 7bb451c3 编写于 作者: J jjg

7068617: Core libraries don't build with javac -Xlint:all -Werror

Reviewed-by: darcy
Contributed-by: alexandre.boulgakov@oracle.com
上级 ea8ffd55
...@@ -32,6 +32,8 @@ BUILDDIR = ../.. ...@@ -32,6 +32,8 @@ BUILDDIR = ../..
PACKAGE = java.lang PACKAGE = java.lang
LIBRARY = java LIBRARY = java
PRODUCT = java PRODUCT = java
SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true
SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
# windows compiler flags # windows compiler flags
......
/* /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,4 +26,6 @@ ...@@ -26,4 +26,6 @@
package sun.reflect.generics.reflectiveObjects; package sun.reflect.generics.reflectiveObjects;
/** Temporary class used to indicate missing functionality */ /** Temporary class used to indicate missing functionality */
public class NotImplementedException extends RuntimeException {} public class NotImplementedException extends RuntimeException {
private static final long serialVersionUID = -9177857708926624790L;
}
/* /*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -32,13 +32,13 @@ public final class ConstructorUtil { ...@@ -32,13 +32,13 @@ public final class ConstructorUtil {
private ConstructorUtil() { private ConstructorUtil() {
} }
public static Constructor getConstructor(Class cls, Class[] params) public static Constructor<?> getConstructor(Class<?> cls, Class<?>[] params)
throws NoSuchMethodException { throws NoSuchMethodException {
ReflectUtil.checkPackageAccess(cls); ReflectUtil.checkPackageAccess(cls);
return cls.getConstructor(params); return cls.getConstructor(params);
} }
public static Constructor[] getConstructors(Class cls) { public static Constructor<?>[] getConstructors(Class<?> cls) {
ReflectUtil.checkPackageAccess(cls); ReflectUtil.checkPackageAccess(cls);
return cls.getConstructors(); return cls.getConstructors();
} }
......
/* /*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -35,18 +35,18 @@ public final class FieldUtil { ...@@ -35,18 +35,18 @@ public final class FieldUtil {
private FieldUtil() { private FieldUtil() {
} }
public static Field getField(Class cls, String name) public static Field getField(Class<?> cls, String name)
throws NoSuchFieldException { throws NoSuchFieldException {
ReflectUtil.checkPackageAccess(cls); ReflectUtil.checkPackageAccess(cls);
return cls.getField(name); return cls.getField(name);
} }
public static Field[] getFields(Class cls) { public static Field[] getFields(Class<?> cls) {
ReflectUtil.checkPackageAccess(cls); ReflectUtil.checkPackageAccess(cls);
return cls.getFields(); return cls.getFields();
} }
public static Field[] getDeclaredFields(Class cls) { public static Field[] getDeclaredFields(Class<?> cls) {
ReflectUtil.checkPackageAccess(cls); ReflectUtil.checkPackageAccess(cls);
return cls.getDeclaredFields(); return cls.getDeclaredFields();
} }
......
/* /*
* Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -36,17 +36,13 @@ import java.io.BufferedInputStream; ...@@ -36,17 +36,13 @@ import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.net.HttpURLConnection;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.AccessibleObject; import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import sun.misc.IOUtils; import sun.misc.IOUtils;
import sun.net.www.ParseUtil;
import sun.security.util.SecurityConstants;
class Trampoline { class Trampoline {
...@@ -68,13 +64,13 @@ public final class MethodUtil extends SecureClassLoader { ...@@ -68,13 +64,13 @@ public final class MethodUtil extends SecureClassLoader {
super(); super();
} }
public static Method getMethod(Class<?> cls, String name, Class[] args) public static Method getMethod(Class<?> cls, String name, Class<?>[] args)
throws NoSuchMethodException { throws NoSuchMethodException {
ReflectUtil.checkPackageAccess(cls); ReflectUtil.checkPackageAccess(cls);
return cls.getMethod(name, args); return cls.getMethod(name, args);
} }
public static Method[] getMethods(Class cls) { public static Method[] getMethods(Class<?> cls) {
ReflectUtil.checkPackageAccess(cls); ReflectUtil.checkPackageAccess(cls);
return cls.getMethods(); return cls.getMethods();
} }
...@@ -85,7 +81,7 @@ public final class MethodUtil extends SecureClassLoader { ...@@ -85,7 +81,7 @@ public final class MethodUtil extends SecureClassLoader {
* Class.getMethods() and walking towards Object until * Class.getMethods() and walking towards Object until
* we're done. * we're done.
*/ */
public static Method[] getPublicMethods(Class cls) { public static Method[] getPublicMethods(Class<?> cls) {
// compatibility for update release // compatibility for update release
if (System.getSecurityManager() == null) { if (System.getSecurityManager() == null) {
return cls.getMethods(); return cls.getMethods();
...@@ -105,11 +101,11 @@ public final class MethodUtil extends SecureClassLoader { ...@@ -105,11 +101,11 @@ public final class MethodUtil extends SecureClassLoader {
/* /*
* Process the immediate interfaces of this class or interface. * Process the immediate interfaces of this class or interface.
*/ */
private static void getInterfaceMethods(Class cls, private static void getInterfaceMethods(Class<?> cls,
Map<Signature, Method> sigs) { Map<Signature, Method> sigs) {
Class[] intfs = cls.getInterfaces(); Class<?>[] intfs = cls.getInterfaces();
for (int i=0; i < intfs.length; i++) { for (int i=0; i < intfs.length; i++) {
Class intf = intfs[i]; Class<?> intf = intfs[i];
boolean done = getInternalPublicMethods(intf, sigs); boolean done = getInternalPublicMethods(intf, sigs);
if (!done) { if (!done) {
getInterfaceMethods(intf, sigs); getInterfaceMethods(intf, sigs);
...@@ -121,7 +117,7 @@ public final class MethodUtil extends SecureClassLoader { ...@@ -121,7 +117,7 @@ public final class MethodUtil extends SecureClassLoader {
* *
* Process the methods in this class or interface * Process the methods in this class or interface
*/ */
private static boolean getInternalPublicMethods(Class cls, private static boolean getInternalPublicMethods(Class<?> cls,
Map<Signature, Method> sigs) { Map<Signature, Method> sigs) {
Method[] methods = null; Method[] methods = null;
try { try {
...@@ -150,7 +146,7 @@ public final class MethodUtil extends SecureClassLoader { ...@@ -150,7 +146,7 @@ public final class MethodUtil extends SecureClassLoader {
*/ */
boolean done = true; boolean done = true;
for (int i=0; i < methods.length; i++) { for (int i=0; i < methods.length; i++) {
Class dc = methods[i].getDeclaringClass(); Class<?> dc = methods[i].getDeclaringClass();
if (!Modifier.isPublic(dc.getModifiers())) { if (!Modifier.isPublic(dc.getModifiers())) {
done = false; done = false;
break; break;
...@@ -171,7 +167,7 @@ public final class MethodUtil extends SecureClassLoader { ...@@ -171,7 +167,7 @@ public final class MethodUtil extends SecureClassLoader {
* stripping away inherited methods. * stripping away inherited methods.
*/ */
for (int i=0; i < methods.length; i++) { for (int i=0; i < methods.length; i++) {
Class dc = methods[i].getDeclaringClass(); Class<?> dc = methods[i].getDeclaringClass();
if (cls.equals(dc)) { if (cls.equals(dc)) {
addMethod(sigs, methods[i]); addMethod(sigs, methods[i]);
} }
...@@ -301,12 +297,12 @@ public final class MethodUtil extends SecureClassLoader { ...@@ -301,12 +297,12 @@ public final class MethodUtil extends SecureClassLoader {
} }
protected synchronized Class loadClass(String name, boolean resolve) protected synchronized Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException throws ClassNotFoundException
{ {
// First, check if the class has already been loaded // First, check if the class has already been loaded
ReflectUtil.checkPackageAccess(name); ReflectUtil.checkPackageAccess(name);
Class c = findLoadedClass(name); Class<?> c = findLoadedClass(name);
if (c == null) { if (c == null) {
try { try {
c = findClass(name); c = findClass(name);
...@@ -324,7 +320,7 @@ public final class MethodUtil extends SecureClassLoader { ...@@ -324,7 +320,7 @@ public final class MethodUtil extends SecureClassLoader {
} }
protected Class findClass(final String name) protected Class<?> findClass(final String name)
throws ClassNotFoundException throws ClassNotFoundException
{ {
if (!name.startsWith(MISC_PKG)) { if (!name.startsWith(MISC_PKG)) {
...@@ -347,7 +343,7 @@ public final class MethodUtil extends SecureClassLoader { ...@@ -347,7 +343,7 @@ public final class MethodUtil extends SecureClassLoader {
/* /*
* Define the proxy classes * Define the proxy classes
*/ */
private Class defineClass(String name, URL url) throws IOException { private Class<?> defineClass(String name, URL url) throws IOException {
byte[] b = getBytes(url); byte[] b = getBytes(url);
CodeSource cs = new CodeSource(null, (java.security.cert.Certificate[])null); CodeSource cs = new CodeSource(null, (java.security.cert.Certificate[])null);
if (!name.equals(TRAMPOLINE)) { if (!name.equals(TRAMPOLINE)) {
...@@ -389,7 +385,7 @@ public final class MethodUtil extends SecureClassLoader { ...@@ -389,7 +385,7 @@ public final class MethodUtil extends SecureClassLoader {
return perms; return perms;
} }
private static Class getTrampolineClass() { private static Class<?> getTrampolineClass() {
try { try {
return Class.forName(TRAMPOLINE, true, new MethodUtil()); return Class.forName(TRAMPOLINE, true, new MethodUtil());
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
......
/* /*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -34,13 +34,13 @@ public final class ReflectUtil { ...@@ -34,13 +34,13 @@ public final class ReflectUtil {
private ReflectUtil() { private ReflectUtil() {
} }
public static Class forName(String name) public static Class<?> forName(String name)
throws ClassNotFoundException { throws ClassNotFoundException {
checkPackageAccess(name); checkPackageAccess(name);
return Class.forName(name); return Class.forName(name);
} }
public static Object newInstance(Class cls) public static Object newInstance(Class<?> cls)
throws InstantiationException, IllegalAccessException { throws InstantiationException, IllegalAccessException {
checkPackageAccess(cls); checkPackageAccess(cls);
return cls.newInstance(); return cls.newInstance();
...@@ -50,8 +50,8 @@ public final class ReflectUtil { ...@@ -50,8 +50,8 @@ public final class ReflectUtil {
* Reflection.ensureMemberAccess is overly-restrictive * Reflection.ensureMemberAccess is overly-restrictive
* due to a bug. We awkwardly work around it for now. * due to a bug. We awkwardly work around it for now.
*/ */
public static void ensureMemberAccess(Class currentClass, public static void ensureMemberAccess(Class<?> currentClass,
Class memberClass, Class<?> memberClass,
Object target, Object target,
int modifiers) int modifiers)
throws IllegalAccessException throws IllegalAccessException
...@@ -102,8 +102,8 @@ public final class ReflectUtil { ...@@ -102,8 +102,8 @@ public final class ReflectUtil {
} }
} }
private static boolean isSubclassOf(Class queryClass, private static boolean isSubclassOf(Class<?> queryClass,
Class ofClass) Class<?> ofClass)
{ {
while (queryClass != null) { while (queryClass != null) {
if (queryClass == ofClass) { if (queryClass == ofClass) {
...@@ -115,7 +115,7 @@ public final class ReflectUtil { ...@@ -115,7 +115,7 @@ public final class ReflectUtil {
} }
public static void checkPackageAccess(Class clazz) { public static void checkPackageAccess(Class<?> clazz) {
checkPackageAccess(clazz.getName()); checkPackageAccess(clazz.getName());
} }
...@@ -136,7 +136,7 @@ public final class ReflectUtil { ...@@ -136,7 +136,7 @@ public final class ReflectUtil {
} }
} }
public static boolean isPackageAccessible(Class clazz) { public static boolean isPackageAccessible(Class<?> clazz) {
try { try {
checkPackageAccess(clazz); checkPackageAccess(clazz);
} catch (SecurityException e) { } catch (SecurityException e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册