Skip to content

Instantly share code, notes, and snippets.

@jqno
Created July 3, 2015 13:09
Show Gist options
  • Save jqno/1739d120887c785f3832 to your computer and use it in GitHub Desktop.
Save jqno/1739d120887c785f3832 to your computer and use it in GitHub Desktop.
CGLib IntelliJ NonNull issue
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.NoOp;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
public class MyObjectTest {
@Test
public void shouldVerifyHashCodeEquals() {
Enhancer e = new Enhancer();
e.setSuperclass(MyObject.class);
e.setCallbackType(NoOp.class);
e.createClass();
}
public static class MyObject {
@Override
@NotNull
public MyObject clone() {
return null;
}
}
}
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>cglib-intellij-problem</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.torstling.intellij</groupId>
<artifactId>notnull-instrumenter-maven-plugin</artifactId>
<version>0.1.0</version>
<executions>
<execution>
<goals>
<goal>instrument</goal>
<goal>tests-instrument</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.intellij</groupId>
<artifactId>annotations</artifactId>
<version>12.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.1</version>
</dependency>
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment