Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8177301

Certain keywords cannot be added to the @XmlAttribute tag.

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_121"
      Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.14393]

      A DESCRIPTION OF THE PROBLEM :
      As I was testing with different values of @XmlAttribute(name="?") that a certain xml file requires simply returns a empty result.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      create a default XML compatible class with the settings:
      @XmlAccessorType(XmlAccessType.FIELD)
      @XmlType(name = "")

      Add @XmlAttribute(name = "id") to all values.

      In main (replace CLASS and CLASS_Object with the class and a object):
      JAXBContext context = JAXBContext.newInstance(CLASS.class);
      Marshaller m = context.createMarshaller();
      m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      m.marshal(CLASS_Object, System.out);

      The result of System.out should look like this:
      <CLASS id="?" id="?" ... />

      Now replace one of the name="id" with one the following:
      x
      y
      lenght

      after you run this the result of System.out is empty.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The result of System.out is empty
      ACTUAL -
      The result of System.out is empty

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      There are no errors or messages for this

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.xml.bind.annotation.*;

      @XmlAccessorType(XmlAccessType.FIELD)
      @XmlType(name = "")
      @XmlRootElement(name = "node")
      public class Node {

          @XmlAttribute(name = "id", required = true)
          protected long id;
          @XmlAttribute(name = "idx", required = true)
          protected long x;
          @XmlAttribute(name = "idy", required = true)
          protected long y;

          public Node() {}

          public Node(long id, long x, long y) {
              this.id = id;
              this.x = x;
              this.y = y;
          }


          public long getId() {
              return id;
          }

          public void setId(long id) {
              this.id = id;
          }

          public long getX() {
              return x;
          }

          public void setX(long x) {
              this.x = x;
          }

          public long getY() {
              return y;
          }

          public void setY(long y) {
              this.y = y;
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      changing the name to something that does not fit the required reading values.

        Attachments

          Activity

            People

            • Assignee:
              psonal Pallavi Sonal (Inactive)
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: