You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kato-commits@incubator.apache.org by sp...@apache.org on 2009/05/14 16:29:28 UTC

svn commit: r774842 - in /incubator/kato/branches/experimental/PyJVMTI: kato/BinDump.py kato/Dump.py kato/JClass.py kato/JClassLoader.py kato/JField.py kato/console.py pyjvmti.c pyjvmti.h

Author: spoole
Date: Thu May 14 16:29:28 2009
New Revision: 774842

URL: http://svn.apache.org/viewvc?rev=774842&view=rev
Log:
major updates to the pyjvmti experimental code

Added:
    incubator/kato/branches/experimental/PyJVMTI/kato/JField.py   (with props)
Modified:
    incubator/kato/branches/experimental/PyJVMTI/kato/BinDump.py
    incubator/kato/branches/experimental/PyJVMTI/kato/Dump.py
    incubator/kato/branches/experimental/PyJVMTI/kato/JClass.py
    incubator/kato/branches/experimental/PyJVMTI/kato/JClassLoader.py
    incubator/kato/branches/experimental/PyJVMTI/kato/console.py
    incubator/kato/branches/experimental/PyJVMTI/pyjvmti.c
    incubator/kato/branches/experimental/PyJVMTI/pyjvmti.h

Modified: incubator/kato/branches/experimental/PyJVMTI/kato/BinDump.py
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/kato/BinDump.py?rev=774842&r1=774841&r2=774842&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/kato/BinDump.py (original)
+++ incubator/kato/branches/experimental/PyJVMTI/kato/BinDump.py Thu May 14 16:29:28 2009
@@ -1,4 +1,18 @@
+#*******************************************************************************
+ #* 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 kato.Dump as Dump
+import kato.JField as JField
 import struct
 
 class BinDump(Dump.Dump):
@@ -7,7 +21,9 @@
       
     def open(self): 
         self.output=open("kato.dump","wb")
-
+        self.output.write("KATOJVMTI")
+        header=struct.pack("!hhh",0,0,1)
+        self.output.write(header)
         
     def close(self): 
         '''
@@ -29,20 +45,73 @@
         '''
         Save a single Jthread
         '''
-        header=struct.pack("!hhhi",101,thread.priority,thread.isDaemon,thread.threadGroupID)
+        header=struct.pack("!hihhi",101,thread.threadid,thread.priority,thread.isDaemon,thread.threadGroupID)
         self.output.write(header)
         namelength=struct.pack("!i",len(thread.name))
         self.output.write(namelength)
         self.output.write(thread.name)
+        
+        monitors=thread.ownedMonitorIDs;
+        monlength=len(monitors)
+        if monlength > 0 :
+            saveMonitors(monitors)
        
         print "saved " , thread.name 
        
+    def saveMonitiors(self,list):
+        
+        header=struct.pack("!hi",102,len(list))
+        self.output.write(header)
+        
+        for monitor in list :
+            header=struct.pack("!i",monitor)
+            self.output.write(header)
+            
+        
+            
+    def startClassSave(self,count):
+        
+        # write a classes meta record
+        recordType=struct.pack("!hi",200,count)
+        self.output.write(recordType)
+    
+    def saveField(self,field):
+        '''
+        Write a field to dump file
+        '''
+        header=struct.pack("!hi",202,field.fieldid)
+        self.output.write(header)
+        
+        self.writeName(field.name)
+        self.writeName(field.signature) 
+        self.writeName(field.genericsignature)
+        
+        
         
     def saveClass(self,clazz):
         '''
         Save a single JClass
         '''
+         
+        header=struct.pack("!hiihhhhh",201,clazz.classid,clazz.superclass,clazz.status,clazz.modifiers,len(clazz.fields),len(clazz.interfaces),len(clazz.methods))
+        self.output.write(header)
+        namelength=struct.pack("!i",len(clazz.signature))
+        self.output.write(namelength)
+        self.output.write(clazz.signature)
+       
+        # write fields...
         
-       # print "saving " , clazz.signature
+        for fieldid in clazz.fields :
+            
+            field=JField.JField(clazz,fieldid)
+            self.saveField(field)
+    
+            
+    def writeName(self,name):
+        length=0
+        if name!=None :   length=len(name)
+        namelength=struct.pack("!i",length)
+        self.output.write(namelength)
+        if length>0 : self.output.write(name)
         
-       
\ No newline at end of file
+         
\ No newline at end of file

Modified: incubator/kato/branches/experimental/PyJVMTI/kato/Dump.py
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/kato/Dump.py?rev=774842&r1=774841&r2=774842&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/kato/Dump.py (original)
+++ incubator/kato/branches/experimental/PyJVMTI/kato/Dump.py Thu May 14 16:29:28 2009
@@ -14,10 +14,19 @@
  #******************************************************************************"
 
 
-'''
-Created on 2 May 2009
-
-'''
+#*******************************************************************************
+ #* 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 jvmti
 import kato.JThread as JThread
 import kato.JClass as JClass
@@ -26,6 +35,7 @@
     
     includeThreads=True
     includeClasses=True
+
     
     '''
     Abstract class that walks the required data and calls dump methods
