提交 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 = ../..
PACKAGE = java.lang
LIBRARY = java
PRODUCT = java
SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true
SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
include $(BUILDDIR)/common/Defs.gmk
# 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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -26,4 +26,6 @@
package sun.reflect.generics.reflectiveObjects;
/** 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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -32,13 +32,13 @@ public final class ConstructorUtil {
private ConstructorUtil() {
}
public static Constructor getConstructor(Class cls, Class[] params)
public static Constructor<?> getConstructor(Class<?> cls, Class<?>[] params)
throws NoSuchMethodException {
ReflectUtil.checkPackageAccess(cls);
return cls.getConstructor(params);
}
public static Constructor[] getConstructors(Class cls) {
public static Constructor<?>[] getConstructors(Class<?> cls) {
ReflectUtil.checkPackageAccess(cls);
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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -35,18 +35,18 @@ public final class FieldUtil {
private FieldUtil() {
}
public static Field getField(Class cls, String name)
public static Field getField(Class<?> cls, String name)
throws NoSuchFieldException {
ReflectUtil.checkPackageAccess(cls);
return cls.getField(name);
}
public static Field[] getFields(Class cls) {
public static Field[] getFields(Class<?> cls) {
ReflectUtil.checkPackageAccess(cls);
return cls.getFields();
}
public static Field[] getDeclaredFields(Class cls) {
public static Field[] getDeclaredFields(Class<?> cls) {
ReflectUtil.checkPackageAccess(cls);
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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -36,17 +36,13 @@ import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.net.HttpURLConnection;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import sun.misc.IOUtils;
import sun.net.www.ParseUtil;
import sun.security.util.SecurityConstants;
class Trampoline {
......@@ -68,13 +64,13 @@ public final class MethodUtil extends SecureClassLoader {
super();
}
public static Method getMethod(Class<?> cls, String name, Class[] args)
public static Method getMethod(Class<?> cls, String name, Class<?>[] args)
throws NoSuchMethodException {
ReflectUtil.checkPackageAccess(cls);
return cls.getMethod(name, args);
}
public static Method[] getMethods(Class cls) {
public static Method[] getMethods(Class<?> cls) {
ReflectUtil.checkPackageAccess(cls);
return cls.getMethods();
}
......@@ -85,7 +81,7 @@ public final class MethodUtil extends SecureClassLoader {
* Class.getMethods() and walking towards Object until
* we're done.
*/
public static Method[] getPublicMethods(Class cls) {
public static Method[] getPublicMethods(Class<?> cls) {
// compatibility for update release
if (System.getSecurityManager() == null) {
return cls.getMethods();
......@@ -105,11 +101,11 @@ public final class MethodUtil extends SecureClassLoader {
/*
* 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) {
Class[] intfs = cls.getInterfaces();
Class<?>[] intfs = cls.getInterfaces();
for (int i=0; i < intfs.length; i++) {
Class intf = intfs[i];
Class<?> intf = intfs[i];
boolean done = getInternalPublicMethods(intf, sigs);
if (!done) {
getInterfaceMethods(intf, sigs);
......@@ -121,7 +117,7 @@ public final class MethodUtil extends SecureClassLoader {
*
* Process the methods in this class or interface
*/
private static boolean getInternalPublicMethods(Class cls,
private static boolean getInternalPublicMethods(Class<?> cls,
Map<Signature, Method> sigs) {
Method[] methods = null;
try {
......@@ -150,7 +146,7 @@ public final class MethodUtil extends SecureClassLoader {
*/
boolean done = true;
for (int i=0; i < methods.length; i++) {
Class dc = methods[i].getDeclaringClass();
Class<?> dc = methods[i].getDeclaringClass();
if (!Modifier.isPublic(dc.getModifiers())) {
done = false;
break;
......@@ -171,7 +167,7 @@ public final class MethodUtil extends SecureClassLoader {
* stripping away inherited methods.
*/
for (int i=0; i < methods.length; i++) {
Class dc = methods[i].getDeclaringClass();
Class<?> dc = methods[i].getDeclaringClass();
if (cls.equals(dc)) {
addMethod(sigs, methods[i]);
}
......@@ -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
{
// First, check if the class has already been loaded
ReflectUtil.checkPackageAccess(name);
Class c = findLoadedClass(name);
Class<?> c = findLoadedClass(name);
if (c == null) {
try {
c = findClass(name);
......@@ -324,7 +320,7 @@ public final class MethodUtil extends SecureClassLoader {
}
protected Class findClass(final String name)
protected Class<?> findClass(final String name)
throws ClassNotFoundException
{
if (!name.startsWith(MISC_PKG)) {
......@@ -347,7 +343,7 @@ public final class MethodUtil extends SecureClassLoader {
/*
* 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);
CodeSource cs = new CodeSource(null, (java.security.cert.Certificate[])null);
if (!name.equals(TRAMPOLINE)) {
......@@ -389,7 +385,7 @@ public final class MethodUtil extends SecureClassLoader {
return perms;
}
private static Class getTrampolineClass() {
private static Class<?> getTrampolineClass() {
try {
return Class.forName(TRAMPOLINE, true, new MethodUtil());
} 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.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -34,13 +34,13 @@ public final class ReflectUtil {
private ReflectUtil() {
}
public static Class forName(String name)
public static Class<?> forName(String name)
throws ClassNotFoundException {
checkPackageAccess(name);
return Class.forName(name);
}
public static Object newInstance(Class cls)
public static Object newInstance(Class<?> cls)
throws InstantiationException, IllegalAccessException {
checkPackageAccess(cls);
return cls.newInstance();
......@@ -50,8 +50,8 @@ public final class ReflectUtil {
* Reflection.ensureMemberAccess is overly-restrictive
* due to a bug. We awkwardly work around it for now.
*/
public static void ensureMemberAccess(Class currentClass,
Class memberClass,
public static void ensureMemberAccess(Class<?> currentClass,
Class<?> memberClass,
Object target,
int modifiers)
throws IllegalAccessException
......@@ -102,8 +102,8 @@ public final class ReflectUtil {
}
}
private static boolean isSubclassOf(Class queryClass,
Class ofClass)
private static boolean isSubclassOf(Class<?> queryClass,
Class<?> ofClass)
{
while (queryClass != null) {
if (queryClass == ofClass) {
......@@ -115,7 +115,7 @@ public final class ReflectUtil {
}
public static void checkPackageAccess(Class clazz) {
public static void checkPackageAccess(Class<?> clazz) {
checkPackageAccess(clazz.getName());
}
......@@ -136,7 +136,7 @@ public final class ReflectUtil {
}
}
public static boolean isPackageAccessible(Class clazz) {
public static boolean isPackageAccessible(Class<?> clazz) {
try {
checkPackageAccess(clazz);
} catch (SecurityException e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册