Skip to content

Commit

Permalink
warnings in core/oxm/schema, jpa/parser, helpers (#1317)
Browse files Browse the repository at this point in the history
* warnings in core/oxm/schema, jpa/parser, helpers (changes applied through the codebase)
* attempt to harden modules with no warnings, warning means compile-time error here

Signed-off-by: Lukas Jungmann <[email protected]>
  • Loading branch information
lukasj authored Sep 22, 2021
1 parent 08e6244 commit 3e2c7e5
Show file tree
Hide file tree
Showing 286 changed files with 1,326 additions and 2,006 deletions.
33 changes: 23 additions & 10 deletions bundles/tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<packaging>jar</packaging>

<properties>
<comp.xlint>-Xlint:all</comp.xlint>
<comp.xdoclint>-Xdoclint:all,-missing</comp.xdoclint>
<comp.test.xlint>-Xlint:all</comp.test.xlint>

<!--Test properties-->
<archive.tmp.dir>archive-tmp</archive.tmp.dir>
<eclipselink.unzip.dir>${project.build.directory}/stage</eclipselink.unzip.dir>
Expand Down Expand Up @@ -86,16 +90,16 @@
<artifactId>parsson</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.corba</groupId>
<artifactId>glassfish-corba-omgapi</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.corba</groupId>
<artifactId>glassfish-corba-orb</artifactId>
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.glassfish.corba</groupId>-->
<!-- <artifactId>glassfish-corba-omgapi</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.glassfish.corba</groupId>-->
<!-- <artifactId>glassfish-corba-orb</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -174,6 +178,15 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-Werror</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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 @@ -63,7 +63,7 @@ public static Option[] config() {

@BeforeClass
public static void setUp() throws Exception {
Class[] classes = new Class[1];
Class<?>[] classes = new Class<?>[1];
classes[0] = Customer.class;
jaxbContext = JAXBContextFactory.createContext(classes, null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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 @@ -52,7 +52,7 @@ public static Option[] config() {

@BeforeClass
public static void setUp() throws Exception {
Class[] classes = new Class[1];
Class<?>[] classes = new Class<?>[1];
classes[0] = Customer.class;
jaxbContext = JAXBContextFactory.createContext(classes, null);
}
Expand Down
13 changes: 13 additions & 0 deletions dbws/eclipselink.dbws.test.oracle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
</parent>

<properties>
<comp.xlint>-Xlint:all</comp.xlint>
<comp.xdoclint>-Xdoclint:all,-missing</comp.xdoclint>
<comp.test.xlint>-Xlint:all</comp.test.xlint>

<test-skip-dbws-oracle>${skipTests}</test-skip-dbws-oracle>
</properties>

Expand Down Expand Up @@ -79,6 +83,15 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-Werror</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import org.eclipse.persistence.queries.DatabaseQuery;
import org.eclipse.persistence.sessions.DatabaseLogin;
import org.eclipse.persistence.sessions.DatabaseSession;
import org.eclipse.persistence.sessions.DatasourceLogin;
import org.eclipse.persistence.sessions.Project;
import org.eclipse.persistence.sessions.Session;
import org.eclipse.persistence.sessions.factories.XMLProjectReader;
Expand Down Expand Up @@ -292,7 +291,7 @@ public void fromProjectXML() {
Class<?> t1Clz = t1Descriptor.getJavaClass();
((DatabaseSession)session).login();
String[] elements = {"first string", "second string", "third string"};
NonSynchronizedVector queryArgs = new NonSynchronizedVector();
NonSynchronizedVector<Object> queryArgs = new NonSynchronizedVector<>();
queryArgs.add(elements);
queryArgs.add("barf");
boolean worked = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,16 +564,15 @@ public byte[] getAttachmentAsByteArray(String id) {
* binary objects, we must convert
*/
org.eclipse.persistence.internal.oxm.schema.model.Element invocationElement =
(org.eclipse.persistence.internal.oxm.schema.model.Element)
dbwsAdapter.getExtendedSchema().getTopLevelElements().get(invocation.getName());
dbwsAdapter.getExtendedSchema().getTopLevelElements().get(invocation.getName());
String typeName = invocationElement.getType();
int idx = typeName.indexOf(':');
if (idx != -1) {
// strip-off any namespace prefix
typeName = typeName.substring(idx+1);
}
ComplexType complexType =
(ComplexType)dbwsAdapter.getExtendedSchema().getTopLevelComplexTypes().get(typeName);
dbwsAdapter.getExtendedSchema().getTopLevelComplexTypes().get(typeName);
if (complexType.getSequence() != null) {
// for each operation, there is a corresponding top-level Request type
// which has the arguments to the operation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 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 @@ -46,7 +46,7 @@ public void addTests() {

for (int index = 0; index < tests.size(); ++index) {
try {
addTest((TestModel) Class.forName(tests.get(index)).newInstance());
addTest((TestModel) Class.forName(tests.get(index)).getConstructor().newInstance());
} catch (Throwable exception) {
System.out.println("Failed to set up " + tests.get(index) + " \n" + exception);
// exception.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
public class HistoryFacade {

private static Map timeOffsetsMap = new IdentityHashMap();
private static Map<Session, Long> timeOffsetsMap = new IdentityHashMap<>();

protected HistoryFacade() {
}
Expand All @@ -62,7 +62,7 @@ protected static void buildHistoricalTableDefinition(HistoryPolicy policy,
fieldDef.setType(ClassConstants.TIMESTAMP);
fieldDef.setSize(6);
histDef.addField(fieldDef);
histDef.setForeignKeys(new Vector());
histDef.setForeignKeys(new Vector<>());

for (FieldDefinition fieldDef2 : histDef.getFields()) {
// For now foreign key constraints are not supported, because shallow inserts are not...
Expand Down Expand Up @@ -107,7 +107,7 @@ public static long currentDatabaseTimeMillis(org.eclipse.persistence.sessions.Se
}
}
if (timeOffsetsMap.containsKey(rootSession)) {
Long offset = (Long)timeOffsetsMap.get(rootSession);
Long offset = timeOffsetsMap.get(rootSession);
return System.currentTimeMillis() + offset;
} else {
DatabaseQuery query =
Expand All @@ -132,11 +132,11 @@ public static long currentDatabaseTimeMillis(org.eclipse.persistence.sessions.Se
public static void generateHistoricalTableDefinitions(TableCreator creator, Session session) {

// First add all table definitions to a hashtable.
Map<String, TableDefinition> tableDefinitions = new HashMap(creator.getTableDefinitions().size());
Map<String, TableDefinition> tableDefinitions = new HashMap<>(creator.getTableDefinitions().size());
for (TableDefinition def : creator.getTableDefinitions()) {
tableDefinitions.put(def.getFullName(), def);
}
Set<String> generatedTables = new HashSet<String>();
Set<String> generatedTables = new HashSet<>();
for (ClassDescriptor descriptor : session.getDescriptors().values()) {
HistoryPolicy policy = descriptor.getHistoryPolicy();
if (policy != null) {
Expand Down Expand Up @@ -188,15 +188,15 @@ public static void generateHistoricalTableDefinitions(TableCreator creator, Sess
* being the current table name with a _HIST suffix. Hence Employee would
* become Employee_Hist.
*/
public static void generateHistoryPolicies(Iterator descriptors, DatasourcePlatform platform) {
public static void generateHistoryPolicies(Iterator<ClassDescriptor> descriptors, DatasourcePlatform platform) {
HistoryPolicy basePolicy = new HistoryPolicy();
basePolicy.addStartFieldName("ROW_START");
basePolicy.addEndFieldName("ROW_END");

HistoryPolicy policy = null;

while (descriptors.hasNext()) {
ClassDescriptor descriptor = (ClassDescriptor)descriptors.next();
ClassDescriptor descriptor = descriptors.next();
policy = (HistoryPolicy)basePolicy.clone();
List<DatabaseTable> tables = descriptor.getTables();
int size = tables.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void addSubGroup(ATTRIBUTE_GROUP group) {
if (this.group == null){
this.group = group;
}
Object type = group.getType();
Serializable type = group.getType();
if (type == null){
type = group.getTypeName();
}
Expand Down Expand Up @@ -202,9 +202,9 @@ public boolean equals(Object obj) {
if(obj == null) {
return false;
}
CoreAttributeItem anotherItem = null;
CoreAttributeItem<ATTRIBUTE_GROUP> anotherItem = null;
try {
anotherItem = (CoreAttributeItem)obj;
anotherItem = (CoreAttributeItem<ATTRIBUTE_GROUP>)obj;
} catch (ClassCastException cce) {
return false;
}
Expand All @@ -215,7 +215,7 @@ public boolean equals(Object obj) {
}
if (this.subGroups.size() == anotherItem.subGroups.size()){
for (Map.Entry<Object, ATTRIBUTE_GROUP> entry : this.subGroups.entrySet()){
ATTRIBUTE_GROUP anotherGroup = (ATTRIBUTE_GROUP)anotherItem.subGroups.get(entry.getKey());
ATTRIBUTE_GROUP anotherGroup = anotherItem.subGroups.get(entry.getKey());
if (! entry.getValue().equals(anotherGroup)){
return false;
}
Expand All @@ -233,7 +233,7 @@ public boolean equals(Object obj) {
}
if (this.keyGroups.size() == anotherItem.keyGroups.size()){
for (Map.Entry<Object, ATTRIBUTE_GROUP> entry : this.keyGroups.entrySet()){
ATTRIBUTE_GROUP anotherGroup = (ATTRIBUTE_GROUP)anotherItem.keyGroups.get(entry.getKey());
ATTRIBUTE_GROUP anotherGroup = anotherItem.keyGroups.get(entry.getKey());
if (! entry.getValue().equals(anotherGroup)){
return false;
}
Expand Down Expand Up @@ -344,10 +344,10 @@ public void setRootGroup(ATTRIBUTE_GROUP group) {

@Override
public String toString() {
return getClass().getSimpleName() + "(" + getAttributeName() + ")" + (this.subGroups!=null ? " => " + this.subGroups.toString() : "") + (this.keyGroups!=null ? " => " + this.keyGroups.toString() : "");
return getClass().getSimpleName() + "(" + getAttributeName() + ")" + (this.subGroups!=null ? " => " + this.subGroups : "") + (this.keyGroups!=null ? " => " + this.keyGroups : "");
}

public String toStringNoClassName() {
return getAttributeName() + (this.subGroups!=null ? " => " + this.subGroups.toString() : "")+ (this.keyGroups!=null ? " => " + this.keyGroups.toString() : "");
return getAttributeName() + (this.subGroups!=null ? " => " + this.subGroups : "")+ (this.keyGroups!=null ? " => " + this.keyGroups : "");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.eclipse.persistence.internal.helper.ClassConstants;
Expand Down Expand Up @@ -43,11 +44,9 @@ public CacheIndex() {
this.fields = new ArrayList<>();
}

public CacheIndex(DatabaseField fields[]) {
public CacheIndex(DatabaseField[] fields) {
this.fields = new ArrayList<>(fields.length);
for (DatabaseField field : fields) {
this.fields.add(field);
}
Collections.addAll(this.fields, fields);
}

public CacheIndex(String... fields) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.Map;
import java.util.Set;

import jakarta.persistence.Cache;
import org.eclipse.persistence.annotations.CacheCoordinationType;
import org.eclipse.persistence.annotations.CacheKeyType;
import org.eclipse.persistence.annotations.DatabaseChangeNotificationType;
Expand All @@ -47,7 +46,6 @@
import org.eclipse.persistence.mappings.DatabaseMapping;
import org.eclipse.persistence.sessions.DatabaseSession;
import org.eclipse.persistence.sessions.interceptors.CacheInterceptor;
import org.eclipse.persistence.sessions.interceptors.CacheKeyInterceptor;

/**
* <p><b>Purpose</b>:
Expand Down
Loading

0 comments on commit 3e2c7e5

Please sign in to comment.