Skip to content
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

Handle xjc XmlEnumValue in DynamicJAXB enum #2273

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

timtatt
Copy link
Contributor

@timtatt timtatt commented Sep 26, 2024

To resolve #2272

  • Changes EnumInfo literals from List to Map to store intended value
  • Adds @XmlEnumValue annotation to DynamicJAXB enum class
  • Check for @XmlEnumValue when adding enum conversion values

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use * in imports. We prefer specific imports like removed part.

@@ -96,17 +94,20 @@ public EclipseLinkClassWriter getClassWriter(String className) {
}

public void addEnum(String className, Object... literalLabels) {
var literalsMap = Arrays.stream(literalLabels)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var is not preferred as we will backport this PR into 2.7 branch with JDK 8.0 support.

<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2018, 2024 Oracle and/or its affiliates. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a new files Copyright (c) 2024 Oracle... is correct.

</xs:complexType>
</xs:element>

<!-- This test contains exactly 6 enum values to test an ASM boundary case (ICONST) -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems inconsistent with values 6 enum vs 4 (QTR1...QTR4).

Copy link
Contributor

@rfelcman rfelcman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general please use specific types instead of var.

import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use specific imports instead of ... .* This should be applied to all changes.

@@ -223,7 +223,7 @@ protected void addMethods(ClassWriter cw, String parentClassType) {

protected byte[] createEnum(EnumInfo enumInfo) {

String[] enumValues = enumInfo.getLiteralLabels();
var enumValues = enumInfo.getEnumValues();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use specific type instead of var.

for (String enumValue : enumValues) {
cw.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC + Opcodes.ACC_ENUM, enumValue, "L" + internalClassName + ";", null, null);
for (var enumValue : enumValues.entrySet()) {
var fv = cw.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC + Opcodes.ACC_ENUM, enumValue.getKey(), "L" + internalClassName + ";", null, null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DynamicJAXB doesn't handle @XmlEnumValue() from XJC class
2 participants