From 1cc206da5981d91defff2c26654603c4cdc6747e Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Thu, 20 Aug 2026 12:33:57 +0200 Subject: [PATCH] [OPENJPA-2981] Remove dead access-type helper methods Remove the private helpers hasMixedAnnotations(Class, OpenJPAConfiguration), hasFieldStrategyAnnotations(Class) and hasGetterStrategyAnnotations(Class) from PersistenceMetaDataDefaults. All three were private and had no callers anywhere in the code base. They were added in b53766529 ("[OPENJPA-2940] Allow mixed FIELD+PROPERTY annotation placement without @Access") as a draft shape of the mixed-annotation access resolution; the version that actually shipped in that commit was written inline in determineImplicitAccessType(...), so the helpers were unused from the moment they were introduced. Commit 58ffe9c53 ("[OPENJPA-2940] Fix AccessDefiningFilter for dual-annotated entities and mappedBy resolution") then rewrote that inline logic and removed the last live uses of the accessTypeFilter field, leaving its only remaining references inside the dead helpers. Consequently the accessTypeFilter field and the AccessTypeFilter nested filter class, which after that rework are reachable only from the removed methods, are dropped as well. No other member or import becomes unused. Raised in review of PR 144. --- .../PersistenceMetaDataDefaults.java | 58 ------------------- 1 file changed, 58 deletions(-) diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java index 5e8cf4b7e0..026cddd848 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java @@ -143,7 +143,6 @@ public class PersistenceMetaDataDefaults protected MemberFilter methodFilter = new MemberFilter(Method.class); protected TransientFilter nonTransientFilter = new TransientFilter(false); protected AnnotatedFilter annotatedFilter = new AnnotatedFilter(); - protected AccessTypeFilter accessTypeFilter = new AccessTypeFilter(); protected GetterFilter getterFilter = new GetterFilter(); protected SetterFilter setterFilter = new SetterFilter(); private Boolean _isAbstractMappingUniDirectional = null; @@ -526,42 +525,6 @@ cls, toFieldNames(uniqueAccessFields), return AccessCode.UNKNOWN; } - /** - * Checks whether the given class has JPA annotations on both fields AND - * getters, indicating mixed annotation placement. - */ - private boolean hasMixedAnnotations(Class cls, OpenJPAConfiguration conf) { - Field[] allFields = cls.getDeclaredFields(); - Method[] methods = cls.getDeclaredMethods(); - List fields = filter(allFields, new TransientFilter(true)); - getterFilter.setIncludePrivate( - conf.getCompatibilityInstance().getPrivatePersistentProperties()); - List getters = filter(methods, getterFilter); - fields = filter(fields, annotatedFilter); - getters = filter(getters, annotatedFilter); - List setters = filter(methods, setterFilter); - getters = matchGetterAndSetter(getters, setters); - return !fields.isEmpty() && !getters.isEmpty(); - } - - private boolean hasFieldStrategyAnnotations(Class cls) { - for (Field f : cls.getDeclaredFields()) { - if (accessTypeFilter.includes(f)) { - return true; - } - } - return false; - } - - private boolean hasGetterStrategyAnnotations(Class cls) { - for (Method m : cls.getDeclaredMethods()) { - if (accessTypeFilter.includes(m)) { - return true; - } - } - return false; - } - /** * Explicit access type, if any, is generally detected by the parser. This * is only used for metadata of an embeddable type which is encountered @@ -1155,27 +1118,6 @@ public boolean includes(AnnotatedElement obj) { } } - /** - * Filter that includes only members annotated with access-type-determining - * annotations: persistence strategy annotations (@Id, @Basic, @ManyToOne, etc.), - * @Version, and @EmbeddedId. Supplementary annotations like @Column, - * @JoinColumn, @Enumerated do NOT determine the access type per JPA spec. - */ - static class AccessTypeFilter implements InclusiveFilter { - @Override - public boolean includes(AnnotatedElement obj) { - for (Annotation anno : obj.getAnnotations()) { - Class type = anno.annotationType(); - if (_strats.containsKey(type) - || type == Id.class - || type == Version.class) { - return true; - } - } - return false; - } - } - private void logNoSetter(ClassMetaData meta, String name, Exception e) { Log log = meta.getRepository().getConfiguration() .getLog(OpenJPAConfiguration.LOG_METADATA);