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.

Library does not match the bytecode for class XXX

See original GitHub issue

Short description

When using libraries built with lombok and attaching source with lombok annotations, IntelliJ complains about mismatch between source and class file.

Expected behavior

IntelliJ should not complain about mismatch since the source, when lombok-ed, will compile to the provided class.

Version information

  • IDEA Version: IntelliJ IDEA 2017.3.2 (Community Edition) Build #IC-173.4127.27, built on December 25, 2017 JRE: 1.8.0_152-release-1024-b8 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Linux 4.10.0-42-generic
  • JDK Version: 1.8.0_111
  • OS Type & Version: Ubuntu 16.04 LTS
  • Lombok Plugin Version: 0.15.17.2
  • Lombok Dependency Version: 1.16.6

Steps to reproduce

  1. In a source root run the following

mvn archetype:generate -DgroupId=com.test.rb.m1 -DartifactId=module1 -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

mvn archetype:generate -DgroupId=com.test.rb.m2 -DartifactId=module2 -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

  1. update module 1 pom.xml: 2.1 add lombok dependency
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.6</version>
            <scope>provided</scope>
        </dependency>

2.2 add source plugin

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
  1. update module 1 App.java:
@Setter
@Getter
public class App {
    private String myField;

    @SneakyThrows
    public void ex() {
        throw new Exception("ex");
    }

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}
  1. update module 2 pom.xml - add dependency on module 1:
        <dependency>
            <groupId>com.test.rb.m1</groupId>
            <artifactId>module1</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
  1. run “mvn install” on module 1
  2. open module 2 in IntelliJ, open class “com.test.rb.m1.App”

IntelliJ shows a red error “Library source does not match the bytecode for class App”

Sample project

Please provide a sample project that exhibits the problem. See lombok_bug.tar.gz](https://github.com/mplushnikov/lombok-intellij-plugin/files/1620326/lombok_bug.tar.gz) You should also include .idea folder so we can inspect the settings.

  • [X ] Sample project provided - [
  • [X ] I am able to reproduce this error on the sample project by following the steps described above

Additional information

no

Stacktrace

none

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:30
  • Comments:10

github_iconTop GitHub Comments

4reactions
wujun8commented, Aug 22, 2018

@mplushnikov Any updates on this?

1reaction
maxidelocommented, May 2, 2019

I’ve done a work a round that helped me to solve this problem. Using this plugin (https://plugins.gradle.org/plugin/io.freefair.lombok) what I do is to delombok my files and use them to create the source. It’s not the best solution but at least now the source is pure Java and it can be debugged.

build.gradle

plugins {
    id "io.freefair.lombok" version "3.2.1"
}

apply plugin: 'maven-publish'

task sourcesJar(type: Jar) {
    from 'build/delombok/main'
    archiveClassifier = 'sources'
}

publishing {
    ...
}

tasks.getByName("publish").dependsOn(delombok)
Read more comments on GitHub >

github_iconTop Results From Across the Web

[cas-user] idea: library source does not match the bytecode for ...
[cas-user] idea: library source does not match the bytecode for class XXX ... When I click the class `org.apereo.cas.web.flow.configurer.
Read more >
Library Source Does Not Match The Bytecode For ... - ADocLib
library source does not match the bytecode for class 1. Use lombok disable lombok 2. Invalidate caches /restart Clear the idea cache and...
Read more >
library source does not match the bytecode for class - 上尤流苏
但是当pom.xml引入了新的版本,此时,再次阅读源码时,就会提示”library source does not match the bytecode for class“ 库源与类的字节码不匹配.
Read more >
彻底解决Library source does not match the bytecode_陌路
Library source does not match the bytecode for class 最佳解决方案首先分析问题打完的jar包,编译的后class跟java文件不一致,原因是重新打包后还是 ...
Read more >
[亲测]完美解决IDEA下因Lombok插件产生的Library source ...
android studio Library source does not match the bytecode for class 这个错误是引用的aar或者jar中的某些代码,还是旧的库中的文件,可能的原因是android Studio 引用 ...
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