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

Schemagen fails with StackOverflowError if element references containing class

    Details

    • Subcomponent:
    • Resolved In Build:
      b113
    • Verification:
      Not verified

      Backports

        Description

        Consider the following java class:
        import java.util.*;
        import javax.xml.bind.annotation.*;

        @XmlAccessorType(XmlAccessType.FIELD)
        @XmlType(name = "", propOrder = {
                    "fooObject"
                })
        @XmlRootElement(name = "Foo")

        public class Foo {
           protected List<Foo> fooObject;
           public List<Foo> getFooObject() {
               if (fooObject == null) {
                   fooObject = new ArrayList<Foo>();
               }
               return this.fooObject;
           }
        }

        schemagen invocation for this class fails on latest JDK9/8/7 builds with:
        java.lang.reflect.InvocationTargetException
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:502)
                at com.sun.tools.internal.jxc.SchemaGenerator.run(SchemaGenerator.java:151)
                at com.sun.tools.internal.jxc.SchemaGenerator.run(SchemaGenerator.java:76)
                at com.sun.tools.internal.jxc.SchemaGenerator.main(SchemaGenerator.java:67)
        Caused by: java.lang.RuntimeException: java.lang.StackOverflowError
                at com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:144)
                at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:93)
                at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:87)
                at com.sun.tools.internal.jxc.SchemaGenerator$Runner.compile(SchemaGenerator.java:251)
                ... 7 more
        Caused by: java.lang.StackOverflowError
                at java.lang.ref.Reference.<init>(Reference.java:304)
                at java.lang.ref.WeakReference.<init>(WeakReference.java:57)
                at java.lang.reflect.Proxy$Key1.<init>(Proxy.java:439)
                at java.lang.reflect.Proxy$KeyFactory.apply(Proxy.java:545)
                at java.lang.reflect.Proxy$KeyFactory.apply(Proxy.java:539)
                at java.lang.reflect.WeakCache.get(WeakCache.java:120)
                at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:419)
                at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:719)
                at com.sun.xml.internal.txw2.ContainerElement._cast(ContainerElement.java:353)
                at com.sun.xml.internal.txw2.ContainerElement._element(ContainerElement.java:374)
                at com.sun.xml.internal.txw2.ContainerElement.addElement(ContainerElement.java:218)
                at com.sun.xml.internal.txw2.ContainerElement.invoke(ContainerElement.java:145)
                at com.sun.proxy.$Proxy15.element(Unknown Source)
                at com.sun.xml.internal.bind.v2.schemagen.XmlSchemaGenerator$Namespace$2.write(XmlSchemaGenerator.java:1054)
                at com.sun.xml.internal.bind.v2.schemagen.Tree$Optional.write(Tree.java:170)
                at com.sun.xml.internal.bind.v2.schemagen.Tree$Repeated.write(Tree.java:196)
                at com.sun.xml.internal.bind.v2.schemagen.Tree$Group.write(Tree.java:240)
                at com.sun.xml.internal.bind.v2.schemagen.Tree.write(Tree.java:123)
                at com.sun.xml.internal.bind.v2.schemagen.Tree.write(Tree.java:126)
                at com.sun.xml.internal.bind.v2.schemagen.XmlSchemaGenerator$Namespace.writeClass(XmlSchemaGenerator.java:969)
                at com.sun.xml.internal.bind.v2.schemagen.XmlSchemaGenerator$Namespace.writeTypeRef(XmlSchemaGenerator.java:794)
                at com.sun.xml.internal.bind.v2.schemagen.XmlSchemaGenerator$Namespace.writeTypeRef(XmlSchemaGenerator.java:765)
                at com.sun.xml.internal.bind.v2.schemagen.XmlSchemaGenerator$Namespace.access$1800(XmlSchemaGenerator.java:491)
                at com.sun.xml.internal.bind.v2.schemagen.XmlSchemaGenerator$Namespace$2.write(XmlSchemaGenerator.java:1092)

          Issue Links

            Activity

            Hide
            aefimov Aleksej Efimov added a comment -
            This bug was fixed in JDK9 as part of sync process with standalone JAXWS project. See JDK-8150174 for details. Changes to XmlSchemaGenerator class solves the reported issue:
            http://hg.openjdk.java.net/jdk9/jdk9/jaxws/rev/ebff1bd3627a#l3.2
            Show
            aefimov Aleksej Efimov added a comment - This bug was fixed in JDK9 as part of sync process with standalone JAXWS project. See JDK-8150174 for details. Changes to XmlSchemaGenerator class solves the reported issue: http://hg.openjdk.java.net/jdk9/jdk9/jaxws/rev/ebff1bd3627a#l3.2
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/9e73bdac39ec
            User: aefimov
            Date: 2016-03-28 14:14:19 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/9e73bdac39ec User: aefimov Date: 2016-03-28 14:14:19 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/9e73bdac39ec
            User: lana
            Date: 2016-04-06 18:32:35 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/9e73bdac39ec User: lana Date: 2016-04-06 18:32:35 +0000

              People

              • Assignee:
                aefimov Aleksej Efimov
                Reporter:
                shadowbug Shadow Bug
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: