com.fitbur.mockito.objenesis.instantiator.basic.ClassDefinitionUtils Maven / Gradle / Ivy
/**
* 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 com.fitbur.mockito.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 com.fitbur.mockito.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
* here
*
* @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() {
public ProtectionDomain run() {
return ClassDefinitionUtils.class.getProtectionDomain();
}
});
AccessController.doPrivileged(new PrivilegedAction
© 2015 - 2024 Weber Informatics LLC | Privacy Policy