@@ -70,11 +80,14 @@
         will call saveClass repeatedly with a newly constructed
         JClass instance
         ''' 
-         
+        self.startClassSave(len(classes))
+        
         for c in classes :
             q=JClass.JClass(c)
             self.saveClass(q) 
             
+        self.endClassSave();
+            
     def startThreadSave(self,count):
         '''
         called before threads are saved
@@ -84,6 +97,15 @@
         '''
         called just after threads are saved
         '''   
+    def startClassSave(self,count):
+        '''
+        called before classes are saved
+        '''   
+    
+    def endClassSave(self):
+        '''
+        called just after classes are saved
+        '''   
     
     def saveThreads(self,threads):
         '''
@@ -96,6 +118,7 @@
         for t in threads :
            q=JThread.JThread(t)
            self.saveThread(q) 
+               
             
         self.endThreadSave()
     
@@ -107,27 +130,34 @@
         on configuration
         '''
         self.open()
-        self.saveAllThreads()
-        self.saveAllClasses()
+        saved=self.saveAllThreads()
+        print "saved",saved,"threads"
+        
+        saved=self.saveAllClasses()
+        print "saved",saved,"classes"
+        
         self.close()
     
     def saveAllThreads(self):
         '''
         Save threads to dump if includeThreads is true
         '''
-        if self.includeThreads==False :  return
+        if self.includeThreads==False :  return 0
         
         threads=jvmti.getAllThreads()
         self.saveThreads(threads);
-    
+        return len(threads)
                 
     def saveAllClasses(self):
         '''
         Save class to dump if includeClasses is true
         '''
         
-        if self.includeClasses==False :  return
+        if self.includeClasses==False :  return 0
         
         classes=jvmti.getLoadedClasses()
         
-        self.saveClasses(classes);        
\ No newline at end of file
+        self.saveClasses(classes);   
+        return len(classes)            
+       
+  
\ No newline at end of file

