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

javah command doesn't throw correct exit code in case of error

    Details

    • Subcomponent:
    • Resolved In Build:
      b21
    • CPU:
      sparc
    • OS:
      solaris_10
    • Verification:
      Verified

      Backports

        Description

        The javah command throws exit code zero even in case of errors. Here, is a sample code that generates it.

        package test;
        public class JavahTest{
                public static void main(String args){
                        System.out.println("Test Message");
                }
                private static native Object nativeTest();
        }

        To reproduce the problem please do the following.
        1. Compile the above program.
        2. Run javah JavaTest.
        This will throw the following error.
        error: cannot access JavahTest
        bad class file: ./JavahTest.class
        class file contains wrong class: test.JavahTest
        Please remove or make sure it appears in the correct subdirectory of the classpath.
        com.sun.tools.javac.util.Abort
                at com.sun.tools.javac.comp.Check.completionError(Check.java:173)
                at com.sun.tools.javadoc.DocEnv.loadClass(DocEnv.java:159)
                at com.sun.tools.javadoc.RootDocImpl.<init>(RootDocImpl.java:77)
                at com.sun.tools.javadoc.JavadocTool.getRootDocImpl(JavadocTool.java:157)
                at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:330)
                at com.sun.tools.javadoc.Start.begin(Start.java:128)
                at com.sun.tools.javadoc.Main.execute(Main.java:66)
                at com.sun.tools.javah.Main.main(Main.java:147)
        javadoc: error - fatal error
        2 errors

        But, the exit code of the command is not some non zero value. The command echo $? prints just zero.

        There are 2 issues here.
        1. The command doesn't throw proper exit code.
        2. It throws some javadoc error message which misleads.

        The javah command with which this behaviour is observed is bundled with jdk version 1.5.0-beta2-b45.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jjg Jonathan Gibbons
                  Reporter:
                  duke J. Duke (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: