How to show full compile error messages info in Checker FrameWork with line numbers etc -


i started using checker framework , have problem reproducible on 1 of example projects authors of framework. project available here: https://github.com/typetools/checker-framework/tree/master/docs/examples/gradleexamples

when run command root:

>gradle compilejava 

i receive compilation output:

       public static /*@nullable*/ object nullable = null;                                                   ^    required: @initialized @nonnull object          list.add(null); // error on line                  ^    required: @initialized @nonnull string 2 errors :compilejava failed 

as can see there no information errors occur class name, line number in code etc. did not find information in official manual compiler parameters can change output format appropriately. want error messages this:

~\gradleexample.java:33 error: ';' expected 

update:

i achieve behaviour on 3 machines:

    • os: microsoft windows 7 x64 ultimate sp1 [version 6.1.7601];
    • java: 1.8.0_73;
    • gradle: 2.14.
    • os: microsoft windows 10 x64 pro [version 10.0.14393];
    • java: 1.8.0_121;
    • gradle: 3.4.1.
    • os: microsoft windows 7 x64 ultimate sp1 [version 6.1.7601];
    • java: 1.8.0_121;
    • gradle: 3.4.1.

the absence of line numbers , class names experienced when running gradle. tried run checker maven , javac command line , worked perfectly.
configure checker framework gradle followed steps manual. there 3 steps:

  1. download framework;
  2. unzip create checker-framework directory;
  3. configure gradle include checker framework on classpath.

as understand, gradle steps 1 , 2 automatically when providing needed checker framework's jars through dependency management. nevertheless tried both options:

  1. dependency management:
    downloaded example project , executed "gradle compilejava" root of gradlejava7example project.
  2. manually writing paths in gradle build file:
    allprojects {          tasks.withtype(javacompile).all { javacompile compile ->              compile.options.compilerargs = [             '-processor', 'org.checkerframework.checker.nullness.nullnesschecker',             '-processorpath', "c:\\checker-framework-2.1.10\\checker\\dist\\checker.jar",             "-xbootclasspath/p:c:\\checker-framework-2.1.10\\checker\\dist\\jdk8.jar",             '-classpath', 'c:\\checker-framework-2.1.10\\checker\\dist\\checker.jar;c:\\checker-framework-2.1.10\\checker\\dist\\javac.jar'             ]         }     } 

i've found workaround. i'll explain later, if has same problem, add line javacompile tasks configuration:

allprojects {     tasks.withtype(javacompile).all { javacompile compile ->          system.setproperty("line.separator", "\n")  // <<<<<< add line          compile.options.compilerargs = [             '-processor', 'org.checkerframework.checker.nullness.nullnesschecker',             '-processorpath', "${configurations.checkerframework.aspath}",             "-xbootclasspath/p:${configurations.checkerframeworkannotatedjdk.aspath}"         ]     } } 

first of must problem not in checker framework @ all. managed reproduce same behavior mentioned in question without checker framework. have created little custom annotation processor. here code:

@supportedsourceversion(value = sourceversion.release_8) @supportedannotationtypes(value = {"*"}) public class myprocessor extends abstractprocessor{      @override     public boolean process(set<? extends typeelement> annotations, roundenvironment roundenv) {         string sepr = system.getproperty("line.separator");          processingenv.getmessager().printmessage(diagnostic.kind.error, "[error code] " + sepr + " catched!!!");          return true;     }  } 

as can see, printing message right away start. note used line separator provided java.lang.system class split message. when registered processor , tried run "gradle compilejava" gradle project produced following output:

:compilejava      catched!!!  1 error :compilejava failed 

the property "line.separator" windows os returns cr+lf: "\r\n". don't know why messager.printmessage(diagnostic.kind kind, charsequence msg) has behaviour, because when type system.err.print("[error code] " + sepr + " catched!!!") instead, works fine (note problem occur when use gradle, if run manually javac arguments or use maven everyting fine).
found if substitude provided system separator simple "\n" symbol compiler error messages displayed correctly. choose solution workaround.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -