[PiranhaJava] Integrate piranha to our microservice
See original GitHub issueWe are working on integrating piranha to our micro-service. we followed the steps mentioned in the Readme file. We are using lombok in our service. When we ran the build, below error is observed.
Stack Trace:
`[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project qb-billing-service-app: Compilation failure
[ERROR] /Users/ssathyamurthy/dev/qb-billing-service/app/src/main/java/com/intuit/billingcomm/billing/integration/IAMTicketClientIntegration.java:[76,42] error: An unhandled exception was thrown by the Error Prone static analysis plugin.
[ERROR] Please report this at https://github.com/google/error-prone/issues/new and include the following:
[ERROR]
[ERROR] error-prone version: 2.4.0
[ERROR] BugPattern: Piranha
[ERROR] Stack Trace:
[ERROR] java.lang.ClassCastException: com.sun.tools.javac.tree.JCTree$JCBinary cannot be cast to com.sun.source.tree.ParenthesizedTree
[ERROR] at com.uber.piranha.XPFlagCleaner.matchIf(XPFlagCleaner.java:1021)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:451)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.visitIf(ErrorProneScanner.java:655)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.visitIf(ErrorProneScanner.java:152)
[ERROR] at com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1427)
[ERROR] at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
[ERROR] at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
[ERROR] at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
[ERROR] at com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
[ERROR] at com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:248)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:522)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:152)
[ERROR] at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
[ERROR] at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
[ERROR] at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
[ERROR] at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
[ERROR] at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
[ERROR] at com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:206)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:742)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:152)
[ERROR] at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898)
[ERROR] at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
[ERROR] at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
[ERROR] at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
[ERROR] at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
[ERROR] at com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
[ERROR] at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
[ERROR] at com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:187)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:550)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:152)
[ERROR] at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
[ERROR] at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
[ERROR] at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
[ERROR] at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
[ERROR] at com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
[ERROR] at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
[ERROR] at com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:144)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:562)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:152)
[ERROR] at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:591)
[ERROR] at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
[ERROR] at com.google.errorprone.scanner.Scanner.scan(Scanner.java:58)
[ERROR] at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
[ERROR] at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
[ERROR] at com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:120)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1404)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1353)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:946)
[ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:302)
[ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:162)
[ERROR] at com.sun.tools.javac.Main.compile(Main.java:57)
[ERROR] at com.sun.tools.javac.Main.main(Main.java:43)
[ERROR] `
Our Code where this issue in seen
@Override public @NonNull IAMTicket createAndRenewOfflineTicket(@NonNull String realmID) throws IAMTicketClientException {
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (4 by maintainers)
Top GitHub Comments
@ketkarameya - That’s nice 👍 I was dreading that I had to learn the rudiments of rust (Yet another programming language 😄 )… to be able to build the binary. But good to know that you folks are on top of that as well.
I will give this a shot at my end and see if I can get past my problem. Please bear with me if I keep coming back with some really silly questions until then. The notion of AST and tree-sitter are all new to me and a bit overwhelming as well 😃 and now have been added to the never ending list of things that I need to still figure out… 😃
Lastly… this is a fantastic library that you folks have built. I loved the engineering blog that was created for Piranha!! Awesome engineering stuff!!!
Lombok modifies the AST in memory during compilation, causing a number of issues when Error Prone tries to associate AST nodes back to the corresponding source code. In this case, it’s almost certain that Lombok is adding a conditional to the AST that doesn’t exist in the source, and there is something in that conditional that Piranha is trying to report/delete. Unfortunately, since the conditional itself doesn’t exist in the code, it can’t be reported on or deleted.
In general, there is no reasonable way to make Piranha refactor code that was injected by Lombok. Our best bet would be to:
lombok.addLombokGeneratedAnnotation = true
as part to the Lombok configuration@lombok.Generated
That will still sometimes fail to clean up flag usages inside java classes that use Lombok (since Lombok can move user code and nest it inside its own generated structures), but it will avoid an outright compiler crash. Doing any better than that would require encoding knowledge of (potentially many) relevant Lombok transformations inside Piranha.