mg6maciej / hrisey

Hrisey - boilerplate code suppressor tool for Android platform
MIT License
148 stars 11 forks source link

Cannot find symbol errors (JDK 8) #1

Open ghost opened 10 years ago

ghost commented 10 years ago

Hello,

I've recently learned auf hrisey and tried to use it. I'm on Android Studio with gradle and included hrisey using the following code:

dependencies {
    provided 'pl.mg6.hrisey:hrisey:0.3.+'
}

I've written a simple hrisey annotated class:

import org.parceler.Parcel;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Value;

@Parcel
@Value
@AllArgsConstructor
@NoArgsConstructor
@RequiredArgsConstructor
public class Product {
    @NonNull String title;
    @NonNull String url;
    @NonNull double price;
    @NonNull String image;
    @NonNull String source;
    String color = "";
}

When I try to compile the project with this class, I get errors like the following ones:

C:\ws\Presents\app\src\main\java\com\unitedinternet\presents\app\PresentsApp.java:67: error: cannot find symbol
                        setTransactionRevenue(product.getPrice()).
                                                     ^
  symbol:   method getPrice()
  location: variable product of type Product
C:\ws\Presents\app\src\main\java\com\unitedinternet\presents\app\PresentsApp.java:63: error: cannot find symbol
                        setBrand(product.getSource())).
                                        ^
  symbol:   method getSource()
  location: variable product of type Product
C:\ws\Presents\app\src\main\java\com\unitedinternet\presents\app\PresentsApp.java:61: error: cannot find symbol
                        setPrice(product.getPrice()).
                                        ^
  symbol:   method getPrice()
  location: variable product of type Product
C:\ws\Presents\app\src\main\java\com\unitedinternet\presents\app\PresentsApp.java:60: error: cannot find symbol
                        setName(product.getTitle()).
                                       ^

What could be the cause of these? And how to fix it?

Could this be caused by combining hrisey with Android Transfuse and Parceler?

mg6maciej commented 10 years ago

I have had similar problem when trying to use Lombok/Hrisey on a class annotated with dagger @Module, so I suppose the combination of Hrisey and Parceler is causing this. You may easily replace Parceler's @Parcel annotation with @hrisey.Parcelable. Your class will directly be android.os.Parcelable, so you will have to modify the code using wrap / unwrap on objects of your Product class.

ghost commented 10 years ago

@mg6maciej : Thanks for your suggestion. I've tried it, but I get the following error:

java.lang.NoSuchMethodError: com.sun.tools.javac.tree.JCTree$JCClassDecl.getExtendsClause()Lcom/sun/tools/javac/tree/JCTree;
    at hrisey.javac.handlers.ParcelableHandler.hasParcelableBaseClass(ParcelableHandler.java:219)
    at hrisey.javac.handlers.ParcelableHandler.generateWriteToParcelMethod(ParcelableHandler.java:203)
    at hrisey.javac.handlers.ParcelableHandler.handle(ParcelableHandler.java:140)
    at lombok.javac.HandlerLibrary$AnnotationHandlerContainer.handle(HandlerLibrary.java:107)
    at lombok.javac.HandlerLibrary.handleAnnotation(HandlerLibrary.java:242)
    at lombok.javac.JavacTransformer$AnnotationVisitor.visitAnnotationOnType(JavacTransformer.java:86)
    at lombok.javac.JavacNode.traverse(JavacNode.java:112)
    at lombok.javac.JavacAST.traverseChildren(JavacAST.java:123)
    at lombok.javac.JavacNode.traverse(JavacNode.java:75)
    at lombok.javac.JavacAST.traverseChildren(JavacAST.java:123)
    at lombok.javac.JavacNode.traverse(JavacNode.java:70)
    at lombok.javac.JavacAST.traverse(JavacAST.java:119)
    at lombok.javac.JavacTransformer.transform(JavacTransformer.java:70)
    at lombok.javac.apt.Processor.process(Processor.java:250)
    at lombok.core.AnnotationProcessor$JavacDescriptor.process(AnnotationProcessor.java:115)
    at lombok.core.AnnotationProcessor.process(AnnotationProcessor.java:165)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1173)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:859)
    at com.sun.tools.javac.main.Main.compile(Main.java:523)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
    at org.gradle.api.internal.tasks.compile.jdk6.Jdk6JavaCompiler.execute(Jdk6JavaCompiler.java:45)
    at org.gradle.api.internal.tasks.compile.jdk6.Jdk6JavaCompiler.execute(Jdk6JavaCompiler.java:38)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:96)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:49)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:35)
    at org.gradle.api.internal.tasks.compile.DelegatingJavaCompiler.execute(DelegatingJavaCompiler.java:29)
    at org.gradle.api.internal.tasks.compile.DelegatingJavaCompiler.execute(DelegatingJavaCompiler.java:20)
    at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:33)
    at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:24)
    at org.gradle.api.tasks.compile.Compile.performCompilation(Compile.java:165)
    at org.gradle.api.tasks.compile.Compile.compile(Compile.java:153)
    at org.gradle.api.tasks.compile.Compile.compile(Compile.java:87)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:236)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:223)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:201)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:533)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:516)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:289)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:86)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
    at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:76)
    at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:31)
    at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:150)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:45)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:42)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:71)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:69)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:69)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:60)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:186)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:36)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.java:39)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:51)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:155)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

In case this is relevant: I'm on JDK 1.8 64bit

mg6maciej commented 10 years ago

Oh, that's a different thing. I'll try to fix it this weekend. Thanks for mentioning JDK version. It's very likely relevant.

ghost commented 10 years ago

Thanks for taking a look at this. I'm looking forward to the new version :)

ghost commented 10 years ago

Just wondering, will this fix make it into a release version? I'd prefer to upgrade to JDK 8, but this bug is stopping me from doing so.

ghost commented 10 years ago

@mg6maciej : Any news on this?

mg6maciej commented 10 years ago

I've recently switched to 1.8 and cannot see this issue. What does java -version show on your machine?

mg6maciej commented 10 years ago

I have this error fixed, but a couple of other JDK8-related appeared. Will take some time before releasing a fix.

ScottPierce commented 9 years ago

Any news on this? @mg6maciej

mg6maciej commented 9 years ago

Hey Scott. Nothing changed recently. You may see Hrisey Gitter channel for more details on this.

ScottPierce commented 9 years ago

@mg6maciej Are there any plans to fix this in the near future? Being able to compile with Java 8 is starting to become a necessity for my team.

mg6maciej commented 9 years ago

Because my current languages for Android development are Kotlin and Groovy, I have no direct interest in making Hrisey compatible with JDK 8 (and things like Retrolambda) right now. If I'm forced back into Java for any reason, one of the first things I would do is finding the reason of this issue. That is however very unlikely to happen in the near future. However if anyone is willing to spend some time finding the root cause, I'd be very happy to help and make a fix. I've asked Lombok developers if they know a reason, but received no answer regarding this. They even though about adding Parcelable annotation to Lombok (which I'd love to do), but this blocks me from sending a pull request.

davidcueva commented 8 years ago

Hi Maciej

Android Studio 2.2 has removed the ability to use JDK 7 (see IdeSdksConfigurable.java). The IDE now requires JDK 8 for itself to run and also to execute Gradle.

For the large amount of people who still use Java for their Android development, this means that hrisey cannot be used anymore starting with with Android Studio 2.2.

Would you reconsider trying to find the root cause for this issue?

mg6maciej commented 8 years ago

Even tho I don't use Java for Android for some time now, I'd love to fix this issue. It saddens me to think there might be even a single project somewhere relying on Hrisey for boilerplate removal which still needs to be using JDK7. I had made a few unsuccessful attempts on finding the cause of this issue. // CC @ghostbuster91

ScottPierce commented 8 years ago

So because of this issue, we migrated off of hrisey a few months back. A few things happened as a result:

  1. Our build times dropped
  2. A memory leak with instant run where we had to kill the gradle daemon every 15 minutes or so during development to keep build times down disappeared. With instant run on a freshly warmed up daemon would be around 15 seconds. It wouldn't take long before all of our builds were 1+ minutes.
  3. All of our instant run issues went away.

I think that Lombok in general really isn't compatible with Android's new build system. It doesn't play nicely with hot swapping frameworks at all (including jrebel).

Because of this I'd recommend either kotlin data classes or autovalue as a replacement. I think you should drive people away from this project, and really lombok on Android in general. There might still be an argument for lombok in other java projects, but it caused WAY to much of a headache to risk having to migrate off of it again. I think I'm done with lombok in general.

mg6maciej commented 7 years ago

@ScottPierce Thanks for the info about leaks. I never noticed this myself, but I'll look out the next time I have to use Java for Android. I myself have use Kotlin for Android recently and even in the last project when we were forced by client's devs to use Java we used plain Lombok instead of Hrisey.

Apart from the cryptic messages this error gives, which makes it hard to even know where to start, that's the main reason I didn't fix it.

Agree Lombok/Hrisey is not the best tool for today's Android development, but it helped me a lot 2-3 years ago when I was using it in each and every project. And I'm happy it helped a few others at least for some time.

I'd still love to see this JDK8 incompatibility fixed... Hrisey "writes" the most efficient Parcelable code as far as I know.