question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

support projects with module-info.java

See original GitHub issue

Short description

The plugin should support code which is modularize with Jigsaw. Simply placing a module-info.java creates problems on code which worked before. And in context of Maven projects. Unmodularized code works with Java 11.

Expected behavior

Same a before or with javac -cp lombok.jar -p lombok.jar *.java

Version information

  • IDEA Version: _2018.3.2
  • JDK Version: java 11 2018-09-25
  • OS Type & Version: Mac OS 10.13.6 (17G4015)
  • Lombok Plugin Version: v0.23-2018.3
  • Lombok Dependency Version: 1.18.4, from Maven and separate download

Steps to reproduce

What steps do we need to take to reproduce this issue?

  1. Run the class Main => fails
  2. remove module-info.java => Main runs
  3. Revert from CVS
  4. place the file lombok.jar into src/main/java
  5. javac -cp lombok.jar -p lombok.jar *.java => Main runs

Sample project

Please provide a sample project that exhibits the problem. You should also include .idea folder so we can inspect the settings.

Additional information

The usage of the Maven Lombok plugin is longterm goal. The the IntelliJ Lombok plugin should work too.

Stacktrace

No stack trace as such. But the following error text shows up:


Person.java:1: error: package lombok does not exist
import lombok.Data;
             ^
Person.java:3: error: cannot find symbol
@Data
 ^
  symbol: class Data
Main.java:4: error: constructor Person in class Person cannot be applied to given types;
		final Person person = new Person("A", "B", 10);
		                      ^
  required: no arguments
  found: String,String,int
  reason: actual and formal argument lists differ in length
Main.java:6: error: cannot find symbol
		System.out.println(person.getFirstName());
		                         ^
  symbol:   method getFirstName()
  location: variable person of type Person
Main.java:7: error: cannot find symbol
		System.out.println(person.getSecondName());
		                         ^
  symbol:   method getSecondName()
  location: variable person of type Person
Main.java:8: error: cannot find symbol
		System.out.println(person.getAge());
		                         ^
  symbol:   method getAge()
  location: variable person of type Person
6 errors

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

1reaction
itgoldcommented, Dec 9, 2019

Adding module-info.java to the project breaks intellij-lombok. Intellij Editor doesn’t show any errors but building the project fails with a bunch of “cannot find symbol”.

Removing module-info.java from the project solves the problem. But it is kind of so-so solution 😦

Gradle build the project with no issues even with modules enabled and the following dependencies: compileOnly group: ‘org.projectlombok’, name: ‘lombok’, version: ‘1.18.10’ annotationProcessor group: ‘org.projectlombok’, name: ‘lombok’, version: ‘1.18.10’

0reactions
quophyiecommented, Mar 14, 2020

I have used a work around for this. I am working with spring boot and I use Gradle as my build tool so this may be helpful to other people with a similar setup whilst this issue gets looked at. I wanted to debug my spring boot app when I ran into this issue so I hope the configuration below will let other people set up an IntelliJ Remote Debug Configuration so they can compile and debug thier app with Lombok from IntelliJ

  1. In my build.gradle, I added
bootRun {   
    jvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,address=5005,suspend=n"]
}   
dependencies {
    compileOnly 'org.projectlombok:lombok:1.18.12'
    annotationProcessor 'org.projectlombok:lombok:1.18.12'
    testCompileOnly 'org.projectlombok:lombok:1.18.12'
    testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
}
  1. Create a Remote Run/Debug Configuration in Intellij . See Remote Debugging with IntelliJ or Run/Debug Configuration: Remote Debug

  2. Enable Annotation Preprocessing in IntelliJ like so

Preferences | Build, Execution, Deployment | Compiler | Annotation Processors and make sure of the following:

Enable annotation processing box is checked
Obtain processors from project classpath option is selected

This just makes sure that IntelliJ will recognise the Lombok annotations. It does not address the compilation issue above

  1. Set your breakpoints

  2. run ./gradlew bootRun from the terminal / cmd

  3. Run the Debug configuration from step 2

Your breakpoints should now be activated

If you have some tests that you want to Debug, you can do the following

  1. Set some breakpoints in your test classes / methods

  2. run ./gradlew test --debug-jvm

  3. Wait for the jvm debugger to suspend and Look out for the log message below in your console

Listening for transport dt_socket at address: 5005

  1. Run the Debug configuration from step 2

Your breakpoints should now be activated

Tip: if you do not want to use the --debug-jvm option on the command line when running the ./gradlew test command, you can add the test configuration below to you build.gradle file. Note that suspend=y. This causes the debugger to suspend

test {
   jvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,address=5005,suspend=y"]
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building Java Modules Sample - Gradle User Manual
This sample shows how to create a multi-project containing Java Modules. ... Java sources can be turned into a module by adding a...
Read more >
Support for Java 9 Modules in IntelliJ IDEA 2017.1
Let's take a look at a basic example of a modular project. ... IntelliJ IDEA lets you create a new module-info.java for your...
Read more >
Older projects with module-info - Apache Maven
Older projects with module-info. Projects that want to be compatible with older versions of Java (i.e 1.8 or below bytecode and API), ...
Read more >
A Guide to Java 9 Modularity - Baeldung
This, of course, is the same as any other Java project so it should ... a special file at the root of our...
Read more >
Embracing Java 9 and beyond with Eclipse JDT
The latest release, Eclipse Photon is now available and supports Java 9 and ... New Java Project Menu which has by default Create...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found