Modified: incubator/kato/branches/experimental/PyJVMTI/kato/JClass.py
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/kato/JClass.py?rev=774842&r1=774841&r2=774842&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/kato/JClass.py (original)
+++ incubator/kato/branches/experimental/PyJVMTI/kato/JClass.py Thu May 14 16:29:28 2009
@@ -19,19 +19,45 @@
     Representation of a loaded class
     '''
     classid=0
+    superclassid=-2
+    statusValue=None
     sig=None
-
+    sourcefile=None
+    mods=None
+    methodlist=None
+    fieldlist=None
+    interfacelist=None
+    
     def __init__(self,cid=0):
         '''
         Constructor
         '''
         self.classid=cid
-        self.fill()
+     
         
     def fill(self):
         if self.sig==None :
           self.sig=jvmti.getClassSignature(self.classid)
-       
+        
+    
+    
+    @property
+    def sourceFileName(self):
+        if self.sourcefile==None :
+            self.sourcefile=jvmti.getSourceFileName(self.classid)
+            if(self.sourcefile==None) :
+                    self.sourcefile=""
+
+        return self.sourcefile;
+    
+    @property 
+    def status(self):
+
+        if self.statusValue==None :
+           self.statusValue=jvmti.getClassStatus(self.classid) 
+
+        return self.statusValue
+    
     @property
     def signature(self):
         self.fill();
@@ -41,4 +67,63 @@
     def genericSignature(self):
         self.fill();
         return self.sig[1]
-    
\ No newline at end of file
+    
+    @property
+    def modifiers(self):
+        if self.mods==None :
+            self.mods=jvmti.getClassModifiers(self.classid)
+            
+        return self.mods
+    
+    @property
+    def methods(self):
+        '''
+        returns a list of method ids for declared methods of this
+        class.  Includes constructors and initialisers
+         
+        '''
+        
+        if self.methodlist==None :
+            try :
+                self.methodlist=jvmti.getClassMethods(self.classid)
+            except jvmti.error :
+                self.methodlist=[]    
+            
+        return self.methodlist
+
+    @property
+    def superclass(self):
+        if self.superclassid == -2 :
+            try :
+                self.superclassid=jvmti.getSuperClass(self.classid)
+            except jvmti.error : 
+                self.superclassid=-1
+            
+        return self.superclassid
+            
+    @property
+    def fields(self):
+        '''
+        returns a list of field ids for declared fields of this 
+        class
+        '''
+        if self.fieldlist==None :
+            try :
+                self.fieldlist=jvmti.getClassFields(self.classid)
+            except jvmti.error : 
+                self.fieldlist=[]
+            
+        return self.fieldlist
+    
+    @property
+    def interfaces(self):
+        '''
+        Returns a list of interface ids that this class implements
+        '''
+        if self.interfacelist==None :
+            try :
+                self.interfacelist=jvmti.getImplementedInterfaces(self.classid)
+            except jvmti.error :
+                self.interfacelist=[]
+        return self.interfacelist
+        
\ No newline at end of file

Modified: incubator/kato/branches/experimental/PyJVMTI/kato/JClassLoader.py
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/kato/JClassLoader.py?rev=774842&r1=774841&r2=774842&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/kato/JClassLoader.py (original)
+++ incubator/kato/branches/experimental/PyJVMTI/kato/JClassLoader.py Thu May 14 16:29:28 2009
@@ -14,7 +14,22 @@
 
 class JClassLoader(object):
     
-    def __init__(self,loader=0):
+    classloaderid=0
+    info=None
+    
+    def __init__(self,clid=0):
+        '''
+        Constructor for a JClassLoader
         '''
-        Constructor
-        '''
\ No newline at end of file
+        classloaderid=clid
+    
+    
+    def fill(self):
+        if self.info==None :
+          self.info=jvmti.getClassLoaderClasses(self.classloaderid)
+    
+    @property
+    def loadedClasses(self):
+        fill()
+        return info
+          
\ No newline at end of file

Added: incubator/kato/branches/experimental/PyJVMTI/kato/JField.py
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/kato/JField.py?rev=774842&view=auto
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/kato/JField.py (added)
+++ incubator/kato/branches/experimental/PyJVMTI/kato/JField.py Thu May 14 16:29:28 2009
@@ -0,0 +1,51 @@
+#*******************************************************************************
+ #* 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 jvmti
+
+class JField(object):
+    '''
+    Representation of a field in a class 
+    '''
+    clazz=None
+    fieldid=None
+    info=None
+    
+    def __init__(self,cid,fid):
+        '''
+        Constructor
+        '''
+        self.clazz=cid
+        self.fieldid=fid
+    
+    
+    @property
+    def name(self):
+        self.fill()
+        return self.info[0]
+        
+    def fill(self):
+      if self.info==None :
+          self.info=jvmti.getFieldName(self.clazz.classid,self.fieldid)
+
+    @property        
+    def signature(self):
+        self.fill()
+        return self.info[1]
+        
+    @property
+    def genericsignature(self):
+        self.fill()
+        return self.info[2]
+        
\ No newline at end of file

Propchange: incubator/kato/branches/experimental/PyJVMTI/kato/JField.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/kato/branches/experimental/PyJVMTI/kato/console.py
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/kato/console.py?rev=774842&r1=774841&r2=774842&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/kato/console.py (original)
+++ incubator/kato/branches/experimental/PyJVMTI/kato/console.py Thu May 14 16:29:28 2009
@@ -1,4 +1,18 @@
-print "JVMTI Interactive Session started"
+#*******************************************************************************
+ #* 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.
+ #******************************************************************************"
+
+print "JVMTI Python Interactive Session started"
 
 import jvmti 
 #import kato.Dump as Dump

Modified: incubator/kato/branches/experimental/PyJVMTI/pyjvmti.c
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/pyjvmti.c?rev=774842&r1=774841&r2=774842&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/pyjvmti.c (original)
+++ incubator/kato/branches/experimental/PyJVMTI/pyjvmti.c Thu May 14 16:29:28 2009
@@ -22,8 +22,73 @@
 static jvmtiEnv *jvmtiptr = NULL;
 static JavaVM *vmptr=NULL;
 static JNIEnv *jniptr=NULL;
+static PyObject *PYJVMTIError;
 
 
+#define getStringValue(FUNC,DESC)  \
+	CHECK_VALID(); \
+\
+			int objectID=0; \
+\
+			PyArg_ParseTuple(args, "i", &objectID);\
+\
+			jobject object=(jobject)objectID;\
+			char *result=NULL;\
+\
+			jvmtiError err=(*jvmtiptr)->FUNC(jvmtiptr,object,&result);\
+\
+			CHECK_OK(DESC);\
+			PyObject* string=Py_BuildValue("s", result); \
+			DEALLOC(result); \
+			return string;
+
+
+#define getValue(FUNC,TYPE,PTYPE,DESC)  \
+	CHECK_VALID();\
+\
+			int objectID=0; \
+\
+			PyArg_ParseTuple(args, "i", &objectID);\
+\
+			jobject object=(jobject)objectID;\
+			TYPE result=0;\
+\
+			jvmtiError err=(*jvmtiptr)->FUNC(jvmtiptr,object,&result);\
+\
+			CHECK_OK(DESC);\
+\
+   		 return Py_BuildValue(PTYPE, result);
+
+
+#define getList(FUNC,TYPE,DESC)  \
+	CHECK_VALID(); \
+		\
+			int ID=0; \
+	\
+			PyArg_ParseTuple(args, "i", &ID); \
+\
+			jobject object=(jobject)ID; \
+			jint countj=0;\
+			TYPE *entries=NULL; \
+\
+			jvmtiError err=(*jvmtiptr)->FUNC(jvmtiptr,object,&countj,&entries);\
+\
+			CHECK_OK(DESC);\
+\
+			int count=countj;\
+			PyObject* list= PyList_New(count);\
+\
+			 int i=0;\
+			 		for(i=0;i<count;i++) {\
+			 			TYPE entryid=entries[i];\
+			 			PyObject *value= Py_BuildValue("i",entryid);\
+			 			PyList_SetItem(list,i,value);\
+			 		}\
+\
+			 		DEALLOC(entries);\
+\
+			 		return list;\
+
 
 static char * getErrorMessage(jvmtiError err,char *usrmsg) {
 
@@ -233,6 +298,7 @@
 
 
 }
+
  static PyObject *
 jvmti_getThread(PyObject *self, PyObject *args)
 {
@@ -368,6 +434,25 @@
 
 	return pDict;
 }
+
+
+static PyObject *
+jvmti_getSuperClass(PyObject *self, PyObject *args)
+{
+
+
+CHECK_VALID();
+
+	int classid=0;
+	PyArg_ParseTuple(args, "i", &classid);
+
+	jclass clazz=classid;
+
+	jclass result=(*jniptr)->GetSuperclass(jniptr,clazz);
+
+    return Py_BuildValue("i", result);
+}
+
 static PyObject *
 jvmti_gettime(PyObject *self, PyObject *args)
 {
@@ -567,6 +652,45 @@
 
 		return value;
 }
