Merge pull request #9454 from kwoyke/JAVA-1782-main
JAVA-1782: Remove byte-buddy dep from the main pom.xml
This commit is contained in:
commit
4cd1dc51f8
|
@ -0,0 +1,40 @@
|
||||||
|
package com.baeldung.varargs;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
public class HeapPollutionUnitTest {
|
||||||
|
|
||||||
|
@Test(expected = ClassCastException.class)
|
||||||
|
public void givenGenericVararg_whenUsedUnsafe_shouldThrowClassCastException() {
|
||||||
|
String one = firstOfFirst(Arrays.asList("one", "two"), Collections.emptyList());
|
||||||
|
|
||||||
|
assertEquals("one", one);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = ClassCastException.class)
|
||||||
|
public void givenGenericVararg_whenRefEscapes_mayCauseSubtleBugs() {
|
||||||
|
String[] args = returnAsIs("One", "Two");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String firstOfFirst(List<String>... strings) {
|
||||||
|
List<Integer> ints = Collections.singletonList(42);
|
||||||
|
Object[] objects = strings;
|
||||||
|
objects[0] = ints;
|
||||||
|
|
||||||
|
return strings[0].get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> T[] toArray(T... arguments) {
|
||||||
|
return arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> T[] returnAsIs(T a, T b) {
|
||||||
|
return toArray(a, b);
|
||||||
|
}
|
||||||
|
}
|
|
@ -200,7 +200,7 @@ public class ReflectionUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenClassField_whenSetsAndGetsValue_thenCorrect() throws Exception {
|
public void givenClassField_whenSetsAndGetsValue_thenCorrect() throws Exception {
|
||||||
final Class<?> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
|
final Class<?> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
|
||||||
final Bird bird = (Bird) birdClass.newInstance();
|
final Bird bird = (Bird) birdClass.getConstructor().newInstance();
|
||||||
final Field field = birdClass.getDeclaredField("walks");
|
final Field field = birdClass.getDeclaredField("walks");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ public class ReflectionUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenMethod_whenInvokes_thenCorrect() throws Exception {
|
public void givenMethod_whenInvokes_thenCorrect() throws Exception {
|
||||||
final Class<?> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
|
final Class<?> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
|
||||||
final Bird bird = (Bird) birdClass.newInstance();
|
final Bird bird = (Bird) birdClass.getConstructor().newInstance();
|
||||||
final Method setWalksMethod = birdClass.getDeclaredMethod("setWalks", boolean.class);
|
final Method setWalksMethod = birdClass.getDeclaredMethod("setWalks", boolean.class);
|
||||||
final Method walksMethod = birdClass.getDeclaredMethod("walks");
|
final Method walksMethod = birdClass.getDeclaredMethod("walks");
|
||||||
final boolean walks = (boolean) walksMethod.invoke(bird);
|
final boolean walks = (boolean) walksMethod.invoke(bird);
|
||||||
|
|
|
@ -26,6 +26,17 @@ public class StringToIntOrIntegerUnitTest {
|
||||||
assertThat(result).isEqualTo(new Integer(42));
|
assertThat(result).isEqualTo(new Integer(42));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenString_whenCallingValueOf_shouldCacheSomeValues() {
|
||||||
|
for (int i = -128; i <= 127; i++) {
|
||||||
|
String value = i + "";
|
||||||
|
Integer first = Integer.valueOf(value);
|
||||||
|
Integer second = Integer.valueOf(value);
|
||||||
|
|
||||||
|
assertThat(first).isSameAs(second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenString_whenCallingIntegerConstructor_shouldConvertToInt() {
|
public void givenString_whenCallingIntegerConstructor_shouldConvertToInt() {
|
||||||
String givenString = "42";
|
String givenString = "42";
|
||||||
|
|
|
@ -225,6 +225,12 @@
|
||||||
<groupId>io.dropwizard.metrics</groupId>
|
<groupId>io.dropwizard.metrics</groupId>
|
||||||
<artifactId>metrics-core</artifactId>
|
<artifactId>metrics-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.bytebuddy</groupId>
|
||||||
|
<artifactId>byte-buddy</artifactId>
|
||||||
|
<version>${byte-buddy.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<!-- jhipster-needle-maven-add-dependency -->
|
<!-- jhipster-needle-maven-add-dependency -->
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,13 @@
|
||||||
<artifactId>renjin-script-engine</artifactId>
|
<artifactId>renjin-script-engine</artifactId>
|
||||||
<version>${renjin.version}</version>
|
<version>${renjin.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
<groupId>net.bytebuddy</groupId>
|
||||||
|
<artifactId>byte-buddy</artifactId>
|
||||||
|
<version>${byte-buddy.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
<groupId>org.apache.kafka</groupId>
|
<groupId>org.apache.kafka</groupId>
|
||||||
<artifactId>kafka-clients</artifactId>
|
<artifactId>kafka-clients</artifactId>
|
||||||
<version>${kafka.version}</version>
|
<version>${kafka.version}</version>
|
||||||
|
|
|
@ -32,11 +32,6 @@
|
||||||
<groupId>io.rest-assured</groupId>
|
<groupId>io.rest-assured</groupId>
|
||||||
<artifactId>rest-assured</artifactId>
|
<artifactId>rest-assured</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>net.bytebuddy</groupId>
|
|
||||||
<artifactId>byte-buddy</artifactId>
|
|
||||||
<version>${byte-buddy.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
|
6
pom.xml
6
pom.xml
|
@ -69,12 +69,6 @@
|
||||||
<version>${hamcrest-all.version}</version>
|
<version>${hamcrest-all.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>net.bytebuddy</groupId>
|
|
||||||
<artifactId>byte-buddy</artifactId>
|
|
||||||
<version>${byte-buddy.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
|
|
Loading…
Reference in New Issue