Bug 45228 - more specific Error Starting Modern Compiler message
Summary: more specific Error Starting Modern Compiler message
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.7.0
Hardware: PC Windows XP
: P2 enhancement with 1 vote (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-18 11:36 UTC by Larry Heidt
Modified: 2008-06-30 15:03 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Larry Heidt 2008-06-18 11:36:33 UTC
After many years of incremental development, our nightly build started failing with the “Error starting modern compiler” message.  After investigation and trial and error, the problem was resolved simply by adding the fork=”yes” option to our javac task.  

Even the –verbose switch was not helpful in the investigation of this issue.  Please investigate displaying some useful output instead of the generic “Error starting modern compiler” message.
Comment 1 Larry Heidt 2008-06-18 12:34:06 UTC
FYI, removing the "fork=yes" work-around and adding the printStackTrace() call below to the end of the execute() method in the Javac13 class: 

    } else {
/***/   ex.printStackTrace();   //*** NEW HACK
        throw new BuildException("Error starting modern compiler",
                                 ex, location);

results in the following extra info in our case:

    [javac] Compiling 408 source files to C:\hk\dvlp\Wh\Source\components\WebApps\build\classes
    [javac] java.lang.reflect.InvocationTargetException
    [javac] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [javac] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [javac] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [javac] 	at java.lang.reflect.Method.invoke(Method.java:597)
    [javac] 	at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:56)
    [javac] 	at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:997)
    [javac] 	at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:820)
    [javac] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    [javac] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [javac] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [javac] 	at java.lang.reflect.Method.invoke(Method.java:597)
    [javac] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
    [javac] 	at org.apache.tools.ant.Task.perform(Task.java:348)
    [javac] 	at org.apache.tools.ant.Target.execute(Target.java:357)
    [javac] 	at org.apache.tools.ant.Target.performTasks(Target.java:385)
    [javac] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
    [javac] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
    [javac] 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    [javac] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
    [javac] 	at org.apache.tools.ant.Main.runBuild(Main.java:698)
    [javac] 	at org.apache.tools.ant.Main.startAnt(Main.java:199)
    [javac] 	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
    [javac] 	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
    [javac] Caused by: java.lang.OutOfMemoryError: Java heap space
    [javac] 	at java.util.jar.Manifest$FastInputStream.<init>(Manifest.java:315)
    [javac] 	at java.util.jar.Manifest$FastInputStream.<init>(Manifest.java:310)
    [javac] 	at java.util.jar.Manifest.read(Manifest.java:178)
    [javac] 	at java.util.jar.Manifest.<init>(Manifest.java:52)
    [javac] 	at java.util.jar.JarFile.getManifestFromReference(JarFile.java:165)
    [javac] 	at java.util.jar.JarFile.getManifest(JarFile.java:146)
    [javac] 	at sun.misc.URLClassPath$JarLoader$2.getManifest(URLClassPath.java:693)
    [javac] 	at java.net.URLClassLoader.defineClass(URLClassLoader.java:221)
    [javac] 	at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    [javac] 	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    [javac] 	at java.security.AccessController.doPrivileged(Native Method)
    [javac] 	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    [javac] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    [javac] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    [javac] 	at java.util.ResourceBundle$Control.newBundle(ResourceBundle.java:2383)
    [javac] 	at java.util.ResourceBundle.loadBundle(ResourceBundle.java:1406)
    [javac] 	at java.util.ResourceBundle.findBundle(ResourceBundle.java:1365)
    [javac] 	at java.util.ResourceBundle.findBundle(ResourceBundle.java:1292)
    [javac] 	at java.util.ResourceBundle.findBundle(ResourceBundle.java:1292)
    [javac] 	at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1234)
    [javac] 	at java.util.ResourceBundle.getBundle(ResourceBundle.java:715)
    [javac] 	at com.sun.tools.javac.util.Messages.add(Messages.java:66)
    [javac] 	at com.sun.tools.javac.util.Messages.<init>(Messages.java:52)
    [javac] 	at com.sun.tools.javac.main.Main.getLocalizedString(Main.java:447)
    [javac] 	at com.sun.tools.javac.main.Main.resourceMessage(Main.java:421)
    [javac] 	at com.sun.tools.javac.main.Main.compile(Main.java:364)
    [javac] 	at com.sun.tools.javac.main.Main.compile(Main.java:279)
    [javac] 	at com.sun.tools.javac.main.Main.compile(Main.java:270)
    [javac] 	at com.sun.tools.javac.Main.compile(Main.java:69)
    [javac] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [javac] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [javac] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

BUILD FAILED
C:\hk\dvlp\Wh\Source\components\WebApps\etc\build.xml:105: Error starting Modern compiler
Comment 2 Larry Heidt 2008-06-30 15:03:00 UTC
suggest adding something like the "log" method and call below to the Javac13 class to reveal problems like the OutOfMemoryError above:

            log(ex);   //*** NEW
            throw new BuildException("Error starting modern compiler",
                                     ex, location);
        }
    }
}

/**
 * Log the specified Throwable.  
 * @param t the Throwable to log.
 */
private void log(Throwable t) {  
    if (getProject() == null) {  
        t.printStackTrace();
    } else { 
        StringWriter sw = new StringWriter();
        PrintWriter w = new PrintWriter(sw);
        t.printStackTrace(w);
        w.close();
        getProject().log(sw.toString(), Project.MSG_ERR);
    }
}