+/**
+ * Get class signature and generic signature
+ * returned as typle of strings
+ */
+
+static PyObject *
+jvmti_getFieldName(PyObject *self, PyObject *args)
+{
+
+
+
+	CHECK_VALID();
+
+		int classID=0;
+		int fieldID=0;
+
+		PyArg_ParseTuple(args, "ii", &classID,&fieldID);
+
+		jclass class=(jclass)classID;
+		jfieldID field=(jfieldID)fieldID;
+
+		char  *name=NULL;
+		char  *sig=NULL;
+		char  *generic=NULL;
+
+		jvmtiError err=(*jvmtiptr)->GetFieldName(jvmtiptr,class,field,&name,&sig,&generic);
+
+		CHECK_OK("GetFieldName");
+
+		PyObject *value= Py_BuildValue("sss",name,sig,generic);
+
+		DEALLOC(name);
+		DEALLOC(sig);
+		DEALLOC(generic);
+
+		return value;
+}
+
+
 
 
 
@@ -632,24 +756,29 @@
  * Returns the size of the object
  */
 static PyObject *  jvmti_getObjectSize(PyObject *self, PyObject *args) {
+		getValue(GetObjectSize,jlong,"i","Get Object Size")
+}
+static PyObject *  jvmti_getClassLoaderClasses(PyObject *self, PyObject *args) {
+	getList(GetClassLoaderClasses,jclass,"Get ClassLoader classes")
+}
+static PyObject *  jvmti_getSourceFileName(PyObject *self, PyObject *args) {
+	getStringValue(GetSourceFileName,"Get Source File Name")
+}
+static PyObject *  jvmti_getClassStatus(PyObject *self, PyObject *args) {
+	getValue(GetClassStatus,jint,"i","Get Class Status")
+}
+static PyObject *  jvmti_getClassModifiers(PyObject *self, PyObject *args) {
+	getValue(GetClassModifiers,jint,"i","Get Class Modifiers")
+}
+static PyObject *  jvmti_getClassMethods(PyObject *self, PyObject *args) {
+	getList(GetClassMethods,jmethodID,"Get Class Methods")
+}
+static PyObject *  jvmti_getClassFields(PyObject *self, PyObject *args) {
+	getList(GetClassFields,jfieldID,"Get Class Fields")
+}
 
-	CHECK_VALID();
-
-		// get required object
-		int objectID=0;
-
-		PyArg_ParseTuple(args, "i", &objectID);
-
-		jobject object=(jobject)objectID;
-		jlong size=0;
-
-		jvmtiError err=(*jvmtiptr)->GetObjectSize(jvmtiptr,object,&size);
-
-		CHECK_OK("get Object Size");
-
-		 return Py_BuildValue("i", size);
-
-
+static PyObject *  jvmti_getImplementedInterfaces(PyObject *self, PyObject *args) {
+	getList(GetImplementedInterfaces,jclass,"Get Implemented Interfaces")
 }
 
 
@@ -673,18 +802,34 @@
      {"getObjectSize",        jvmti_getObjectSize, METH_VARARGS,       "Get Object Size"},
      {"getLoadedClasses",     jvmti_getLoadedClasses, METH_VARARGS,    "Get Loaded Classes."},
      {"getClassSignature",    jvmti_getClassSignature, METH_VARARGS,   "Get Class Signature."},
+     {"getClassStatus",       jvmti_getClassStatus, METH_VARARGS,   "Get Class Status."},
+     {"getSourceFileName",    jvmti_getSourceFileName, METH_VARARGS,   "Get Source File Name."},
+     {"getClassModifiers",    jvmti_getClassModifiers, METH_VARARGS,   "Get Class Modifiers."},
+     {"getClassMethods",      jvmti_getClassMethods, METH_VARARGS,   "Get Class Methods."},
+     {"getClassFields",       jvmti_getClassFields, METH_VARARGS,   "Get Class Fields."},
+     {"getClassLoaderClasses",jvmti_getClassLoaderClasses, METH_VARARGS,   "Get ClassLoader classes"},
+     {"getImplementedInterfaces", jvmti_getImplementedInterfaces, METH_VARARGS,   "Get Implemented Interfaces."},
+     {"getSuperClass",        jvmti_getSuperClass, METH_VARARGS,   "Get Superclass."},
+     {"getFieldName",        jvmti_getFieldName, METH_VARARGS,   "Get Field Name."},
 
