Search code examples
javamaven

Maven compile huge Java file


I have a Java-File which holds WSDL-Strings for testing purposes. The file has 469kb Eclipse compiles the Project without problems. But when i try "mvn clean compile" i get an error:

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error:


The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
        at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:460)
        at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:2062)
        at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:460)
        at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:2062)
        at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:460)
        at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:2062)
        at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:460)
        at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:2062)
        at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565)

...

        at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:460)

[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.265s

my compiler plugin is configured like that

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>

i already tried to set

MAVEN_OPTS=-Xmx1024m

in my windows7

why can eclipse compile this file but maven not?


Solution

  • Your problem is not Maven but the Java compiler itself. But even if the compiler would not crash you will quite likly exeed the class file's code_length of 64 KiB.

    I suggest splitting the Java source into multiple source files.