这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
28 changes: 25 additions & 3 deletions libraries-bytecode/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>libraries-bytecode</artifactId>
<version>0.0.1-SNAPSHOT</version>
Expand Down Expand Up @@ -40,6 +40,28 @@
<artifactId>asm-util</artifactId>
<version>${asm.version}</version>
</dependency>
<!--
Importing the libraries as jars using system path. These are two versions of the same library, which is generated
from the code inside /incompatibleclasschange/libraries/modified and /incompatibleclasschange/libraries/original

To simulate the incompatible class change error, build the jars from the above-mentioned paths, place them in the locations mentioned in
the systemPath property and uncomment the following lines.

-->
<!--<dependency>
<groupId>org.dinosaur</groupId>
<artifactId>dinosaur</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/dinosaur-1.jar</systemPath>
</dependency>
<dependency>
<groupId>org.dinosaur</groupId>
<artifactId>dinosaur</artifactId>
<version>2</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/dinosaur-2.jar</systemPath>
</dependency>-->
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.baeldung.incompatibleclasschange.libraries.modified;

public class Dinosaur {

/**
* This is the modified version of the library where the species() method is made static.
* The original version of the same hierarchy is not static.
*
*/
public static void species(String sp) {
if (sp == null) {
System.out.println("I am a generic Dinosaur");
} else {
System.out.println(sp);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.baeldung.incompatibleclasschange.libraries.original;

public class Coelophysis extends Dinosaur {
public void mySpecies() {
species("My species is Coelophysis of the Triassic Period");
}

public static void main(String[] args) {
Coelophysis coelophysis = new Coelophysis();
coelophysis.mySpecies();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.baeldung.incompatibleclasschange.libraries.original;

public class Dinosaur {
public void species(String sp) {
if (sp == null) {
System.out.println("I am a generic Dinosaur");
} else {
System.out.println(sp);
}
}
}
Binary file not shown.
Binary file not shown.