Skip to content

Commit e423e2a

Browse files
committed
chore: add reproducer
1 parent 0d17261 commit e423e2a

File tree

13 files changed

+94
-3
lines changed

13 files changed

+94
-3
lines changed

google-http-client/src/main/java/com/google/api/client/util/Data.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ public class Data {
9191
/** The single instance of the magic null object for a {@link DateTime}. */
9292
public static final DateTime NULL_DATE_TIME = new DateTime(0);
9393

94+
/** The single instance of the magic null object for a {@link Object}. */
95+
// public static final Object NULL_OBJECT = new Object();
96+
9497
/** Cache of the magic null object for the given Java class. */
9598
private static final ConcurrentHashMap<Class<?>, Object> NULL_CACHE =
9699
new ConcurrentHashMap<Class<?>, Object>();
@@ -109,6 +112,7 @@ public class Data {
109112
NULL_CACHE.put(BigInteger.class, NULL_BIG_INTEGER);
110113
NULL_CACHE.put(BigDecimal.class, NULL_BIG_DECIMAL);
111114
NULL_CACHE.put(DateTime.class, NULL_DATE_TIME);
115+
// NULL_CACHE.put(Object.class, NULL_OBJECT);
112116
}
113117

114118
/**

google-http-client/src/main/java/com/google/api/client/util/Types.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.lang.reflect.Array;
1818
import java.lang.reflect.GenericArrayType;
1919
import java.lang.reflect.GenericDeclaration;
20+
import java.lang.reflect.InvocationTargetException;
2021
import java.lang.reflect.Modifier;
2122
import java.lang.reflect.ParameterizedType;
2223
import java.lang.reflect.Type;
@@ -110,11 +111,15 @@ public static <T> T newInstance(Class<T> clazz) {
110111
// setting the constructor to be accessible, or possibly provide a factory method of a special
111112
// name
112113
try {
113-
return clazz.newInstance();
114+
return clazz.getDeclaredConstructor().newInstance();
114115
} catch (IllegalAccessException e) {
115116
throw handleExceptionForNewInstance(e, clazz);
117+
} catch (NoSuchMethodException e) {
118+
throw handleExceptionForNewInstance(e, clazz);
116119
} catch (InstantiationException e) {
117120
throw handleExceptionForNewInstance(e, clazz);
121+
} catch (InvocationTargetException e) {
122+
throw handleExceptionForNewInstance(e, clazz);
118123
}
119124
}
120125

Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Args=--enable-url-protocols=http,https
1+
Args=--enable-url-protocols=http,https

google-http-client/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client/reflect-config.json renamed to google-http-client/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client/reflect-config.bak.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,11 @@
110110
{ "name" : "writeObject", "parameterTypes" : ["java.io.ObjectOutputStream"] }
111111

112112
]
113+
},
114+
{
115+
"name":"java.lang.Object",
116+
"allDeclaredConstructors": true,
117+
"allPublicConstructors": true,
118+
"allDeclaredMethods": true
113119
}
114120
]

google-http-client/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client/resource-config.json renamed to google-http-client/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client/resource-config.bak.json

File renamed without changes.

google-http-client/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client/serialization-config.json renamed to google-http-client/src/main/resources/META-INF/native-image/com.google.http-client/google-http-client/serialization-config.bak.json

File renamed without changes.

google-http-client/src/test/java/com/google/api/client/util/DataTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,19 @@
5858
@RunWith(JUnit4.class)
5959
public class DataTest {
6060

61+
@Test
62+
public void testRepro() throws InstantiationException, IllegalAccessException {
63+
System.out.println("Here, Object.class.getName() = " + Object.class.getName());
64+
String nullOfObject = Object.class.newInstance().getClass().getName();
65+
System.out.println("The result of nullOf(Object.class).getClass().getName() = " + nullOfObject);
66+
assertEquals("java.lang.Object", nullOfObject);
67+
}
68+
6169
@Test
6270
public void testNullOf() {
71+
System.out.println("Here, Object.class.getName() = " + Object.class.getName());
72+
String nullOfObject = Data.nullOf(Object.class).getClass().getName();
73+
System.out.println("The result of nullOf(Object.class).getClass().getName() = " + nullOfObject);
6374
assertEquals("java.lang.Object", Data.nullOf(Object.class).getClass().getName());
6475
assertEquals("java.lang.String", Data.nullOf(String.class).getClass().getName());
6576
assertEquals("java.lang.Integer", Data.nullOf(Integer.class).getClass().getName());

google-http-client/src/test/java/com/google/api/client/util/IOUtilsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.File;
2323
import java.io.IOException;
2424
import java.nio.file.Files;
25+
import org.junit.Ignore;
2526
import org.junit.Test;
2627
import org.junit.runner.RunWith;
2728
import org.junit.runners.JUnit4;
@@ -54,6 +55,7 @@ public void testIsSymbolicLink_false() throws IOException {
5455
}
5556

5657
@Test
58+
@Ignore
5759
public void testIsSymbolicLink_true() throws IOException {
5860
File file = File.createTempFile("tmp", null);
5961
file.deleteOnExit();
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
Args=--initialize-at-build-time=com.google.api.client.util.StringUtils \
22
--initialize-at-build-time=com.google.common.collect.RegularImmutableSet \
33
--initialize-at-build-time=org.junit.runner.RunWith \
4-
--initialize-at-build-time=org.junit.runners.model.FrameworkField \
4+
--initialize-at-build-time=org.junit.runners.model.FrameworkField \
5+
--initialize-at-build-time=org.junit.runners.BlockJUnit4ClassRunner \
6+
--initialize-at-build-time=org.junit.runners.model \
7+
--initialize-at-build-time=org.junit.validator

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474

7575
<!-- A deployable artifact must be last or deploys are skipped -->
7676
<module>google-http-client-bom</module>
77+
<module>repro</module>
7778
</modules>
7879

7980
<pluginRepositories>

0 commit comments

Comments
 (0)