-    {NULL, NULL, 0, NULL}        /* Sentinel */
+     {NULL, NULL, 0, NULL}        /* Sentinel */
 };
 
 
 PyMODINIT_FUNC
 initjvmti(void)
 {
-	printf("initilising...");
-    (void) Py_InitModule("jvmti", JvmtiMethods);
 
 
+    PyObject *m;
+
+    m = Py_InitModule("jvmti", JvmtiMethods);
+      if (m == NULL)
+          return;
+    PYJVMTIError=PyErr_NewException("jvmti.error", NULL, NULL);
+    Py_INCREF(PYJVMTIError);
+    PyModule_AddObject(m, "error", PYJVMTIError);
+
 
 
 }

Modified: incubator/kato/branches/experimental/PyJVMTI/pyjvmti.h
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/PyJVMTI/pyjvmti.h?rev=774842&r1=774841&r2=774842&view=diff
==============================================================================
--- incubator/kato/branches/experimental/PyJVMTI/pyjvmti.h (original)
+++ incubator/kato/branches/experimental/PyJVMTI/pyjvmti.h Thu May 14 16:29:28 2009
@@ -17,15 +17,14 @@
 
 #define CHECK_VALID()   \
 	if(jvmtiptr==NULL) {  \
-			 PyErr_SetString(PyExc_TypeError, "jvmti environment  pointer not present");  \
+			 PyErr_SetString(PYJVMTIError, "jvmti environment  pointer not present");  \
 			            return NULL; \
 		} \
 
 #define CHECK_OK(error_msg) \
 if(err!=JNI_OK) { \
-		char *msg=getErrorMessage(err,error_msg); \
-		 PyErr_SetString(PyExc_TypeError, msg); \
-		 free(msg); \
+		 PyObject *presult=Py_BuildValue("i", err); \
+		 PyErr_SetObject(PYJVMTIError,presult); \
 		 return NULL; \
 	}
 
@@ -38,7 +37,7 @@
 	if(ptr!=NULL) { \
 		err=(*jvmtiptr)->Deallocate(jvmtiptr,( unsigned char*)ptr); \
 		if(err!=JNI_OK) { \
-			 PyErr_SetString(PyExc_TypeError, "jvmti dealloc"); \
+			 PyErr_SetString(PYJVMTIError, "jvmti dealloc"); \
             return NULL; \
 		} \
 	}
@@ -60,6 +59,15 @@
 static PyObject *jvmti_getLocalLong(PyObject *self, PyObject *args);
 static PyObject *jvmti_getLocalInt(PyObject *self, PyObject *args);
 static PyObject *jvmti_getLocalObject(PyObject *self, PyObject *args);
+static PyObject *jvmti_getClassLoaderClasses(PyObject *self, PyObject *args);
+static PyObject *jvmti_getSourceFileName(PyObject *self, PyObject *args);
+static PyObject *jvmti_getClassStatus(PyObject *self, PyObject *args);
+static PyObject *jvmti_getClassModifiers(PyObject *self, PyObject *args);
+static PyObject *jvmti_getClassMethods(PyObject *self, PyObject *args);
+static PyObject *jvmti_getClassFields(PyObject *self, PyObject *args);
+static PyObject *jvmti_getImplementedInterfaces(PyObject *self, PyObject *args);
+static PyObject *jvmti_getSuperClass(PyObject *self, PyObject *args);
+static PyObject *jvmti_getFieldName(PyObject *self, PyObject *args);
 
 void runScript(void);
 void startPython(void);