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

javac with a annotation processor returns incorrect error code

XMLWordPrintable

    • generic
    • generic

      FULL PRODUCT VERSION :
      java version "1.8.0_40"
      Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
      Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.10240]

      A DESCRIPTION OF THE PROBLEM :
      when you compile with a corrupted jar and a annotation processor in the class path the javac command does not exit with a error code(error code 0). If you just compile with a corrupted jar in the classpath the javac command exits with a error code of 1. So for some reason having a annotation processor causes it to not return a correct error code.

      This issue was caught because our ant scripts returns successfully but our jar files had class files in them.

      I have also posted it on StackOverflow: http://stackoverflow.com/questions/35481375/javac-returning-incorrect-error-code-with-annotation-processor

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      javac -cp annotationProcessor.jar;corruptedJar.jar HelloWorld.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      it should error out with a error code of 1
      ACTUAL -
      it does not error out it just returns error code of 0 which means it was successful. But there are no generated class files.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      > javac -cp annotationProcessor.jar;corruptedJar.jar HelloWorld.java
      error: error reading corruptedJar.jar; error in opening zip file
      Using Test AnnotationProcessor
      > echo %errorlevel%
      0

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      HelloWorld.java
      public class HelloWorld {
      public static void main(String[] args) {
      System.out.println("hello world");
      }
      }

      AnnotationProcessor.java
      package com.test;

      import java.util.Set;

      import javax.annotation.processing.AbstractProcessor;
      import javax.annotation.processing.RoundEnvironment;
      import javax.annotation.processing.SupportedAnnotationTypes;
      import javax.annotation.processing.SupportedSourceVersion;
      import javax.lang.model.element.TypeElement;
      import javax.lang.model.SourceVersion;

      @SupportedSourceVersion(SourceVersion.RELEASE_8)
      @SupportedAnnotationTypes("*")
      public class AnnotationProcessor extends AbstractProcessor{

      public AnnotationProcessor() {
      System.out.println("Using Test AnnotationProcessor");
      }

      @Override
      public boolean process(Set<? extends TypeElement> arg0, RoundEnvironment arg1) {
      // TODO Auto-generated method stub
      return false;
      }

      }

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

        1. HelloWorld.java
          0.1 kB
          Abhijit Roy
        2. AnnotationProcessor.java
          0.8 kB
          Abhijit Roy

            aefimov Aleksej Efimov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: