1/** 2 * Copyright 2006-2013 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package org.objenesis.instantiator.sun; 17 18import java.lang.reflect.InvocationTargetException; 19 20import org.objenesis.ObjenesisException; 21 22/** 23 * Instantiates a class by making a call to internal Sun private methods. It is only supposed to 24 * work on Sun HotSpot 1.3 JVM. This instantiator will not call any constructors. 25 * 26 * @author Leonardo Mesquita 27 * @see org.objenesis.instantiator.ObjectInstantiator 28 */ 29public class Sun13Instantiator extends Sun13InstantiatorBase { 30 public Sun13Instantiator(Class type) { 31 super(type); 32 } 33 34 public Object newInstance() { 35 try { 36 return allocateNewObjectMethod.invoke(null, new Object[] {type, Object.class}); 37 } 38 catch(RuntimeException e) { 39 throw new ObjenesisException(e); 40 } 41 catch(IllegalAccessException e) { 42 throw new ObjenesisException(e); 43 } 44 catch(InvocationTargetException e) { 45 throw new ObjenesisException(e); 46 } 47 } 48 49} 50