-
Notifications
You must be signed in to change notification settings - Fork 52
Make JAXB final fields non-final for reflection compatibility #1621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: integration
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,18 +45,18 @@ | |
| final class ValidationResultImpl implements ValidationResult { | ||
| private static final ValidationResultImpl DEFAULT = new ValidationResultImpl(); | ||
| @XmlAttribute | ||
| private final PDFAFlavour flavour; | ||
| private PDFAFlavour flavour; | ||
| @XmlElement | ||
| private final ProfileDetails profileDetails; | ||
| private ProfileDetails profileDetails; | ||
| @XmlAttribute | ||
| private final int totalAssertions; | ||
| private int totalAssertions; | ||
| @XmlElementWrapper | ||
| @XmlElement(name = "assertion") | ||
| private final List<TestAssertion> assertions; | ||
| private List<TestAssertion> assertions; | ||
| @XmlAttribute | ||
| private final boolean isCompliant; | ||
| private boolean isCompliant; | ||
| @XmlAttribute | ||
| private final JobEndStatus jobEndStatus; | ||
| private JobEndStatus jobEndStatus; | ||
|
Comment on lines
+48
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== locate file =="
fd -a 'ValidationResultImpl.java' . || true
echo "== file stats =="
file=$(fd 'ValidationResultImpl.java' . | head -n 1)
if [ -n "${file:-}" ]; then
wc -l "$file"
echo "== relevant sections =="
sed -n '1,130p' "$file" | cat -n
fi
echo "== search validations/profile usages =="
rg -n "getValidationProfile|validationProfile|validationProfile\(|fromValidationResult|Profiles\.defaultProfile|setValidationProfile|PDFAFlavour|profileDetails" "$(dirname "$file")" "$file" || true
echo "== search unmarshal JAXB annotations on ValidationResultImpl =="
rg -n "^`@XmlRootElement`|^`@XmlAccessorType`|`@XmlTrans`|JAXBContext|migrate|mangle|Unmarsh" -S core src 2>/dev/null || trueRepository: veraPDF/veraPDF-library Length of output: 22609 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== git diff stat and relevant diff context =="
git diff --stat || true
git diff -- core/src/main/java/org/verapdf/pdfa/results/ValidationResultImpl.java | sed -n '1,220p' || true
echo "== search serialization tests around validationProfile/flavour =="
fd -e java . | rg 'ValidationResult|result|migrate|mangle|report' | head -n 50 || true
pgrep java || trueRepository: veraPDF/veraPDF-library Length of output: 3923 🏁 Script executed: #!/bin/bash
set -euo pipefail
file="core/src/main/java/org/verapdf/pdfa/results/ValidationResultImpl.java"
echo "== full ValidationResultImpl =="
sed -n '120,175p' "$file" | cat -n
echo "== remaining methods =="
sed -n '175,250p' "$file" | cat -n
echo "== ValidationProfileImpl relevant annotations and construction =="
vp="$(fd 'ValidationProfileImpl.java' . | head -n 1)"
if [ -n "${vp:-}" ]; then
wc -l "$vp"
sed -n '1,140p' "$vp" | cat -n
fi
echo "== ProfileDetailsImpl relevant annotations =="
pd="$(fd 'ProfileDetailsImpl.java' . | head -n 1)"
if [ -n "${pd:-}" ]; then
sed -n '1,140p' "$pd" | cat -n
fi
echo "== Profiles.defaultProfile definition =="
pp="$(fd 'Profiles.java' . | head -n 1)"
rg -n "defaultProfile|defaut|\bProfileDetails\(" "$pp" -A12 -B8
echo "== XmlSerialiser validation test usage around results =="
rg -n "XmlSerialiser|validate|ValidationReport|ValidationResult|resultFromValues|fromValidationResult" core/src/test core/src/main -g '*.java' | head -n 200
echo "== deterministic annotation/invariant scan =="
python3 - <<'PY'
from pathlib import Path
p=Path('core/src/main/java/org/verapdf/pdfa/results/ValidationResultImpl.java')
text=p.read_text()
for name in ['flavour','profileDetails','totalAssertions','assertions','isCompliant','jobEndStatus','failedChecks','validationProfile']:
idx=text.index(f'private {name}')
snippet=text[max(0,idx-180):idx+80].splitlines()
has_xml=any(a.strip() in {'`@XmlAttribute`','`@XmlElement`','`@XmlElementWrapper`'} for a in snippet)
has_final=' final ' in text[text.index(f'private {name}'):text.index(';', text.index(f'private {name}'))]
print(f'{name}: fields_nearby_has_annotation={has_xml} field_final={has_final}')
print('default_profile_used_in_default_cctor=', 'Profiles.defaultProfile()' in text[text.index('ValidationResultImpl()'):text.index('ValidationResultImpl(', text.index('private ValidationResultImpl(', text.index('`@XmlAttribute`', text.index('ValidationResultImpl()'))) + 1000) ])
PYRepository: veraPDF/veraPDF-library Length of output: 47039 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== ValidationResultTest non-default xml methods =="
sed -n '100,165p' core/src/test/java/org/verapdf/pdfa/results/ValidationResultTest.java | cat -n
echo "== non-default profile XML snippets in repository =="
rg -n "PDFAFlavour|noFlavour|NO_FLAVOUR|profileDetails|resultFromValues|resultFromXmlString|xmlSource|typeFromXml" core/src/test/core/src/main -g '*.java' | rg "ValidationResult|PDFAFlavour|Profiles" | head -n 200 || true
echo "== deterministic Java/annotation/source invariant scan =="
python3 - <<'PY'
from pathlib import Path
v = Path('core/src/main/java/org/verapdf/pdfa/results/ValidationResultImpl.java')
t = v.read_text()
defs = {
'flavour': t.index('private PDFAFlavour flavour'),
'profileDetails': t.index('private ProfileDetails profileDetails'),
'totalAssertions': t.index('private int totalAssertions'),
'assertions': t.index('private List<TestAssertion> assertions'),
'isCompliant': t.index('private boolean isCompliant'),
'jobEndStatus': t.index('private JobEndStatus jobEndStatus'),
'validationProfile': t.index('private final ValidationProfile validationProfile'),
}
for name, idx in defs.items():
line = t[:idx].count('\n')+1
field_line = [l.strip() for l in t[idx:idx+220].splitlines() if 'validationProfile=' in l or name in l and line <= t[:idx+220].count('\n')+1 and t[idx:idx+220].index(name)==0][(0) if True else None]
before = max(0, idx-220)
snippet = t[before:idx+220]
print(f"{name} line {line}: annotations_nearby={any(a.strip() for a in ['`@XmlAttribute`','`@XmlElement`','`@XmlElementWrapper`'] if a.strip() in snippet)}")
print("validationProfile_initialized_default_ctor_contains_defaultProfile=", "Profiles.defaultProfile()" in t[t.index('private ValidationResultImpl()'):t.index('this.validationProfile = validationProfile;')])
PYRepository: veraPDF/veraPDF-library Length of output: 3662 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== annotation and constructor invariant scan =="
python3 - <<'PY'
from pathlib import Path
p = Path('core/src/main/java/org/verapdf/pdfa/results/ValidationResultImpl.java')
t = p.read_text()
for name in ['flavour','profileDetails','totalAssertions','assertions','isCompliant','jobEndStatus','failedChecks','validationProfile']:
idx = t.index(f'private{(" final" if name=="validationProfile" else "")} {name}')
line = t[:idx].count('\n') + 1
snippet = t[max(0, idx-200):idx+80]
xml_tags = [line.strip() for line in ['`@XmlAttribute`','`@XmlElement`','`@XmlElementWrapper`'] if line.strip() in snippet]
f = 'final ' in snippet[:snippet.index(';', 80)]
print(f'{name:20} line {line:3} annotations={xml_tags} final={f}')
default_ctor = t.index('private ValidationResultImpl() {')
tail = t.index('super();', default_ctor)
print('default_ctor_uses_defaultProfile_before_super=true', 'Profiles.defaultProfile()' in t[default_ctor:tail])
print('validationProfile_final=true', 'private final ValidationProfile validationProfile' in t)
PY
echo "== only non-default ValidationResult XML serialization tests =="
rg -n "Profiles\.[A-Z]|[A-Z][A-Za-z0-9_]+Flavour|NO_FLAVOUR|resultFromValues|typeFromXml|resultFromXmlString|fromXml|toXml" core/src/test/java/org/verapdf/pdfa/results/ValidationResultTest.java -A 15 -B 10Repository: veraPDF/veraPDF-library Length of output: 314 🏁 Script executed: #!/bin/bash
set -euo pipefail
file="core/src/main/java/org/verapdf/pdfa/results/ValidationResultImpl.java"
echo "== exact constructor and field search =="
rg -n "Profiles\.defaultProfile\(|private ValidationResultImpl\(\)|private validationProfile|flavour|profileDetails|totalAssertions|assertions|isCompliant|jobEndStatus|failedChecks" "$file" -A2 -B2
echo "== test XML serialization methods =="
testfile="core/src/test/java/org/verapdf/pdfa/results/ValidationResultTest.java"
rg -n "resultFromValues|Profiles\.[AD-ZA0-9_]|NO_FLAVOUR|typeFromXml|resultFromXmlString|toXml\(" "$testfile" -A 18 -B 8
echo "== deterministic invariant summary =="
python3 - <<'PY'
from pathlib import Path
src = Path('core/src/main/java/org/verapdf/pdfa/results/ValidationResultImpl.java').read_text()
test = Path('core/src/test/java/org/verapdf/pdfa/results/ValidationResultTest.java').read_text()
print("validationProfile_final_present=", "private final ValidationProfile validationProfile" in src)
print("default_ctor_uses_defaultProfile_present=", "Profiles.defaultProfile()" in src)
print("current_tests_use_defaultProfile_only=", "Profiles.defaultProfile()" in test and "Profiles.N" not in test and "Profiles.A" not in test)
print("default_constructors_are_jaxb_accessible=", "private ValidationResultImpl()" in src and "private ValidationResultImpl(final ValidationProfile validationProfile" in src)
PYRepository: veraPDF/veraPDF-library Length of output: 11423 Keep The JAXB-deserialized 🤖 Prompt for AI Agents |
||
|
|
||
| private HashMap<RuleId, Integer> failedChecks = null; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,21 +48,21 @@ | |
| class ProcessorResultImpl implements ProcessorResult { | ||
| private static final ProcessorResult defaultInstance = new ProcessorResultImpl(); | ||
| @XmlAttribute | ||
| private final boolean isPdf; | ||
| private boolean isPdf; | ||
| @XmlAttribute | ||
| private final boolean isEncryptedPdf; | ||
| private boolean isEncryptedPdf; | ||
| @XmlAttribute | ||
| private final boolean isOutOfMemory; | ||
| private boolean isOutOfMemory; | ||
| @XmlAttribute | ||
| private final boolean hasException; | ||
| private boolean hasException; | ||
| @XmlElement | ||
| private final ItemDetails itemDetails; | ||
| private final EnumMap<TaskType, TaskResult> taskResults; | ||
| private ItemDetails itemDetails; | ||
| private EnumMap<TaskType, TaskResult> taskResults; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Files:"
git ls-files | rg '(^|/)ProcessorResultImpl\.java$|(^|/)TaskResultImpl\.java$' || true
echo
echo "ProcessorResultImpl outline:"
ast-grep outline core/src/main/java/org/verapdf/processor/ProcessorResultImpl.java || true
echo
echo "TaskResultImpl outline:"
ast-grep outline core/src/main/java/org/verapdf/processor/TaskResultImpl.java || true
echo
echo "Relevant sections:"
sed -n '1,140p' core/src/main/java/org/verapdf/processor/ProcessorResultImpl.java
echo "----"
sed -n '1,140p' core/src/main/java/org/verapdf/processor/TaskResultImpl.java
echo
echo "Search related JAXB annotations/usages:"
rg -n "`@Xml`|getTaskResults|setTaskResults|featuresResult|getFeatures|set|exception|AuditException|taskResults" core/src/main/java/org/verapdf/processor -SRepository: veraPDF/veraPDF-library Length of output: 33099 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "ProcessorResult.java:"
cat -n core/src/main/java/org/verapdf/processor/ProcessorResult.java
echo
echo "TaskResult.java:"
cat -n core/src/main/java/org/verapdf/processor/TaskResult.java
echo
echo "Remaining ProcessorResultImpl sections:"
sed -n '140,260p' core/src/main/java/org/verapdf/processor/ProcessorResultImpl.java
echo
echo "Remaining TaskResultImpl sections:"
sed -n '140,260p' core/src/main/java/org/verapdf/processor/TaskResultImpl.java
echo
echo "Find processorResult/taskException serialization handling:"
rg -n "processorResult|taskException|getResultSet|set|features|FeatureExtraction|ExceptionMessage|VeraPDFException" core/src/main/java/core/src/main/java/org/verapdf/processor -S --glob '*.java'Repository: veraPDF/veraPDF-library Length of output: 10051 🌐 Web query:
💡 Result: In Jakarta XML Binding (JAXB), the unmarshalling process depends heavily on how the class is annotated and the configured access type [1][2][3]. Whether JAXB uses setters or direct field access is determined by these factors: Access Type and Semantics JAXB uses XmlAccessorType to control how it interacts with class members [1][3]. - XmlAccessType.FIELD: JAXB ignores properties (getters/setters) and directly accesses the fields, even if they are private [4][5]. If you place annotations on your setters, they will be ignored or may even cause configuration conflicts if the corresponding field is also annotated [4][5][6]. - XmlAccessType.PROPERTY (or default PUBLIC_MEMBER): JAXB prioritizes JavaBean property access (getter/setter pairs) [1][3]. If this mode is active, JAXB will attempt to use the setter method to inject unmarshalled values [5][7]. Forceing Setter Usage To ensure JAXB uses your setter methods (e.g., for custom validation logic), follow these practices: 1. Do not use Citations:
Provide mutable JAXB storage for derived processor result properties. XML unmarshalling cannot restore state through derived getters: 📍 Affects 2 files
🤖 Prompt for AI AgentsSource: MCP tools |
||
| @XmlElement | ||
| private final List<ValidationResult> validationResults; | ||
| private final FeatureExtractionResult featuresResult; | ||
| private List<ValidationResult> validationResults; | ||
| private FeatureExtractionResult featuresResult; | ||
| @XmlElement | ||
| private final MetadataFixerResult fixerResult; | ||
| private MetadataFixerResult fixerResult; | ||
|
|
||
| private ProcessorResultImpl() { | ||
| this(ItemDetails.defaultInstance(), TaskResultImpl.defaultInstance()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: veraPDF/veraPDF-library
Length of output: 49453
Run JAXB-popped fields through normal construction validation.
JAXB unmarshalling sets
start,finish,level, andcontextdirectly, bypassingfromValues. Incore/src/main/java/org/verapdf/component/AuditDurationImpl.javathis can unmarshal negative or end-before-start durations; incore/src/main/java/org/verapdf/pdfa/results/LocationImpl.javait can skipcontextderefing such as0000 (Abcd)becoming0000 (Abcdin the persisted object. Use a JAXB post-unmarshall callback or adapter path to applyfromValuesafter field population, not only at construction.📍 Affects 2 files
core/src/main/java/org/verapdf/component/AuditDurationImpl.java#L45-L48(this comment)core/src/main/java/org/verapdf/pdfa/results/LocationImpl.java#L45-L47🤖 Prompt for AI Agents