{Class clazz=NULL;//This.findloadedclass (name);//The parent class is loaded//if (clazz = = null) {//Check if the class has been loaded byte[] Classdata = Getclassdata (name);//gets the byte-code array of the class file, based on the binary name of the if(Classdata = =NULL) { Throw Newclassnotfoundexception (); } clazz= Def
program, and which account is used to execute jps, except for the root account), run the jps command to see the following results:
root@ubuntu:/home/fengzheng/codes/btrace# jps10906 Jps10860 NumberUtil
3. the java Process just executed is 10860.
4. Compile the btrace script. The script content is as follows:
package kite;import com.sun.btrace.annotations.*;import static com.sun.btrace.BTraceUtils.Strings.strcat;import static com.sun.btrace.BTraceUtils.jstack;import static com.sun.btrace.BTraceU
"System.out"#defineLOGE (...) __android_log_print (Android_log_error, Log_tag, __va_args__)Jniexportvoidjnicall java_com_zz_ccalljava_jni_callvoid (jnienv*env, Jobject thiz) { //① found byte-code object Class Jclass (*findclass) (jnienv*, const char*); //The second parameter to find the full class name of the bytecodeJclass clazz = (*env)->findclass (env,"Com/zz/ccalljava/jni"); //② Find the method to invoke in class//Jmethodid (*getmethodid) (jni
); } public static UserKey getById = new UserKey ("id"); public static UserKey Getbyname = new UserKey ("name");}4. Write Redisservice.java provides Redis service, mainly get (), set (), exists (), serialization, deserialization,Be sure to return to the pool after using the Redis link.@Servicepublic class Redisservice { Annotations recommend the use of @resource, need to guide the package@AutowiredJedispool Jedispool; /*** Get an Object* */Public Jedis Jedis = null;try {Jedis = Jedispo
of the class objectString getName (): Returns the name of the entity (class, interface, array class, base type, or void) represented by this class objectClass Getsuperclass (): Returns the Class object of the parent class of the current class objectclass [] Getinterfaces (): Gets the interface of the current class objectClassLoader getClassLoader (): Returns the class loader for this classConstructor[] GetConstructors (): Returns an array containing some Constructor objectsField[] GetFields ():
The code is as follows:
Copy Code code as follows:
Package xiaogang.enif.utils;
/**
* The Class logutils for log printing, which help us
* Easy to trace we codes or logics in the project.
*
* @author Zhao Xiaogang
* @time 2011.4.12
*/
public class Logutils {
Private final static int VERBOSE = 0;
Private final static int DEBUG = 1;
Private final static int INFO = 2;
Private final static int WARN = 3;
Private final static int ERROR = 4;
Private final static int defaul
class[] Getclassarrays (classif (CLA!= null) {CL = arrays.copyof (cl,cl.length + 1);CL[CL.LENGTH-1] = CLA;return CL;}else{return CL;}}
/*** Get an instance of the class** @param clazz* The class to instantiate* @return the class after instantiation* @throws instantiationexception* @throws illegalaccessexception* @throws IllegalArgumentException* @throws SecurityException* @throws InvocationTargetException* @throws nosuchmethodexception*/@SuppressWa
memory insufficiency error, that is, outofmemoryerror
2.Jclass getsuperclass (jnienv * ENV, jclass clazz );Obtain the parent class or superclass
The second parameter of this function is the jclass class. When we call this function, it is a subclass. Otherwise, the return value is null.
3.Jboolean isassignablefrom (jnienv * ENV, jclass clazz1, jclass clazz2 );Determine whether the class1 object can be safely forcibly converted to a class2 object
If jn
Importjava.lang.reflect.InvocationTargetException;ImportJava.lang.reflect.Method;ImportJava.util.HashMap;ImportJava.util.Map;ImportOrg.apache.log4j.Logger; Public classDynamicserver {Private StaticLogger log = Logger.getlogger (dynamicserver.class); Public StaticMapNewHashmap(); Public StaticMapNewHashmap(); Public StaticMapNewHashmap(); Public StaticMapNewHashmap(); /*** Efficient invocation of a method within a class by reflection + cache **/ Public StaticObject cacheexce (String
must be identified first.The first two methods are not conducive to the extension of the program, because it is necessary to use a specific class to complete the program.3: The method used in class, the static Forname method .Specifies what class name to get what class bytecode file object, this way is strongest, as long as the class name of the string passed in.//1. obtained for class loading based on the given class nameString classname = "Cn.xushouwei.cn.Person";//From configuration fileClas
. getClass (). getName (); // result com. hzg. testReflect }}Obtain complete attributes and methods through an object
Class clazz = Person. class (); // 1. Create the Person object Person p = (Person) clazz. getInstance (); // 2. Call the specified attribute Filed f1 = clazz during runtime through reflection. getField ("name"); f1.set (p, "LiudeHua"); // 3. Call
(e.g. findclass). Because we haven ' t really * started the VM yet, they ' re all getting stored in the base frame * and never released. Use Push/pop to manage the storage. */Env->pushlocalframe (200); Gregjni is a list of functions that register some local functions. if (Register_jni_procs (Gregjni, Nelem (GREGJNI), env) Gregjni:static const REGJNIREC gregjni[] = { ... Reg_jni (Register_android_util_log), ...};TakeREG_JNI(register_android_util_Log), the functionregi
Customer object GetNameJstring js_name= (jstring) Env->callobjectmethod (customer,methodid,null);...}3.c returning object Types to JavaIn the C program, you first create the Java object that you want to return, get the ID of each property, assign a value to each property, and finally return. An example of this is the customer object, which has a property value such as name, which needs to be returned after assigning a value to each property in the C program.Jniexport Jobject Jnicall Java_com_or
caches some classes, which improves the execution efficiency of the loadClass method. The other is packagesMap: this map maintains the package name of the class and the mapping relationship of UCL. For details about the logic of UCL to load class, see the following activity diagram:Shows the inheritance structure of UnifiedClassLoader3. The RepositoryClassLoader parent class of UnifiedClassLoader3 overrides the loadClass method of URLClassLoader and implements the logic.See the following code:R
first.The first two methods are not conducive to the extension of the program, because it is necessary to use a specific class to complete the program.3: The method used in class, the static Forname method.Specifies what class name to get what class bytecode file object, this way is strongest, as long as the class name of the string passed in.1. obtained for class loading based on the given class nameString classname = "Cn.itcast.reflect.Person";//From configuration fileClass
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.