Skip to content

Commit

Permalink
Rawtypes warnings in core and other foundation modules (#1294)
Browse files Browse the repository at this point in the history
lowhanging rawtypes
few unchecked warnings
adde generics to some API methods

Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
  • Loading branch information
lukasj committed Sep 12, 2021
1 parent 67c8f11 commit fec4bc8
Show file tree
Hide file tree
Showing 542 changed files with 3,425 additions and 3,361 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,12 @@ public Object createSimpleXMLFormat(XRServiceAdapter xrService, Object value) {
Object xmlTypeFactory;
Method getStringMethod;
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
oracleOPAQUE = AccessController.doPrivileged(new PrivilegedClassForName(IORACLEOPAQUE_STR, true, this.getClass().getClassLoader()));
xmlTypeFactoryClass = AccessController.doPrivileged(new PrivilegedClassForName(XMLTYPEFACTORY_STR, true, this.getClass().getClassLoader()));
xmlTypeFactoryConstructor = AccessController.doPrivileged(new PrivilegedGetConstructorFor(xmlTypeFactoryClass, new Class[0], true));
xmlTypeFactory = AccessController.doPrivileged(new PrivilegedInvokeConstructor(xmlTypeFactoryConstructor, new Object[0]));
oracleOPAQUE = AccessController.doPrivileged(new PrivilegedClassForName<>(IORACLEOPAQUE_STR, true, this.getClass().getClassLoader()));
xmlTypeFactoryClass = AccessController.doPrivileged(new PrivilegedClassForName<>(XMLTYPEFACTORY_STR, true, this.getClass().getClassLoader()));
xmlTypeFactoryConstructor = AccessController.doPrivileged(new PrivilegedGetConstructorFor<>(xmlTypeFactoryClass, new Class[0], true));
xmlTypeFactory = AccessController.doPrivileged(new PrivilegedInvokeConstructor<>(xmlTypeFactoryConstructor, new Object[0]));
getStringMethod = AccessController.doPrivileged(new PrivilegedGetDeclaredMethod(xmlTypeFactoryClass, GETSTRING_METHOD, new Class[] {oracleOPAQUE}));
fieldValue = AccessController.doPrivileged(new PrivilegedMethodInvoker(getStringMethod, fieldValue, new Object[] {}));
fieldValue = AccessController.doPrivileged(new PrivilegedMethodInvoker<>(getStringMethod, fieldValue, new Object[] {}));
} else {
oracleOPAQUE = PrivilegedAccessHelper.getClassForName(IORACLEOPAQUE_STR, false, this.getClass().getClassLoader());
xmlTypeFactoryClass = PrivilegedAccessHelper.getClassForName(XMLTYPEFACTORY_STR, true, this.getClass().getClassLoader());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -26,7 +26,6 @@
import static org.eclipse.persistence.internal.helper.ClassConstants.FLOAT;
import static org.eclipse.persistence.internal.helper.ClassConstants.INTEGER;
import static org.eclipse.persistence.internal.helper.ClassConstants.LONG;
import static org.eclipse.persistence.internal.helper.ClassConstants.Object_Class;
import static org.eclipse.persistence.internal.helper.ClassConstants.SHORT;
import static org.eclipse.persistence.internal.helper.ClassConstants.STRING;
import static org.eclipse.persistence.internal.oxm.Constants.ANY_SIMPLE_TYPE_QNAME;
Expand Down Expand Up @@ -67,6 +66,7 @@
import javax.xml.namespace.QName;

// EclipseLink imports
import org.eclipse.persistence.internal.core.helper.CoreClassConstants;
import org.eclipse.persistence.internal.databaseaccess.DatabasePlatform;
import org.eclipse.persistence.platform.xml.XMLPlatform;
import org.eclipse.persistence.platform.xml.XMLPlatformFactory;
Expand Down Expand Up @@ -434,7 +434,7 @@ public static boolean isFirstNameChar(char c) {
public static Class<?> getClassFromJDBCType(String typeName, DatabasePlatform databasePlatform) {
Class<?> clz = databasePlatform.getClassTypes().get(typeName);
if (clz == null) {
return Object_Class;
return CoreClassConstants.OBJECT;
}
return clz;
}
Expand All @@ -444,7 +444,7 @@ public static Class<?> getClassFromJDBCType(String typeName, DatabasePlatform da
public static final Map<QName, Class<?>> SCHEMA_2_CLASS;
static {
SCHEMA_2_CLASS = Collections.unmodifiableMap(new HashMap<QName, Class<?>>() {{
put(ANY_SIMPLE_TYPE_QNAME,Object_Class);
put(ANY_SIMPLE_TYPE_QNAME,CoreClassConstants.OBJECT);
put(BASE_64_BINARY_QNAME, APBYTE);
put(BOOLEAN_QNAME, BOOLEAN);
put(BYTE_QNAME, BYTE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -387,7 +387,7 @@ protected static void prepareDescriptors(Project oxProject, Project orProject, X
}
}
// convert class names to classes on the associated OR descriptor
ClassDescriptor odesc = (ClassDescriptor) orProject.getAliasDescriptors().get(alias);
ClassDescriptor odesc = orProject.getAliasDescriptors().get(alias);
if (odesc != null) { // shouldn't be null...
// step three: align OR alias and ordered descriptors (alias names and mappings)
ClassDescriptor orderedDescriptor = getDescriptorForClassName(orProject, odesc.getJavaClassName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -268,7 +268,7 @@ private MetadataCatalog buildMetadataCatalog(PersistenceContext context) {
final MetadataCatalog result = new MetadataCatalog();

// Entities
final Map<Class, ClassDescriptor> descriptors = context.getServerSession().getDescriptors();
final Map<Class<?>, ClassDescriptor> descriptors = context.getServerSession().getDescriptors();
for (ClassDescriptor descriptor : descriptors.values()) {

// Skip embeddables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ protected Response getTypesInternal(String version, String persistenceUnit, Http
PersistenceContext context = getPersistenceContext(persistenceUnit, null, baseURI, version, null);
PersistenceUnit pu = new PersistenceUnit();
pu.setPersistenceUnitName(persistenceUnit);
Map<Class, ClassDescriptor> descriptors = context.getServerSession().getDescriptors();
Map<Class<?>, ClassDescriptor> descriptors = context.getServerSession().getDescriptors();
String mediaType = StreamingOutputMarshaller.mediaType(headers.getAcceptableMediaTypes()).toString();
Iterator<Class> contextIterator = descriptors.keySet().iterator();
Iterator<Class<?>> contextIterator = descriptors.keySet().iterator();
while (contextIterator.hasNext()) {
ClassDescriptor descriptor = descriptors.get(contextIterator.next());
String alias = descriptor.getAlias();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void preLogin(SessionEvent event) {
ClassLoader cl = jpaSession.getDatasourcePlatform().getConversionManager().getLoader();
DefaultXMLNameTransformer xmlNameTransformer = new DefaultXMLNameTransformer();
for (Object descriptorAlias : project.getAliasDescriptors().keySet()) {
ClassDescriptor descriptor = (ClassDescriptor) project.getAliasDescriptors().get(descriptorAlias);
ClassDescriptor descriptor = project.getAliasDescriptors().get(descriptorAlias);

if (!PersistenceWeavedRest.class.isAssignableFrom(descriptor.getJavaClass())) {
continue;
Expand Down Expand Up @@ -190,7 +190,7 @@ public void preLogin(SessionEvent event) {
}

for (Object descriptorAlias : project.getAliasDescriptors().keySet()) {
ClassDescriptor descriptor = (ClassDescriptor) project.getAliasDescriptors().get(descriptorAlias);
ClassDescriptor descriptor = project.getAliasDescriptors().get(descriptorAlias);
ClassDescriptor jpaDescriptor = jpaSession.getDescriptorForAlias(descriptor.getAlias());
Vector<DatabaseMapping> descriptorMappings = (Vector<DatabaseMapping>) descriptor.getMappings().clone();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void preLogin(SessionEvent event) {
final Project project = event.getSession().getProject();
final DefaultXMLNameTransformer xmlNameTransformer = new DefaultXMLNameTransformer();
for (Object descriptorAlias : project.getAliasDescriptors().keySet()) {
final ClassDescriptor descriptor = (ClassDescriptor) project.getAliasDescriptors().get(descriptorAlias);
final ClassDescriptor descriptor = project.getAliasDescriptors().get(descriptorAlias);

if (!PersistenceWeavedRest.class.isAssignableFrom(descriptor.getJavaClass())) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ public Time[] buildNormalHours(org.eclipse.persistence.sessions.Record row, Sess

/** This conversion allows for the database type not to match, i.e. may be a Timestamp or String. */
try {
hours[0] = (Time) session.getDatasourcePlatform().convertObject(row.get("START_TIME"), java.sql.Time.class);
hours[1] = (Time) session.getDatasourcePlatform().convertObject(row.get("END_TIME"), java.sql.Time.class);
hours[0] = session.getDatasourcePlatform().convertObject(row.get("START_TIME"), Time.class);
hours[1] = session.getDatasourcePlatform().convertObject(row.get("END_TIME"), Time.class);
} catch (Throwable in904) {
// Allow performance tests to be run in 904.
hours[0] = (Time)ConversionManager.getDefaultManager().convertObject(row.get("START_TIME"), java.sql.Time.class);
hours[1] = (Time)ConversionManager.getDefaultManager().convertObject(row.get("END_TIME"), java.sql.Time.class);
hours[0] = ConversionManager.getDefaultManager().convertObject(row.get("START_TIME"), Time.class);
hours[1] = ConversionManager.getDefaultManager().convertObject(row.get("END_TIME"), Time.class);
}
return hours;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
import java.io.*;
import java.util.Enumeration;
import org.eclipse.persistence.descriptors.*;
import org.eclipse.persistence.sessions.*;
import org.eclipse.persistence.mappings.*;
import org.eclipse.persistence.tools.schemaframework.*;
import org.eclipse.persistence.testing.models.inheritance.PC;

public class Computer implements Serializable {
public int id;
Expand All @@ -35,7 +33,7 @@ public static void addToDescriptor(ClassDescriptor descriptor) {
// As a result, we check for the mapping before adding it.
// The reason this mapping is not added in the project is that some Mapping Workbench
// tests rely on the ammendment method.
Enumeration mappings = descriptor.getMappings().elements();
Enumeration<DatabaseMapping> mappings = descriptor.getMappings().elements();
while (mappings.hasMoreElements()) {
DatabaseMapping mapping = (DatabaseMapping)mappings.nextElement();
if (mapping.isTransformationMapping()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void addToDescriptor(ClassDescriptor descriptor) {
// As a result, we check for the mapping before adding it.
// The reason this mapping is not added in the project is that some Mapping Workbench
// tests rely on the ammendment method.
Enumeration mappings = descriptor.getMappings().elements();
Enumeration<DatabaseMapping> mappings = descriptor.getMappings().elements();
while (mappings.hasMoreElements()) {
DatabaseMapping mapping = (DatabaseMapping)mappings.nextElement();
if (mapping.isTransformationMapping()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ public void setComputer(Hardware computer) {
}

public java.util.Date setDateAndTime(org.eclipse.persistence.sessions.Record row, org.eclipse.persistence.sessions.Session session) {
java.sql.Date sqlDateOfBirth = (java.sql.Date)ConversionManager.getDefaultManager().convertObject(row.get("BDAY"), java.sql.Date.class);
java.sql.Time timeOfBirth = (java.sql.Time)session.getLogin().getPlatform().convertObject(row.get("BTIME"), java.sql.Time.class);
java.sql.Date sqlDateOfBirth = ConversionManager.getDefaultManager().convertObject(row.get("BDAY"), java.sql.Date.class);
java.sql.Time timeOfBirth = session.getLogin().getPlatform().convertObject(row.get("BTIME"), java.sql.Time.class);
if ((timeOfBirth == null) || (sqlDateOfBirth == null)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class AgentBuilderHelper {

public static List getCustomers(Object object) {
Class cls = object.getClass();
Class<? extends Object> cls = object.getClass();
if(Agent.class.equals(cls)) {
return ((Agent)object).getCustomers();
} else if (Builder.class.equals(cls)) {
Expand All @@ -43,7 +43,7 @@ public static List getCustomers(Object object) {
}

public static List getHouses(Object object) {
Class cls = object.getClass();
Class<? extends Object> cls = object.getClass();
if(Agent.class.equals(cls)) {
return ((Agent)object).getHouses();
} else if (Builder.class.equals(cls)) {
Expand Down Expand Up @@ -74,7 +74,7 @@ public static String getNameInBrackets(Class cls) {
}

public static String getLastName(Object object) {
Class cls = object.getClass();
Class<? extends Object> cls = object.getClass();
if(Agent.class.equals(cls)) {
return ((Agent)object).getLastName();
} else if (Builder.class.equals(cls)) {
Expand All @@ -85,7 +85,7 @@ public static String getLastName(Object object) {
}

public static void setLastName(Object object, String lastName) {
Class cls = object.getClass();
Class<? extends Object> cls = object.getClass();
if(Agent.class.equals(cls)) {
((Agent)object).setLastName(lastName);
} else if (Builder.class.equals(cls)) {
Expand All @@ -96,7 +96,7 @@ public static void setLastName(Object object, String lastName) {
}

public static String getFirstName(Object object) {
Class cls = object.getClass();
Class<? extends Object> cls = object.getClass();
if(Agent.class.equals(cls)) {
return ((Agent)object).getFirstName();
} else if (Builder.class.equals(cls)) {
Expand All @@ -107,7 +107,7 @@ public static String getFirstName(Object object) {
}

public static void setFirstName(Object object, String firstName) {
Class cls = object.getClass();
Class<? extends Object> cls = object.getClass();
if(Agent.class.equals(cls)) {
((Agent)object).setFirstName(firstName);
} else if (Builder.class.equals(cls)) {
Expand All @@ -118,7 +118,7 @@ public static void setFirstName(Object object, String firstName) {
}

public static void addCustomer(Object object, Customer customer) {
Class cls = object.getClass();
Class<? extends Object> cls = object.getClass();
if(Agent.class.equals(cls)) {
((Agent)object).addCustomer(customer);
} else if (Builder.class.equals(cls)) {
Expand All @@ -129,7 +129,7 @@ public static void addCustomer(Object object, Customer customer) {
}

public static void addHouse(Object object, House house) {
Class cls = object.getClass();
Class<? extends Object> cls = object.getClass();
if(Agent.class.equals(cls)) {
((Agent)object).addHouse(house);
} else if (Builder.class.equals(cls)) {
Expand All @@ -140,7 +140,7 @@ public static void addHouse(Object object, House house) {
}

public static void removeCustomer(Object object, Customer customer) {
Class cls = object.getClass();
Class<? extends Object> cls = object.getClass();
if(Agent.class.equals(cls)) {
((Agent)object).removeCustomer(customer);
} else if (Builder.class.equals(cls)) {
Expand All @@ -151,7 +151,7 @@ public static void removeCustomer(Object object, Customer customer) {
}

public static void removeHouse(Object object, House house) {
Class cls = object.getClass();
Class<? extends Object> cls = object.getClass();
if(Agent.class.equals(cls)) {
((Agent)object).removeHouse(house);
} else if (Builder.class.equals(cls)) {
Expand Down

0 comments on commit fec4bc8

Please sign in to comment.