Skip to content

Commit 528604a

Browse files
authored
[BAEL-5406] IncompatibleClassChange Error (#16786)
* [BAEL-5406] IncompatibleClassChange Error * [BAEL-5406] IncompatibleClassChange Error * [BAEL-5406] IncompatibleClassChange Error * [BAEL-5406] IncompatibleClassChange Error * [BAEL-5406] IncompatibleClassChange Error * [BAEL-5406] IncompatibleClassChange Error * [BAEL-5406] IncompatibleClassChange Error Review comments * [BAEL-5406] IncompatibleClassChange Error Review comments * [BAEL-5406] IncompatibleClassChange Error Review comments * [BAEL-5406] IncompatibleClassChange Error Review comments
1 parent a282aec commit 528604a

File tree

6 files changed

+65
-3
lines changed

6 files changed

+65
-3
lines changed

libraries-bytecode/pom.xml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66
<artifactId>libraries-bytecode</artifactId>
77
<version>0.0.1-SNAPSHOT</version>
@@ -40,6 +40,28 @@
4040
<artifactId>asm-util</artifactId>
4141
<version>${asm.version}</version>
4242
</dependency>
43+
<!--
44+
Importing the libraries as jars using system path. These are two versions of the same library, which is generated
45+
from the code inside /incompatibleclasschange/libraries/modified and /incompatibleclasschange/libraries/original
46+
47+
To simulate the incompatible class change error, build the jars from the above-mentioned paths, place them in the locations mentioned in
48+
the systemPath property and uncomment the following lines.
49+
50+
-->
51+
<!--<dependency>
52+
<groupId>org.dinosaur</groupId>
53+
<artifactId>dinosaur</artifactId>
54+
<version>1</version>
55+
<scope>system</scope>
56+
<systemPath>${project.basedir}/src/main/resources/dinosaur-1.jar</systemPath>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.dinosaur</groupId>
60+
<artifactId>dinosaur</artifactId>
61+
<version>2</version>
62+
<scope>system</scope>
63+
<systemPath>${project.basedir}/src/main/resources/dinosaur-2.jar</systemPath>
64+
</dependency>-->
4365
</dependencies>
4466

4567
<build>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.baeldung.incompatibleclasschange.libraries.modified;
2+
3+
public class Dinosaur {
4+
5+
/**
6+
* This is the modified version of the library where the species() method is made static.
7+
* The original version of the same hierarchy is not static.
8+
*
9+
*/
10+
public static void species(String sp) {
11+
if (sp == null) {
12+
System.out.println("I am a generic Dinosaur");
13+
} else {
14+
System.out.println(sp);
15+
}
16+
}
17+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.baeldung.incompatibleclasschange.libraries.original;
2+
3+
public class Coelophysis extends Dinosaur {
4+
public void mySpecies() {
5+
species("My species is Coelophysis of the Triassic Period");
6+
}
7+
8+
public static void main(String[] args) {
9+
Coelophysis coelophysis = new Coelophysis();
10+
coelophysis.mySpecies();
11+
}
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.baeldung.incompatibleclasschange.libraries.original;
2+
3+
public class Dinosaur {
4+
public void species(String sp) {
5+
if (sp == null) {
6+
System.out.println("I am a generic Dinosaur");
7+
} else {
8+
System.out.println(sp);
9+
}
10+
}
11+
}
2.52 KB
Binary file not shown.
2.52 KB
Binary file not shown.

0 commit comments

Comments
 (0)