Skip to content

Commit

Permalink
fix some compiler warnings,
Browse files Browse the repository at this point in the history
clean up

Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
(cherry picked from commit 1ab0d5c)
  • Loading branch information
lukasj committed Aug 31, 2021
1 parent fcec3e7 commit 77baf1b
Show file tree
Hide file tree
Showing 164 changed files with 1,392 additions and 1,287 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 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 @@ -12,12 +12,6 @@

package org.eclipse.persistence.internal.jpa.rs.weaving;

import static org.eclipse.persistence.internal.jpa.weaving.ClassWeaver.ITEM_LINKS_SIGNATURE;
import static org.eclipse.persistence.internal.jpa.weaving.ClassWeaver.LINK_SIGNATURE;
import static org.eclipse.persistence.internal.jpa.weaving.ClassWeaver.LIST_RELATIONSHIP_INFO_GENERIC_SIGNATURE;
import static org.eclipse.persistence.internal.jpa.weaving.ClassWeaver.LIST_RELATIONSHIP_INFO_SIGNATURE;
import static org.eclipse.persistence.internal.jpa.weaving.ClassWeaver.PERSISTENCE_FIELDNAME_PREFIX;
import static org.eclipse.persistence.internal.jpa.weaving.ClassWeaver.WEAVED_REST_LAZY_SHORT_SIGNATURE;
import static org.eclipse.persistence.internal.libraries.asm.Opcodes.ACC_PUBLIC;
import static org.eclipse.persistence.internal.libraries.asm.Opcodes.ALOAD;
import static org.eclipse.persistence.internal.libraries.asm.Opcodes.ARETURN;
Expand All @@ -39,6 +33,13 @@
* @since EclipseLink 3.0
*/
public class RestDynamicClassWriter extends MetadataDynamicClassWriter {
//from org.eclipse.persistence.internal.jpa.weaving.ClassWeaver which we do not want to export from o.e.p.jpa
public static final String WEAVED_REST_LAZY_SHORT_SIGNATURE = "org/eclipse/persistence/internal/jpa/rs/weaving/PersistenceWeavedRest";
public static final String LIST_RELATIONSHIP_INFO_SIGNATURE = "Ljava/util/List;";
public static final String LIST_RELATIONSHIP_INFO_GENERIC_SIGNATURE = "Ljava/util/List<Lorg/eclipse/persistence/internal/jpa/rs/weaving/RelationshipInfo;>;";
public static final String LINK_SIGNATURE = "Lorg/eclipse/persistence/internal/jpa/rs/metadata/model/Link;";
public static final String ITEM_LINKS_SIGNATURE = "Lorg/eclipse/persistence/internal/jpa/rs/metadata/model/ItemLinks;";
public static final String PERSISTENCE_FIELDNAME_PREFIX = "_persistence_";

public RestDynamicClassWriter(MetadataDynamicClassWriter w) {
super(w.getDescriptor());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019 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 @@ -19,7 +19,7 @@
import java.lang.reflect.InvocationTargetException;


public class PrivilegedMethodInvoker implements PrivilegedExceptionAction {
public class PrivilegedMethodInvoker<T> implements PrivilegedExceptionAction<T> {

private final Method method;
private final Object target;
Expand All @@ -36,8 +36,8 @@ public PrivilegedMethodInvoker(Method method, Object target, Object[] args){
}

@Override
public Object run() throws IllegalAccessException, InvocationTargetException {
return PrivilegedAccessHelper.invokeMethod(method, target, args);
public T run() throws IllegalAccessException, InvocationTargetException {
return (T) PrivilegedAccessHelper.invokeMethod(method, target, args);
}

}
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 @@ -204,10 +204,8 @@ public String getPKClassName() {
@Override
public Object getPKClassInstance() {
try {
return getPKClass().newInstance();
} catch (IllegalAccessException ex) {
throw DescriptorException.exceptionAccessingPrimaryKeyInstance(this.getDescriptor(), ex);
} catch (InstantiationException ex){
return getPKClass().getConstructor().newInstance();
} catch (ReflectiveOperationException ex) {
throw DescriptorException.exceptionAccessingPrimaryKeyInstance(this.getDescriptor(), ex);
}
}
Expand Down Expand Up @@ -329,7 +327,7 @@ public Object createBeanUsingKey(Object key, AbstractSession session) {
while (mapping.isAggregateObjectMapping()) {
Object aggregate = mapping.getRealAttributeValueFromObject(toWriteInto, session);
if (aggregate == null) {
aggregate = mapping.getReferenceDescriptor().getJavaClass().newInstance();
aggregate = mapping.getReferenceDescriptor().getJavaClass().getConstructor().newInstance();
mapping.setRealAttributeValueInObject(toWriteInto, aggregate);
}
mapping = mapping.getReferenceDescriptor().getObjectBuilder().getMappingForAttributeName(keyElements[index].getAttributeName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ public class EntityManagerFactoryProvider {
{PersistenceUnitProperties.LOGGING_LEVEL + "." + SessionLog.METADATA, PersistenceUnitProperties.LOGGING_LEVEL + ".ejb_or_" + SessionLog.METADATA}
};

/**
* Default constructor to allow reflection.
*/
public EntityManagerFactoryProvider() {
}

/**
* Add an EntityManagerSetupImpl to the cached list
* These are used to ensure all persistence units that are the same get the same underlying session
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.
* Copyright (c) 1998, 2019 IBM Corporation and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -157,7 +157,7 @@ public class EntityManagerImpl implements org.eclipse.persistence.jpa.JpaEntityM
protected enum OperationType {FIND, REFRESH, LOCK};

/** Allows transparent transactions across JTA and local transactions. */
protected TransactionWrapperImpl transaction;
private TransactionWrapperImpl transaction;

/** Store if this entity manager has been closed. */
protected boolean isOpen;
Expand Down Expand Up @@ -255,7 +255,7 @@ protected enum OperationType {FIND, REFRESH, LOCK};
abstract static class PropertyProcessor {
abstract void process(String name, Object value, EntityManagerImpl em);
}
static Map<String, PropertyProcessor> processors = new HashMap() {
static Map<String, PropertyProcessor> processors = new HashMap<>() {
{
put(EntityManagerProperties.JOIN_EXISTING_TRANSACTION, new PropertyProcessor() {
@Override
Expand Down Expand Up @@ -377,10 +377,10 @@ void process(String name, Object value, EntityManagerImpl em) {
@Override
void process(String name, Object value, EntityManagerImpl em) {
if( em.connectionPolicies != null) {
Map mapOfProperties = (Map)value;
Iterator it = mapOfProperties.keySet().iterator();
Map<String, ?> mapOfProperties = (Map<String, ?>) value;
Iterator<String> it = mapOfProperties.keySet().iterator();
while (it.hasNext()) {
String sessionName = (String)it.next();
String sessionName = it.next();
if (em.connectionPolicies.containsKey(sessionName)) {
// Property used to create ConnectionPolicy has changed - already existing ConnectionPolicy should be removed.
// A new one will be created when the new active persistence context is created.
Expand Down Expand Up @@ -508,7 +508,7 @@ protected void initialize(Map properties) {
this.connectionPolicy = ((ServerSession)this.databaseSession).getDefaultConnectionPolicy();
} else if (this.databaseSession.isBroker()) {
SessionBroker broker = (SessionBroker)this.databaseSession;
this.connectionPolicies = new HashMap(broker.getSessionsByName().size());
this.connectionPolicies = new HashMap<>(broker.getSessionsByName().size());
Iterator<Map.Entry<String, AbstractSession>> it = broker.getSessionsByName().entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, AbstractSession> entry = it.next();
Expand Down Expand Up @@ -2157,7 +2157,7 @@ public void setProperty(String propertyName, Object value) {
// getProperties method always returns non-null Map
this.properties = this.extendedPersistenceContext.getParent().getProperties();
} else {
this.properties = new HashMap();
this.properties = new HashMap<>();
}
}

Expand Down Expand Up @@ -2873,7 +2873,7 @@ public LockModeType getLockMode(Object entity) {
*/
@Override
public Map<String, Object> getProperties() {
Map sessionMap = new HashMap(getAbstractSession().getProperties());
Map<String, Object> sessionMap = new HashMap<>(getAbstractSession().getProperties());
if (this.properties != null) {
sessionMap.putAll(this.properties);
}
Expand Down Expand Up @@ -3100,13 +3100,13 @@ public <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass) {
}
List<EntityGraph<? super T>> result = new ArrayList<EntityGraph<? super T>>();
for (AttributeGroup group : descriptor.getAttributeGroups().values()){
result.add(new EntityGraphImpl(group));
result.add(new EntityGraphImpl<>(group));
}
if (descriptor.hasInheritance()){
while(descriptor.getInheritancePolicy().getParentDescriptor() != null){
descriptor = descriptor.getInheritancePolicy().getParentDescriptor();
for (AttributeGroup group : descriptor.getAttributeGroups().values()){
result.add(new EntityGraphImpl(group));
result.add(new EntityGraphImpl<>(group));
}
}
}
Expand Down
Loading

0 comments on commit 77baf1b

Please sign in to comment.