summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2017-03-09 16:19:08 +0000
committerPaul Duffin <paulduffin@google.com>2017-03-09 16:21:02 +0000
commit095e59560786379fec292d186cc862c5393916cb (patch)
tree581ecf0d783dfc13b46904c1b191fb5058df5409
parent0d5630ec510d256afd553cc54f3e61151cb662ca (diff)
downloadobjenesis-oreo-dr3-release.tar.gz
The recent upgrade of objenesis to 2.5 and the change to switch mockito-updated-target to use objenesis-target means that this code is no longer needed. Bug: 32912773 Test: make checkbuild Change-Id: I040c33b2a50fcdbb07e9a7cee27f05b0e7f1626e
-rw-r--r--objenesis-updated/Android.mk46
-rw-r--r--objenesis-updated/main/src/org/objenesis/Objenesis.java46
-rw-r--r--objenesis-updated/main/src/org/objenesis/ObjenesisBase.java99
-rw-r--r--objenesis-updated/main/src/org/objenesis/ObjenesisException.java49
-rw-r--r--objenesis-updated/main/src/org/objenesis/ObjenesisHelper.java84
-rw-r--r--objenesis-updated/main/src/org/objenesis/ObjenesisSerializer.java43
-rw-r--r--objenesis-updated/main/src/org/objenesis/ObjenesisStd.java43
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/ObjectInstantiator.java33
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/SerializationInstantiatorHelper.java49
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/android/Android10Instantiator.java64
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/android/Android17Instantiator.java87
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/android/Android18Instantiator.java87
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/android/AndroidSerializationInstantiator.java84
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/basic/AccessibleInstantiator.java34
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/basic/ClassDefinitionUtils.java230
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/basic/ConstructorInstantiator.java53
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/basic/FailingInstantiator.java37
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/basic/NewInstanceInstantiator.java45
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/basic/NullInstantiator.java36
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java175
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java72
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/basic/ProxyingInstantiator.java189
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/gcj/GCJInstantiator.java49
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java69
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java47
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/perc/PercInstantiator.java64
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/perc/PercSerializationInstantiator.java97
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/sun/MagicInstantiator.java269
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/sun/SunReflectionFactoryHelper.java96
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java60
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java65
-rw-r--r--objenesis-updated/main/src/org/objenesis/instantiator/sun/UnsafeFactoryInstantiator.java75
-rw-r--r--objenesis-updated/main/src/org/objenesis/strategy/BaseInstantiatorStrategy.java25
-rw-r--r--objenesis-updated/main/src/org/objenesis/strategy/InstantiatorStrategy.java35
-rw-r--r--objenesis-updated/main/src/org/objenesis/strategy/PlatformDescription.java198
-rw-r--r--objenesis-updated/main/src/org/objenesis/strategy/SerializingInstantiatorStrategy.java81
-rw-r--r--objenesis-updated/main/src/org/objenesis/strategy/SingleInstantiatorStrategy.java70
-rw-r--r--objenesis-updated/main/src/org/objenesis/strategy/StdInstantiatorStrategy.java100
-rw-r--r--objenesis-updated/tck-android/Android.mk36
-rw-r--r--objenesis-updated/tck-android/AndroidManifest.xml46
-rw-r--r--objenesis-updated/tck-android/src/org/objenesis/tck/android/ObjenesisTest.java92
-rw-r--r--objenesis-updated/tck-android/src/org/objenesis/tck/android/TckInstrumentation.java62
-rw-r--r--objenesis-updated/tck/resources/org/objenesis/tck/candidates/candidates.properties40
-rw-r--r--objenesis-updated/tck/resources/org/objenesis/tck/candidates/serializable-candidates.properties31
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/CandidateLoader.java131
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/Main.java161
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/Reporter.java81
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/TCK.java145
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/TextReporter.java259
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/ConstructorThrowingException.java27
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/ConstructorWithArguments.java34
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/ConstructorWithMandatoryArguments.java28
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultPackageConstructor.java26
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultPrivateConstructor.java26
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultProtectedConstructor.java26
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultPublicConstructor.java26
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/NoConstructor.java22
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableConstructorThrowingException.java31
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithArguments.java38
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithMandatoryArguments.java32
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultPackageConstructor.java30
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultPrivateConstructor.java30
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultProtectedConstructor.java30
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultPublicConstructor.java30
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableNoConstructor.java25
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableReplacer.java30
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableResolver.java30
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableWithAncestorThrowingException.java31
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/search/ClassEnumerator.java123
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/search/SearchWorkingInstantiator.java77
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/search/SearchWorkingInstantiatorListener.java26
-rw-r--r--objenesis-updated/tck/src/org/objenesis/tck/search/SystemOutListener.java32
72 files changed, 0 insertions, 4979 deletions
diff --git a/objenesis-updated/Android.mk b/objenesis-updated/Android.mk
deleted file mode 100644
index a76cbcd..0000000
--- a/objenesis-updated/Android.mk
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#
-
-LOCAL_PATH := $(call my-dir)
-
-#-------------------------------
-# build a target jar
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, main/src)
-# This is an updated version of objenesis to be kept in sync with
-# external/mockito/mockito-updated, updates to objenesis-updated
-# may be required anytime mockito is updated.
-LOCAL_MODULE := objenesis-updated-target
-# SDK 10 needed for ObjectStreamClass lookupAny
-LOCAL_SDK_VERSION := 10
-LOCAL_MODULE_TAGS := optional
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-#--------------------------------
-# Builds the Objenesis TCK as a device-targeted library
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := objenesis-updated-tck-target
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_STATIC_JAVA_LIBRARIES := objenesis-updated-target
-LOCAL_SRC_FILES := $(call all-java-files-under, tck/src)
-LOCAL_JAVA_RESOURCE_DIRS := tck/resources
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-include $(call all-makefiles-under, $(LOCAL_PATH))
diff --git a/objenesis-updated/main/src/org/objenesis/Objenesis.java b/objenesis-updated/main/src/org/objenesis/Objenesis.java
deleted file mode 100644
index 2618d1b..0000000
--- a/objenesis-updated/main/src/org/objenesis/Objenesis.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis;
-
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * Common interface to all kind of Objenesis objects
- *
- * @author Henri Tremblay
- */
-public interface Objenesis {
-
- /**
- * Will create a new object without any constructor being called
- *
- * @param <T> Type instantiated
- * @param clazz Class to instantiate
- * @return New instance of clazz
- */
- <T> T newInstance(Class<T> clazz);
-
- /**
- * Will pick the best instantiator for the provided class. If you need to create a lot of
- * instances from the same class, it is way more efficient to create them from the same
- * ObjectInstantiator than calling {@link #newInstance(Class)}.
- *
- * @param <T> Type to instantiate
- * @param clazz Class to instantiate
- * @return Instantiator dedicated to the class
- */
- <T> ObjectInstantiator<T> getInstantiatorOf(Class<T> clazz);
-}
diff --git a/objenesis-updated/main/src/org/objenesis/ObjenesisBase.java b/objenesis-updated/main/src/org/objenesis/ObjenesisBase.java
deleted file mode 100644
index 6afdf24..0000000
--- a/objenesis-updated/main/src/org/objenesis/ObjenesisBase.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.objenesis.instantiator.ObjectInstantiator;
-import org.objenesis.strategy.InstantiatorStrategy;
-
-/**
- * Base class to extend if you want to have a class providing your own default strategy. Can also be
- * instantiated directly.
- *
- * @author Henri Tremblay
- */
-public class ObjenesisBase implements Objenesis {
-
- /** Strategy used by this Objenesi implementation to create classes */
- protected final InstantiatorStrategy strategy;
-
- /** Strategy cache. Key = Class, Value = InstantiatorStrategy */
- protected ConcurrentHashMap<String, ObjectInstantiator<?>> cache;
-
- /**
- * Constructor allowing to pick a strategy and using cache
- *
- * @param strategy Strategy to use
- */
- public ObjenesisBase(InstantiatorStrategy strategy) {
- this(strategy, true);
- }
-
- /**
- * Flexible constructor allowing to pick the strategy and if caching should be used
- *
- * @param strategy Strategy to use
- * @param useCache If {@link ObjectInstantiator}s should be cached
- */
- public ObjenesisBase(InstantiatorStrategy strategy, boolean useCache) {
- if(strategy == null) {
- throw new IllegalArgumentException("A strategy can't be null");
- }
- this.strategy = strategy;
- this.cache = useCache ? new ConcurrentHashMap<String, ObjectInstantiator<?>>() : null;
- }
-
- @Override
- public String toString() {
- return getClass().getName() + " using " + strategy.getClass().getName()
- + (cache == null ? " without" : " with") + " caching";
- }
-
- /**
- * Will create a new object without any constructor being called
- *
- * @param clazz Class to instantiate
- * @return New instance of clazz
- */
- public <T> T newInstance(Class<T> clazz) {
- return getInstantiatorOf(clazz).newInstance();
- }
-
- /**
- * Will pick the best instantiator for the provided class. If you need to create a lot of
- * instances from the same class, it is way more efficient to create them from the same
- * ObjectInstantiator than calling {@link #newInstance(Class)}.
- *
- * @param clazz Class to instantiate
- * @return Instantiator dedicated to the class
- */
- @SuppressWarnings("unchecked")
- public <T> ObjectInstantiator<T> getInstantiatorOf(Class<T> clazz) {
- if(cache == null) {
- return strategy.newInstantiatorOf(clazz);
- }
- ObjectInstantiator<?> instantiator = cache.get(clazz.getName());
- if(instantiator == null) {
- ObjectInstantiator<?> newInstantiator = strategy.newInstantiatorOf(clazz);
- instantiator = cache.putIfAbsent(clazz.getName(), newInstantiator);
- if(instantiator == null) {
- instantiator = newInstantiator;
- }
- }
- return (ObjectInstantiator<T>) instantiator;
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/ObjenesisException.java b/objenesis-updated/main/src/org/objenesis/ObjenesisException.java
deleted file mode 100644
index f3c151e..0000000
--- a/objenesis-updated/main/src/org/objenesis/ObjenesisException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis;
-
-/**
- * Exception thrown by Objenesis. It wraps any instantiation exceptions. Note that this exception is
- * runtime to prevent having to catch it.
- *
- * @author Henri Tremblay
- */
-public class ObjenesisException extends RuntimeException {
-
- private static final long serialVersionUID = -2677230016262426968L;
-
- /**
- * @param msg Error message
- */
- public ObjenesisException(String msg) {
- super(msg);
- }
-
- /**
- * @param cause Wrapped exception. The message will be the one of the cause.
- */
- public ObjenesisException(Throwable cause) {
- super(cause);
- }
-
- /**
- * @param msg Error message
- * @param cause Wrapped exception
- */
- public ObjenesisException(String msg, Throwable cause) {
- super(msg, cause);
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/ObjenesisHelper.java b/objenesis-updated/main/src/org/objenesis/ObjenesisHelper.java
deleted file mode 100644
index a657af2..0000000
--- a/objenesis-updated/main/src/org/objenesis/ObjenesisHelper.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis;
-
-import java.io.Serializable;
-
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * Use Objenesis in a static way. <strong>It is strongly not recommended to use this class.</strong>
- *
- * @author Henri Tremblay
- */
-public final class ObjenesisHelper {
-
- private static final Objenesis OBJENESIS_STD = new ObjenesisStd();
-
- private static final Objenesis OBJENESIS_SERIALIZER = new ObjenesisSerializer();
-
- private ObjenesisHelper() {
- }
-
- /**
- * Will create a new object without any constructor being called
- *
- * @param <T> Type instantiated
- * @param clazz Class to instantiate
- * @return New instance of clazz
- */
- public static <T> T newInstance(Class<T> clazz) {
- return OBJENESIS_STD.newInstance(clazz);
- }
-
- /**
- * Will create an object just like it's done by ObjectInputStream.readObject (the default
- * constructor of the first non serializable class will be called)
- *
- * @param <T> Type instantiated
- * @param clazz Class to instantiate
- * @return New instance of clazz
- */
- public static <T extends Serializable> T newSerializableInstance(Class<T> clazz) {
- return (T) OBJENESIS_SERIALIZER.newInstance(clazz);
- }
-
- /**
- * Will pick the best instantiator for the provided class. If you need to create a lot of
- * instances from the same class, it is way more efficient to create them from the same
- * ObjectInstantiator than calling {@link #newInstance(Class)}.
- *
- * @param <T> Type to instantiate
- * @param clazz Class to instantiate
- * @return Instantiator dedicated to the class
- */
- public static <T> ObjectInstantiator<T> getInstantiatorOf(Class<T> clazz) {
- return OBJENESIS_STD.getInstantiatorOf(clazz);
- }
-
- /**
- * Same as {@link #getInstantiatorOf(Class)} but providing an instantiator emulating
- * ObjectInputStream.readObject behavior.
- *
- * @see #newSerializableInstance(Class)
- * @param <T> Type to instantiate
- * @param clazz Class to instantiate
- * @return Instantiator dedicated to the class
- */
- public static <T extends Serializable> ObjectInstantiator<T> getSerializableObjectInstantiatorOf(Class<T> clazz) {
- return OBJENESIS_SERIALIZER.getInstantiatorOf(clazz);
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/ObjenesisSerializer.java b/objenesis-updated/main/src/org/objenesis/ObjenesisSerializer.java
deleted file mode 100644
index 6cc7730..0000000
--- a/objenesis-updated/main/src/org/objenesis/ObjenesisSerializer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis;
-
-import org.objenesis.strategy.SerializingInstantiatorStrategy;
-
-/**
- * Objenesis implementation using the {@link SerializingInstantiatorStrategy}.
- *
- * @author Henri Tremblay
- */
-public class ObjenesisSerializer extends ObjenesisBase {
-
- /**
- * Default constructor using the {@link org.objenesis.strategy.SerializingInstantiatorStrategy}
- */
- public ObjenesisSerializer() {
- super(new SerializingInstantiatorStrategy());
- }
-
- /**
- * Instance using the {@link org.objenesis.strategy.SerializingInstantiatorStrategy} with or without caching
- * {@link org.objenesis.instantiator.ObjectInstantiator}s
- *
- * @param useCache If {@link org.objenesis.instantiator.ObjectInstantiator}s should be cached
- */
- public ObjenesisSerializer(boolean useCache) {
- super(new SerializingInstantiatorStrategy(), useCache);
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/ObjenesisStd.java b/objenesis-updated/main/src/org/objenesis/ObjenesisStd.java
deleted file mode 100644
index 8f9e8f9..0000000
--- a/objenesis-updated/main/src/org/objenesis/ObjenesisStd.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis;
-
-import org.objenesis.strategy.StdInstantiatorStrategy;
-
-/**
- * Objenesis implementation using the {@link org.objenesis.strategy.StdInstantiatorStrategy}.
- *
- * @author Henri Tremblay
- */
-public class ObjenesisStd extends ObjenesisBase {
-
- /**
- * Default constructor using the {@link org.objenesis.strategy.StdInstantiatorStrategy}
- */
- public ObjenesisStd() {
- super(new StdInstantiatorStrategy());
- }
-
- /**
- * Instance using the {@link org.objenesis.strategy.StdInstantiatorStrategy} with or without
- * caching {@link org.objenesis.instantiator.ObjectInstantiator}s
- *
- * @param useCache If {@link org.objenesis.instantiator.ObjectInstantiator}s should be cached
- */
- public ObjenesisStd(boolean useCache) {
- super(new StdInstantiatorStrategy(), useCache);
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/ObjectInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/ObjectInstantiator.java
deleted file mode 100644
index d9be1c9..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/ObjectInstantiator.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator;
-
-/**
- * Instantiates a new object.
- *
- * @author Leonardo Mesquita
- */
-public interface ObjectInstantiator<T> {
-
- /**
- * Returns a new instance of an object. The returned object's class is defined by the
- * implementation.
- *
- * @return A new instance of an object.
- */
- T newInstance();
-
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/SerializationInstantiatorHelper.java b/objenesis-updated/main/src/org/objenesis/instantiator/SerializationInstantiatorHelper.java
deleted file mode 100644
index 6aa7266..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/SerializationInstantiatorHelper.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator;
-
-import java.io.Serializable;
-
-/**
- * Helper for common serialization-compatible instantiation functions
- *
- * @author Leonardo Mesquita
- */
-public class SerializationInstantiatorHelper {
-
- /**
- * Returns the first non-serializable superclass of a given class. According to Java Object
- * Serialization Specification, objects read from a stream are initialized by calling an
- * accessible no-arg constructor from the first non-serializable superclass in the object's
- * hierarchy, allowing the state of non-serializable fields to be correctly initialized.
- *
- * @param <T> Type to instantiate
- * @param type Serializable class for which the first non-serializable superclass is to be found
- * @return The first non-serializable superclass of 'type'.
- * @see java.io.Serializable
- */
- public static <T> Class<? super T> getNonSerializableSuperClass(Class<T> type) {
- Class<? super T> result = type;
- while(Serializable.class.isAssignableFrom(result)) {
- result = result.getSuperclass();
- if(result == null) {
- throw new Error("Bad class hierarchy: No non-serializable parents");
- }
- }
- return result;
-
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/android/Android10Instantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/android/Android10Instantiator.java
deleted file mode 100644
index 14e213c..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/android/Android10Instantiator.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.android;
-
-import java.io.ObjectInputStream;
-import java.lang.reflect.Method;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * Instantiator for Android API level 10 and lover which creates objects without driving their
- * constructors, using internal methods on the Dalvik implementation of
- * {@link java.io.ObjectInputStream}.
- *
- * @author Piotr 'Qertoip' WÅ‚odarek
- */
-public class Android10Instantiator<T> implements ObjectInstantiator<T> {
- private final Class<T> type;
- private final Method newStaticMethod;
-
- public Android10Instantiator(Class<T> type) {
- this.type = type;
- newStaticMethod = getNewStaticMethod();
- }
-
- public T newInstance() {
- try {
- return type.cast(newStaticMethod.invoke(null, type, Object.class));
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
-
- private static Method getNewStaticMethod() {
- try {
- Method newStaticMethod = ObjectInputStream.class.getDeclaredMethod(
- "newInstance", Class.class, Class.class);
- newStaticMethod.setAccessible(true);
- return newStaticMethod;
- }
- catch(RuntimeException e) {
- throw new ObjenesisException(e);
- }
- catch(NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- }
-
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/android/Android17Instantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/android/Android17Instantiator.java
deleted file mode 100644
index c2d41f9..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/android/Android17Instantiator.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.android;
-
-import java.io.ObjectStreamClass;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * Instantiator for Android API level 11 to 17 which creates objects without driving their
- * constructors, using internal methods on the Dalvik implementation of {@link ObjectStreamClass}.
- *
- * @author Ian Parkinson (Google Inc.)
- */
-public class Android17Instantiator<T> implements ObjectInstantiator<T> {
- private final Class<T> type;
- private final Method newInstanceMethod;
- private final Integer objectConstructorId;
-
- public Android17Instantiator(Class<T> type) {
- this.type = type;
- newInstanceMethod = getNewInstanceMethod();
- objectConstructorId = findConstructorIdForJavaLangObjectConstructor();
- }
-
- public T newInstance() {
- try {
- return type.cast(newInstanceMethod.invoke(null, type, objectConstructorId));
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
-
- private static Method getNewInstanceMethod() {
- try {
- Method newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod(
- "newInstance", Class.class, Integer.TYPE);
- newInstanceMethod.setAccessible(true);
- return newInstanceMethod;
- }
- catch(RuntimeException e) {
- throw new ObjenesisException(e);
- }
- catch(NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- }
-
- private static Integer findConstructorIdForJavaLangObjectConstructor() {
- try {
- Method newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod(
- "getConstructorId", Class.class);
- newInstanceMethod.setAccessible(true);
-
- return (Integer) newInstanceMethod.invoke(null, Object.class);
- }
- catch(RuntimeException e) {
- throw new ObjenesisException(e);
- }
- catch(NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- catch(IllegalAccessException e) {
- throw new ObjenesisException(e);
- }
- catch(InvocationTargetException e) {
- throw new ObjenesisException(e);
- }
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/android/Android18Instantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/android/Android18Instantiator.java
deleted file mode 100644
index 1e2db53..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/android/Android18Instantiator.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.android;
-
-import java.io.ObjectStreamClass;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * Instantiator for Android API leve 18 and higher. Same as the version 17 but the
- * <code>newInstance</code> now takes a long in parameter
- *
- * @author Henri Tremblay
- */
-public class Android18Instantiator<T> implements ObjectInstantiator<T> {
- private final Class<T> type;
- private final Method newInstanceMethod;
- private final Long objectConstructorId;
-
- public Android18Instantiator(Class<T> type) {
- this.type = type;
- newInstanceMethod = getNewInstanceMethod();
- objectConstructorId = findConstructorIdForJavaLangObjectConstructor();
- }
-
- public T newInstance() {
- try {
- return type.cast(newInstanceMethod.invoke(null, type, objectConstructorId));
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
-
- private static Method getNewInstanceMethod() {
- try {
- Method newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod("newInstance",
- Class.class, Long.TYPE);
- newInstanceMethod.setAccessible(true);
- return newInstanceMethod;
- }
- catch(RuntimeException e) {
- throw new ObjenesisException(e);
- }
- catch(NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- }
-
- private static Long findConstructorIdForJavaLangObjectConstructor() {
- try {
- Method newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod("getConstructorId",
- Class.class);
- newInstanceMethod.setAccessible(true);
-
- return (Long) newInstanceMethod.invoke(null, Object.class);
- }
- catch(RuntimeException e) {
- throw new ObjenesisException(e);
- }
- catch(NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- catch(IllegalAccessException e) {
- throw new ObjenesisException(e);
- }
- catch(InvocationTargetException e) {
- throw new ObjenesisException(e);
- }
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/android/AndroidSerializationInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/android/AndroidSerializationInstantiator.java
deleted file mode 100644
index 21bcc96..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/android/AndroidSerializationInstantiator.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.android;
-
-import java.io.ObjectStreamClass;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * {@link ObjectInstantiator} for Android which creates objects using the constructor from the first
- * non-serializable parent class constructor, using internal methods on the Dalvik implementation of
- * {@link ObjectStreamClass}.
- *
- * @author Ian Parkinson (Google Inc.)
- */
-public class AndroidSerializationInstantiator<T> implements ObjectInstantiator<T> {
- private final Class<T> type;
- private final ObjectStreamClass objectStreamClass;
- private final Method newInstanceMethod;
-
- public AndroidSerializationInstantiator(Class<T> type) {
- this.type = type;
- newInstanceMethod = getNewInstanceMethod();
- Method m = null;
- try {
- m = ObjectStreamClass.class.getMethod("lookupAny", Class.class);
- } catch (NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- try {
- objectStreamClass = (ObjectStreamClass) m.invoke(null, type);
- } catch (IllegalAccessException e) {
- throw new ObjenesisException(e);
- } catch (InvocationTargetException e) {
- throw new ObjenesisException(e);
- }
- }
-
- public T newInstance() {
- try {
- return type.cast(newInstanceMethod.invoke(objectStreamClass, type));
- }
- catch(IllegalAccessException e) {
- throw new ObjenesisException(e);
- }
- catch(IllegalArgumentException e) {
- throw new ObjenesisException(e);
- }
- catch(InvocationTargetException e) {
- throw new ObjenesisException(e);
- }
- }
-
- private static Method getNewInstanceMethod() {
- try {
- Method newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod(
- "newInstance", Class.class);
- newInstanceMethod.setAccessible(true);
- return newInstanceMethod;
- }
- catch(RuntimeException e) {
- throw new ObjenesisException(e);
- }
- catch(NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/basic/AccessibleInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/basic/AccessibleInstantiator.java
deleted file mode 100644
index 809f3b1..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/basic/AccessibleInstantiator.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.basic;
-
-/**
- * Instantiates a class by grabbing the no-args constructor, making it accessible and then calling
- * Constructor.newInstance(). Although this still requires no-arg constructors, it can call
- * non-public constructors (if the security manager allows it).
- *
- * @author Joe Walnes
- * @see org.objenesis.instantiator.ObjectInstantiator
- */
-public class AccessibleInstantiator<T> extends ConstructorInstantiator<T> {
-
- public AccessibleInstantiator(Class<T> type) {
- super(type);
- if(constructor != null) {
- constructor.setAccessible(true);
- }
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/basic/ClassDefinitionUtils.java b/objenesis-updated/main/src/org/objenesis/instantiator/basic/ClassDefinitionUtils.java
deleted file mode 100644
index 1c76097..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/basic/ClassDefinitionUtils.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.basic;
-
-/*
- * Copyright 2003,2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.objenesis.ObjenesisException;
-
-import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.ProtectionDomain;
-
-/**
- * Helper class for ProxyObjectInstantiator. We can see the details of a class specification
- * <a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html">here</a>
- *
- * @author Henri Tremblay
- */
-public final class ClassDefinitionUtils {
-
- public static final byte OPS_aload_0 = 42;
- public static final byte OPS_invokespecial = -73; // has two bytes parameters
- public static final byte OPS_return = -79;
- public static final byte OPS_new = -69;
- public static final byte OPS_dup = 89;
- public static final byte OPS_areturn = -80;
-
- public static final int CONSTANT_Utf8 = 1;
- public static final int CONSTANT_Integer = 3;
- public static final int CONSTANT_Float = 4;
- public static final int CONSTANT_Long = 5;
- public static final int CONSTANT_Double = 6;
- public static final int CONSTANT_Class = 7;
- public static final int CONSTANT_String = 8;
- public static final int CONSTANT_Fieldref = 9;
- public static final int CONSTANT_Methodref = 10;
- public static final int CONSTANT_InterfaceMethodref = 11;
- public static final int CONSTANT_NameAndType = 12;
- public static final int CONSTANT_MethodHandle = 15;
- public static final int CONSTANT_MethodType = 16;
- public static final int CONSTANT_InvokeDynamic = 18;
-
- public static final int ACC_PUBLIC = 0x0001; // Declared public; may be accessed from outside its package.
- public static final int ACC_FINAL = 0x0010; // Declared final; no subclasses allowed.
- public static final int ACC_SUPER = 0x0020; // Treat superclass methods specially when invoked by the invokespecial instruction.
- public static final int ACC_INTERFACE = 0x0200; // Is an interface, not a class.
- public static final int ACC_ABSTRACT = 0x0400; // Declared abstract; must not be instantiated.
- public static final int ACC_SYNTHETIC = 0x1000; // Declared synthetic; not present in the source code.
- public static final int ACC_ANNOTATION = 0x2000; // Declared as an annotation type.
- public static final int ACC_ENUM = 0x4000; // Declared as an enum type.
-
- public static final byte[] MAGIC = { (byte) 0xca, (byte) 0xfe, (byte) 0xba, (byte) 0xbe };
- public static final byte[] VERSION = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x31 }; // minor_version, major_version (Java 5)
-
- private ClassDefinitionUtils() { }
-
- private static Method DEFINE_CLASS;
- private static final ProtectionDomain PROTECTION_DOMAIN;
-
- static {
- PROTECTION_DOMAIN = AccessController.doPrivileged(new PrivilegedAction<ProtectionDomain>() {
- public ProtectionDomain run() {
- return ClassDefinitionUtils.class.getProtectionDomain();
- }
- });
-
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- try {
- Class<?> loader = Class.forName("java.lang.ClassLoader"); // JVM crash w/o this
- DEFINE_CLASS = loader.getDeclaredMethod("defineClass",
- new Class[]{ String.class,
- byte[].class,
- Integer.TYPE,
- Integer.TYPE,
- ProtectionDomain.class });
- DEFINE_CLASS.setAccessible(true);
- } catch (ClassNotFoundException e) {
- throw new ObjenesisException(e);
- } catch (NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- return null;
- }
- });
- }
-
- /**
- * Define a class in the provided class loader from the array of bytes. Inspired by cglib
- * <code>ReflectUtils.defineClass</code>
- *
- * @param <T> type of the class returned
- * @param className class name in the format <code>org.objenesis.MyClass</code>
- * @param b bytes representing the class
- * @param loader the class loader where the class will be loaded
- * @return the newly loaded class
- * @throws Exception whenever something goes wrong
- */
- @SuppressWarnings("unchecked")
- public static <T> Class<T> defineClass(String className, byte[] b, ClassLoader loader)
- throws Exception {
- Object[] args = new Object[]{className, b, new Integer(0), new Integer(b.length), PROTECTION_DOMAIN };
- Class<T> c = (Class<T>) DEFINE_CLASS.invoke(loader, args);
- // Force static initializers to run.
- Class.forName(className, true, loader);
- return c;
- }
-
- /**
- * Read the bytes of a class from the classpath
- *
- * @param className full class name including the package
- * @return the bytes representing the class
- * @throws IllegalArgumentException if the class is longer than 2500 bytes
- * @throws IOException if we fail to read the class
- */
- public static byte[] readClass(String className) throws IOException {
- // convert to a resource
- className = classNameToResource(className);
-
- byte[] b = new byte[2500]; // I'm assuming that I'm reading class that are not too big
-
- int length;
-
- InputStream in = ClassDefinitionUtils.class.getClassLoader().getResourceAsStream(className);
- try {
- length = in.read(b);
- }
- finally {
- in.close();
- }
-
- if(length >= 2500) {
- throw new IllegalArgumentException("The class is longer that 2500 bytes which is currently unsupported");
- }
-
- byte[] copy = new byte[length];
- System.arraycopy(b, 0, copy, 0, length);
- return copy;
- }
-
- /**
- * Write all class bytes to a file.
- *
- * @param fileName file where the bytes will be written
- * @param bytes bytes representing the class
- * @throws IOException if we fail to write the class
- */
- public static void writeClass(String fileName, byte[] bytes) throws IOException {
- BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(fileName));
- try {
- out.write(bytes);
- }
- finally {
- out.close();
- }
- }
-
- /**
- * Will convert a class name to its name in the class definition format (e.g {@code org.objenesis.EmptyClass}
- * becomes {@code org/objenesis/EmptyClass})
- *
- * @param className full class name including the package
- * @return the internal name
- */
- public static String classNameToInternalClassName(String className) {
- return className.replace('.', '/');
- }
-
- /**
- * Will convert a class name to its class loader resource name (e.g {@code org.objenesis.EmptyClass}
- * becomes {@code org/objenesis/EmptyClass.class})
- *
- * @param className full class name including the package
- * @return the resource name
- */
- public static String classNameToResource(String className) {
- return classNameToInternalClassName(className) + ".class";
- }
-
- /**
- * Check if this class already exists in the class loader and return it if it does
- *
- * @param <T> type of the class returned
- * @param classLoader Class loader where to search the class
- * @param className Class name with full path
- * @return the class if it already exists or null
- */
- @SuppressWarnings("unchecked")
- public static <T> Class<T> getExistingClass(ClassLoader classLoader, String className) {
- try {
- return (Class<T>) Class.forName(className, true, classLoader);
- }
- catch (ClassNotFoundException e) {
- return null;
- }
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/basic/ConstructorInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/basic/ConstructorInstantiator.java
deleted file mode 100644
index 01858fd..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/basic/ConstructorInstantiator.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.basic;
-
-import java.lang.reflect.Constructor;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * Instantiates a class by grabbing the no args constructor and calling Constructor.newInstance().
- * This can deal with default public constructors, but that's about it.
- *
- * @author Joe Walnes
- * @param <T> Type instantiated
- * @see ObjectInstantiator
- */
-public class ConstructorInstantiator<T> implements ObjectInstantiator<T> {
-
- protected Constructor<T> constructor;
-
- public ConstructorInstantiator(Class<T> type) {
- try {
- constructor = type.getDeclaredConstructor((Class[]) null);
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
-
- public T newInstance() {
- try {
- return constructor.newInstance((Object[]) null);
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
-
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/basic/FailingInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/basic/FailingInstantiator.java
deleted file mode 100644
index b33f5be..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/basic/FailingInstantiator.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.basic;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * The instantiator that always throws an exception. Mainly used for tests
- *
- * @author Henri Tremblay
- */
-public class FailingInstantiator<T> implements ObjectInstantiator<T> {
-
- public FailingInstantiator(Class<T> type) {
- }
-
- /**
- * @return Always throwing an exception
- */
- public T newInstance() {
- throw new ObjenesisException("Always failing");
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/basic/NewInstanceInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/basic/NewInstanceInstantiator.java
deleted file mode 100644
index 307b95f..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/basic/NewInstanceInstantiator.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.basic;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * The simplest instantiator - simply calls Class.newInstance(). This can deal with default public
- * constructors, but that's about it.
- *
- * @author Joe Walnes
- * @see ObjectInstantiator
- */
-public class NewInstanceInstantiator<T> implements ObjectInstantiator<T> {
-
- private final Class<T> type;
-
- public NewInstanceInstantiator(Class<T> type) {
- this.type = type;
- }
-
- public T newInstance() {
- try {
- return type.newInstance();
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
-
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/basic/NullInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/basic/NullInstantiator.java
deleted file mode 100644
index e569f4b..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/basic/NullInstantiator.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.basic;
-
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * The instantiator that always return a null instance
- *
- * @author Henri Tremblay
- */
-public class NullInstantiator<T> implements ObjectInstantiator<T> {
-
- public NullInstantiator(Class<T> type) {
- }
-
- /**
- * @return Always null
- */
- public T newInstance() {
- return null;
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java
deleted file mode 100644
index 1f6954e..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.basic;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-import java.io.*;
-
-/**
- * Instantiates a class by using a dummy input stream that always feeds data for an empty object of
- * the same kind. NOTE: This instantiator may not work properly if the class being instantiated
- * defines a "readResolve" method, since it may return objects that have been returned previously
- * (i.e., there's no guarantee that the returned object is a new one), or even objects from a
- * completely different class.
- *
- * @author Leonardo Mesquita
- * @see org.objenesis.instantiator.ObjectInstantiator
- */
-public class ObjectInputStreamInstantiator<T> implements ObjectInstantiator<T> {
- private static class MockStream extends InputStream {
-
- private int pointer;
- private byte[] data;
- private int sequence;
- private static final int[] NEXT = new int[] {1, 2, 2};
- private byte[][] buffers;
-
- private final byte[] FIRST_DATA;
- private static byte[] HEADER;
- private static byte[] REPEATING_DATA;
-
- static {
- initialize();
- }
-
- private static void initialize() {
- try {
- ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream(byteOut);
- dout.writeShort(ObjectStreamConstants.STREAM_MAGIC);
- dout.writeShort(ObjectStreamConstants.STREAM_VERSION);
- HEADER = byteOut.toByteArray();
-
- byteOut = new ByteArrayOutputStream();
- dout = new DataOutputStream(byteOut);
-
- dout.writeByte(ObjectStreamConstants.TC_OBJECT);
- dout.writeByte(ObjectStreamConstants.TC_REFERENCE);
- dout.writeInt(ObjectStreamConstants.baseWireHandle);
- REPEATING_DATA = byteOut.toByteArray();
- }
- catch(IOException e) {
- throw new Error("IOException: " + e.getMessage());
- }
-
- }
-
- public MockStream(Class<?> clazz) {
- this.pointer = 0;
- this.sequence = 0;
- this.data = HEADER;
-
- // (byte) TC_OBJECT
- // (byte) TC_CLASSDESC
- // (short length)
- // (byte * className.length)
- // (long)serialVersionUID
- // (byte) SC_SERIALIZABLE
- // (short)0 <fields>
- // TC_ENDBLOCKDATA
- // TC_NULL
- ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
- DataOutputStream dout = new DataOutputStream(byteOut);
- try {
- dout.writeByte(ObjectStreamConstants.TC_OBJECT);
- dout.writeByte(ObjectStreamConstants.TC_CLASSDESC);
- dout.writeUTF(clazz.getName());
- dout.writeLong(ObjectStreamClass.lookup(clazz).getSerialVersionUID());
- dout.writeByte(ObjectStreamConstants.SC_SERIALIZABLE);
- dout.writeShort((short) 0); // Zero fields
- dout.writeByte(ObjectStreamConstants.TC_ENDBLOCKDATA);
- dout.writeByte(ObjectStreamConstants.TC_NULL);
- }
- catch(IOException e) {
- throw new Error("IOException: " + e.getMessage());
- }
- this.FIRST_DATA = byteOut.toByteArray();
- buffers = new byte[][] {HEADER, FIRST_DATA, REPEATING_DATA};
- }
-
- private void advanceBuffer() {
- pointer = 0;
- sequence = NEXT[sequence];
- data = buffers[sequence];
- }
-
- @Override
- public int read() throws IOException {
- int result = data[pointer++];
- if(pointer >= data.length) {
- advanceBuffer();
- }
-
- return result;
- }
-
- @Override
- public int available() throws IOException {
- return Integer.MAX_VALUE;
- }
-
- @Override
- public int read(byte[] b, int off, int len) throws IOException {
- int left = len;
- int remaining = data.length - pointer;
-
- while(remaining <= left) {
- System.arraycopy(data, pointer, b, off, remaining);
- off += remaining;
- left -= remaining;
- advanceBuffer();
- remaining = data.length - pointer;
- }
- if(left > 0) {
- System.arraycopy(data, pointer, b, off, left);
- pointer += left;
- }
-
- return len;
- }
- }
-
- private ObjectInputStream inputStream;
-
- public ObjectInputStreamInstantiator(Class<T> clazz) {
- if(Serializable.class.isAssignableFrom(clazz)) {
- try {
- this.inputStream = new ObjectInputStream(new MockStream(clazz));
- }
- catch(IOException e) {
- throw new Error("IOException: " + e.getMessage());
- }
- }
- else {
- throw new ObjenesisException(new NotSerializableException(clazz + " not serializable"));
- }
- }
-
- @SuppressWarnings("unchecked")
- public T newInstance() {
- try {
- return (T) inputStream.readObject();
- }
- catch(ClassNotFoundException e) {
- throw new Error("ClassNotFoundException: " + e.getMessage());
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java
deleted file mode 100644
index 3b6d919..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.basic;
-
-import java.io.ObjectStreamClass;
-import java.lang.reflect.Method;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * Instantiates a class by using reflection to make a call to private method
- * ObjectStreamClass.newInstance, present in many JVM implementations. This instantiator will create
- * classes in a way compatible with serialization, calling the first non-serializable superclass'
- * no-arg constructor.
- *
- * @author Leonardo Mesquita
- * @see ObjectInstantiator
- * @see java.io.Serializable
- */
-public class ObjectStreamClassInstantiator<T> implements ObjectInstantiator<T> {
-
- private static Method newInstanceMethod;
-
- private static void initialize() {
- if(newInstanceMethod == null) {
- try {
- newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod("newInstance");
- newInstanceMethod.setAccessible(true);
- }
- catch(RuntimeException e) {
- throw new ObjenesisException(e);
- }
- catch(NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- }
- }
-
- private final ObjectStreamClass objStreamClass;
-
- public ObjectStreamClassInstantiator(Class<T> type) {
- initialize();
- objStreamClass = ObjectStreamClass.lookup(type);
- }
-
- @SuppressWarnings("unchecked")
- public T newInstance() {
-
- try {
- return (T) newInstanceMethod.invoke(objStreamClass);
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
-
- }
-
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/basic/ProxyingInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/basic/ProxyingInstantiator.java
deleted file mode 100644
index f7a2999..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/basic/ProxyingInstantiator.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.basic;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import static org.objenesis.instantiator.basic.ClassDefinitionUtils.*;
-
-/**
- * This instantiator creates a class by dynamically extending it. It will skip the call to the parent constructor
- * in the bytecode. So that the constructor is indeed not called but you however instantiate a child class, not
- * the actual class. The class loader will normally throw a {@code VerifyError} is you do that. However, using
- * {@code -Xverify:none} shoud make it work
- *
- * @author Henri Tremblay
- */
-public class ProxyingInstantiator<T> implements ObjectInstantiator<T> {
-
- private static final int INDEX_CLASS_THIS = 1;
- private static final int INDEX_CLASS_SUPERCLASS = 2;
- private static final int INDEX_UTF8_CONSTRUCTOR_NAME = 3;
- private static final int INDEX_UTF8_CONSTRUCTOR_DESC = 4;
- private static final int INDEX_UTF8_CODE_ATTRIBUTE = 5;
- private static final int INDEX_UTF8_CLASS = 7;
- private static final int INDEX_UTF8_SUPERCLASS = 8;
-
- private static int CONSTANT_POOL_COUNT = 9;
-
- private static final byte[] CODE = { OPS_aload_0, OPS_return};
- private static final int CODE_ATTRIBUTE_LENGTH = 12 + CODE.length;
-
- private static final String SUFFIX = "$$$Objenesis";
-
- private static final String CONSTRUCTOR_NAME = "<init>";
- private static final String CONSTRUCTOR_DESC = "()V";
-
- private final Class<?> newType;
-
- public ProxyingInstantiator(Class<T> type) {
-
- byte[] classBytes = writeExtendingClass(type, SUFFIX);
-
- try {
- newType = ClassDefinitionUtils.defineClass(type.getName() + SUFFIX, classBytes, type.getClassLoader());
- } catch (Exception e) {
- throw new ObjenesisException(e);
- }
- }
-
- @SuppressWarnings("unchecked")
- public T newInstance() {
- try {
- return (T) newType.newInstance();
- } catch (InstantiationException e) {
- throw new ObjenesisException(e);
- } catch (IllegalAccessException e) {
- throw new ObjenesisException(e);
- }
- }
-
- /**
- * Will generate the bytes for a class extending the type passed in parameter. This class will
- * only have an empty default constructor
- *
- * @param type type to extend
- * @param suffix the suffix appended to the class name to create the next extending class name
- * @return the byte for the class
- * @throws ObjenesisException is something goes wrong
- */
- private static byte[] writeExtendingClass(Class<?> type, String suffix) {
- String parentClazz = classNameToInternalClassName(type.getName());
- String clazz = parentClazz + suffix;
-
- DataOutputStream in = null;
- ByteArrayOutputStream bIn = new ByteArrayOutputStream(1000); // 1000 should be large enough to fit the entire class
- try {
- in = new DataOutputStream(bIn);
-
- in.write(MAGIC);
- in.write(VERSION);
- in.writeShort(CONSTANT_POOL_COUNT);
-
- // set all the constant pool here
-
- // 1. class
- in.writeByte(CONSTANT_Class);
- in.writeShort(INDEX_UTF8_CLASS);
-
- // 2. super class
- in.writeByte(CONSTANT_Class);
- in.writeShort(INDEX_UTF8_SUPERCLASS);
-
- // 3. default constructor name
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF(CONSTRUCTOR_NAME);
-
- // 4. default constructor description
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF(CONSTRUCTOR_DESC);
-
- // 5. Code
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF("Code");
-
- // 6. Class name
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF("L" + clazz + ";");
-
- // 7. Class name (again)
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF(clazz);
-
- // 8. Superclass name
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF(parentClazz);
-
- // end of constant pool
-
- // access flags: We want public, ACC_SUPER is always there
- in.writeShort(ACC_PUBLIC | ACC_SUPER);
-
- // this class index in the constant pool
- in.writeShort(INDEX_CLASS_THIS);
-
- // super class index in the constant pool
- in.writeShort(INDEX_CLASS_SUPERCLASS);
-
- // interfaces implemented count (we have none)
- in.writeShort(0);
-
- // fields count (we have none)
- in.writeShort(0);
-
- // methods count (we have one: the default constructor)
- in.writeShort(1);
-
- // default constructor method_info
- in.writeShort(ACC_PUBLIC);
- in.writeShort(INDEX_UTF8_CONSTRUCTOR_NAME); // index of the method name (<init>)
- in.writeShort(INDEX_UTF8_CONSTRUCTOR_DESC); // index of the description
- in.writeShort(1); // number of attributes: only one, the code
-
- // code attribute of the default constructor
- in.writeShort(INDEX_UTF8_CODE_ATTRIBUTE);
- in.writeInt(CODE_ATTRIBUTE_LENGTH); // attribute length
- in.writeShort(1); // max_stack
- in.writeShort(1); // max_locals
- in.writeInt(CODE.length); // code length
- in.write(CODE);
- in.writeShort(0); // exception_table_length = 0
- in.writeShort(0); // attributes count = 0, no need to have LineNumberTable and LocalVariableTable
-
- // class attributes
- in.writeShort(0); // none. No need to have a source file attribute
-
-
- } catch (IOException e) {
- throw new ObjenesisException(e);
- } finally {
- if(in != null) {
- try {
- in.close();
- } catch (IOException e) {
- throw new ObjenesisException(e);
- }
- }
- }
-
- return bIn.toByteArray();
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/gcj/GCJInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/gcj/GCJInstantiator.java
deleted file mode 100644
index 943daa1..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/gcj/GCJInstantiator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.gcj;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.objenesis.ObjenesisException;
-
-/**
- * Instantiates a class by making a call to internal GCJ private methods. It is only supposed to
- * work on GCJ JVMs. This instantiator will not call any constructors.
- *
- * @author Leonardo Mesquita
- * @see org.objenesis.instantiator.ObjectInstantiator
- */
-public class GCJInstantiator<T> extends GCJInstantiatorBase<T> {
- public GCJInstantiator(Class<T> type) {
- super(type);
- }
-
- @Override
- public T newInstance() {
- try {
- return type.cast(newObjectMethod.invoke(dummyStream, type, Object.class));
- }
- catch(RuntimeException e) {
- throw new ObjenesisException(e);
- }
- catch(IllegalAccessException e) {
- throw new ObjenesisException(e);
- }
- catch(InvocationTargetException e) {
- throw new ObjenesisException(e);
- }
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java b/objenesis-updated/main/src/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java
deleted file mode 100644
index 4918c7f..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.gcj;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.lang.reflect.Method;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * Base class for GCJ-based instantiators. It initializes reflection access to method
- * ObjectInputStream.newObject, as well as creating a dummy ObjectInputStream to be used as the
- * "this" argument for the method.
- *
- * @author Leonardo Mesquita
- */
-public abstract class GCJInstantiatorBase<T> implements ObjectInstantiator<T> {
- static Method newObjectMethod = null;
- static ObjectInputStream dummyStream;
-
- private static class DummyStream extends ObjectInputStream {
- public DummyStream() throws IOException {
- }
- }
-
- private static void initialize() {
- if(newObjectMethod == null) {
- try {
- newObjectMethod = ObjectInputStream.class.getDeclaredMethod("newObject", new Class[] {
- Class.class, Class.class});
- newObjectMethod.setAccessible(true);
- dummyStream = new DummyStream();
- }
- catch(RuntimeException e) {
- throw new ObjenesisException(e);
- }
- catch(NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- catch(IOException e) {
- throw new ObjenesisException(e);
- }
- }
- }
-
- protected final Class<T> type;
-
- public GCJInstantiatorBase(Class<T> type) {
- this.type = type;
- initialize();
- }
-
- public abstract T newInstance();
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java
deleted file mode 100644
index e29f98f..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.gcj;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.SerializationInstantiatorHelper;
-
-/**
- * Instantiates a class by making a call to internal GCJ private methods. It is only supposed to
- * work on GCJ JVMs. This instantiator will create classes in a way compatible with serialization,
- * calling the first non-serializable superclass' no-arg constructor.
- *
- * @author Leonardo Mesquita
- * @see org.objenesis.instantiator.ObjectInstantiator
- */
-public class GCJSerializationInstantiator<T> extends GCJInstantiatorBase<T> {
- private Class<? super T> superType;
-
- public GCJSerializationInstantiator(Class<T> type) {
- super(type);
- this.superType = SerializationInstantiatorHelper.getNonSerializableSuperClass(type);
- }
-
- @Override
- public T newInstance() {
- try {
- return type.cast(newObjectMethod.invoke(dummyStream, type, superType));
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
-
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/perc/PercInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/perc/PercInstantiator.java
deleted file mode 100644
index 8f6f11e..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/perc/PercInstantiator.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.perc;
-
-import java.io.ObjectInputStream;
-import java.lang.reflect.Method;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * Instantiates a class by making a call to internal Perc private methods. It is only supposed to
- * work on Perc JVMs. This instantiator will not call any constructors. The code was provided by
- * Aonix Perc support team.
- *
- * @author Henri Tremblay
- * @see org.objenesis.instantiator.ObjectInstantiator
- */
-public class PercInstantiator<T> implements ObjectInstantiator<T> {
-
- private final Method newInstanceMethod;
-
- private final Object[] typeArgs = new Object[] { null, Boolean.FALSE };
-
- public PercInstantiator(Class<T> type) {
-
- typeArgs[0] = type;
-
- try {
- newInstanceMethod = ObjectInputStream.class.getDeclaredMethod("newInstance", Class.class,
- Boolean.TYPE);
- newInstanceMethod.setAccessible(true);
- }
- catch(RuntimeException e) {
- throw new ObjenesisException(e);
- }
- catch(NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- }
-
- @SuppressWarnings("unchecked")
- public T newInstance() {
- try {
- return (T) newInstanceMethod.invoke(null, typeArgs);
- } catch (Exception e) {
- throw new ObjenesisException(e);
- }
- }
-
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/perc/PercSerializationInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/perc/PercSerializationInstantiator.java
deleted file mode 100644
index 4cdfa65..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/perc/PercSerializationInstantiator.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.perc;
-
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * Instantiates a class by making a call to internal Perc private methods. It is only supposed to
- * work on Perc JVMs. This instantiator will create classes in a way compatible with serialization,
- * calling the first non-serializable superclass' no-arg constructor.
- * <p>
- * Based on code provided by Aonix but <b>doesn't work right now</b>
- *
- * @author Henri Tremblay
- * @see org.objenesis.instantiator.ObjectInstantiator
- */
-public class PercSerializationInstantiator<T> implements ObjectInstantiator<T> {
-
- private Object[] typeArgs;
-
- private final Method newInstanceMethod;
-
- public PercSerializationInstantiator(Class<T> type) {
-
- // Find the first unserializable parent class
- Class<? super T> unserializableType = type;
-
- while(Serializable.class.isAssignableFrom(unserializableType)) {
- unserializableType = unserializableType.getSuperclass();
- }
-
- try {
- // Get the special Perc method to call
- Class<?> percMethodClass = Class.forName("COM.newmonics.PercClassLoader.Method");
-
- newInstanceMethod = ObjectInputStream.class.getDeclaredMethod("noArgConstruct",
- new Class[] {Class.class, Object.class, percMethodClass});
- newInstanceMethod.setAccessible(true);
-
- // Create invoke params
- Class<?> percClassClass = Class.forName("COM.newmonics.PercClassLoader.PercClass");
- Method getPercClassMethod = percClassClass.getDeclaredMethod("getPercClass", Class.class);
- Object someObject = getPercClassMethod.invoke(null, unserializableType);
- Method findMethodMethod = someObject.getClass().getDeclaredMethod("findMethod",
- new Class[] {String.class});
- Object percMethod = findMethodMethod.invoke(someObject, "<init>()V");
-
- typeArgs = new Object[] {unserializableType, type, percMethod};
-
- }
- catch(ClassNotFoundException e) {
- throw new ObjenesisException(e);
- }
- catch(NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- catch(InvocationTargetException e) {
- throw new ObjenesisException(e);
- }
- catch(IllegalAccessException e) {
- throw new ObjenesisException(e);
- }
- }
-
- @SuppressWarnings("unchecked")
- public T newInstance() {
- try {
- return (T) newInstanceMethod.invoke(null, typeArgs);
- }
- catch(IllegalAccessException e) {
- throw new ObjenesisException(e);
- }
- catch(InvocationTargetException e) {
- throw new ObjenesisException(e);
- }
- }
-
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/sun/MagicInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/sun/MagicInstantiator.java
deleted file mode 100644
index 7743f02..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/sun/MagicInstantiator.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.sun;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-import org.objenesis.instantiator.basic.ClassDefinitionUtils;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import static org.objenesis.instantiator.basic.ClassDefinitionUtils.*;
-
-/**
- * This instantiator will correctly bypass the constructors by instantiating the class using the default
- * constructor from Object. It will be allowed to do so by extending {@code MagicAccessorImpl} which prevents
- * its children to be verified by the class loader
- *
- * @author Henri Tremblay
- */
-public class MagicInstantiator<T> implements ObjectInstantiator<T> {
-
- private static final int INDEX_CLASS_THIS = 1;
- private static final int INDEX_CLASS_SUPERCLASS = 2;
- private static final int INDEX_UTF8_CONSTRUCTOR_NAME = 3;
- private static final int INDEX_UTF8_CONSTRUCTOR_DESC = 4;
- private static final int INDEX_UTF8_CODE_ATTRIBUTE = 5;
- private static final int INDEX_UTF8_INSTANTIATOR_CLASS = 7;
- private static final int INDEX_UTF8_SUPERCLASS = 8;
- private static final int INDEX_CLASS_INTERFACE = 9;
- private static final int INDEX_UTF8_INTERFACE = 10;
- private static final int INDEX_UTF8_NEWINSTANCE_NAME = 11;
- private static final int INDEX_UTF8_NEWINSTANCE_DESC = 12;
- private static final int INDEX_METHODREF_OBJECT_CONSTRUCTOR = 13;
- private static final int INDEX_CLASS_OBJECT = 14;
- private static final int INDEX_UTF8_OBJECT = 15;
- private static final int INDEX_NAMEANDTYPE_DEFAULT_CONSTRUCTOR = 16;
- private static final int INDEX_CLASS_TYPE = 17;
- private static final int INDEX_UTF8_TYPE = 18;
-
- private static int CONSTANT_POOL_COUNT = 19;
-
- private static final byte[] CONSTRUCTOR_CODE = { OPS_aload_0, OPS_invokespecial, 0, INDEX_METHODREF_OBJECT_CONSTRUCTOR, OPS_return};
- private static final int CONSTRUCTOR_CODE_ATTRIBUTE_LENGTH = 12 + CONSTRUCTOR_CODE.length;
-
- private static final byte[] NEWINSTANCE_CODE = { OPS_new, 0, INDEX_CLASS_TYPE, OPS_dup, OPS_invokespecial, 0, INDEX_METHODREF_OBJECT_CONSTRUCTOR, OPS_areturn};
- private static final int NEWINSTANCE_CODE_ATTRIBUTE_LENGTH = 12 + NEWINSTANCE_CODE.length;
-
- private static final String CONSTRUCTOR_NAME = "<init>";
- private static final String CONSTRUCTOR_DESC = "()V";
-
- private ObjectInstantiator<T> instantiator;
-
- public MagicInstantiator(Class<T> type) {
- instantiator = newInstantiatorOf(type);
- }
-
- private <T> ObjectInstantiator<T> newInstantiatorOf(Class<T> type) {
- String suffix = type.getSimpleName();
- String className = getClass().getName() + "$$$" + suffix;
-
- Class<ObjectInstantiator<T>> clazz = getExistingClass(getClass().getClassLoader(), className);
-
- if(clazz == null) {
- byte[] classBytes = writeExtendingClass(type, className);
-
- try {
- clazz = ClassDefinitionUtils.defineClass(className, classBytes, getClass().getClassLoader());
- } catch (Exception e) {
- throw new ObjenesisException(e);
- }
- }
-
- try {
- return clazz.newInstance();
- } catch (InstantiationException e) {
- throw new ObjenesisException(e);
- } catch (IllegalAccessException e) {
- throw new ObjenesisException(e);
- }
- }
-
- /**
- * Will generate the bytes for a class extending the type passed in parameter. This class will
- * only have an empty default constructor
- *
- * @param type type to extend
- * @param className name of the wrapped instantiator class
- * @return the byte for the class
- * @throws ObjenesisException is something goes wrong
- */
- private byte[] writeExtendingClass(Class<?> type, String className) {
- String clazz = classNameToInternalClassName(className);
-
- DataOutputStream in = null;
- ByteArrayOutputStream bIn = new ByteArrayOutputStream(1000); // 1000 should be large enough to fit the entire class
- try {
- in = new DataOutputStream(bIn);
-
- in.write(MAGIC);
- in.write(VERSION);
- in.writeShort(CONSTANT_POOL_COUNT);
-
- // set all the constant pool here
-
- // 1. class
- in.writeByte(CONSTANT_Class);
- in.writeShort(INDEX_UTF8_INSTANTIATOR_CLASS);
-
- // 2. super class
- in.writeByte(CONSTANT_Class);
- in.writeShort(INDEX_UTF8_SUPERCLASS);
-
- // 3. default constructor name
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF(CONSTRUCTOR_NAME);
-
- // 4. default constructor description
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF(CONSTRUCTOR_DESC);
-
- // 5. Code
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF("Code");
-
- // 6. Class name
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF("L" + clazz + ";");
-
- // 7. Class name (again)
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF(clazz);
-
- // 8. Superclass name
- in.writeByte(CONSTANT_Utf8);
-// in.writeUTF("java/lang/Object");
- in.writeUTF("sun/reflect/MagicAccessorImpl");
-
- // 9. ObjectInstantiator interface
- in.writeByte(CONSTANT_Class);
- in.writeShort(INDEX_UTF8_INTERFACE);
-
- // 10. ObjectInstantiator name
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF(ObjectInstantiator.class.getName().replace('.', '/'));
-
- // 11. newInstance name
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF("newInstance");
-
- // 12. newInstance desc
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF("()Ljava/lang/Object;");
-
- // 13. Methodref to the Object constructor
- in.writeByte(CONSTANT_Methodref);
- in.writeShort(INDEX_CLASS_OBJECT);
- in.writeShort(INDEX_NAMEANDTYPE_DEFAULT_CONSTRUCTOR);
-
- // 14. Object class
- in.writeByte(CONSTANT_Class);
- in.writeShort(INDEX_UTF8_OBJECT);
-
- // 15. Object class name
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF("java/lang/Object");
-
- // 16. Default constructor name and type
- in.writeByte(CONSTANT_NameAndType);
- in.writeShort(INDEX_UTF8_CONSTRUCTOR_NAME);
- in.writeShort(INDEX_UTF8_CONSTRUCTOR_DESC);
-
- // 17. Type to instantiate class
- in.writeByte(CONSTANT_Class);
- in.writeShort(INDEX_UTF8_TYPE);
-
- // 18. Type to instantiate name
- in.writeByte(CONSTANT_Utf8);
- in.writeUTF(classNameToInternalClassName(type.getName()));
-
- // end of constant pool
-
- // access flags: We want public, ACC_SUPER is always there
- in.writeShort(ACC_PUBLIC | ACC_SUPER | ACC_FINAL);
-
- // this class index in the constant pool
- in.writeShort(INDEX_CLASS_THIS);
-
- // super class index in the constant pool
- in.writeShort(INDEX_CLASS_SUPERCLASS);
-
- // interfaces implemented count (we have none)
- in.writeShort(1);
- in.writeShort(INDEX_CLASS_INTERFACE);
-
- // fields count (we have none)
- in.writeShort(0);
-
- // method count (we have two: the default constructor and newInstance)
- in.writeShort(2);
-
- // default constructor method_info
- in.writeShort(ACC_PUBLIC);
- in.writeShort(INDEX_UTF8_CONSTRUCTOR_NAME); // index of the method name (<init>)
- in.writeShort(INDEX_UTF8_CONSTRUCTOR_DESC); // index of the description
- in.writeShort(1); // number of attributes: only one, the code
-
- // code attribute of the default constructor
- in.writeShort(INDEX_UTF8_CODE_ATTRIBUTE);
- in.writeInt(CONSTRUCTOR_CODE_ATTRIBUTE_LENGTH); // attribute length
- in.writeShort(0); // max_stack
- in.writeShort(1); // max_locals
- in.writeInt(CONSTRUCTOR_CODE.length); // code length
- in.write(CONSTRUCTOR_CODE);
- in.writeShort(0); // exception_table_length = 0
- in.writeShort(0); // attributes count = 0, no need to have LineNumberTable and LocalVariableTable
-
- // newInstance method_info
- in.writeShort(ACC_PUBLIC);
- in.writeShort(INDEX_UTF8_NEWINSTANCE_NAME); // index of the method name (newInstance)
- in.writeShort(INDEX_UTF8_NEWINSTANCE_DESC); // index of the description
- in.writeShort(1); // number of attributes: only one, the code
-
- // code attribute of newInstance
- in.writeShort(INDEX_UTF8_CODE_ATTRIBUTE);
- in.writeInt(NEWINSTANCE_CODE_ATTRIBUTE_LENGTH); // attribute length
- in.writeShort(2); // max_stack
- in.writeShort(1); // max_locals
- in.writeInt(NEWINSTANCE_CODE.length); // code length
- in.write(NEWINSTANCE_CODE);
- in.writeShort(0); // exception_table_length = 0
- in.writeShort(0); // attributes count = 0, no need to have LineNumberTable and LocalVariableTable
-
- // class attributes
- in.writeShort(0); // none. No need to have a source file attribute
-
- } catch (IOException e) {
- throw new ObjenesisException(e);
- } finally {
- if(in != null) {
- try {
- in.close();
- } catch (IOException e) {
- throw new ObjenesisException(e);
- }
- }
- }
-
- return bIn.toByteArray();
- }
-
- public T newInstance() {
- return instantiator.newInstance();
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/sun/SunReflectionFactoryHelper.java b/objenesis-updated/main/src/org/objenesis/instantiator/sun/SunReflectionFactoryHelper.java
deleted file mode 100644
index 49d7b87..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/sun/SunReflectionFactoryHelper.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.sun;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-
-/**
- * Helper methods providing access to {@link sun.reflect.ReflectionFactory} via reflection, for use
- * by the {@link ObjectInstantiator}s that use it.
- *
- * @author Henri Tremblay
- */
-@SuppressWarnings("restriction")
-class SunReflectionFactoryHelper {
-
- @SuppressWarnings("unchecked")
- public static <T> Constructor<T> newConstructorForSerialization(Class<T> type,
- Constructor<?> constructor) {
- Class<?> reflectionFactoryClass = getReflectionFactoryClass();
- Object reflectionFactory = createReflectionFactory(reflectionFactoryClass);
-
- Method newConstructorForSerializationMethod = getNewConstructorForSerializationMethod(
- reflectionFactoryClass);
-
- try {
- return (Constructor<T>) newConstructorForSerializationMethod.invoke(
- reflectionFactory, type, constructor);
- }
- catch(IllegalArgumentException e) {
- throw new ObjenesisException(e);
- }
- catch(IllegalAccessException e) {
- throw new ObjenesisException(e);
- }
- catch(InvocationTargetException e) {
- throw new ObjenesisException(e);
- }
- }
-
- private static Class<?> getReflectionFactoryClass() {
- try {
- return Class.forName("sun.reflect.ReflectionFactory");
- }
- catch(ClassNotFoundException e) {
- throw new ObjenesisException(e);
- }
- }
-
- private static Object createReflectionFactory(Class<?> reflectionFactoryClass) {
- try {
- Method method = reflectionFactoryClass.getDeclaredMethod(
- "getReflectionFactory");
- return method.invoke(null);
- }
- catch(NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- catch(IllegalAccessException e) {
- throw new ObjenesisException(e);
- }
- catch(IllegalArgumentException e) {
- throw new ObjenesisException(e);
- }
- catch(InvocationTargetException e) {
- throw new ObjenesisException(e);
- }
- }
-
- private static Method getNewConstructorForSerializationMethod(Class<?> reflectionFactoryClass) {
- try {
- return reflectionFactoryClass.getDeclaredMethod(
- "newConstructorForSerialization", Class.class, Constructor.class);
- }
- catch(NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java
deleted file mode 100644
index 53e8b55..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.sun;
-
-import java.lang.reflect.Constructor;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * Instantiates an object, WITHOUT calling it's constructor, using internal
- * sun.reflect.ReflectionFactory - a class only available on JDK's that use Sun's 1.4 (or later)
- * Java implementation. This is the best way to instantiate an object without any side effects
- * caused by the constructor - however it is not available on every platform.
- *
- * @author Joe Walnes
- * @see ObjectInstantiator
- */
-public class SunReflectionFactoryInstantiator<T> implements ObjectInstantiator<T> {
-
- private final Constructor<T> mungedConstructor;
-
- public SunReflectionFactoryInstantiator(Class<T> type) {
- Constructor<Object> javaLangObjectConstructor = getJavaLangObjectConstructor();
- mungedConstructor = SunReflectionFactoryHelper.newConstructorForSerialization(
- type, javaLangObjectConstructor);
- mungedConstructor.setAccessible(true);
- }
-
- public T newInstance() {
- try {
- return mungedConstructor.newInstance((Object[]) null);
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
-
- private static Constructor<Object> getJavaLangObjectConstructor() {
- try {
- return Object.class.getConstructor((Class[]) null);
- }
- catch(NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java
deleted file mode 100644
index 542beb0..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.sun;
-
-import java.io.NotSerializableException;
-import java.lang.reflect.Constructor;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-import org.objenesis.instantiator.SerializationInstantiatorHelper;
-
-/**
- * Instantiates an object using internal sun.reflect.ReflectionFactory - a class only available on
- * JDK's that use Sun's 1.4 (or later) Java implementation. This instantiator will create classes in
- * a way compatible with serialization, calling the first non-serializable superclass' no-arg
- * constructor. This is the best way to instantiate an object without any side effects caused by the
- * constructor - however it is not available on every platform.
- *
- * @author Leonardo Mesquita
- * @see ObjectInstantiator
- */
-public class SunReflectionFactorySerializationInstantiator<T> implements ObjectInstantiator<T> {
-
- private final Constructor<T> mungedConstructor;
-
- public SunReflectionFactorySerializationInstantiator(Class<T> type) {
- Class<? super T> nonSerializableAncestor = SerializationInstantiatorHelper
- .getNonSerializableSuperClass(type);
-
- Constructor<? super T> nonSerializableAncestorConstructor;
- try {
- nonSerializableAncestorConstructor = nonSerializableAncestor
- .getConstructor((Class[]) null);
- }
- catch(NoSuchMethodException e) {
- throw new ObjenesisException(new NotSerializableException(type+" has no suitable superclass constructor"));
- }
-
- mungedConstructor = SunReflectionFactoryHelper.newConstructorForSerialization(
- type, nonSerializableAncestorConstructor);
- mungedConstructor.setAccessible(true);
- }
-
- public T newInstance() {
- try {
- return mungedConstructor.newInstance((Object[]) null);
- }
- catch(Exception e) {
- throw new ObjenesisException(e);
- }
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/instantiator/sun/UnsafeFactoryInstantiator.java b/objenesis-updated/main/src/org/objenesis/instantiator/sun/UnsafeFactoryInstantiator.java
deleted file mode 100644
index 97cfe5a..0000000
--- a/objenesis-updated/main/src/org/objenesis/instantiator/sun/UnsafeFactoryInstantiator.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.instantiator.sun;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-/**
- * Instantiates an object, WITHOUT calling it's constructor, using
- * sun.misc.Unsafe.allocateInstance(). Unsafe and its methods are implemented by most
- * modern JVMs.
- *
- * @author Henri Tremblay
- * @see ObjectInstantiator
- */
-@SuppressWarnings("restriction")
-public class UnsafeFactoryInstantiator<T> implements ObjectInstantiator<T> {
-
- private static Object unsafe;
- private static Method allocateInstance;
- private final Class<T> type;
-
- public UnsafeFactoryInstantiator(Class<T> type) {
- if (unsafe == null) {
- Class<?> unsafeClass;
- try {
- unsafeClass = Class.forName("sun.misc.Unsafe");
- } catch (ClassNotFoundException e) {
- throw new ObjenesisException(e);
- }
- Field f;
- try {
- f = unsafeClass.getDeclaredField("theUnsafe");
- } catch (NoSuchFieldException e) {
- throw new ObjenesisException(e);
- }
- f.setAccessible(true);
- try {
- unsafe = f.get(null);
- } catch (IllegalAccessException e) {
- throw new ObjenesisException(e);
- }
- try {
- allocateInstance = unsafeClass.getMethod("allocateInstance", Class.class);
- } catch (NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- }
- this.type = type;
- }
-
- public T newInstance() {
- try {
- return type.cast(allocateInstance.invoke(unsafe, type));
- } catch (Exception e) {
- throw new ObjenesisException(e);
- }
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/strategy/BaseInstantiatorStrategy.java b/objenesis-updated/main/src/org/objenesis/strategy/BaseInstantiatorStrategy.java
deleted file mode 100644
index b9a43be..0000000
--- a/objenesis-updated/main/src/org/objenesis/strategy/BaseInstantiatorStrategy.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.strategy;
-
-/**
- * Base {@link InstantiatorStrategy} class basically. Only implements {@link InstantiatorStrategy}
- *
- * @author Henri Tremblay
- */
-public abstract class BaseInstantiatorStrategy implements InstantiatorStrategy {
-
-}
diff --git a/objenesis-updated/main/src/org/objenesis/strategy/InstantiatorStrategy.java b/objenesis-updated/main/src/org/objenesis/strategy/InstantiatorStrategy.java
deleted file mode 100644
index 1452b5c..0000000
--- a/objenesis-updated/main/src/org/objenesis/strategy/InstantiatorStrategy.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.strategy;
-
-import org.objenesis.instantiator.ObjectInstantiator;
-
-/**
- * Defines a strategy to determine the best instantiator for a class.
- *
- * @author Henri Tremblay
- */
-public interface InstantiatorStrategy {
-
- /**
- * Create a dedicated instantiator for the given class
- *
- * @param <T> Type to instantiate
- * @param type Class that will be instantiated
- * @return Dedicated instantiator
- */
- <T> ObjectInstantiator<T> newInstantiatorOf(Class<T> type);
-}
diff --git a/objenesis-updated/main/src/org/objenesis/strategy/PlatformDescription.java b/objenesis-updated/main/src/org/objenesis/strategy/PlatformDescription.java
deleted file mode 100644
index 734aa1e..0000000
--- a/objenesis-updated/main/src/org/objenesis/strategy/PlatformDescription.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.strategy;
-
-import org.objenesis.ObjenesisException;
-
-import java.lang.reflect.Field;
-
-/**
- * List of constants describing the currently used platform.
- *
- * @author Henri Tremblay
- */
-public final class PlatformDescription {
-
- /** JVM_NAME prefix for JRockit */
- public static final String JROCKIT = "BEA";
-
- /** JVM_NAME prefix for GCJ */
- public static final String GNU = "GNU libgcj";
-
- /** JVM_NAME prefix for Java HotSpot */
- public static final String HOTSPOT = "Java HotSpot";
-
- /**
- * JVM_NAME prefix for Java HotSpot
- *
- * @deprecated Use {@link #HOTSPOT} instead
- */
- @Deprecated
- public static final String SUN = HOTSPOT;
-
- /** JVM_NAME prefix for the OpenJDK */
- public static final String OPENJDK = "OpenJDK";
-
- /** JVM_NAME prefix for Aonix PERC */
- public static final String PERC = "PERC";
-
- /** JVM_NAME prefix for Dalvik/Android */
- public static final String DALVIK = "Dalvik";
-
- /** Java specification version */
- public static final String SPECIFICATION_VERSION = System
- .getProperty("java.specification.version");
-
- /** JVM version */
- public static final String VM_VERSION = System.getProperty("java.runtime.version");
-
- /** JVM version */
- public static final String VM_INFO = System.getProperty("java.vm.info");
-
- /** VM vendor version */
- public static final String VENDOR_VERSION = System.getProperty("java.vm.version");
-
- /** VM vendor name */
- public static final String VENDOR = System.getProperty("java.vm.vendor");
-
- /** JVM name */
- public static final String JVM_NAME = System.getProperty("java.vm.name");
-
- /** Android version. Will be 0 for none android platform */
- public static final int ANDROID_VERSION = getAndroidVersion();
-
- /** Flag telling if this version of Android is based on the OpenJDK */
- public static final boolean IS_ANDROID_OPENJDK = getIsAndroidOpenJDK();
-
- /** Google App Engine version or null is we are not on GAE */
- public static final String GAE_VERSION = getGaeRuntimeVersion();
-
- /**
- * Describes the platform. Outputs Java version and vendor.
- *
- * @return Description of the current platform
- */
- public static String describePlatform() {
- String desc = "Java " + SPECIFICATION_VERSION + " ("
- + "VM vendor name=\"" + VENDOR + "\", "
- + "VM vendor version=" + VENDOR_VERSION + ", "
- + "JVM name=\"" + JVM_NAME + "\", "
- + "JVM version=" + VM_VERSION + ", "
- + "JVM info=" + VM_INFO;
-
- // Add the API level is it's an Android platform
- int androidVersion = ANDROID_VERSION;
- if(androidVersion != 0) {
- desc += ", API level=" + ANDROID_VERSION;
- }
- desc += ")";
-
- return desc;
- }
-
- /**
- * Check if the current JVM is of the type passed in parameter. Normally, this will be a constant
- * from this class. We basically do
- * <code>System.getProperty("java.vm.name").startWith(name)</code>.
- *
- * @param name jvm name we are looking for
- * @return if it's the requested JVM
- */
- public static boolean isThisJVM(String name) {
- return JVM_NAME.startsWith(name);
- }
-
- /**
- * Check if this JVM is an Android JVM based on OpenJDK.
- *
- * @return if it's an Android version based on the OpenJDK. Will return false if this JVM isn't an Android JVM at all
- */
- public static boolean isAndroidOpenJDK() {
- return IS_ANDROID_OPENJDK;
- }
-
- private static boolean getIsAndroidOpenJDK() {
- if(getAndroidVersion() == 0) {
- return false; // Not android at all
- }
- // Sadly, Android N is still API 23. So we can't base ourselves on the API level to know if it is an OpenJDK
- // version or not
- String bootClasspath = System.getProperty("java.boot.class.path");
- return bootClasspath != null && bootClasspath.toLowerCase().contains("core-oj.jar");
- }
-
- public static boolean isGoogleAppEngine() {
- return GAE_VERSION != null;
- }
-
- private static String getGaeRuntimeVersion() {
- return System.getProperty("com.google.appengine.runtime.version");
- }
-
- private static int getAndroidVersion() {
- if(!isThisJVM(DALVIK)) {
- return 0;
- }
- return getAndroidVersion0();
- }
-
- private static int getAndroidVersion0() {
- Class<?> clazz;
- try {
- clazz = Class.forName("android.os.Build$VERSION");
- }
- catch(ClassNotFoundException e) {
- throw new ObjenesisException(e);
- }
- Field field;
- try {
- field = clazz.getField("SDK_INT");
- }
- catch(NoSuchFieldException e) {
- // Might be a really old API (before 4), go for SDK
- return getOldAndroidVersion(clazz);
- }
- int version;
- try {
- version = (Integer) field.get(null);
- }
- catch(IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- return version;
- }
-
- private static int getOldAndroidVersion(Class<?> versionClass) {
- Field field;
- try {
- field = versionClass.getField("SDK");
- }
- catch(NoSuchFieldException e) {
- throw new ObjenesisException(e);
- }
- String version;
- try {
- version = (String) field.get(null);
- }
- catch(IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- return Integer.parseInt(version);
- }
-
- private PlatformDescription() {
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/strategy/SerializingInstantiatorStrategy.java b/objenesis-updated/main/src/org/objenesis/strategy/SerializingInstantiatorStrategy.java
deleted file mode 100644
index 1dfcb1c..0000000
--- a/objenesis-updated/main/src/org/objenesis/strategy/SerializingInstantiatorStrategy.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.strategy;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-import org.objenesis.instantiator.android.AndroidSerializationInstantiator;
-import org.objenesis.instantiator.basic.ObjectInputStreamInstantiator;
-import org.objenesis.instantiator.basic.ObjectStreamClassInstantiator;
-import org.objenesis.instantiator.gcj.GCJSerializationInstantiator;
-import org.objenesis.instantiator.perc.PercSerializationInstantiator;
-
-import java.io.NotSerializableException;
-import java.io.Serializable;
-
-import static org.objenesis.strategy.PlatformDescription.*;
-
-/**
- * Guess the best serializing instantiator for a given class. The returned instantiator will
- * instantiate classes like the genuine java serialization framework (the constructor of the first
- * not serializable class will be called). Currently, the selection doesn't depend on the class. It
- * relies on the
- * <ul>
- * <li>JVM version</li>
- * <li>JVM vendor</li>
- * <li>JVM vendor version</li>
- * </ul>
- * However, instantiators are stateful and so dedicated to their class.
- *
- * @author Henri Tremblay
- * @see ObjectInstantiator
- */
-public class SerializingInstantiatorStrategy extends BaseInstantiatorStrategy {
-
- /**
- * Return an {@link ObjectInstantiator} allowing to create instance following the java
- * serialization framework specifications.
- *
- * @param type Class to instantiate
- * @return The ObjectInstantiator for the class
- */
- public <T> ObjectInstantiator<T> newInstantiatorOf(Class<T> type) {
- if(!Serializable.class.isAssignableFrom(type)) {
- throw new ObjenesisException(new NotSerializableException(type+" not serializable"));
- }
- if(JVM_NAME.startsWith(HOTSPOT) || PlatformDescription.isThisJVM(OPENJDK)) {
- if(isGoogleAppEngine()) {
- return new ObjectInputStreamInstantiator<T>(type);
- }
- return new ObjectStreamClassInstantiator<T>(type);
- }
- else if(JVM_NAME.startsWith(DALVIK)) {
- if(PlatformDescription.isAndroidOpenJDK()) {
- return new ObjectStreamClassInstantiator<T>(type);
- }
- return new AndroidSerializationInstantiator<T>(type);
- }
- else if(JVM_NAME.startsWith(GNU)) {
- return new GCJSerializationInstantiator<T>(type);
- }
- else if(JVM_NAME.startsWith(PERC)) {
- return new PercSerializationInstantiator<T>(type);
- }
-
- return new ObjectStreamClassInstantiator<T>(type);
- }
-
-}
diff --git a/objenesis-updated/main/src/org/objenesis/strategy/SingleInstantiatorStrategy.java b/objenesis-updated/main/src/org/objenesis/strategy/SingleInstantiatorStrategy.java
deleted file mode 100644
index 370335b..0000000
--- a/objenesis-updated/main/src/org/objenesis/strategy/SingleInstantiatorStrategy.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.strategy;
-
-import org.objenesis.ObjenesisException;
-import org.objenesis.instantiator.ObjectInstantiator;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * Strategy returning only one instantiator type. Useful if you know on which JVM Objenesis
- * will be used and want to specify it explicitly.
- *
- * @author Henri Tremblay
- */
-public class SingleInstantiatorStrategy implements InstantiatorStrategy {
-
- private Constructor<?> constructor;
-
- /**
- * Create a strategy that will return always the same instantiator type. We assume this instantiator
- * has one constructor taking the class to instantiate in parameter.
- *
- * @param <T> the type we want to instantiate
- * @param instantiator the instantiator type
- */
- public <T extends ObjectInstantiator<?>> SingleInstantiatorStrategy(Class<T> instantiator) {
- try {
- constructor = instantiator.getConstructor(Class.class);
- }
- catch(NoSuchMethodException e) {
- throw new ObjenesisException(e);
- }
- }
-
- /**
- * Return an instantiator for the wanted type and of the one and only type of instantiator returned by this
- * class.
- *
- * @param <T> the type we want to instantiate
- * @param type Class to instantiate
- * @return The ObjectInstantiator for the class
- */
- @SuppressWarnings("unchecked")
- public <T> ObjectInstantiator<T> newInstantiatorOf(Class<T> type) {
- try {
- return (ObjectInstantiator<T>) constructor.newInstance(type);
- } catch (InstantiationException e) {
- throw new ObjenesisException(e);
- } catch (IllegalAccessException e) {
- throw new ObjenesisException(e);
- } catch (InvocationTargetException e) {
- throw new ObjenesisException(e);
- }
- }
-}
diff --git a/objenesis-updated/main/src/org/objenesis/strategy/StdInstantiatorStrategy.java b/objenesis-updated/main/src/org/objenesis/strategy/StdInstantiatorStrategy.java
deleted file mode 100644
index 2d7ce43..0000000
--- a/objenesis-updated/main/src/org/objenesis/strategy/StdInstantiatorStrategy.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.strategy;
-
-import org.objenesis.instantiator.ObjectInstantiator;
-import org.objenesis.instantiator.android.Android10Instantiator;
-import org.objenesis.instantiator.android.Android17Instantiator;
-import org.objenesis.instantiator.android.Android18Instantiator;
-import org.objenesis.instantiator.basic.AccessibleInstantiator;
-import org.objenesis.instantiator.basic.ObjectInputStreamInstantiator;
-import org.objenesis.instantiator.gcj.GCJInstantiator;
-import org.objenesis.instantiator.perc.PercInstantiator;
-import org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator;
-import org.objenesis.instantiator.sun.UnsafeFactoryInstantiator;
-
-import java.io.Serializable;
-
-import static org.objenesis.strategy.PlatformDescription.*;
-
-/**
- * Guess the best instantiator for a given class. The instantiator will instantiate the class
- * without calling any constructor. Currently, the selection doesn't depend on the class. It relies
- * on the
- * <ul>
- * <li>JVM version</li>
- * <li>JVM vendor</li>
- * <li>JVM vendor version</li>
- * </ul>
- * However, instantiators are stateful and so dedicated to their class.
- *
- * @author Henri Tremblay
- * @see ObjectInstantiator
- */
-public class StdInstantiatorStrategy extends BaseInstantiatorStrategy {
-
- /**
- * Return an {@link ObjectInstantiator} allowing to create instance without any constructor being
- * called.
- *
- * @param type Class to instantiate
- * @return The ObjectInstantiator for the class
- */
- public <T> ObjectInstantiator<T> newInstantiatorOf(Class<T> type) {
-
- if(PlatformDescription.isThisJVM(HOTSPOT) || PlatformDescription.isThisJVM(OPENJDK)) {
- if(PlatformDescription.isGoogleAppEngine()) {
- if(Serializable.class.isAssignableFrom(type)) {
- return new ObjectInputStreamInstantiator<T>(type);
- }
- return new AccessibleInstantiator<T>(type);
- }
- // The UnsafeFactoryInstantiator would also work. But according to benchmarks, it is 2.5
- // times slower. So I prefer to use this one
- return new SunReflectionFactoryInstantiator<T>(type);
- }
- else if(PlatformDescription.isThisJVM(DALVIK)) {
- if(PlatformDescription.isAndroidOpenJDK()) {
- // Starting at Android N which is based on OpenJDK
- return new UnsafeFactoryInstantiator<T>(type);
- }
- if(ANDROID_VERSION <= 10) {
- // Android 2.3 Gingerbread and lower
- return new Android10Instantiator<T>(type);
- }
- if(ANDROID_VERSION <= 17) {
- // Android 3.0 Honeycomb to 4.2 Jelly Bean
- return new Android17Instantiator<T>(type);
- }
- // Android 4.3 until Android N
- return new Android18Instantiator<T>(type);
- }
- else if(PlatformDescription.isThisJVM(JROCKIT)) {
- // JRockit is compliant with HotSpot
- return new SunReflectionFactoryInstantiator<T>(type);
- }
- else if(PlatformDescription.isThisJVM(GNU)) {
- return new GCJInstantiator<T>(type);
- }
- else if(PlatformDescription.isThisJVM(PERC)) {
- return new PercInstantiator<T>(type);
- }
-
- // Fallback instantiator, should work with most modern JVM
- return new UnsafeFactoryInstantiator<T>(type);
-
- }
-}
diff --git a/objenesis-updated/tck-android/Android.mk b/objenesis-updated/tck-android/Android.mk
deleted file mode 100644
index e5d647a..0000000
--- a/objenesis-updated/tck-android/Android.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#
-
-LOCAL_PATH := $(call my-dir)
-
-# -------------------------------
-# Builds the deployable Objenesis TCK for Android
-# To build and run:
-# make APP-ObjenesisTck
-# adb install -r out/target/product/generic/data/app/ObjenesisTck.apk
-# adb shell am instrument -w org.objenesis.tck.android/.TckInstrumentation
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := ObjenesisUpdatedTck
-LOCAL_MODULE_TAGS := tests
-LOCAL_CERTIFICATE := platform
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- objenesis-updated-tck-target \
- junit \
- legacy-android-test
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-include $(BUILD_PACKAGE)
diff --git a/objenesis-updated/tck-android/AndroidManifest.xml b/objenesis-updated/tck-android/AndroidManifest.xml
deleted file mode 100644
index cb173f9..0000000
--- a/objenesis-updated/tck-android/AndroidManifest.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-
- Copyright 2006-2016 the original author or authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<!--
- Describes an Android application with a single Instrumentation,
- which runs the Objenesis TCK.
-
- Author: Ian Parkinson, Google Inc.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.objenesis.tck.android"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk
- android:minSdkVersion="1"
- android:targetSdkVersion="23" />
-
- <application android:allowBackup="false">
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation
- android:name=".TckInstrumentation"
- android:targetPackage="org.objenesis.tck.android" />
-
- <instrumentation android:name="android.test.InstrumentationTestRunner"
- android:targetPackage="org.objenesis.tck.android"
- android:label="Objenesis Android TCK."/>
-</manifest>
diff --git a/objenesis-updated/tck-android/src/org/objenesis/tck/android/ObjenesisTest.java b/objenesis-updated/tck-android/src/org/objenesis/tck/android/ObjenesisTest.java
deleted file mode 100644
index af541ba..0000000
--- a/objenesis-updated/tck-android/src/org/objenesis/tck/android/ObjenesisTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.android;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.util.Map;
-
-import org.objenesis.ObjenesisSerializer;
-import org.objenesis.ObjenesisStd;
-import org.objenesis.tck.Main;
-import org.objenesis.tck.Reporter;
-
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Test case running the entire tck on android.
- *
- * @author Henri Tremblay
- */
-public class ObjenesisTest extends AndroidTestCase {
-
- public static class JUnitReporter implements Reporter {
-
- private String currentObjenesis;
-
- private String currentCandidate;
-
- public void startTests(String platformDescription, Map<String, Object> allCandidates,
- Map<String, Object> allInstantiators) {
- }
-
- public void startTest(String candidateDescription, String objenesisDescription) {
- currentCandidate = candidateDescription;
- currentObjenesis = objenesisDescription;
- }
-
- public void endObjenesis(String description) {
- }
-
- public void endTests() {
- }
-
- public void exception(Exception exception) {
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- PrintStream out = new PrintStream(buffer);
- out.println("Exception when instantiating " + currentCandidate + " with "
- + currentObjenesis + ": ");
- exception.printStackTrace(out);
- fail(buffer.toString());
- }
-
- public void result(boolean instantiatedObject) {
- assertTrue("Instantiating " + currentCandidate + " with " + currentObjenesis + " failed",
- instantiatedObject);
- }
-
- public void endTest() {
- }
- }
-
- @SmallTest
- public void testObjenesisStd() throws Exception {
- Main.runStandardTest(new ObjenesisStd(), new JUnitReporter());
- }
-
- @SmallTest
- public void testObjenesisSerializer() throws Exception {
- Main.runSerializerTest(new ObjenesisSerializer(), new JUnitReporter());
- }
-
- @SmallTest
- public void testObjenesisSerializerParentConstructorCalled() throws Exception {
- boolean result = Main.runParentConstructorTest(new ObjenesisSerializer());
- assertTrue(result);
- }
-
-} \ No newline at end of file
diff --git a/objenesis-updated/tck-android/src/org/objenesis/tck/android/TckInstrumentation.java b/objenesis-updated/tck-android/src/org/objenesis/tck/android/TckInstrumentation.java
deleted file mode 100644
index 89451c9..0000000
--- a/objenesis-updated/tck-android/src/org/objenesis/tck/android/TckInstrumentation.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.android;
-
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.os.Bundle;
-import org.objenesis.tck.Main;
-import org.objenesis.tck.TextReporter;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-
-/**
- * Wraps the Objenesis TCK so that it can be invoked on Android as an {@link Instrumentation}.
- *
- * @author Ian Parkinson (Google Inc.)
- */
-public class TckInstrumentation extends Instrumentation {
-
- @Override
- public void onCreate(Bundle arguments) {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- PrintStream printStream = new PrintStream(outputStream);
- System.setOut(printStream);
- System.setErr(printStream);
-
- try {
- launch();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- Bundle bundle = new Bundle();
- String fromStdout = outputStream.toString();
- bundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT, fromStdout);
- finish(Activity.RESULT_OK, bundle);
- }
-
- private void launch() throws IOException {
- TextReporter reporter = new TextReporter(System.out, System.err);
-
- boolean parentConstructorTestSuccessful = Main.run(reporter);
-
- reporter.printResult(parentConstructorTestSuccessful);
-
- }
-}
diff --git a/objenesis-updated/tck/resources/org/objenesis/tck/candidates/candidates.properties b/objenesis-updated/tck/resources/org/objenesis/tck/candidates/candidates.properties
deleted file mode 100644
index fa52243..0000000
--- a/objenesis-updated/tck/resources/org/objenesis/tck/candidates/candidates.properties
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Copyright 2006-2016 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# List of candidate classes to attempt to instantiate in the Objenesis TCK.
-
-# Different visibilities of constructor.
-org.objenesis.tck.candidates.NoConstructor = No constructor
-org.objenesis.tck.candidates.SerializableNoConstructor = No constructor (serializable)
-org.objenesis.tck.candidates.DefaultPublicConstructor = Default public constructor
-org.objenesis.tck.candidates.SerializableDefaultPublicConstructor = Default public constructor (serializable)
-org.objenesis.tck.candidates.DefaultProtectedConstructor = Default protected constructor
-org.objenesis.tck.candidates.SerializableDefaultProtectedConstructor = Default protected constructor (serializable)
-org.objenesis.tck.candidates.DefaultPackageConstructor = Default package constructor
-org.objenesis.tck.candidates.SerializableDefaultPackageConstructor = Default package constructor (serializable)
-org.objenesis.tck.candidates.DefaultPrivateConstructor = Default private constructor
-org.objenesis.tck.candidates.SerializableDefaultPrivateConstructor = Default private constructor (serializable)
-org.objenesis.tck.candidates.SerializableWithAncestorThrowingException = Serializable with ancestor throwing exception
-org.objenesis.tck.candidates.SerializableReplacer = Serializable replacing with another class
-org.objenesis.tck.candidates.SerializableResolver = Serializable resolving to another class
-
-# Constructors that work with arguments passed in.
-org.objenesis.tck.candidates.ConstructorThrowingException = Constructor throwing exception
-org.objenesis.tck.candidates.SerializableConstructorThrowingException = Constructor throwing exception (serializable)
-org.objenesis.tck.candidates.ConstructorWithArguments = Constructor with arguments
-org.objenesis.tck.candidates.SerializableConstructorWithArguments = Constructor with arguments (serializable)
-org.objenesis.tck.candidates.ConstructorWithMandatoryArguments = Constructor with mandatory arguments
-org.objenesis.tck.candidates.SerializableConstructorWithMandatoryArguments = Constructor with mandatory arguments (serializable)
diff --git a/objenesis-updated/tck/resources/org/objenesis/tck/candidates/serializable-candidates.properties b/objenesis-updated/tck/resources/org/objenesis/tck/candidates/serializable-candidates.properties
deleted file mode 100644
index ce26867..0000000
--- a/objenesis-updated/tck/resources/org/objenesis/tck/candidates/serializable-candidates.properties
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright 2006-2016 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# List of candidate classes to attempt to instantiate in the Objenesis TCK.
-
-# Different visibilities of constructor.
-org.objenesis.tck.candidates.SerializableNoConstructor = No constructor (serializable)
-org.objenesis.tck.candidates.SerializableDefaultPublicConstructor = Default public constructor (serializable)
-org.objenesis.tck.candidates.SerializableDefaultProtectedConstructor = Default protected constructor (serializable)
-org.objenesis.tck.candidates.SerializableDefaultPackageConstructor = Default package constructor (serializable)
-org.objenesis.tck.candidates.SerializableDefaultPrivateConstructor = Default private constructor (serializable)
-org.objenesis.tck.candidates.SerializableReplacer = Serializable replacing with another class
-org.objenesis.tck.candidates.SerializableResolver = Serializable resolving to another class
-
-# Constructors that work with arguments passed in.
-org.objenesis.tck.candidates.SerializableConstructorThrowingException = Constructor throwing exception (serializable)
-org.objenesis.tck.candidates.SerializableConstructorWithArguments = Constructor with arguments (serializable)
-org.objenesis.tck.candidates.SerializableConstructorWithMandatoryArguments = Constructor with mandatory arguments (serializable)
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/CandidateLoader.java b/objenesis-updated/tck/src/org/objenesis/tck/CandidateLoader.java
deleted file mode 100644
index 617572b..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/CandidateLoader.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.util.Properties;
-
-/**
- * Loads a set of candidate classes from a properties file into the TCK.
- * <p>
- * The properties file takes the form of candidateClassName=shortDescription.
- *
- * @author Joe Walnes
- * @see TCK
- */
-public class CandidateLoader {
-
- private final TCK tck;
- private final ClassLoader classloader;
- private final ErrorHandler errorHandler;
-
- /**
- * Handler for reporting errors from the CandidateLoader.
- */
- public interface ErrorHandler {
- /**
- * Called whenever, trying to retrieve a candidate class from its name, a
- * ClassNotFoundException is thrown
- *
- * @param name Candidate class name
- */
- void classNotFound(String name);
- }
-
- /**
- * Error handler that logs errors to a text stream.
- */
- public static class LoggingErrorHandler implements CandidateLoader.ErrorHandler {
-
- private final PrintStream out;
-
- /**
- * @param out Stream in which to log
- */
- public LoggingErrorHandler(PrintStream out) {
- this.out = out;
- }
-
- public void classNotFound(String name) {
- out.println("Class not found : " + name);
- }
-
- }
-
- /**
- * @param tck TCK that will use the candidates
- * @param classloader ClassLoader from which candidates classes are loaded
- * @param errorHandler Handler called in case of error
- */
- public CandidateLoader(TCK tck, ClassLoader classloader, ErrorHandler errorHandler) {
- this.tck = tck;
- this.classloader = classloader;
- this.errorHandler = errorHandler;
- }
-
- /**
- * @param inputStream Stream containing the properties
- * @throws IOException If something goes wrong while reading the stream
- */
- public void loadFrom(InputStream inputStream) throws IOException {
- // Properties contains a convenient key=value parser, however it stores
- // the entries in a Hashtable which loses the original order.
- // So, we create a special Properties instance that writes its
- // entries directly to the TCK (which retains order).
- Properties properties = new Properties() {
- private static final long serialVersionUID = 1L;
- @Override
- public Object put(Object key, Object value) {
- handlePropertyEntry((String) key, (String) value);
- return null;
- }
- };
- properties.load(inputStream);
- }
-
- /**
- * Load a candidate property file
- *
- * @param cls Class on which <code>getResourceAsStream</code> is called
- * @param resource File name
- * @throws IOException If there's problem reading the file
- */
- public void loadFromResource(Class<?> cls, String resource) throws IOException {
- InputStream candidatesConfig = cls.getResourceAsStream(resource);
- if(candidatesConfig == null) {
- throw new IOException("Resource '" + resource + "' not found relative to " + cls.getName());
- }
- try {
- loadFrom(candidatesConfig);
- }
- finally {
- candidatesConfig.close();
- }
- }
-
- private void handlePropertyEntry(String key, String value) {
- try {
- Class<?> candidate = Class.forName(key, true, classloader);
- tck.registerCandidate(candidate, value);
- }
- catch(ClassNotFoundException e) {
- errorHandler.classNotFound(key);
- }
- }
-
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/Main.java b/objenesis-updated/tck/src/org/objenesis/tck/Main.java
deleted file mode 100644
index 3bbabf9..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/Main.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck;
-
-import org.objenesis.Objenesis;
-import org.objenesis.ObjenesisSerializer;
-import org.objenesis.ObjenesisStd;
-
-import java.io.IOException;
-import java.io.Serializable;
-
-/**
- * Command line launcher for Technology Compatibility Kit (TCK).
- *
- * @author Joe Walnes
- * @see TCK
- */
-public class Main {
-
- private static class MockSuperClass {
- private final boolean superConstructorCalled;
-
- public MockSuperClass() {
- superConstructorCalled = true;
- }
-
- public boolean isSuperConstructorCalled() {
- return superConstructorCalled;
- }
- }
-
- private static class MockClass extends MockSuperClass implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private final boolean constructorCalled;
-
- @SuppressWarnings("unused")
- public MockClass() {
- constructorCalled = true;
- }
-
- public boolean isConstructorCalled() {
- return constructorCalled;
- }
- }
-
- /**
- * Main class of the TCK. Can also be called as a normal method from an application server.
- *
- * @param args No parameters are required
- * @throws IOException When the TCK fails to read properties' files.
- */
- public static void main(String[] args) throws IOException {
-
- TextReporter reporter = new TextReporter(System.out, System.err);
-
- boolean result = run(reporter);
-
- reporter.printResult(result);
-
- if(reporter.hasErrors()) {
- System.exit(1);
- }
- }
-
- /**
- * Run the full test suite using standard Objenesis instances
- *
- * @param reporter result are recorded in the reporter
- * @return if the parent constructor test was successful
- */
- public static boolean run(Reporter reporter) {
- runStandardTest(new ObjenesisStd(), reporter);
- runSerializerTest(new ObjenesisSerializer(), reporter);
-
- boolean result = runParentConstructorTest(new ObjenesisSerializer());
- return result;
- }
-
- /**
- * Run the serializing suite on the provided Objenesis instance
- *
- * @param reporter result are recorded in the reporter
- * @param objenesis Objenesis instance to test
- */
- public static void runSerializerTest(Objenesis objenesis, Reporter reporter) {
- runTest(objenesis, reporter, "Objenesis serializer",
- "candidates/serializable-candidates.properties");
- }
-
- /**
- * Run the standard suite on the provided Objenesis instance
- *
- * @param reporter result are recorded in the reporter
- * @param objenesis Objenesis instance to test
- */
- public static void runStandardTest(Objenesis objenesis, Reporter reporter) {
- runTest(objenesis, reporter, "Objenesis std", "candidates/candidates.properties");
- }
-
- /**
- * A special test making sure the first none serializable class no-args constructor is called
- *
- * @param objenesis Objenesis instance to test
- * @return if the test was successful
- */
- public static boolean runParentConstructorTest(Objenesis objenesis) {
- try {
- Object result = objenesis.newInstance(MockClass.class);
- MockClass mockObject = (MockClass) result;
- return mockObject.isSuperConstructorCalled() && !mockObject.isConstructorCalled();
- }
- catch(Exception e) {
- System.err.println("--- Not serializable parent constructor called as expected ---");
- e.printStackTrace(System.err);
- return false;
- }
- }
-
- /**
- * Run a suite of tests (candidates) on the Objenesis instance, sending the results to the
- * reporter
- *
- * @param objenesis Objenesis instance to test
- * @param reporter result are recorded in the reporter
- * @param description description of the ran suite
- * @param candidates property file containing a list of classes to test (key) and their
- * description (value)
- */
- public static void runTest(Objenesis objenesis, Reporter reporter, String description,
- String candidates) {
- TCK tck = new TCK();
- tck.registerObjenesisInstance(objenesis, description);
-
- CandidateLoader candidateLoader = new CandidateLoader(tck, Main.class.getClassLoader(),
- new CandidateLoader.LoggingErrorHandler(System.err));
-
- try {
- candidateLoader.loadFromResource(Main.class, candidates);
- }
- catch(IOException e) {
- throw new RuntimeException(e);
- }
-
- tck.runTests(reporter);
- }
-
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/Reporter.java b/objenesis-updated/tck/src/org/objenesis/tck/Reporter.java
deleted file mode 100644
index d24899d..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/Reporter.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck;
-
-import java.util.Map;
-
-/**
- * Reports results from the TCK back to the user.
- * <p>
- * The sequence these methods are called is described below:
- * </p>
- *
- * <pre>
- * startTests(startObjenesis(result | exception) * endObjenesis) * endTests
- * </pre>
- *
- * @author Joe Walnes
- * @see TCK
- * @see TextReporter
- */
-public interface Reporter {
-
- /**
- * Report that the tests are starting. Provides information that is useful to be reported.
- *
- * @param platformDescription Description the platform being run on (i.e. JVM version, vendor,
- * etc).
- * @param allCandidates Descriptions (String) of all candidates (Object) being used in tests.
- * @param allObjenesisInstances Descriptions (String) of all Objenesis instances (Object) being
- * used in tests.
- */
- void startTests(String platformDescription, Map<String, Object> allCandidates,
- Map<String, Object> allObjenesisInstances);
-
- /**
- * Report that a test between a candidate and an objenesis instance if about to start.
- *
- * @param candidateDescription Description of the candidate class.
- * @param objenesisDescription Description of the objenesis instance.
- */
- void startTest(String candidateDescription, String objenesisDescription);
-
- /**
- * Report details about what happened when an Objenesis instance tried to instantiate the current
- * candidate.
- *
- * @param instantiatedObject Whether the ObjectInstantiator successfully instantiated the
- * candidate class.
- */
- void result(boolean instantiatedObject);
-
- /**
- * Report that something bad happened during the test.
- *
- * @param exception Exception thrown by instantiator.
- */
- void exception(Exception exception);
-
- /**
- * Report that tests have been completed for a particular Objenesis instance and candidate.
- */
- void endTest();
-
- /**
- * Report that all tests have finished. Nothing will be called after this method.
- */
- void endTests();
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/TCK.java b/objenesis-updated/tck/src/org/objenesis/tck/TCK.java
deleted file mode 100644
index c42df1e..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/TCK.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck;
-
-import org.objenesis.Objenesis;
-import org.objenesis.strategy.PlatformDescription;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * <b>Technology Compatibility Kit</b> (TCK) for {@link Objenesis}s.
- * <p>
- * This TCK accepts a set of candidate classes (class it attempts to instantiate) and a set of
- * Objenesis implementations. It then tries instantiating every candidate with every Objenesis
- * implementations, reporting the results to a {@link Reporter}.
- *
- * <h3>Example usage</h3>
- *
- * <pre>
- * TCK tck = new TCK();
- * // register candidate classes.
- * tck.registerCandidate(SomeClass.class, &quot;A basic class&quot;);
- * tck.registerCandidate(SomeEvil.class, &quot;Something evil&quot;);
- * tck.registerCandidate(NotEvil.class, &quot;Something nice&quot;);
- * // register Objenesis instances.
- * tck.registerObjenesisInstance(new ObjenesisStd(), &quot;Objenesis&quot;);
- * tck.registerObjenesisInstance(new ObjenesisSerializaer(), &quot;Objenesis for serialization&quot;);
- * // go!
- * Reporter reporter = new TextReporter(System.out, System.err);
- * tck.runTests(reporter);
- * </pre>
- *
- * @author Joe Walnes
- * @see org.objenesis.instantiator.ObjectInstantiator
- * @see Reporter
- * @see Main
- */
-public class TCK {
-
- private final List<Objenesis> objenesisInstances = new ArrayList<Objenesis>();
- private final List<Class<?>> candidates = new ArrayList<Class<?>>();
- private final Map<Object, String> descriptions = new HashMap<Object, String>();
-
- /**
- * Register a candidate class to attempt to instantiate.
- *
- * @param candidateClass Class to attempt to instantiate
- * @param description Description of the class
- */
- public void registerCandidate(Class<?> candidateClass, String description) {
- candidates.add(candidateClass);
- descriptions.put(candidateClass, description);
- }
-
- /**
- * Register an Objenesis instance to use when attempting to instantiate a class.
- *
- * @param objenesis Tested Objenesis instance
- * @param description Description of the Objenesis instance
- */
- public void registerObjenesisInstance(Objenesis objenesis, String description) {
- objenesisInstances.add(objenesis);
- descriptions.put(objenesis, description);
- }
-
- /**
- * Run all TCK tests.
- *
- * @param reporter Where to report the results of the test to.
- */
- public void runTests(Reporter reporter) {
- reporter.startTests(describePlatform(), findAllDescriptions(candidates, descriptions),
- findAllDescriptions(objenesisInstances, descriptions));
-
- for(Class<?> candidateClass : candidates) {
- String candidateDescription = descriptions.get(candidateClass);
-
- for(Objenesis objenesis : objenesisInstances) {
- String objenesisDescription = descriptions.get(objenesis);
-
- reporter.startTest(candidateDescription, objenesisDescription);
-
- runTest(reporter, candidateClass, objenesis);
-
- reporter.endTest();
- }
- }
- reporter.endTests();
- }
-
- private void runTest(Reporter reporter, Class<?> candidate, Objenesis objenesis) {
- try {
- Object instance = objenesis.newInstance(candidate);
- boolean success = instance != null && instance.getClass() == candidate;
- reporter.result(success);
- }
- catch(Exception e) {
- reporter.exception(e);
- }
- }
-
- /**
- * Return the human readable description for list of TCK items (Objenesis instances or test
- * candidates)
- *
- * @param keys list of items for which we are searching for a description
- * @param descriptions all descriptions
- * @return map of items with their description. Will contain one entry per entry in the original
- * key list
- */
- private Map<String, Object> findAllDescriptions(List<?> keys, Map<?, String> descriptions) {
- Map<String, Object> results = new HashMap<String, Object>(keys.size());
- for(Object o : keys) {
- results.put(descriptions.get(o), o);
- }
- return results;
- }
-
- /**
- * Describes the platform. Outputs Java version and vendor. To change this behavior, override
- * this method.
- *
- * @return Description of the current platform
- */
- protected String describePlatform() {
- return PlatformDescription.describePlatform();
- }
-
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/TextReporter.java b/objenesis-updated/tck/src/org/objenesis/tck/TextReporter.java
deleted file mode 100644
index b9c3735..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/TextReporter.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck;
-
-import org.objenesis.Objenesis;
-
-import java.io.PrintStream;
-import java.util.*;
-
-/**
- * Reports results from TCK as tabulated text, suitable for dumping to the console or a file and
- * being read by a human. It can be reused to provide a summary reports of different candidates as
- * long as the same <code>objenesisDescription</code> is not used twice.
- *
- * @author Joe Walnes
- * @author Henri Tremblay
- * @see TCK
- * @see Reporter
- */
-public class TextReporter implements Reporter {
-
- private static class Result {
-
- String objenesisDescription;
-
- String candidateDescription;
-
- boolean result;
-
- Exception exception;
-
- /**
- * @param objenesisDescription Description of the tested Objenesis instance
- * @param candidateDescription Description of the tested candidate
- * @param result If the test is successful or not
- * @param exception Exception that might have occured during the test
- */
- public Result(String objenesisDescription, String candidateDescription, boolean result,
- Exception exception) {
- this.objenesisDescription = objenesisDescription;
- this.candidateDescription = candidateDescription;
- this.result = result;
- this.exception = exception;
- }
- }
-
- private final PrintStream summary;
-
- private final PrintStream log;
-
- private long startTime;
-
- private long totalTime = 0;
-
- private int errorCount = 0;
-
- private SortedMap<String, Object> allCandidates = new TreeMap<String, Object>();
-
- private SortedMap<String, Object> allInstantiators = new TreeMap<String, Object>();
-
- private String currentObjenesis;
-
- private String currentCandidate;
-
- private Map<Object, Map<String, Result>> objenesisResults = new HashMap<Object, Map<String, Result>>();
-
- private String platformDescription;
-
- /**
- * @param summary Output of main report.
- * @param log Any additional information, useful for diagnostics.
- */
- public TextReporter(PrintStream summary, PrintStream log) {
- this.summary = summary;
- this.log = log;
- }
-
- public int getErrorCount() {
- return errorCount;
- }
-
- public void startTests(String platformDescription, Map<String, Object> allCandidates,
- Map<String, Object> allInstantiators) {
-
- // HT: in case the same reporter is reused, I'm guessing that it will
- // always be the same platform
- this.platformDescription = platformDescription;
- this.allCandidates.putAll(allCandidates);
- this.allInstantiators.putAll(allInstantiators);
-
- for(String desc : allInstantiators.keySet()) {
- objenesisResults.put(desc, new HashMap<String, Result>());
- }
-
- startTime = System.currentTimeMillis();
- }
-
- public void startTest(String candidateDescription, String objenesisDescription) {
- currentCandidate = candidateDescription;
- currentObjenesis = objenesisDescription;
- }
-
- public void result(boolean instantiatedObject) {
- if(!instantiatedObject) {
- errorCount++;
- }
- objenesisResults.get(currentObjenesis).put(currentCandidate,
- new Result(
- currentObjenesis, currentCandidate, instantiatedObject, null));
- }
-
- public void exception(Exception exception) {
-
- errorCount++;
-
- objenesisResults.get(currentObjenesis).put(currentCandidate,
- new Result(
- currentObjenesis, currentCandidate, false, exception));
- }
-
- public void endTest() {
- }
-
- public void endTests() {
- totalTime += System.currentTimeMillis() - startTime;
- }
-
- /**
- * Print the final summary report
- *
- * @param parentConstructorTest If the test checking that the none serializable constructor was called was successful
- */
- public void printResult(boolean parentConstructorTest) {
- // Platform
- summary.println("Running TCK on platform: " + platformDescription);
- summary.println();
-
- // Instantiator implementations
- summary.println("Instantiators used: ");
- for(Map.Entry<String, Object> o : allInstantiators.entrySet()) {
- String inst = ((Objenesis) o.getValue()).getInstantiatorOf(String.class).getClass()
- .getSimpleName();
- summary.println(" " + o.getKey() + ": " + inst);
- }
- summary.println();
-
- // Parent constructor special test
- summary.println("Not serializable parent constructor called as expected: "
- + (parentConstructorTest ? 'Y' : 'N'));
- summary.println();
-
- if(!parentConstructorTest) {
- errorCount++;
- }
-
- Set<String> instantiators = this.allInstantiators.keySet();
- Set<String> candidates = this.allCandidates.keySet();
-
- int maxObjenesisWidth = lengthOfLongestStringIn(instantiators);
- int maxCandidateWidth = lengthOfLongestStringIn(candidates);
-
- // Strategy used
- summary.print(pad("", maxCandidateWidth) + ' ');
- for(String desc : instantiators) {
- summary.print(pad(desc, maxObjenesisWidth) + ' ');
- }
- summary.println();
-
- List<Result> exceptions = new ArrayList<Result>();
-
- // Candidates (and keep the exceptions meanwhile)
- for(String candidateDesc : candidates) {
- summary.print(pad(candidateDesc, maxCandidateWidth) + ' ');
-
- for(String instDesc : instantiators) {
- Result result = objenesisResults.get(instDesc).get(candidateDesc);
- if(result == null) {
- summary.print(pad("N/A", maxObjenesisWidth) + " ");
- }
- else {
- summary.print(pad(result.result ? "Y" : "n", maxObjenesisWidth) + " ");
-
- if(result.exception != null) {
- exceptions.add(result);
- }
- }
- }
- summary.println();
- }
-
- summary.println();
-
- // Final
- if(errorCount != 0) {
-
- for(Result element : exceptions) {
- log.println("--- Candidate '" + element.candidateDescription + "', Instantiator '"
- + element.objenesisDescription + "' ---");
- element.exception.printStackTrace(log);
- log.println();
- }
-
- log.println();
-
- summary.println("--- FAILED: " + errorCount + " error(s) occured ---");
- }
- else {
- summary.println("--- SUCCESSFUL: TCK tests passed without errors in " + totalTime + " ms");
- }
-
- summary.println();
- }
-
- /**
- * Return true if the reporter has registered some errors
- *
- * @return if there was errors during execution
- */
- public boolean hasErrors() {
- return errorCount != 0;
- }
-
- private String pad(String text, int width) {
- if(text.length() == width) {
- return text;
- }
- else if(text.length() > width) {
- return text.substring(0, width);
- }
- else {
- StringBuilder padded = new StringBuilder(text);
- while(padded.length() < width) {
- padded.append(' ');
- }
- return padded.toString();
- }
- }
-
- private int lengthOfLongestStringIn(Collection<String> descriptions) {
- int result = 0;
- for(Iterator<String> it = descriptions.iterator(); it.hasNext();) {
- result = Math.max(result, it.next().length());
- }
- return result;
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/ConstructorThrowingException.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/ConstructorThrowingException.java
deleted file mode 100644
index 855cfb7..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/ConstructorThrowingException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-/**
- * @author Joe Walnes
- */
-public class ConstructorThrowingException {
-
- public ConstructorThrowingException() {
- throw new IllegalArgumentException("Constructor throwing an exception");
- }
-
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/ConstructorWithArguments.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/ConstructorWithArguments.java
deleted file mode 100644
index e2c8d3a..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/ConstructorWithArguments.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-/**
- * @author Joe Walnes
- */
-public class ConstructorWithArguments {
-
- private final String something;
- private final int another;
-
- public ConstructorWithArguments(String something, int another) {
- this.something = something;
- this.another = another;
- }
-
- public String toString() {
- return something + another;
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/ConstructorWithMandatoryArguments.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/ConstructorWithMandatoryArguments.java
deleted file mode 100644
index a26924d..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/ConstructorWithMandatoryArguments.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-/**
- * @author Joe Walnes
- */
-public class ConstructorWithMandatoryArguments {
-
- public ConstructorWithMandatoryArguments(String something) {
- if(something == null) {
- throw new IllegalArgumentException("Need arguments");
- }
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultPackageConstructor.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultPackageConstructor.java
deleted file mode 100644
index 7c386fc..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultPackageConstructor.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-/**
- * @author Joe Walnes
- */
-public class DefaultPackageConstructor {
-
- DefaultPackageConstructor() {
-
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultPrivateConstructor.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultPrivateConstructor.java
deleted file mode 100644
index e008ed6..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultPrivateConstructor.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-/**
- * @author Joe Walnes
- */
-public class DefaultPrivateConstructor {
-
- private DefaultPrivateConstructor() {
-
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultProtectedConstructor.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultProtectedConstructor.java
deleted file mode 100644
index f81f2ee..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultProtectedConstructor.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-/**
- * @author Joe Walnes
- */
-public class DefaultProtectedConstructor {
-
- protected DefaultProtectedConstructor() {
-
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultPublicConstructor.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultPublicConstructor.java
deleted file mode 100644
index 2321590..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/DefaultPublicConstructor.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-/**
- * @author Joe Walnes
- */
-public class DefaultPublicConstructor {
-
- public DefaultPublicConstructor() {
-
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/NoConstructor.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/NoConstructor.java
deleted file mode 100644
index e83cb0b..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/NoConstructor.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-/**
- * @author Joe Walnes
- */
-public class NoConstructor {
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableConstructorThrowingException.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableConstructorThrowingException.java
deleted file mode 100644
index b5bf807..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableConstructorThrowingException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-import java.io.Serializable;
-
-/**
- * @author Joe Walnes
- */
-public class SerializableConstructorThrowingException implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public SerializableConstructorThrowingException() {
- throw new IllegalArgumentException("Constructor throwing an exception");
- }
-
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithArguments.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithArguments.java
deleted file mode 100644
index 6c07e4a..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithArguments.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-import java.io.Serializable;
-
-/**
- * @author Joe Walnes
- */
-public class SerializableConstructorWithArguments implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private final String something;
- private final int another;
-
- public SerializableConstructorWithArguments(String something, int another) {
- this.something = something;
- this.another = another;
- }
-
- public String toString() {
- return something + another;
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithMandatoryArguments.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithMandatoryArguments.java
deleted file mode 100644
index 045be68..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithMandatoryArguments.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-import java.io.Serializable;
-
-/**
- * @author Joe Walnes
- */
-public class SerializableConstructorWithMandatoryArguments implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public SerializableConstructorWithMandatoryArguments(String something) {
- if(something == null) {
- throw new IllegalArgumentException("Need arguments");
- }
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultPackageConstructor.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultPackageConstructor.java
deleted file mode 100644
index 795e8eb..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultPackageConstructor.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-import java.io.Serializable;
-
-/**
- * @author Joe Walnes
- */
-public class SerializableDefaultPackageConstructor implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- SerializableDefaultPackageConstructor() {
-
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultPrivateConstructor.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultPrivateConstructor.java
deleted file mode 100644
index 20a9e0f..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultPrivateConstructor.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-import java.io.Serializable;
-
-/**
- * @author Joe Walnes
- */
-public class SerializableDefaultPrivateConstructor implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private SerializableDefaultPrivateConstructor() {
-
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultProtectedConstructor.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultProtectedConstructor.java
deleted file mode 100644
index d14df0d..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultProtectedConstructor.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-import java.io.Serializable;
-
-/**
- * @author Joe Walnes
- */
-public class SerializableDefaultProtectedConstructor implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- protected SerializableDefaultProtectedConstructor() {
-
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultPublicConstructor.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultPublicConstructor.java
deleted file mode 100644
index d1d26d9..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableDefaultPublicConstructor.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-import java.io.Serializable;
-
-/**
- * @author Joe Walnes
- */
-public class SerializableDefaultPublicConstructor implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public SerializableDefaultPublicConstructor() {
-
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableNoConstructor.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableNoConstructor.java
deleted file mode 100644
index 9996a52..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableNoConstructor.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-import java.io.Serializable;
-
-/**
- * @author Joe Walnes
- */
-public class SerializableNoConstructor implements Serializable {
- private static final long serialVersionUID = 1L;
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableReplacer.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableReplacer.java
deleted file mode 100644
index a78db46..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableReplacer.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-import java.io.Serializable;
-
-/**
- * @author Joe Walnes
- */
-public class SerializableReplacer implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- protected Object writeReplace() {
- return new SerializableResolver();
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableResolver.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableResolver.java
deleted file mode 100644
index 875aab1..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableResolver.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-import java.io.Serializable;
-
-/**
- * @author Joe Walnes
- */
-public class SerializableResolver implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- protected Object readResolve() {
- return new SerializableReplacer();
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableWithAncestorThrowingException.java b/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableWithAncestorThrowingException.java
deleted file mode 100644
index 33aeae6..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/candidates/SerializableWithAncestorThrowingException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.candidates;
-
-import java.io.Serializable;
-
-/**
- * @author Joe Walnes
- */
-public class SerializableWithAncestorThrowingException extends ConstructorThrowingException
- implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public SerializableWithAncestorThrowingException() {
-
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/search/ClassEnumerator.java b/objenesis-updated/tck/src/org/objenesis/tck/search/ClassEnumerator.java
deleted file mode 100644
index 9394af3..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/search/ClassEnumerator.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.search;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.*;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-/**
- * Taken and adapted from <a href="https://raw.githubusercontent.com/ddopson/java-class-enumerator/master/src/pro/ddopson/ClassEnumerator.java">here</a>
- *
- * @author Henri Tremblay
- */
-public class ClassEnumerator {
-
- private static Class<?> loadClass(String className) {
- try {
- return Class.forName(className);
- }
- catch (ClassNotFoundException e) {
- throw new RuntimeException("Unexpected ClassNotFoundException loading class '" + className + "'");
- }
- }
-
- private static void processDirectory(File directory, String pkgname, SortedSet<Class<?>> classes) {
-
- // Get the list of the files contained in the package
- String[] files = directory.list();
-
- for (int i = 0; i < files.length; i++) {
- String fileName = files[i];
- // we are only interested in .class files
- if (fileName.endsWith(".class")) {
- // removes the .class extension
- String className = pkgname + '.' + fileName.substring(0, fileName.length() - 6);
- classes.add(loadClass(className));
- continue;
- }
-
- File subdir = new File(directory, fileName);
- if (subdir.isDirectory()) {
- processDirectory(subdir, pkgname + '.' + fileName, classes);
- }
- }
- }
-
- private static void processJarfile(URL resource, String pkgname, SortedSet<Class<?>> classes) {
- String relPath = pkgname.replace('.', '/');
- String resPath = resource.getPath();
- String jarPath = resPath.replaceFirst("[.]jar[!].*", ".jar").replaceFirst("file:", "");
-
- JarFile jarFile;
- try {
- jarFile = new JarFile(jarPath);
- } catch (IOException e) {
- throw new RuntimeException("Unexpected IOException reading JAR File '" + jarPath + "'", e);
- }
- Enumeration<JarEntry> entries = jarFile.entries();
- while(entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
- String entryName = entry.getName();
- String className = null;
- if(entryName.endsWith(".class") && entryName.startsWith(relPath) && entryName.length() > (relPath.length() + "/".length())) {
- className = entryName.replace('/', '.').replace('\\', '.').replace(".class", "");
- }
-
- if (className != null) {
- classes.add(loadClass(className));
- }
- }
- }
-
- public static SortedSet<Class<?>> getClassesForPackage(Package pkg) {
- return getClassesForPackage(pkg, ClassEnumerator.class.getClassLoader());
- }
-
- public static SortedSet<Class<?>> getClassesForPackage(Package pkg, ClassLoader classLoader) {
- SortedSet<Class<?>> classes = new TreeSet<Class<?>>(new Comparator<Class<?>>() {
- public int compare(Class<?> o1, Class<?> o2) {
- return o1.getSimpleName().compareTo(o2.getSimpleName());
- }
- });
-
- String pkgname = pkg.getName();
- String relPath = pkgname.replace('.', '/');
-
- // Get a File object for the package
- Enumeration<URL> resources;
- try {
- resources = classLoader.getResources(relPath);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- while(resources.hasMoreElements()) {
- URL resource = resources.nextElement();
- if (resource.toString().startsWith("jar:")) {
- processJarfile(resource, pkgname, classes);
- } else {
- processDirectory(new File(resource.getPath()), pkgname, classes);
- }
- }
-
- return classes;
- }
-
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/search/SearchWorkingInstantiator.java b/objenesis-updated/tck/src/org/objenesis/tck/search/SearchWorkingInstantiator.java
deleted file mode 100644
index 0e019dc..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/search/SearchWorkingInstantiator.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.search;
-
-import org.objenesis.instantiator.ObjectInstantiator;
-import org.objenesis.strategy.PlatformDescription;
-import org.objenesis.tck.candidates.SerializableNoConstructor;
-
-import java.io.Serializable;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-/**
- * This class will try every available instantiator on the platform to see which works.
- *
- * @author Henri Tremblay
- */
-public class SearchWorkingInstantiator implements Serializable { // implements Serializable just for the test
-
- private SearchWorkingInstantiatorListener listener;
-
- public static void main(String[] args) throws Exception {
- System.out.println();
- System.out.println(PlatformDescription.describePlatform());
- System.out.println();
-
- SearchWorkingInstantiator searchWorkingInstantiator = new SearchWorkingInstantiator(new SystemOutListener());
- searchWorkingInstantiator.searchForInstantiator(SerializableNoConstructor.class);
- }
-
- public SearchWorkingInstantiator(SearchWorkingInstantiatorListener listener) {
- this.listener = listener;
- }
-
- public void searchForInstantiator(Class<?> toInstantiate) {
- SortedSet<Class<?>> classes = ClassEnumerator.getClassesForPackage(ObjectInstantiator.class.getPackage());
-
- for (Iterator<Class<?>> it = classes.iterator(); it.hasNext();) {
- Class<?> c = it.next();
- if(c.isInterface() || !ObjectInstantiator.class.isAssignableFrom(c)) {
- continue;
- }
-
- Constructor<?> constructor;
- try {
- constructor = c.getConstructor(Class.class);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- }
-
- try {
- ObjectInstantiator<?> instantiator =
- (ObjectInstantiator<?>) constructor.newInstance(toInstantiate);
- instantiator.newInstance();
- listener.instantiatorSupported(c);
- }
- catch(Exception e) {
- Throwable t = (e instanceof InvocationTargetException) ? e.getCause() : e;
- listener.instantiatorUnsupported(c, t);
- }
- }
- }
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/search/SearchWorkingInstantiatorListener.java b/objenesis-updated/tck/src/org/objenesis/tck/search/SearchWorkingInstantiatorListener.java
deleted file mode 100644
index f2b53d7..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/search/SearchWorkingInstantiatorListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.search;
-
-/**
- * @author Henri Tremblay
- */
-public interface SearchWorkingInstantiatorListener {
-
- void instantiatorSupported(Class<?> c);
-
- void instantiatorUnsupported(Class<?> c, Throwable t);
-}
diff --git a/objenesis-updated/tck/src/org/objenesis/tck/search/SystemOutListener.java b/objenesis-updated/tck/src/org/objenesis/tck/search/SystemOutListener.java
deleted file mode 100644
index 0babf1c..0000000
--- a/objenesis-updated/tck/src/org/objenesis/tck/search/SystemOutListener.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright 2006-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.objenesis.tck.search;
-
-/**
- * @author Henri Tremblay
- */
-public class SystemOutListener implements SearchWorkingInstantiatorListener {
-
- private static final String PATTERN = "%-50s: %s%n";
-
- public void instantiatorSupported(Class<?> c) {
- System.out.printf(PATTERN, c.getSimpleName(), "Working!");
- }
-
- public void instantiatorUnsupported(Class<?> c, Throwable t) {
- System.out.printf(PATTERN, c.getSimpleName(), "KO - " + t);
- }
-}