Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 148629 | Differences between
and this patch

Collapse All | Expand All

(-)src-native/BCI/BCIEng/BCIEngInterface.h (+2 lines)
Lines 152-157 typedef void* pbcieng_t; Link Here
152
	_BCIENGINTERFACE_EXT_REF unsigned Initialize(pbcieng_t i_pbcieng, const char* i_pchOptions, size_t i_cbOptions);
152
	_BCIENGINTERFACE_EXT_REF unsigned Initialize(pbcieng_t i_pbcieng, const char* i_pchOptions, size_t i_cbOptions);
153
	_BCIENGINTERFACE_EXT_REF unsigned Instrument(pbcieng_t i_pbcieng, void* i_pInClass, size_t i_cbInClass, 
153
	_BCIENGINTERFACE_EXT_REF unsigned Instrument(pbcieng_t i_pbcieng, void* i_pInClass, size_t i_cbInClass, 
154
							          void** o_ppOutClass, size_t* o_pcbOutClass);
154
							          void** o_ppOutClass, size_t* o_pcbOutClass);
155
	_BCIENGINTERFACE_EXT_REF unsigned Instrument2(pbcieng_t i_pbcieng, void* i_pInClass, size_t i_cbInClass, 
156
							          void** o_ppOutClass, size_t* o_pcbOutClass, void *(*)(void **));
155
	_BCIENGINTERFACE_EXT_REF unsigned SetAllocator(pbcieng_t i_pbcieng, pfnMalloc_t i_pfnMalloc);
157
	_BCIENGINTERFACE_EXT_REF unsigned SetAllocator(pbcieng_t i_pbcieng, pfnMalloc_t i_pfnMalloc);
156
	_BCIENGINTERFACE_EXT_REF unsigned SetCallback(pbcieng_t i_pbcieng, pfnCallback_t i_pfnCallback, unsigned i_uFlags);
158
	_BCIENGINTERFACE_EXT_REF unsigned SetCallback(pbcieng_t i_pbcieng, pfnCallback_t i_pfnCallback, unsigned i_uFlags);
157
159
(-)src-native/BCI/BCIEng/Module.h (-1 / +2 lines)
Lines 132-138 public: Link Here
132
132
133
	virtual const vector<string>& GetSourceFileNames() = 0;
133
	virtual const vector<string>& GetSourceFileNames() = 0;
134
134
135
	virtual void	Parse()=0;
135
	virtual int	Parse()=0;
136
	virtual void	Emit();
136
	virtual void	Emit();
137
137
138
	CMethods*		GetMethods(){return m_pMethods;}
138
	CMethods*		GetMethods(){return m_pMethods;}
Lines 527-532 public: Link Here
527
		X_REASON_PARSE_ERROR,			// Parsing error
527
		X_REASON_PARSE_ERROR,			// Parsing error
528
		X_REASON_INVALID_CALL,			// Invalid method call (e.g. abstract method)
528
		X_REASON_INVALID_CALL,			// Invalid method call (e.g. abstract method)
529
		X_REASON_CODE_OVERRUN,			// Code overrun during emission
529
		X_REASON_CODE_OVERRUN,			// Code overrun during emission
530
		X_REASON_VERIFICATION_FAILED,	// Verifier stack map recalculation failed
530
		X_REASON_LAST
531
		X_REASON_LAST
531
	};
532
	};
532
533
(-)src-native/BCI/BCIEng/BCIEngJ/ModuleJ.cpp (-6 / +100 lines)
Lines 34-41 Link Here
34
#include <iostream>
34
#include <iostream>
35
#endif
35
#endif
36
36
37
static CInsSetJ InsSet;
37
#include <assert.h>
38
38
39
static CInsSetJ InsSet;
39
//==============================================================================
40
//==============================================================================
40
// CModuleJ implementation
41
// CModuleJ implementation
41
//------------------------------------------------------------------------------
42
//------------------------------------------------------------------------------
Lines 51-56 CModuleJ::CModuleJ() Link Here
51
	m_fDestroyClass = false;
52
	m_fDestroyClass = false;
52
	m_fAccessFlags = 0;
53
	m_fAccessFlags = 0;
53
	m_sourceFileNamesPopulated = false;
54
	m_sourceFileNamesPopulated = false;
55
	m_verificationContext = NULL;
56
	m_classHandler = NULL;
57
	m_methodContexts = NULL;
58
	m_use_stack_map_recalculation = false;
54
}
59
}
55
60
56
//------------------------------------------------------------------------------
61
//------------------------------------------------------------------------------
Lines 63-68 CModuleJ::~CModuleJ() Link Here
63
	{
68
	{
64
		delete m_pClass;
69
		delete m_pClass;
65
	}
70
	}
71
	if (m_verificationContext != NULL) {
72
		free_verification_context(m_verificationContext);
73
		m_verificationContext = NULL; 
74
	}
75
	if (m_classHandler != NULL) {
76
		class_destroy_handler(m_classHandler);
77
		m_classHandler = NULL;
78
	}
79
	if (m_methodContexts != NULL) {
80
		free(m_methodContexts);
81
		m_methodContexts = NULL;
82
	}
66
}
83
}
67
84
68
//------------------------------------------------------------------------------
85
//------------------------------------------------------------------------------
Lines 83-88 CModuleJ::Open(CSTR i_szName) Link Here
83
	m_fDestroyClass = true;
100
	m_fDestroyClass = true;
84
	FileStreamIn.Close();
101
	FileStreamIn.Close();
85
	Verify();
102
	Verify();
103
	
86
}
104
}
87
105
88
//------------------------------------------------------------------------------
106
//------------------------------------------------------------------------------
Lines 184-190 CModuleJ::CreateMethod(u2 i_u2AccFlags, Link Here
184
}
202
}
185
203
186
//------------------------------------------------------------------------------
204
//------------------------------------------------------------------------------
187
void	
205
int	
188
CModuleJ::Parse()
206
CModuleJ::Parse()
189
{
207
{
190
	CJMethods* pMethods	= m_pClass->GetMethods();
208
	CJMethods* pMethods	= m_pClass->GetMethods();
Lines 227-238 CModuleJ::Parse() Link Here
227
		}
245
		}
228
		m_pMethods->push_back(pMtd);
246
		m_pMethods->push_back(pMtd);
229
	}
247
	}
248
249
	vf_Result status;
250
	int ind;
251
	if (GetClassBuilder().GetMajorVersion() >= 50 
252
		&& IsStackMapCalculationUsed()) {
253
		m_classHandler = get_class_handler_from_builder(this);
254
		assert(m_classHandler);
255
		m_verificationContext = allocate_verification_context(m_classHandler);
256
		assert(m_verificationContext);
257
		m_methodContexts = (method_handler *)malloc(m_pMethods->size() * sizeof(method_handler));
258
		assert(m_methodContexts);
259
		memset(m_methodContexts, 0, m_pMethods->size() * sizeof(method_handler));
260
		//fprintf(stderr, "class : %s is java6 compiled\n", m_strName.c_str());
261
	}
230
	
262
	
231
	CMethods::iterator iterm;
263
	CMethods::iterator iterm;
232
	for(iterm =  m_pMethods->begin(); iterm < m_pMethods->end(); iterm++)
264
	for(iterm =  m_pMethods->begin(), ind = 0; iterm < m_pMethods->end(); iterm++, ind++)
233
	{
265
	{
234
		(*iterm)->Parse();
266
		(*iterm)->Parse();
267
		if (GetClassBuilder().GetMajorVersion() >= 50
268
			&& IsStackMapCalculationUsed()) {
269
			m_methodContexts[ind] = get_method_handler_for_cmethod(*iterm);
270
			assert(m_methodContexts[ind]);
271
			status = init_verification_context_for_method(m_methodContexts[ind], m_verificationContext);
272
273
			if (status != VF_OK) {
274
				fprintf(stderr, "class was skiped: %s\n", m_strName.c_str());
275
				return (1); /*skip*/
276
			}
277
			//fprintf(stderr, "class was instrumented: %s\n", m_strName.c_str());
278
			((CMethodJ *)(*iterm))->SetMethodHandler(m_methodContexts[ind]);
279
			
280
		}
235
	}
281
	}
282
	return (0);
236
}
283
}
237
284
238
//------------------------------------------------------------------------------
285
//------------------------------------------------------------------------------
Lines 385-392 CMethodJ::Emit() Link Here
385
	m_pMtdExTable->Emit();
432
	m_pMtdExTable->Emit();
386
433
387
	//-------
434
	//-------
388
	// Loop over instructions and patch the local variable info table
435
	// Loop over instructions and patch the local variable info table, 
436
    // local variable type table (Java 5.0) and stack map table (Java 6.0)
389
	//
437
	//
438
	
439
	
390
440
391
	// Local variable table LVT
441
	// Local variable table LVT
392
	CLocalVariableTableAttribute* pLclAttr = m_pCodeAttr->GetLocalVariables();
442
	CLocalVariableTableAttribute* pLclAttr = m_pCodeAttr->GetLocalVariables();
Lines 403-408 CMethodJ::Emit() Link Here
403
	CLocalVariableTypeTable  LclTypeTableSav;
453
	CLocalVariableTypeTable  LclTypeTableSav;
404
	CLocalVariableTypeTable::iterator itrLclType, itrLclTypeSav; // LVTT Iterator
454
	CLocalVariableTypeTable::iterator itrLclType, itrLclTypeSav; // LVTT Iterator
405
455
456
    // The smtNull variable is for reference initialization in case the method does not have
457
    // a Stack Map Table attribute
458
    CStackMapTable smtNull;
459
    CStackMapTableAttribute* pSmtAttr = m_pCodeAttr->GetStackMaps();
460
    CStackMapTable& StackMapTable = pSmtAttr?pSmtAttr->GetStackMapTable():smtNull;
461
    CStackMapTable::iterator itrStackMapFrame = StackMapTable.begin();
462
406
	CInsBlocks::iterator iterBlocks;
463
	CInsBlocks::iterator iterBlocks;
407
	IP_t ip = 0;
464
	IP_t ip = 0;
408
465
Lines 458-463 CMethodJ::Emit() Link Here
458
					}
515
					}
459
				}
516
				}
460
			}
517
			}
518
			
519
            // Scan for a relevant entry in the Stack Map Table and fix it
520
            while (itrStackMapFrame != StackMapTable.end()
521
                && (*itrStackMapFrame)->GetByteCodeOffset() < ipOrig)
522
            {
523
                ++itrStackMapFrame;
524
            }
525
            if (itrStackMapFrame != StackMapTable.end()
526
                && (*itrStackMapFrame)->GetByteCodeOffset() == ipOrig)
527
            {
528
                (*itrStackMapFrame)->SetByteCodeOffset(ip);
529
            }
461
530
462
			// Advance ip
531
			// Advance ip
463
			ip += (*iterIns)->GetSize(ip);
532
			ip += (*iterIns)->GetSize(ip);
Lines 503-513 CMethodJ::Emit() Link Here
503
			}
572
			}
504
		}
573
		}
505
	}
574
	}
575
	// Replace the method body
576
	m_pCodeAttr->SetCode(m_pBody->GetCodeSize(), m_pBody->GiveAvayCode());
506
577
578
	// Calculate new stack depth
507
	CalcStackDepth();
579
	CalcStackDepth();
508
580
509
	// Replace the method body
581
	if (((CModuleJ *)GetModule())->GetClassBuilder().GetMajorVersion() >= 50 
510
	m_pCodeAttr->SetCode(m_pBody->GetCodeSize(), m_pBody->GiveAvayCode());
582
		&& ((CModuleJ *)GetModule())->IsStackMapCalculationUsed()) {
583
	
584
		u1 *tbl;
585
		vf_Result status;
586
		status = recompute_stackmaptable((uint8 **)&tbl, m_methodHandler, ((CModuleJ *)GetModule())->GetVerificationContext());
587
		if (status != VF_OK) {
588
			throw CModuleException(CModuleException::X_REASON_VERIFICATION_FAILED, "stack map recalcualtion failed");
589
		}
590
		else {
591
			//CStackMapTable smt (tbl);
592
			CStackMapTableAttribute* smta = GetCodeAttribute()->GetOrCreateStackMaps();
593
			if (tbl != NULL) {
594
				smta->RereadFromBuffer(tbl); //skiping name
595
				smta->GetStackMapTable().AdjustOffsetDeltas();
596
			}
597
		}
598
	}
599
    // Final Stack Map Table handling: adjust offset deltas
600
    //StackMapTable.AdjustOffsetDeltas();
601
602
    
603
511
604
512
}
605
}
513
606
Lines 628-633 CMtdExTableJ::Emit() Link Here
628
				}
721
				}
629
			}
722
			}
630
		}
723
		}
724
		
631
		CJException jex = CJException(uType, ipStart, ipRealEnd, ipHandler); 
725
		CJException jex = CJException(uType, ipStart, ipRealEnd, ipHandler); 
632
		extblj.push_back(jex);
726
		extblj.push_back(jex);
633
	}
727
	}
(-)src-native/BCI/BCIEng/BCIEngJ/ModuleJ.h (-2 / +15 lines)
Lines 30-35 Link Here
30
30
31
#include "Module.h"
31
#include "Module.h"
32
#include "JClassBuilder.h"
32
#include "JClassBuilder.h"
33
#include "class_inerface_int.h"
33
34
34
class CModuleJ;
35
class CModuleJ;
35
class CMethodJ;
36
class CMethodJ;
Lines 57-75 public: Link Here
57
	virtual void	Open(CJClassBuilder* io_pClass, bool i_fDestroyClass = false);
58
	virtual void	Open(CJClassBuilder* io_pClass, bool i_fDestroyClass = false);
58
	virtual void	AddExtRef(CExtRef& i_ExtRef);
59
	virtual void	AddExtRef(CExtRef& i_ExtRef);
59
	virtual void	AddStringAttrib(CSTR i_szName, CSTR i_szValue);
60
	virtual void	AddStringAttrib(CSTR i_szName, CSTR i_szValue);
60
	virtual void	Parse();
61
	virtual int	Parse();
61
	virtual void	Emit();
62
	virtual void	Emit();
62
63
63
	void	Emit(CJStream& i_jstream);	// Java specific emission
64
	void	Emit(CJStream& i_jstream);	// Java specific emission
64
	CJClassFile&	GetClass();
65
	CJClassFile&	GetClass();
65
	CJClassBuilder& GetClassBuilder();
66
	CJClassBuilder& GetClassBuilder();
67
	class_handler GetClassHandler() {return m_classHandler;}
68
	verification_context GetVerificationContext(){return m_verificationContext;}
66
69
67
	virtual const vector<string>& GetSourceFileNames();
70
	virtual const vector<string>& GetSourceFileNames();
68
71
69
	// Module modification methods
72
	// Module modification methods
70
	CCPFieldrefInfo*	CreateFieldRef(u2 i_u2AccFlags, CSTR i_szName, CJavaType i_jtype);
73
	CCPFieldrefInfo*	CreateFieldRef(u2 i_u2AccFlags, CSTR i_szName, CJavaType i_jtype);
71
	CMethodJ*			CreateMethod(u2 i_u2AccFlags, CSTR i_szName, CSTR i_szSignature);
74
	CMethodJ*			CreateMethod(u2 i_u2AccFlags, CSTR i_szName, CSTR i_szSignature);
72
75
	bool IsStackMapCalculationUsed() const {return m_use_stack_map_recalculation;}
76
	void UseStackMapCalculation(bool a_use_stack_map_recalculation) {m_use_stack_map_recalculation = a_use_stack_map_recalculation;}
73
protected:
77
protected:
74
78
75
private:
79
private:
Lines 85-90 private: Link Here
85
	// Storage in support of GetSourceFileNames:
89
	// Storage in support of GetSourceFileNames:
86
	vector<string>	m_sourceFileNames;
90
	vector<string>	m_sourceFileNames;
87
	bool			m_sourceFileNamesPopulated;
91
	bool			m_sourceFileNamesPopulated;
92
	verification_context m_verificationContext; /*verifier context for support java 6.0 and latter*/
93
	class_handler m_classHandler; /* class descriptor used for verification needs(recalculations) introduced in java 6.0*/
94
	method_handler *m_methodContexts; /*collections of method handlers*/
95
	bool m_use_stack_map_recalculation;
88
};
96
};
89
97
90
//==============================================================================
98
//==============================================================================
Lines 100-105 public: Link Here
100
		m_strSignature = i_szSignature;
108
		m_strSignature = i_szSignature;
101
		m_pCodeAttr = i_pCodeAttr;
109
		m_pCodeAttr = i_pCodeAttr;
102
		m_u2AccessFlags = i_u2AccessFlags;
110
		m_u2AccessFlags = i_u2AccessFlags;
111
		m_methodHandler = NULL;
112
		
103
113
104
		// Set the "hasThis" attribute, which is accessible to all CMethod users
114
		// Set the "hasThis" attribute, which is accessible to all CMethod users
105
		SetHasThis(!(m_u2AccessFlags & ACC_STATIC));
115
		SetHasThis(!(m_u2AccessFlags & ACC_STATIC));
Lines 110-115 public: Link Here
110
	CSTR	GetSignature() const {return m_strSignature.c_str();}
120
	CSTR	GetSignature() const {return m_strSignature.c_str();}
111
	bool IsAbstract() { return ((m_u2AccessFlags & ACC_ABSTRACT) != 0); };
121
	bool IsAbstract() { return ((m_u2AccessFlags & ACC_ABSTRACT) != 0); };
112
    u2 GetAccessFlags() const { return m_u2AccessFlags; }
122
    u2 GetAccessFlags() const { return m_u2AccessFlags; }
123
	void SetMethodHandler(method_handler i_methodHandler) {m_methodHandler = i_methodHandler;}
124
	method_handler GetMethodHandler() {return m_methodHandler;}
113
125
114
	virtual void Parse();
126
	virtual void Parse();
115
	virtual void Emit();
127
	virtual void Emit();
Lines 121-126 private: Link Here
121
	CCodeAttribute*		m_pCodeAttr;		// Code attribute from CJClassFile
133
	CCodeAttribute*		m_pCodeAttr;		// Code attribute from CJClassFile
122
	u2					m_u2AccessFlags;	// Method access flags
134
	u2					m_u2AccessFlags;	// Method access flags
123
	IP_t				m_origCodeLength;	// Saved code length from Parse to Emit
135
	IP_t				m_origCodeLength;	// Saved code length from Parse to Emit
136
	method_handler		m_methodHandler;
124
};
137
};
125
138
126
139
(-)src-native/BCI/BCIEng/BCIEngJ/class_inerface_int.h (+42 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id$ 
8
 * 
9
 * Contributors: 
10
 * Intel - Initial API and implementation 
11
 **********************************************************************/ 
12
13
#ifndef _CLASS_INTERFACE_INT_H_
14
#define _CLASS_INTERFACE_INT_H_
15
16
#include "JClassBuilder.h"
17
18
//typedef u1 uint8;
19
//typedef u2 uint16;
20
//#include "class_interface.h"
21
//#include "class_interface_x.h"
22
23
#include "x_verifier/x_class_interface.h"
24
#include "x_verifier/x_verifier.h"
25
26
typedef Class_Handle class_handler;
27
typedef Method_Handle method_handler;
28
typedef void *(*get_vm_pointer_t)(void **);
29
30
class_handler get_class_handler_from_builder(class CModuleJ *);
31
method_handler get_method_handler_for_cmethod(class CMethod *);
32
33
//extern "C" {
34
//unsigned method_get_bytecode_length( method_handler);
35
//}
36
37
extern int initialize_dynamic(get_vm_pointer_t);
38
void class_destroy_handler(class_handler);
39
40
int initialize_static();
41
42
#endif
(-)src-native/BCI/BCIEng/BCIEngJ/class_interface.cpp (+907 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id$ 
8
 * 
9
 * Contributors: 
10
 * Intel - Initial API and implementation 
11
 **********************************************************************/ 
12
13
#include <stdlib.h>
14
#include <string.h>
15
16
#include <map>
17
18
#include <assert.h>
19
#include "BCIEng.h"
20
#include "JClassBuilder.h"
21
#include "ModuleJ.h"
22
23
#include "JMemStream.h"
24
#include "class_inerface_int.h"
25
26
27
#include <jni.h>
28
29
typedef unsigned long intptr;
30
31
static JNIEnv *(*m_get_vm_pointer)(void **);
32
static jclass m_j_l_class;
33
static jclass m_j_l_classloader;
34
static jmethodID m_j_l_class_getName; /*()Ljava/lang/String;*/
35
static jmethodID m_j_l_class_isInterface;/* ()Z */
36
static jmethodID m_j_l_class_getClassLoader; /*()Ljava/lang/ClassLoader;*/
37
static jmethodID m_j_l_classloader_findLoadedClass; /*(Ljava/lang/String;)Ljava/lang/Class;*/
38
static jmethodID m_j_l_classloader_getSystemClassLoader; /*()Ljava/lang/ClassLoader;*/
39
static jobject m_system_classloader;
40
/**
41
 * Define class handler
42
 */
43
/*[0xdead0001 - simplefied, 0xdead0002 - instrumented, 0xdead0000 - none]*/
44
#define CLASS_HANDLER_MASK 0xdeadffff
45
#define CLASS_HANDLER_SIMPLEFIED 0xdead0001
46
#define CLASS_HANDLER_INSTRUMENTED 0xdead0002
47
#define CLASS_HANDLER_NONE 0xdead0000
48
#define IS_CLASS_INSTRUMENTED(x) (((x)->magic & CLASS_HANDLER_MASK) == CLASS_HANDLER_INSTRUMENTED)
49
struct Class{
50
	int magic; 
51
	struct {
52
		class CModuleJ *instrumented_class;
53
		void *simplified_class;	
54
	} X; /*XXX: possible union here will be more applieble */
55
	int loaded;
56
	const char *class_name; /*used if loaded = 0*/
57
	struct Class *super_class;
58
};
59
60
typedef std::map<std::string,class_handler> name2ch_t;
61
static name2ch_t m_name2ch;
62
63
#define MEHTOD_HANDLER_MASK 0xbabeffff
64
#define METHOD_HANDLER_SELF 0xbabe0001
65
#define METHOD_HANDLER_EXT 0xbabe0002
66
#define METHOD_HANDLER_NONE 0xbabe0000
67
struct Method {
68
	int magic; 
69
	struct {
70
		class CMethodJ *instrumented_method;
71
		void *simplefied_method;
72
	} X; /*XXX: possible union here will be more applieble */
73
	class_handler class_owner;
74
	const char *method_name; /*used for METHOD_HANDLER_EXT only*/
75
	const char *method_descriptor; /*used for METHOD_HANDLER_EXT only*/
76
};
77
78
static struct Class *m_j_l_object_ch; 
79
/**
80
 * Define field handler
81
 */
82
typedef struct Field_ * field_handler;
83
84
/**
85
 * Define method handler
86
 */
87
//typedef struct Method_ * method_handler;
88
89
/**
90
 * Define class loader handler
91
 */
92
typedef struct ClassLoader_ * classloader_handler;
93
94
static int 
95
create_class_handler(class_handler *pch, int flag, const char *class_name, int loaded, void *dsk)
96
{
97
	class_handler ch0 = m_name2ch[class_name]; /*for debug*/
98
	if (m_name2ch[class_name] != NULL 
99
		&& m_name2ch[class_name]->magic == flag) {
100
			*pch = m_name2ch[class_name];
101
			return (0);
102
	} 
103
	class_handler ch = (class_handler)malloc(sizeof(struct Class));
104
	memset(ch, 0, sizeof(struct Class));
105
	assert(ch);
106
	ch->loaded = loaded;
107
	if (loaded == 0) {
108
		ch->class_name = class_name;
109
	}
110
	ch->magic = flag;
111
	switch(flag) {
112
	case (CLASS_HANDLER_SIMPLEFIED):
113
		ch->X.simplified_class = dsk;
114
		if (loaded == 0) {
115
			ch->class_name = class_name;
116
		}
117
		ch->loaded = loaded;
118
		break;
119
	case (CLASS_HANDLER_INSTRUMENTED):
120
		ch->X.instrumented_class = (CModuleJ *)dsk;
121
		break;
122
	default:
123
		assert(!"shouldn't be here!!!");
124
	}
125
	*pch = ch;
126
	m_name2ch[class_name] = ch;
127
	return (0);
128
}
129
130
extern "C" int
131
create_method_handler(method_handler *pmh, class_handler ch, int flag, void *dsk) 
132
{
133
	method_handler mh = (method_handler)malloc(sizeof(struct Method));
134
	assert(mh);
135
	memset(mh, 0, sizeof(struct Method));
136
	switch (flag) {
137
	case METHOD_HANDLER_SELF:
138
		mh->X.instrumented_method = (class CMethodJ *)dsk;
139
		break;
140
	case METHOD_HANDLER_EXT:
141
		mh->X.simplefied_method = dsk;
142
		break;
143
	default:
144
		assert(!"shouldn't enter here");
145
	}
146
	mh->magic = (IS_CLASS_INSTRUMENTED(ch))?METHOD_HANDLER_SELF:flag;
147
	mh->class_owner = ch;
148
	*pmh = mh;
149
	return (0);
150
}
151
/**
152
 * Class interface
153
 */
154
155
extern "C" unsigned short 
156
class_get_version( class_handler klass ) {
157
	if (IS_CLASS_INSTRUMENTED(klass)) {
158
		return klass->X.instrumented_class->GetClassBuilder().GetMajorVersion();
159
	} else {
160
		assert (!"not implemented yet!");
161
	}
162
	return (0);
163
}
164
165
extern "C" const char *
166
class_get_name( class_handler klass ) 
167
{
168
	JNIEnv *env;
169
	jstring class_name;
170
	if (IS_CLASS_INSTRUMENTED(klass)) {
171
		return klass->X.instrumented_class->GetName();
172
	} 
173
	else {
174
		if (klass->loaded == 0) {
175
			return(klass->class_name);
176
		}
177
		env = m_get_vm_pointer((void **)&env);
178
		class_name = (jstring)env->CallObjectMethod((jobject)klass->X.simplified_class, m_j_l_class_getName);
179
		if (class_name == NULL)
180
			return (NULL);
181
		char *class_name_simple = (char *)env->GetStringUTFChars(class_name, NULL);
182
		char *ch = strchr(class_name_simple, '.');
183
		while (ch != NULL) {
184
			*ch = '/';
185
			ch = strchr(ch, '.');
186
		}
187
		return(class_name_simple);
188
	
189
	}
190
	return (NULL);
191
}
192
193
extern "C" classloader_handler
194
class_get_class_loader( class_handler klass )
195
{
196
	if (IS_CLASS_INSTRUMENTED(klass)) {
197
		return (0);
198
	} else {
199
		assert(!"simplefied");
200
	}
201
	return (NULL);
202
}
203
204
extern "C" class_handler
205
class_get_super_class( class_handler klass )
206
{
207
208
	const char *class_name;
209
	const char *super_class_name = NULL;
210
	jobject this_class = NULL;
211
	jobject super_class;
212
	JNIEnv *env = NULL;
213
	env = m_get_vm_pointer((void **)&env);
214
	assert(env);
215
	int loaded = 1;
216
	if (klass->loaded == 0 && strcmp(klass->class_name,"java/lang/Object") == 0) return (NULL);
217
	if (klass->super_class != NULL) return (klass->super_class);
218
	
219
	if (IS_CLASS_INSTRUMENTED(klass)) {
220
		class_name = klass->X.instrumented_class->GetName();
221
		CConstPool* cpool = klass->X.instrumented_class->GetClass().GetConstPool();
222
		CCPUtf8Info* utfinfo = cpool->GetClass(klass->X.instrumented_class->GetClass().GetSuperClass());
223
		super_class_name = (const char *)utfinfo->GetBytes();
224
		assert(super_class_name);	
225
		super_class = (jclass)env->FindClass(super_class_name);		
226
	} 
227
	else {
228
		if (klass->loaded == 0) {
229
			assert(klass->class_name);
230
			this_class = (jclass)env->FindClass(klass->class_name);
231
			if (this_class == NULL && env->ExceptionCheck()) {
232
				//env->ExceptionDescribe();
233
				env->ExceptionClear();
234
				//XXX: class wasn't found or loaded
235
				return (m_j_l_object_ch);
236
				//return (NULL);
237
			}
238
		}
239
		this_class = this_class?this_class:(jobject)klass->X.simplified_class;
240
		super_class = (jobject)env->GetSuperclass((jclass)this_class);
241
	}
242
243
	if (super_class == NULL) {
244
		if (env->ExceptionCheck()) {
245
			//env->ExceptionDescribe();
246
			env->ExceptionClear();
247
			//XXX: class wasn't found or loaded
248
			loaded = 0;
249
			//return (NULL);
250
		}
251
		else {
252
			klass->super_class = m_j_l_object_ch;
253
			return (m_j_l_object_ch);
254
			//return (NULL); /*it happends when klass is java.lang.Object*/
255
		}
256
	}
257
	else {
258
		jstring jclass_name = (jstring)env->CallObjectMethod(super_class, m_j_l_class_getName);
259
		if (jclass_name == NULL) {
260
			return (m_j_l_object_ch);
261
		}
262
		char *class_name_simple = (char *)env->GetStringUTFChars(jclass_name, NULL);
263
		assert (class_name_simple);
264
		char *ch = strchr(class_name_simple, '.');
265
		while (ch != NULL) {
266
			*ch = '/';
267
			ch = strchr(ch, '.');
268
		}
269
		super_class_name = class_name_simple;
270
	}
271
	
272
	//assert(super_class);
273
	class_handler ch;
274
	jobject super_class_ref = env->NewGlobalRef(super_class);
275
	env->DeleteLocalRef(super_class);
276
	int status = create_class_handler(&ch, CLASS_HANDLER_SIMPLEFIED, super_class_name, loaded, super_class_ref);
277
	assert(status == 0);
278
	return (ch);
279
}
280
281
extern "C" unsigned
282
class_is_same_class( class_handler klass1, class_handler klass2 )
283
{
284
	assert(!"verifier entered!!");
285
	return 0;
286
}
287
288
static char* 
289
package_name(const char* kname)
290
{
291
	char *tokp;
292
	char *tok0;
293
	tokp = tok0 = (char *)&kname[0];
294
	tok0 = strchr(kname, '/');
295
	while (tok0 != NULL) {
296
		tokp = tok0;
297
		tok0 = strchr(tok0 + 1, '/');
298
	}
299
	return (tokp);
300
}
301
302
extern "C" unsigned
303
class_is_same_package( class_handler klass1, class_handler klass2 ) 
304
{
305
	if (klass1 == klass2) {
306
		return (1);
307
	}
308
	else {
309
		const char *klass1_name = class_get_name(klass1);
310
		const char *klass2_name = class_get_name(klass2);
311
		char* package1 = package_name(klass1_name);
312
		char* package2 = package_name(klass2_name);
313
		int package1_len = (package1 - klass1_name);
314
		int package2_len = (package2 - klass2_name);
315
		if (package1_len != package2_len)
316
			return (0);
317
		return(strncmp(klass1_name, klass2_name, package2_len) == 0);
318
		assert(!"verifier entered!!");
319
	}
320
	return (0);
321
}
322
323
extern "C" unsigned
324
class_is_interface( class_handler klass ) 
325
{
326
	JNIEnv *env;
327
	env = m_get_vm_pointer((void **)&env);
328
	assert(env);
329
	if (IS_CLASS_INSTRUMENTED(klass)) {
330
		return (0);
331
	} 
332
	else {
333
		return (unsigned)(env->CallBooleanMethod((jobject)klass->X.simplified_class, m_j_l_class_isInterface));
334
	}
335
	
336
	return (0);
337
}
338
339
extern "C" unsigned
340
class_is_array( class_handler klass ) 
341
{
342
	assert(!"verifier entered!!");
343
	return (0);
344
}
345
346
extern "C" unsigned
347
class_is_final_( class_handler klass ) 
348
{
349
	assert(!"verifier entered!!");
350
	return (0);
351
}
352
353
extern "C" unsigned short
354
class_get_superinterface_number( class_handler klass )
355
{
356
	assert(!"verifier entered!!");
357
	return (0);
358
}
359
360
extern "C" class_handler
361
class_get_superinterface( class_handler klass, unsigned short index )
362
{
363
	assert(!"verifier entered!!");
364
	return (NULL);
365
}
366
367
extern "C" class_handler
368
class_get_array_element_class( class_handler klass )
369
{
370
	assert(!"verifier entered!!");
371
	return (NULL);
372
}
373
374
375
extern "C" class_handler
376
class_get_extended_class( class_handler klass, const char *super_name )
377
{
378
	return (NULL);
379
}
380
381
extern "C" unsigned short
382
class_get_method_number( class_handler klass )
383
{
384
	assert(!"verifier entered!!");
385
	return (0);
386
}
387
388
extern "C" method_handler
389
class_get_method( class_handler klass, unsigned short index )
390
{
391
	assert(!"verifier entered!!");
392
	return (NULL);
393
}
394
395
396
/**
397
 * Constant pool inteface
398
 */
399
400
extern "C" unsigned short
401
class_cp_get_size( class_handler klass )
402
{
403
	assert(klass);
404
	if (IS_CLASS_INSTRUMENTED(klass)) {
405
		assert(klass->X.instrumented_class);
406
		assert(klass->X.instrumented_class->GetClassBuilder().GetConstPool());
407
		return klass->X.instrumented_class->GetClassBuilder().GetConstPool()->GetSize();
408
	} else {
409
		assert (!"not implemented yet!");
410
	}
411
	assert(!"verifier entered!!");
412
	return (0);
413
}
414
415
416
extern "C" unsigned char
417
class_cp_get_tag( class_handler klass, unsigned short index )
418
{
419
	if (IS_CLASS_INSTRUMENTED(klass)) {
420
		return (*klass->X.instrumented_class->GetClassBuilder().GetConstPool())[index]->GetTag();
421
	} else {
422
		assert (!"not implemented yet!");
423
	}
424
	return (0);
425
}
426
427
extern "C" unsigned short
428
class_cp_get_class_name_index( class_handler klass, unsigned short index )
429
{
430
	if (IS_CLASS_INSTRUMENTED(klass)) {
431
		CCPInfo * ccinfo = (*klass->X.instrumented_class->GetClassBuilder().GetConstPool())[index];
432
		assert(ccinfo->GetTag() == CONSTANT_Class);
433
		return ((CCPClassInfo *)ccinfo)->GetClassInd();
434
	} else {
435
		assert (!"not implemented yet!");
436
	}
437
	return (0);
438
}
439
440
extern "C" unsigned short
441
class_cp_get_ref_class_index( class_handler klass, unsigned short index )
442
{
443
	if (IS_CLASS_INSTRUMENTED(klass)) {
444
		CCPInfo * ccinfo = (*klass->X.instrumented_class->GetClassBuilder().GetConstPool())[index];
445
		unsigned char tag = ccinfo->GetTag();
446
		switch(tag) {
447
		case CONSTANT_Fieldref:
448
			return ((CCPFieldrefInfo *)ccinfo)->GetClassInd();
449
		break;
450
		case CONSTANT_Methodref:
451
			return ((CCPMethodrefInfo *)ccinfo)->GetClassInd();
452
		break;
453
		case CONSTANT_InterfaceMethodref:
454
			return ((CCPInterfaceMethodrefInfo *)ccinfo)->GetClassInd();
455
		break;
456
		default:
457
			assert(!"unsupported tag");
458
		}
459
	} else {
460
		assert (!"not implemented yet!");
461
	}
462
	return (0);
463
}
464
465
extern "C" unsigned short
466
class_cp_get_ref_name_and_type_index( class_handler klass, unsigned short index )
467
{
468
	if (IS_CLASS_INSTRUMENTED(klass)) {
469
		CCPInfo * ccinfo = (*klass->X.instrumented_class->GetClassBuilder().GetConstPool())[index];
470
		unsigned char tag = ccinfo->GetTag();
471
		switch(tag) {
472
		case CONSTANT_Fieldref:
473
			return ((CCPFieldrefInfo *)ccinfo)->GetNameAndTypeInd();
474
		break;
475
		case CONSTANT_Methodref:
476
			return ((CCPMethodrefInfo *)ccinfo)->GetNameAndTypeInd();
477
		break;
478
		case CONSTANT_InterfaceMethodref:
479
			return ((CCPInterfaceMethodrefInfo *)ccinfo)->GetNameAndTypeInd();
480
		break;
481
		default:
482
			assert(!"unsupported tag");
483
		}
484
	} else {
485
		assert (!"not implemented yet!");
486
	}
487
	return (0);
488
}
489
490
extern "C" unsigned short
491
class_cp_get_string_index( class_handler klass, unsigned short index )
492
{
493
	assert(!"verifier entered!!");
494
	return (0);
495
}
496
497
extern "C" unsigned short
498
class_cp_get_name_index( class_handler klass, unsigned short index )
499
{
500
	if (IS_CLASS_INSTRUMENTED(klass)) {
501
		CCPInfo * ccinfo = (*klass->X.instrumented_class->GetClassBuilder().GetConstPool())[index];
502
		unsigned char tag = ccinfo->GetTag();
503
		assert(tag == CONSTANT_NameAndType);
504
		return ((CCPNameAndTypeInfo *)ccinfo)->GetNameInd();
505
	} else {
506
		assert (!"not implemented yet!");
507
	}
508
	return (0);
509
}
510
511
extern "C" unsigned short
512
class_cp_get_descriptor_index( class_handler klass, unsigned short index )
513
{
514
	if (IS_CLASS_INSTRUMENTED(klass)) {
515
		CCPInfo * ccinfo = (*klass->X.instrumented_class->GetClassBuilder().GetConstPool())[index];
516
		unsigned char tag = ccinfo->GetTag();
517
		assert(tag == CONSTANT_NameAndType);
518
		return ((CCPNameAndTypeInfo *)ccinfo)->GetDescriptorInd();
519
	} else {
520
		assert (!"not implemented yet!");
521
	}
522
	return (0);
523
}
524
525
extern "C" const char *
526
class_cp_get_utf8_bytes( class_handler klass, unsigned short index )
527
{
528
	if (IS_CLASS_INSTRUMENTED(klass)) {
529
		return (const char *)((CCPUtf8Info *)(*klass->X.instrumented_class->GetClassBuilder().GetConstPool())[index])->GetBytes();
530
	} else {
531
		assert (!"not implemented yet!");
532
	}
533
	return (0);
534
}
535
536
extern "C" void
537
class_set_verify_data_ptr( class_handler klass, void *data )
538
{
539
	assert(!"verifier entered!!");
540
	return;
541
}
542
543
extern "C" void *
544
class_get_verify_data_ptr( class_handler klass )
545
{
546
	assert(!"verifier entered!!");
547
	return (NULL);
548
}
549
550
extern "C" method_handler
551
class_resolve_method( class_handler klass, unsigned short index )
552
{
553
	assert(!"verifier entered!!");
554
	return (NULL);
555
}
556
557
extern "C" field_handler
558
class_resolve_nonstatic_field( class_handler klass, unsigned short index )
559
{
560
	assert(!"verifier entered!!");
561
	return (NULL);
562
}
563
564
/**
565
 * Method interface
566
 */
567
568
extern "C" class_handler
569
method_get_class( method_handler hmethod )
570
{
571
	assert(hmethod);
572
	return hmethod->class_owner;
573
}
574
575
extern "C" const char *
576
method_get_name( method_handler method )
577
{
578
	if (method->magic == METHOD_HANDLER_SELF) {
579
		return (method->X.instrumented_method->GetName());
580
	}
581
	else {
582
		assert(!"verifier entered!!");
583
	}
584
	return (NULL);
585
}
586
587
extern "C" const char *
588
method_get_descriptor( method_handler method )
589
{
590
	if (method->magic == METHOD_HANDLER_SELF) {
591
		return (method->X.instrumented_method->GetSignature());
592
	}
593
	else {
594
		assert(!"verifier entered!!");
595
	}
596
	return (NULL);
597
}
598
599
extern "C" unsigned
600
method_get_bytecode_length( method_handler method )
601
{
602
	/*insert check about instrumentation*/
603
	if (method->magic == METHOD_HANDLER_SELF) {
604
		unsigned size = 0;
605
		CInstructions::const_iterator insIterator;
606
		if (method->X.instrumented_method->GetCodeAttribute() == NULL) return (0);
607
		return (method->X.instrumented_method->GetCodeAttribute()->GetCodeLength());
608
	}
609
	else {
610
		assert(!"verifier entered!!");
611
	}
612
	return (0);	
613
}
614
615
extern "C" unsigned char *
616
method_get_bytecode( method_handler method )
617
{
618
	if (method->magic == METHOD_HANDLER_SELF) {
619
		return (method->X.instrumented_method->GetCodeAttribute()->GetCode());
620
	}
621
	else {
622
		assert(!"verifier entered!!");
623
	}
624
	return (NULL);	
625
}
626
627
extern "C" unsigned
628
method_get_max_locals( method_handler method )
629
{
630
	if (method->magic == METHOD_HANDLER_SELF) {
631
		/*XXX: add check for instrumented method*/
632
		CMethodJ * jmethod = (CMethodJ *)(method->X.instrumented_method);
633
		return (jmethod->GetCodeAttribute()->GetMaxLocals());
634
	}
635
	else {
636
		assert(!"verifier entered!!");
637
	}
638
	return (0);	
639
	
640
}
641
642
extern "C" unsigned 
643
method_get_max_stack( method_handler method )
644
{
645
	if (method->magic == METHOD_HANDLER_SELF) {
646
		CMethodJ * jmethod = (CMethodJ *)(method->X.instrumented_method);
647
		return (jmethod->GetCodeAttribute()->GetMaxStack());
648
	}
649
	else {
650
		assert(!"verifier entered!!");
651
	}
652
	return (0);	
653
}
654
655
extern "C" unsigned
656
method_is_static( method_handler method )
657
{
658
	if (method->magic == METHOD_HANDLER_SELF) {
659
		return (method->X.instrumented_method->GetAccessFlags() & ACC_STATIC);
660
	}
661
	else {
662
		//assert(!"verifier entered!!");
663
		return (0); /*we're assuming that this function called after class_resolve_method and couldn't return static methods*/
664
	}
665
	return (0);	
666
	
667
}
668
669
extern "C" unsigned
670
method_is_protected( method_handler method )
671
{
672
	assert(!"verifier entered!!");
673
	return (0);
674
}
675
676
/**
677
 * Method exception handler
678
 */
679
680
extern "C" unsigned short
681
method_get_exc_handler_number( method_handler method )
682
{
683
	return (method->X.instrumented_method->GetExTable()->size());
684
}
685
686
extern "C" void
687
method_get_exc_handler_info( method_handler method, unsigned short index,
688
                             unsigned short *start_pc, unsigned short *end_pc,
689
                             unsigned short *handler_pc, unsigned short *catch_type )
690
{
691
	class CExTable& exc = method->X.instrumented_method->GetCodeAttribute()->GetExTable();
692
	*start_pc = exc[index].GetStartPC();
693
	*end_pc = exc[index].GetEndPC();
694
	*handler_pc = exc[index].GetHandlerPC();
695
	*catch_type = exc[index].GetCatchtype();
696
697
	return;
698
}
699
700
extern "C" unsigned short
701
method_get_number_exc_method_can_throw( method_handler hmethod )
702
{
703
	assert(!"verifier entered!!");
704
	return (0);
705
}
706
707
extern "C" const char *
708
method_get_exc_method_can_throw( method_handler hmethod, unsigned short index )
709
{
710
	assert(!"verifier entered!!");
711
	return (NULL);
712
}
713
714
715
extern "C" unsigned char *
716
method_get_stackmaptable( method_handler hmethod )
717
{
718
	
719
	CStackMapTableAttribute *attr = hmethod->X.instrumented_method->GetCodeAttribute()->GetStackMaps();
720
	if (attr == NULL)
721
		return (NULL);
722
	u4 length = attr->GetLength();
723
	u1 *stackmap = (u1 *)malloc(length);
724
	CJMemStream mem_stream;
725
	mem_stream.Open(stackmap, length);
726
	CJStream stream(&mem_stream);
727
	attr->Write(stream);
728
	//return (attr->GetInfo());
729
	return (stackmap);
730
}
731
732
extern "C" void 
733
method_modify_exc_handler_info(method_handler method, 
734
                                    unsigned short idx, 
735
                                    unsigned short start_pc,
736
                                    unsigned short end_pc, 
737
                                    unsigned short handler_pc, 
738
                                    unsigned short handler_cp_index )
739
{
740
741
	class CExTable& exc = method->X.instrumented_method->GetCodeAttribute()->GetExTable();
742
	exc[idx].SetStartPC(start_pc);
743
	exc[idx].SetEndPC(end_pc);
744
	exc[idx].SetHandlerPC(handler_pc);
745
	return;
746
}
747
748
extern "C" void 
749
method_remove_exc_handler( method_handler method, unsigned short idx )
750
{
751
	assert(!"verifier entered!!");
752
	return;
753
}
754
755
/**
756
 * Class loader interface
757
 */
758
759
extern "C" void
760
class_loader_set_verifier_data_ptr( classloader_handler classloader, void *data )
761
{
762
	assert(!"verifier entered!!");
763
	return;
764
}
765
766
extern "C" void *
767
class_loader_get_verifier_data_ptr( classloader_handler classloader )
768
{
769
	assert(!"verifier entered!!");
770
	return (NULL);
771
}
772
773
extern "C" void
774
class_loader_lock( classloader_handler classloader )
775
{
776
	assert(!"verifier entered!!");
777
	return;
778
}
779
780
extern "C" void
781
class_loader_unlock( classloader_handler classloader )
782
{
783
	assert(!"verifier entered!!");
784
	return;
785
}
786
787
extern "C" class_handler
788
class_loader_lookup_class( classloader_handler classloader, const char *name )
789
{
790
	if (m_name2ch[name] != NULL && IS_CLASS_INSTRUMENTED(m_name2ch[name])) 
791
		return (m_name2ch[name]);
792
	else
793
		return (NULL);
794
}
795
796
extern "C" class_handler
797
class_loader_load_class( classloader_handler classloader, const char *name )
798
{
799
	assert(!"verifier entered!!");
800
	return (NULL);
801
}
802
803
extern "C" unsigned
804
field_is_protected( field_handler field )
805
{
806
	assert(!"verifier entered!!");
807
	return (0);
808
}
809
810
class_handler
811
get_class_handler_from_builder(class CModuleJ *module) 
812
{
813
	class_handler ch;
814
815
	m_name2ch.clear();
816
	int status = create_class_handler(&m_j_l_object_ch, CLASS_HANDLER_SIMPLEFIED, "java/lang/Object", 0, NULL);
817
	assert(!status);
818
	
819
	status = create_class_handler(&ch, CLASS_HANDLER_INSTRUMENTED, module->GetName(), 1, module);
820
	assert(!status);
821
	return (ch);
822
}
823
824
method_handler 
825
get_method_handler_for_cmethod(class CMethod *method)
826
{
827
	class_handler ch = NULL;
828
	method_handler mh = NULL;
829
	int status;
830
	status = create_class_handler(&ch, CLASS_HANDLER_INSTRUMENTED, (const char *)method->GetModule()->GetName(), 1, method->GetModule());
831
	assert(!status);
832
	status = create_method_handler(&mh, ch, METHOD_HANDLER_SELF, method);
833
	assert(!status);
834
	return (mh);
835
}
836
837
extern "C" unsigned short
838
class_cp_get_class_entry(class_handler klass, const char* name)
839
{
840
841
	
842
	CCPClassInfo *cinfo;
843
	if (IS_CLASS_INSTRUMENTED(klass)) {
844
		/*for this class we'll have entry somewhere in some future */
845
		if (strcmp(klass->X.instrumented_class->GetName(), name) == 0) {
846
			return (klass->X.instrumented_class->GetClass().GetThisClass());
847
		}
848
		assert(name);
849
		cinfo = (klass->X.instrumented_class->GetClassBuilder().FindClass(name));
850
		if (cinfo == NULL) {
851
			/*should be created new class antry */
852
			cinfo = *klass->X.instrumented_class->GetClassBuilder().CreateClassConstant(name);
853
			assert(cinfo);
854
		} 
855
		return(cinfo->GetCpIndex());
856
	} else {
857
		assert (!"not implemented yet!");
858
	}
859
	return (0);
860
}
861
862
int
863
initialize_dynamic(get_vm_pointer_t a_get_vm_pointer)
864
{
865
	m_get_vm_pointer = (JNIEnv *(*)(void **))a_get_vm_pointer;
866
	JNIEnv *env;
867
	
868
	env = m_get_vm_pointer((void **)&env);
869
	assert(env);
870
	
871
	if (m_j_l_class) return (0);
872
	
873
	m_j_l_class = env->NewGlobalRef(env->FindClass("java/lang/Class"));
874
		assert(m_j_l_class);
875
	
876
	m_j_l_class_getName = env->GetMethodID(m_j_l_class, "getName", "()Ljava/lang/String;");
877
	assert(m_j_l_class_getName);
878
	
879
	m_j_l_class_getClassLoader = env->GetMethodID(m_j_l_class, "getClassLoader", "()Ljava/lang/ClassLoader;");
880
	assert(m_j_l_class_getClassLoader);
881
	
882
	m_j_l_class_isInterface = env->GetMethodID(m_j_l_class, "isInterface", "()Z");
883
	assert(m_j_l_class_isInterface);
884
	
885
	m_j_l_classloader = env->NewGlobalRef(env->FindClass("java/lang/ClassLoader"));
886
	assert(m_j_l_classloader);
887
888
	m_j_l_classloader_findLoadedClass = env->GetMethodID(m_j_l_classloader, "findLoadedClass", "(Ljava/lang/String;)Ljava/lang/Class;"); 
889
	assert(m_j_l_classloader_findLoadedClass);
890
891
	return (0);
892
}
893
894
void 
895
class_destroy_handler(class_handler ch) 
896
{
897
	if (ch == NULL) return;
898
	if (!IS_CLASS_INSTRUMENTED(ch) && ch->loaded == 1) {
899
		JNIEnv *env;
900
		env = m_get_vm_pointer((void **)&env);
901
		assert(env);
902
		env->DeleteGlobalRef((jobject)ch->X.simplified_class);
903
	
904
	}
905
	free(ch);
906
	ch = NULL;
907
}
(-)src-native/BCI/BCIEng/BCIEngJ/class_interface_x.h (+46 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * $Id$ 
8
 * 
9
 * Contributors: 
10
 * Intel - Initial API and implementation 
11
 **********************************************************************/ 
12
13
#ifndef _CLASS_INTERFACE_X_H_
14
#define _CLASS_INTERFACE_X_H_
15
16
typedef unsigned long intptr;
17
18
19
#ifdef __cplusplus
20
//extern "C" {
21
#endif
22
23
#if 0
24
#include "class_interface.h"
25
#include "x_verifier.h"
26
#else
27
#define __INSURE__
28
#include "verifier-ext/class_interface.h"
29
#include "verifier-ext/x_verifier.h"
30
#endif
31
32
// removes given exception handler (handlers with greater indexes shift)
33
void method_remove_exc_handler( method_handler method, unsigned short idx );
34
35
//modifies start_pc, end_pc 
36
void method_modify_exc_handler_info(method_handler method, 
37
                                    unsigned short idx, 
38
                                    unsigned short start_pc,
39
                                    unsigned short end_pc, 
40
                                    unsigned short handler_pc, 
41
                                    unsigned short handler_cp_index );
42
unsigned short class_get_cp_class_entry(class_handler k_class, const char* name);
43
#ifdef __cplusplus
44
//}
45
#endif
46
#endif /*!_CLASS_INTERFACE_X_H_*/
(-)src-native/BCI/BCIEng/BCIEngProbe/BCIEngProbe.cpp (-5 / +21 lines)
Lines 20-25 Link Here
20
#pragma convert(819)	/* see comment in CommonDef.h about this */
20
#pragma convert(819)	/* see comment in CommonDef.h about this */
21
#endif
21
#endif
22
22
23
#include <assert.h>
24
23
#ifdef WIN32
25
#ifdef WIN32
24
#pragma warning(disable:4786)
26
#pragma warning(disable:4786)
25
#endif
27
#endif
Lines 32-37 Link Here
32
#include "BCIEngProbe.h"			// BCI Engine for Probe Kit
34
#include "BCIEngProbe.h"			// BCI Engine for Probe Kit
33
#include "BCIEngInterface.h"		// for callback message number defines
35
#include "BCIEngInterface.h"		// for callback message number defines
34
36
37
35
#include <stdio.h> // for sprintf on Linux
38
#include <stdio.h> // for sprintf on Linux
36
#ifdef MVS
39
#ifdef MVS
37
#    include <unistd.h> /* for __etoa */
40
#    include <unistd.h> /* for __etoa */
Lines 1830-1839 CBCIEngProbe::Instrument(void* i_pInClas Link Here
1830
	// Starting with the call to Open, we don't need to delete pClass any more:
1833
	// Starting with the call to Open, we don't need to delete pClass any more:
1831
	// The module owns it.
1834
	// The module owns it.
1832
	CModuleJ* pModuleJ = new CModuleJ;
1835
	CModuleJ* pModuleJ = new CModuleJ;
1836
	pModuleJ->UseStackMapCalculation(m_use_external_verifier);
1833
	pModuleJ->Open(pClass, true);
1837
	pModuleJ->Open(pClass, true);
1834
	pModuleJ->SetAccessFlags(pClass->GetAccessFlags());
1838
	pModuleJ->SetAccessFlags(pClass->GetAccessFlags());
1835
	pModuleJ->Parse();
1839
	if (pModuleJ->Parse() != 0) {
1836
1840
		*o_pcbOutClass = i_cbInClass;
1841
		*o_ppOutClass = i_pInClass;
1842
		delete pClass;
1843
		return false;
1844
	}
1845
	
1837
	// If we were asked to, then dump the module before and after instrumentation
1846
	// If we were asked to, then dump the module before and after instrumentation
1838
	const char *dump_output_file;
1847
	const char *dump_output_file;
1839
	if ((dump_output_file = getenv("PROBEKIT_DUMP_FILE")) != NULL) {
1848
	if ((dump_output_file = getenv("PROBEKIT_DUMP_FILE")) != NULL) {
Lines 1845-1850 CBCIEngProbe::Instrument(void* i_pInClas Link Here
1845
		output_stream << "=========== DUMP BEFORE INSTRUMENTATION" << endl;
1854
		output_stream << "=========== DUMP BEFORE INSTRUMENTATION" << endl;
1846
		pModuleJ->Dump(output_stream);
1855
		pModuleJ->Dump(output_stream);
1847
1856
1857
1848
#if defined(MVS) || defined(__OS400__)
1858
#if defined(MVS) || defined(__OS400__)
1849
		/* On EBCDIC systems, convert ASCII to EBCDIC */
1859
		/* On EBCDIC systems, convert ASCII to EBCDIC */
1850
		char* data = output_stream.str();
1860
		char* data = output_stream.str();
Lines 1864-1870 CBCIEngProbe::Instrument(void* i_pInClas Link Here
1864
	// to this module, but we still ran callsite probes against this
1874
	// to this module, but we still ran callsite probes against this
1865
	// module and maybe we didn't actually do anything.
1875
	// module and maybe we didn't actually do anything.
1866
	// In that case we should set out == in and return without calling emit.
1876
	// In that case we should set out == in and return without calling emit.
1867
1868
	pModuleJ->Emit();
1877
	pModuleJ->Emit();
1869
1878
1870
	// Tell the client that's driving us that we did something to this module
1879
	// Tell the client that's driving us that we did something to this module
Lines 1882-1887 CBCIEngProbe::Instrument(void* i_pInClas Link Here
1882
#else
1891
#else
1883
		ofstream output_stream(dump_output_file, ios::app);
1892
		ofstream output_stream(dump_output_file, ios::app);
1884
#endif
1893
#endif
1894
1885
		output_stream << "=========== DUMP AFTER INSTRUMENTATION" << endl;
1895
		output_stream << "=========== DUMP AFTER INSTRUMENTATION" << endl;
1886
		pModuleJ->Dump(output_stream);
1896
		pModuleJ->Dump(output_stream);
1887
1897
Lines 1898-1903 CBCIEngProbe::Instrument(void* i_pInClas Link Here
1898
	}
1908
	}
1899
1909
1900
	*o_pcbOutClass = pClass->GetSize();
1910
	*o_pcbOutClass = pClass->GetSize();
1911
	if (m_pfnMalloc == NULL) {
1912
		/*skipping*/
1913
		*o_pcbOutClass = i_cbInClass;
1914
		*o_ppOutClass = i_pInClass;
1915
		delete pClass;
1916
		return false;
1917
	}
1901
	*o_ppOutClass = m_pfnMalloc(*o_pcbOutClass);
1918
	*o_ppOutClass = m_pfnMalloc(*o_pcbOutClass);
1902
1919
1903
	CJMemStream		OutStream;					// Memory stream
1920
	CJMemStream		OutStream;					// Memory stream
Lines 1998-2004 CBCIEngProbe::Instrument(CModule* i_pmod Link Here
1998
	{
2015
	{
1999
		InstrumentMethod(*itrMeth); 
2016
		InstrumentMethod(*itrMeth); 
2000
	}
2017
	}
2001
2002
	// Process any staticInitializer fragments that matched this class,
2018
	// Process any staticInitializer fragments that matched this class,
2003
	// and default initializers for staticField elements in probes that matched.
2019
	// and default initializers for staticField elements in probes that matched.
2004
	HandleStaticInitializers(pmodj);
2020
	HandleStaticInitializers(pmodj);
Lines 3179-3185 CBCIEngProbe::InstrumentMethod(CMethod* Link Here
3179
	{
3195
	{
3180
		return;
3196
		return;
3181
	}
3197
	}
3182
3198
	
3183
	// Allow the client that's driving us to veto instrumentation of this module
3199
	// Allow the client that's driving us to veto instrumentation of this module
3184
	if (NULL != m_pfnCallback &&
3200
	if (NULL != m_pfnCallback &&
3185
		(m_wCBFlags & BCIENGINTERFACE_CALLBACK_METHOD) &&
3201
		(m_wCBFlags & BCIENGINTERFACE_CALLBACK_METHOD) &&
(-)src-native/BCI/BCIEng/BCIEngProbe/BCIEngProbe.h (+2 lines)
Lines 504-509 private: Link Here
504
	// These fields are reset and reused for each instrumented method
504
	// These fields are reset and reused for each instrumented method
505
	IP_t			m_ipFinally;				// Finally wrapper label
505
	IP_t			m_ipFinally;				// Finally wrapper label
506
	IP_t			m_ipCatchAll;				// catch-all wrapper label
506
	IP_t			m_ipCatchAll;				// catch-all wrapper label
507
friend class CBCIEngProbeInterface;
508
	bool m_use_external_verifier;
507
};
509
};
508
510
509
#endif // defined _BCIENGPROBE_H_
511
#endif // defined _BCIENGPROBE_H_
(-)src-native/BCI/BCIEng/BCIEngProbe/BCIEngProbeInterface.cpp (+31 lines)
Lines 20-25 Link Here
20
#pragma convert(819)	/* see comment in CommonDef.h about this */
20
#pragma convert(819)	/* see comment in CommonDef.h about this */
21
#endif
21
#endif
22
22
23
#include <assert.h>
24
23
#ifdef MVS 
25
#ifdef MVS 
24
#include <unistd.h> /* for __atoe */
26
#include <unistd.h> /* for __atoe */
25
#endif
27
#endif
Lines 37-42 Link Here
37
39
38
#define TOK_WHITESPACE " \t"
40
#define TOK_WHITESPACE " \t"
39
41
42
int g_use_verifier;
40
//------------------------------------------------------------------------------
43
//------------------------------------------------------------------------------
41
inline static unsigned ExceptionToError(CBCIEngProbeInterfaceException& ex)
44
inline static unsigned ExceptionToError(CBCIEngProbeInterfaceException& ex)
42
{
45
{
Lines 341-346 CBCIEngProbeInterface::Initialize(const Link Here
341
344
342
}
345
}
343
346
347
//------------------------------------------------------------------------------
348
void 
349
CBCIEngProbeInterface::UseStackMapRecalculation(bool a_use_recalculation)
350
{
351
	m_peng.m_use_external_verifier = a_use_recalculation;
352
}
344
353
345
//------------------------------------------------------------------------------
354
//------------------------------------------------------------------------------
346
void 
355
void 
Lines 439-444 unsigned Instrument(pbcieng_t i_pbcieng, Link Here
439
	try
448
	try
440
	{
449
	{
441
		CBCIEngProbeInterface* peng = (CBCIEngProbeInterface*)i_pbcieng;
450
		CBCIEngProbeInterface* peng = (CBCIEngProbeInterface*)i_pbcieng;
451
		peng->UseStackMapRecalculation(false);
452
		peng->Instrument(i_pInClass, i_cbInClass, o_ppOutClass, o_pcbOutClass);
453
	}
454
	catch (CBCIEngProbeInterfaceException& ex)
455
	{
456
		uErr = ExceptionToError(ex);
457
	}
458
	return uErr;
459
}
460
461
//------------------------------------------------------------------------------
462
unsigned Instrument2(pbcieng_t i_pbcieng, void* i_pInClass, size_t i_cbInClass, 
463
		            void** o_ppOutClass, size_t* o_pcbOutClass, void *(*pEnv)(void **))
464
{
465
	unsigned uErr = 0;
466
	initialize_dynamic(pEnv);
467
	try
468
	{
469
470
		CBCIEngProbeInterface* peng = (CBCIEngProbeInterface*)i_pbcieng;
471
		peng->UseStackMapRecalculation(true);
442
		peng->Instrument(i_pInClass, i_cbInClass, o_ppOutClass, o_pcbOutClass);
472
		peng->Instrument(i_pInClass, i_cbInClass, o_ppOutClass, o_pcbOutClass);
443
	}
473
	}
444
	catch (CBCIEngProbeInterfaceException& ex)
474
	catch (CBCIEngProbeInterfaceException& ex)
Lines 453-458 unsigned SetAllocator(pbcieng_t i_pbcien Link Here
453
{
483
{
454
	unsigned uErr = 0;
484
	unsigned uErr = 0;
455
	CBCIEngProbeInterface* peng = (CBCIEngProbeInterface*)i_pbcieng;
485
	CBCIEngProbeInterface* peng = (CBCIEngProbeInterface*)i_pbcieng;
486
	//assert(i_pfnMalloc);
456
	peng->SetAllocator(i_pfnMalloc);
487
	peng->SetAllocator(i_pfnMalloc);
457
	return uErr;
488
	return uErr;
458
}
489
}
(-)src-native/BCI/BCIEng/BCIEngProbe/BCIEngProbeInterface.h (+3 lines)
Lines 85-90 public: Link Here
85
85
86
private: 
86
private: 
87
	CBCIEngProbe m_peng;
87
	CBCIEngProbe m_peng;
88
	void UseStackMapRecalculation(bool a_use_recalculation);
89
	friend unsigned Instrument(pbcieng_t, void*, size_t , void** , size_t* );
90
	friend unsigned Instrument2(pbcieng_t, void*, size_t , void** , size_t*, void *(*f)(void **));
88
};
91
};
89
92
90
//------------------------------------------------------------------------------
93
//------------------------------------------------------------------------------
(-)src-native/BCI/Common/CommonDef.h (-9 / +14 lines)
Lines 22-35 Link Here
22
// For this header to work, you need to define one of these ARCH symbols:
22
// For this header to work, you need to define one of these ARCH symbols:
23
//
23
//
24
//	WIN32 (means x86)
24
//	WIN32 (means x86)
25
//	IA32_ARCH (means x86)
25
//  IPF_ARCH (means Itanium Processor Family)
26
//  IPF_ARCH (means Itanium Processor Family)
26
//  EM64T_ARCH (means Intel/AMD 64-bit processors)
27
//  EM64T_ARCH (means Intel/AMD 64-bit processors)
27
//	IA32_ARCH (means x86)
28
//	SPARC_ARCH
28
//	SPARC_ARCH
29
//	HPPA_ARCH
29
//	HPPA_ARCH
30
//	ALPHA_ARCH
30
//	ALPHA_ARCH
31
//	PPC_ARCH
31
//	PPC_ARCH
32
//  LINUX_PPC_ARCH  (LINUX PPC64)
33
//	OS390_ARCH (means zSeries)
32
//	OS390_ARCH (means zSeries)
34
//	AS400_ARCH (means iSeries)
33
//	AS400_ARCH (means iSeries)
35
//
34
//
Lines 72-81 Link Here
72
    // This brings _WINDOWS_ into scope. Use _WINDOWS_ to wrap Windows code.
71
    // This brings _WINDOWS_ into scope. Use _WINDOWS_ to wrap Windows code.
73
#   include <windows.h>           /* for lots o' stuff, but esp. _WINDOWS_ */
72
#   include <windows.h>           /* for lots o' stuff, but esp. _WINDOWS_ */
74
#   include <malloc.h>            /* for alloca */
73
#   include <malloc.h>            /* for alloca */
75
#elif defined(IPF_ARCH) || (EM64T_ARCH) || (LINUX_PPC_ARCH)
74
#elif defined(IPF_ARCH) || (EM64T_ARCH)
76
#   include <stdint.h>         /* for int64_t and uint64_t */
75
#   include <stdint.h>         /* for int64_t and uint64_t */
77
#endif
76
#endif
78
77
78
/* On LinuxPPC64 we need this to get int64_t */
79
#if defined(PPC_ARCH)
80
#   include </usr/include/sys/types.h>
81
#endif
79
/* Only on OS400, we need this to get malloc/free */
82
/* Only on OS400, we need this to get malloc/free */
80
#ifdef OS400
83
#ifdef OS400
81
#include <stdlib.h>
84
#include <stdlib.h>
Lines 113-127 typedef unsigned short WORD, *PWORD; Link Here
113
	typedef signed long long int int64_t;
116
	typedef signed long long int int64_t;
114
	typedef unsigned long long int uint64_t;
117
	typedef unsigned long long int uint64_t;
115
#else
118
#else
116
#if defined(_WINDOWS_)
119
#   if defined(_WINDOWS_)
117
		typedef __int64 int64_t;
120
		typedef __int64 int64_t;
118
		typedef unsigned __int64 uint64_t;
121
		typedef unsigned __int64 uint64_t;
119
#else
122
#elif defined(PPC_ARCH)
120
#       if !defined(IPF_ARCH) && !defined(EM64T_ARCH) && !defined(LINUX_PPC_ARCH) // Already being declared in stdint.h
121
		typedef long long int64_t;
122
		typedef unsigned long long uint64_t;
123
		typedef unsigned long long uint64_t;
124
#   else
125
#       if !defined(IPF_ARCH) && !defined(EM64T_ARCH)
126
	        typedef long long int64_t;
127
			typedef unsigned long long uint64_t;
123
#       endif
128
#       endif
124
#endif
129
#   endif
125
#endif
130
#endif
126
131
127
//------------------------------------------------------------------------------
132
//------------------------------------------------------------------------------
Lines 197-203 typedef unsigned short WORD, *PWORD; Link Here
197
///////
202
///////
198
#if defined(WIN32) || defined(IA32_ARCH) || defined(IPF_ARCH) || defined(EM64T_ARCH) || defined(ALPHA_ARCH)
203
#if defined(WIN32) || defined(IA32_ARCH) || defined(IPF_ARCH) || defined(EM64T_ARCH) || defined(ALPHA_ARCH)
199
#   define BIG_ENDIAN_HW
204
#   define BIG_ENDIAN_HW
200
#elif defined(SPARC_ARCH) || defined(HPPA_ARCH) || defined(PPC_ARCH) || defined(AS400_ARCH) || defined(OS390_ARCH) || defined(LINUX_PPC_ARCH)
205
#elif defined(SPARC_ARCH) || defined(HPPA_ARCH) || defined(PPC_ARCH) || defined(AS400_ARCH) || defined(OS390_ARCH)
201
#   define LITTLE_ENDIAN_HW
206
#   define LITTLE_ENDIAN_HW
202
#else
207
#else
203
#   error "Platform-specific configuration required"
208
#   error "Platform-specific configuration required"
(-)src-native/BCI/Common/JavaDef.h (-1 / +16 lines)
Lines 50-55 Link Here
50
#define CONSTANT_InterfaceMethodref	11		// Interface method refernce constant 
50
#define CONSTANT_InterfaceMethodref	11		// Interface method refernce constant 
51
#define CONSTANT_NameAndType		12		// Name and type constant
51
#define CONSTANT_NameAndType		12		// Name and type constant
52
52
53
#define CONSTANT_Unknown			0
53
// Array types
54
// Array types
54
#define T_BOOLEAN					4		// bool
55
#define T_BOOLEAN					4		// bool
55
#define T_CHAR						5		// char
56
#define T_CHAR						5		// char
Lines 60-66 Link Here
60
#define T_INT						10		// int
61
#define T_INT						10		// int
61
#define T_LONG						11		// long
62
#define T_LONG						11		// long
62
63
63
#define CONSTANT_Unknown			0
64
// stack map frame types (new in Java 6.0)
65
#define SAME_LOCALS_1_STACK_ITEM_EXTENDED   247
66
#define SAME_FRAME_EXTENDED                 251
67
#define FULL_FRAME                          255
68
69
// verification types (new in Java 6.0)
70
#define ITEM_Top                    0
71
#define ITEM_Integer                1
72
#define ITEM_Float                  2
73
#define ITEM_Double                 3
74
#define ITEM_Long                   4
75
#define ITEM_Null                   5
76
#define ITEM_UninitializedThis      6
77
#define ITEM_Object                 7
78
#define ITEM_Uninitialized          8
64
79
65
// ToDo: other Java specific definitions
80
// ToDo: other Java specific definitions
66
typedef unsigned char				u1;		// 1 byte
81
typedef unsigned char				u1;		// 1 byte
(-)src-native/BCI/JClass/JClassBuilder.cpp (-1 / +19 lines)
Lines 80-86 CJClassBuilder::GetThisClassName() Link Here
80
string
80
string
81
CJClassBuilder::GetSuperClassName()
81
CJClassBuilder::GetSuperClassName()
82
{
82
{
83
	CCPUtf8Info* pcpUtf8 = (CCPUtf8Info*)((*m_pConstPool)[GetSuperClass()]);
83
	CCPClassInfo* pccpClassInfo = (CCPClassInfo*)((*m_pConstPool)[GetSuperClass()]);
84
	CCPUtf8Info* pcpUtf8 = (CCPUtf8Info*)((*m_pConstPool)[pccpClassInfo->GetClassInd()]);
84
	string strSuperClass = (string)*pcpUtf8;
85
	string strSuperClass = (string)*pcpUtf8;
85
	return strSuperClass;
86
	return strSuperClass;
86
}
87
}
Lines 245-250 CJClassBuilder::FindClass(CSTR i_szName) Link Here
245
	CConstPool::iterator itr = m_pConstPool->begin();
246
	CConstPool::iterator itr = m_pConstPool->begin();
246
	while(itr != m_pConstPool->end())
247
	while(itr != m_pConstPool->end())
247
	{
248
	{
249
		if (*itr == NULL) return NULL;
248
		if((*itr)->GetTag() == CONSTANT_Class)
250
		if((*itr)->GetTag() == CONSTANT_Class)
249
		{
251
		{
250
			CCPClassInfo* pcpci = (CCPClassInfo*)*itr;
252
			CCPClassInfo* pcpci = (CCPClassInfo*)*itr;
Lines 278-283 CJClassBuilder::CreateStringConstant(CST Link Here
278
}
280
}
279
281
280
//------------------------------------------------------------------------------
282
//------------------------------------------------------------------------------
283
// CreateClassConstant
284
// In:
285
//	i_szClassName - class name
286
// Returns:
287
//	CCPClassInfo* - pointer to the class infoin the constant pool
288
//
289
CCPClassInfo* 
290
CJClassBuilder::CreateClassConstant(CSTR i_szClassName)
291
{
292
	u2 u2ClassName = m_pConstPool->Add(new CCPUtf8Info(i_szClassName));
293
	u2 u2ClassRef  = m_pConstPool->Add(new CCPClassInfo(u2ClassName));
294
	CCPClassInfo* pcpClass = (CCPClassInfo*)((*m_pConstPool)[u2ClassRef]);
295
	return pcpClass;
296
}
297
298
//------------------------------------------------------------------------------
281
// CreateIntegerConstant
299
// CreateIntegerConstant
282
// In:
300
// In:
283
//	i_int - Integer value to add
301
//	i_int - Integer value to add
(-)src-native/BCI/JClass/JClassBuilder.h (-1 / +2 lines)
Lines 62-68 public: Link Here
62
62
63
	// Constant pool manipulation
63
	// Constant pool manipulation
64
	CCPStringInfo* CreateStringConstant(CSTR i_szString);
64
	CCPStringInfo* CreateStringConstant(CSTR i_szString);
65
	CCPIntegerInfo* CreateIntegerConstant (JINTEGER i_int);
65
    CCPClassInfo* CreateClassConstant(CSTR i_szClassName);
66
    CCPIntegerInfo* CreateIntegerConstant (JINTEGER i_int);
66
	CCPLongInfo* CreateLongConstant(JLONG  i_long);
67
	CCPLongInfo* CreateLongConstant(JLONG  i_long);
67
	CCPFloatInfo* CreateFloatConstant(JFLOAT i_float);
68
	CCPFloatInfo* CreateFloatConstant(JFLOAT i_float);
68
	CCPDoubleInfo* CreateDoubleConstant(JDOUBLE i_double);
69
	CCPDoubleInfo* CreateDoubleConstant(JDOUBLE i_double);
(-)src-native/BCI/JClass/JClassFile.cpp (-11 / +809 lines)
Lines 47-54 Link Here
47
#  include <iostream>
47
#  include <iostream>
48
#endif
48
#endif
49
49
50
#include "JavaDef.h"
50
#include "CommonDef.h"
51
#include "CommonDef.h"
52
51
#include "JClassFile.h"
53
#include "JClassFile.h"
54
#include "JMemStream.h"
52
55
53
USE_NAMESPACE(std);
56
USE_NAMESPACE(std);
54
57
Lines 224-231 CCPUtf8Info::CCPUtf8Info(const CCPUtf8In Link Here
224
:CCPInfo(CONSTANT_Utf8)
227
:CCPInfo(CONSTANT_Utf8)
225
{
228
{
226
	m_u2Length = i_utf8Info.GetLength();
229
	m_u2Length = i_utf8Info.GetLength();
227
	m_pu1Bytes = new u1[m_u2Length];
230
	m_pu1Bytes = new u1[m_u2Length + 1];
228
	memcpy(m_pu1Bytes, i_utf8Info.GetBytes(), m_u2Length);
231
	m_pu1Bytes[m_u2Length] = '\0';
232
	memcpy(m_pu1Bytes, i_utf8Info.GetBytes(), m_u2Length + 1);
229
}
233
}
230
234
231
//------------------------------------------------------------------------------
235
//------------------------------------------------------------------------------
Lines 259-266 CCPUtf8Info::~CCPUtf8Info() Link Here
259
void
263
void
260
CCPUtf8Info::Read(CJStream& i_jstream)
264
CCPUtf8Info::Read(CJStream& i_jstream)
261
{
265
{
262
	i_jstream >> m_u2Length;
266
	i_jstream >> m_u2Length; 
263
	m_pu1Bytes = new u1[m_u2Length];
267
	m_pu1Bytes = new u1[m_u2Length + 1];
268
	m_pu1Bytes[m_u2Length] = 0; /*Helps standard string functions find end of the string*/
264
	i_jstream.ReadUtf8((void*)m_pu1Bytes, m_u2Length);
269
	i_jstream.ReadUtf8((void*)m_pu1Bytes, m_u2Length);
265
}
270
}
266
271
Lines 1738-1743 CJAttribs::Read(CJStream& i_jstream) Link Here
1738
		{
1743
		{
1739
			pCurrent = new CLocalVariableTypeTableAttribute(m_pClassFile);
1744
			pCurrent = new CLocalVariableTypeTableAttribute(m_pClassFile);
1740
		}
1745
		}
1746
 		else if(*pcpUtf8 == "StackMapTable")
1747
		{
1748
			pCurrent = new CStackMapTableAttribute(m_pClassFile);
1749
		}
1741
		else if(*pcpUtf8 == "Exceptions")
1750
		else if(*pcpUtf8 == "Exceptions")
1742
		{
1751
		{
1743
			pCurrent = new CExceptionsAttribute(m_pClassFile);
1752
			pCurrent = new CExceptionsAttribute(m_pClassFile);
Lines 2119-2124 CCodeAttribute::GetLocalVariableTypes() Link Here
2119
	return NULL;
2128
	return NULL;
2120
}
2129
}
2121
2130
2131
//------------------------------------------------------------------------------
2132
CStackMapTableAttribute* 
2133
CCodeAttribute::GetStackMaps()
2134
{
2135
	for(CJAttribs::iterator iter = m_Attribs.begin(); iter < m_Attribs.end(); iter++)
2136
	{
2137
		if(*(*iter)->GetName() == "StackMapTable")
2138
			return (CStackMapTableAttribute*)*iter;
2139
	}
2140
	return NULL;
2141
}
2142
2143
//------------------------------------------------------------------------------
2144
CStackMapTableAttribute* 
2145
CCodeAttribute::GetOrCreateStackMaps()
2146
{
2147
    // Return the StackMapTable attribute of this Code attribute, creating a new one
2148
    // if such an attribute does not exist
2149
2150
    CStackMapTableAttribute* result = NULL;
2151
	for(CJAttribs::iterator iter = m_Attribs.begin(); iter < m_Attribs.end(); iter++)
2152
	{
2153
		if(*(*iter)->GetName() == "StackMapTable")
2154
        {
2155
			result = (CStackMapTableAttribute*)*iter;
2156
        }
2157
	}
2158
2159
    if (result == NULL)
2160
    {
2161
        result = new CStackMapTableAttribute(m_pClassFile);
2162
        m_Attribs.push_back(result);
2163
    }
2164
    return result;
2165
}
2122
2166
2123
//==============================================================================
2167
//==============================================================================
2124
// CExceptionsAttribute implementation
2168
// CExceptionsAttribute implementation
Lines 2500-2505 CSourceDirAttribute::CSourceDirAttribute Link Here
2500
{}
2544
{}
2501
2545
2502
//==============================================================================
2546
//==============================================================================
2547
// CStackMapTableAttribute implementation
2548
//
2549
CVerificationTypeInfo::CVerificationTypeInfo(u1 i_u1Tag)
2550
: m_u1Tag(i_u1Tag)
2551
{
2552
}
2553
2554
CVerificationTypeInfo::~CVerificationTypeInfo()
2555
{
2556
}
2557
2558
void
2559
CVerificationTypeInfo::Read(CJStream& i_jstream)
2560
{
2561
    // m_u1Tag is read by the CVerificationTypes container.
2562
}
2563
2564
u2
2565
CVerificationTypeInfo::Read(u1 *i_tbl)
2566
{
2567
    // m_u1Tag is read by the CVerificationTypes container.
2568
	return 0;
2569
}
2570
2571
void
2572
CVerificationTypeInfo::Write(CJStream& i_jstream) const
2573
{
2574
    i_jstream << m_u1Tag;
2575
}
2576
2577
u4
2578
CVerificationTypeInfo::GetSize() const
2579
{
2580
    return sizeof(m_u1Tag);
2581
}
2582
2583
//------------------------------------------------------------------------------
2584
CVerificationTypes::~CVerificationTypes()
2585
{
2586
    for (iterator iter = begin(); iter != end(); iter++)
2587
    {
2588
        delete *iter;
2589
    }
2590
}
2591
2592
CVerificationTypes::CVerificationTypes(const CVerificationTypes &i_VerTypes)
2593
{
2594
    *this = i_VerTypes;
2595
}
2596
2597
CVerificationTypes&
2598
CVerificationTypes::operator =(const CVerificationTypes &i_VerTypes)
2599
{
2600
	for(iterator iter = begin(); iter != end(); iter++)
2601
	{
2602
		delete *iter;
2603
	}
2604
	if(!i_VerTypes.empty())
2605
	{
2606
		const_iterator iterIn;
2607
		clear();
2608
		for(iterIn = i_VerTypes.begin(); iterIn != i_VerTypes.end(); iterIn++)
2609
		{
2610
			push_back((*iterIn)->Clone());
2611
		}
2612
	}
2613
	return *this;
2614
}
2615
2616
void
2617
CVerificationTypes::Read(CJStream& i_jstream, u2 i_u2EntriesToRead)
2618
{
2619
    CVerificationTypeInfo* pCurrent;
2620
    
2621
    resize(i_u2EntriesToRead);
2622
    for(u2 u2Ind = 0; u2Ind < i_u2EntriesToRead; u2Ind++)
2623
    {
2624
        u1 u1Tag;
2625
        i_jstream >> u1Tag;
2626
        switch (u1Tag)
2627
        {
2628
        case ITEM_Top:
2629
        case ITEM_Integer:
2630
        case ITEM_Float:
2631
        case ITEM_Double:
2632
        case ITEM_Long:
2633
        case ITEM_Null:
2634
        case ITEM_UninitializedThis:
2635
            pCurrent = new CVerificationTypeInfo(u1Tag);
2636
            break;
2637
        case ITEM_Object:
2638
            pCurrent = new CVerificationTypeObjectInfo(u1Tag);
2639
            break;
2640
        case ITEM_Uninitialized:
2641
            pCurrent = new CVerificationTypeUninitializedVariableInfo(u1Tag);
2642
            break;
2643
        default:
2644
            throw CJClassFileException(CJClassFileException::X_INTERNAL_ERROR);
2645
        }
2646
2647
        pCurrent->Read(i_jstream);
2648
        (*this)[u2Ind] = pCurrent;
2649
    }
2650
}
2651
2652
void 
2653
CVerificationTypes::Write(CJStream& i_jstream) const
2654
{
2655
    for (u2 u2Ind = 0; u2Ind < size(); u2Ind++)
2656
    {
2657
        (*this)[u2Ind]->Write(i_jstream);
2658
    }
2659
}
2660
2661
u4
2662
CVerificationTypes::GetSize() const
2663
{
2664
    u4 u4Size = 0;
2665
	for (const_iterator iter = begin(); iter != end(); iter++)
2666
	{
2667
		u4Size += (*iter)->GetSize();
2668
	}
2669
    return u4Size;
2670
}
2671
2672
//------------------------------------------------------------------------------
2673
CVerificationTypeObjectInfo::CVerificationTypeObjectInfo(u1 i_u1Tag)
2674
: CVerificationTypeInfo(i_u1Tag)
2675
{
2676
}
2677
2678
CVerificationTypeObjectInfo::~CVerificationTypeObjectInfo()
2679
{
2680
}
2681
2682
void
2683
CVerificationTypeObjectInfo::Read(CJStream& i_jstream)
2684
{
2685
    CVerificationTypeInfo::Read(i_jstream);
2686
    i_jstream >> m_u2CpoolIndex;
2687
}
2688
2689
void
2690
CVerificationTypeObjectInfo::Write(CJStream& i_jstream) const
2691
{
2692
    CVerificationTypeInfo::Write(i_jstream);
2693
    i_jstream << m_u2CpoolIndex;
2694
}
2695
2696
u4
2697
CVerificationTypeObjectInfo::GetSize() const
2698
{
2699
    u4 u4Size = CVerificationTypeInfo::GetSize()
2700
        + sizeof(m_u2CpoolIndex);
2701
    return u4Size;
2702
}
2703
2704
//------------------------------------------------------------------------------
2705
CVerificationTypeUninitializedVariableInfo::CVerificationTypeUninitializedVariableInfo(u1 i_u1Tag)
2706
: CVerificationTypeInfo(i_u1Tag)
2707
{
2708
}
2709
2710
CVerificationTypeUninitializedVariableInfo::~CVerificationTypeUninitializedVariableInfo()
2711
{
2712
}
2713
2714
void
2715
CVerificationTypeUninitializedVariableInfo::Read(CJStream& i_jstream)
2716
{
2717
    CVerificationTypeInfo::Read(i_jstream);
2718
    i_jstream >> m_u2Offset;
2719
}
2720
2721
void
2722
CVerificationTypeUninitializedVariableInfo::Write(CJStream& i_jstream) const
2723
{
2724
    CVerificationTypeInfo::Write(i_jstream);
2725
    i_jstream << m_u2Offset;
2726
}
2727
2728
u4
2729
CVerificationTypeUninitializedVariableInfo::GetSize() const
2730
{
2731
    u4 u4Size = CVerificationTypeInfo::GetSize()
2732
        + sizeof(m_u2Offset);
2733
    return u4Size;
2734
}
2735
2736
//------------------------------------------------------------------------------
2737
CStackMapFrameInfo::CStackMapFrameInfo(u1 i_u1FrameType)
2738
: m_u1FrameType(i_u1FrameType)
2739
{
2740
    m_u2ByteCodeOffset = 0;
2741
    m_u2OffsetDelta = 0;
2742
}
2743
2744
CStackMapFrameInfo::~CStackMapFrameInfo()
2745
{
2746
}
2747
2748
void
2749
CStackMapFrameInfo::Read(CJStream& i_jstream)
2750
{
2751
    // m_u1FrameType is read by the CStackMapTable container
2752
}
2753
2754
void
2755
CStackMapFrameInfo::Write(CJStream& i_jstream) const
2756
{
2757
    i_jstream << m_u1FrameType;
2758
}
2759
2760
u4
2761
CStackMapFrameInfo::GetSize() const
2762
{
2763
    return sizeof(m_u1FrameType);
2764
}
2765
2766
void 
2767
CStackMapFrameInfo::SetByteCodeOffset(u2 i_u2Offset) 
2768
{ 
2769
    m_u2ByteCodeOffset = i_u2Offset; 
2770
}
2771
2772
void
2773
CStackMapFrameInfo::AdjustOffsetDelta(int i_s2PrevFrameOffset)
2774
{
2775
    int newOffsetDelta = m_u2ByteCodeOffset - 1 - i_s2PrevFrameOffset;
2776
    if (newOffsetDelta < 0)
2777
    {
2778
        // Frame order was changed. This is not supported
2779
        throw CJClassFileException(CJClassFileException::X_INTERNAL_ERROR);
2780
    }
2781
    m_u2OffsetDelta = (u2)newOffsetDelta; // this is a safe cast since newDelta >= 1
2782
}
2783
2784
CStackMapFrameInfo::CStackMapFrameInfo(const CStackMapFrameInfo &i_Other)
2785
: m_u2ByteCodeOffset(i_Other.m_u2ByteCodeOffset), m_u2OffsetDelta(i_Other.m_u2OffsetDelta),
2786
    m_u1FrameType(i_Other.m_u1FrameType)
2787
{
2788
}
2789
2790
//------------------------------------------------------------------------------
2791
CStackMapSameFrameInfo::CStackMapSameFrameInfo(u1 i_u1FrameType, bool i_IsExtended)
2792
: CStackMapFrameInfo(i_u1FrameType), m_IsExtended(i_IsExtended)
2793
{
2794
}
2795
2796
CStackMapSameFrameInfo::~CStackMapSameFrameInfo()
2797
{
2798
}
2799
2800
void
2801
CStackMapSameFrameInfo::Read(CJStream& i_jstream)
2802
{
2803
    CStackMapFrameInfo::Read(i_jstream);
2804
    if (m_IsExtended)
2805
    {
2806
        // SAME_FRAME_EXTENDED type
2807
        i_jstream >> m_u2OffsetDelta;
2808
    }
2809
    else        
2810
    {
2811
        // SAME frame type. offset_delta is stored in the tag
2812
        m_u2OffsetDelta = GetFrameType();
2813
    }
2814
}
2815
2816
void
2817
CStackMapSameFrameInfo::Write(CJStream& i_jstream) const
2818
{
2819
    CStackMapFrameInfo::Write(i_jstream);
2820
    if (m_IsExtended)
2821
    {
2822
        // SAME_FRAME_EXTENDED type
2823
        i_jstream << m_u2OffsetDelta;
2824
    }
2825
}
2826
2827
u4
2828
CStackMapSameFrameInfo::GetSize() const
2829
{
2830
    u4 u4Size = CStackMapFrameInfo::GetSize();
2831
    if (m_IsExtended)
2832
    {
2833
        u4Size += sizeof(m_u2OffsetDelta);
2834
    }
2835
    return u4Size;
2836
}
2837
2838
void
2839
CStackMapSameFrameInfo::AdjustOffsetDelta(int i_s2PrevFrameOffset)
2840
{
2841
    CStackMapFrameInfo::AdjustOffsetDelta(i_s2PrevFrameOffset);
2842
    if (m_u2OffsetDelta > 63)
2843
    {
2844
        // Frame type is SAME_FRAME_EXTENDED
2845
        m_u1FrameType = SAME_FRAME_EXTENDED;
2846
        m_IsExtended = true;
2847
    }
2848
    else
2849
    {
2850
        // Frame type is SAME_FRAME. offset_delta is stored in the tag
2851
        m_u1FrameType = (u1)m_u2OffsetDelta; // this is safe since m_u2OffsetDelta <= 63
2852
        m_IsExtended = false;
2853
    }
2854
}
2855
2856
CStackMapFrameInfo*
2857
CStackMapSameFrameInfo::Clone() const
2858
{
2859
    return new CStackMapSameFrameInfo(*this);
2860
}
2861
2862
//------------------------------------------------------------------------------
2863
CStackMapChopFrameInfo::CStackMapChopFrameInfo(u1 i_u1FrameType)
2864
: CStackMapFrameInfo(i_u1FrameType)
2865
{
2866
}
2867
2868
CStackMapChopFrameInfo::~CStackMapChopFrameInfo()
2869
{
2870
}
2871
2872
void
2873
CStackMapChopFrameInfo::Read(CJStream& i_jstream)
2874
{
2875
    CStackMapFrameInfo::Read(i_jstream);
2876
    i_jstream >> m_u2OffsetDelta;
2877
}
2878
2879
void
2880
CStackMapChopFrameInfo::Write(CJStream& i_jstream) const
2881
{
2882
    CStackMapFrameInfo::Write(i_jstream);
2883
    i_jstream << m_u2OffsetDelta;
2884
}
2885
2886
u4
2887
CStackMapChopFrameInfo::GetSize() const
2888
{
2889
    u4 u4Size = CStackMapFrameInfo::GetSize()
2890
        + sizeof(m_u2OffsetDelta);
2891
    return u4Size;
2892
}
2893
2894
CStackMapFrameInfo*
2895
CStackMapChopFrameInfo::Clone() const
2896
{
2897
    return new CStackMapChopFrameInfo(*this);
2898
}
2899
2900
//------------------------------------------------------------------------------
2901
CStackMapSameLocals1StackItemFrameInfo::CStackMapSameLocals1StackItemFrameInfo(u1 i_u1FrameType, 
2902
                                                                               bool i_IsExtended)
2903
: CStackMapFrameInfo(i_u1FrameType), m_IsExtended(i_IsExtended)
2904
{
2905
}
2906
2907
CStackMapSameLocals1StackItemFrameInfo::~CStackMapSameLocals1StackItemFrameInfo()
2908
{
2909
}
2910
2911
void
2912
CStackMapSameLocals1StackItemFrameInfo::Read(CJStream& i_jstream)
2913
{
2914
    CStackMapFrameInfo::Read(i_jstream);
2915
    if (m_IsExtended)
2916
    {
2917
        // SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED type
2918
        i_jstream >> m_u2OffsetDelta;
2919
    }
2920
    else        
2921
    {
2922
        // SAME_LOCALS_1_STACK_ITEM_FRAME frame type
2923
        m_u2OffsetDelta = GetFrameType() - 64;
2924
    }
2925
    m_Stack.Read(i_jstream, 1); // must hold exactly one stack item
2926
}
2927
2928
void
2929
CStackMapSameLocals1StackItemFrameInfo::Write(CJStream& i_jstream) const
2930
{
2931
    CStackMapFrameInfo::Write(i_jstream);
2932
    if (m_IsExtended)
2933
    {
2934
        // SAME_FRAME_EXTENDED type
2935
        i_jstream << m_u2OffsetDelta;
2936
    }
2937
    m_Stack.Write(i_jstream);
2938
}
2939
2940
u4
2941
CStackMapSameLocals1StackItemFrameInfo::GetSize() const
2942
{
2943
    u4 u4Size = CStackMapFrameInfo::GetSize();
2944
    if (m_IsExtended)
2945
    {
2946
        u4Size += sizeof(m_u2OffsetDelta);
2947
    }
2948
    u4Size += m_Stack.GetSize();
2949
    return u4Size;
2950
}
2951
2952
void
2953
CStackMapSameLocals1StackItemFrameInfo::AdjustOffsetDelta(int i_s2PrevFrameOffset)
2954
{
2955
    CStackMapFrameInfo::AdjustOffsetDelta(i_s2PrevFrameOffset);
2956
    if (m_u2OffsetDelta + 64 > 127)
2957
    {
2958
        // Frame type is SAME_LOCALS_1_STACK_FRAME_EXTENDED
2959
        m_u1FrameType = SAME_LOCALS_1_STACK_ITEM_EXTENDED;
2960
        m_IsExtended = true;
2961
    }
2962
    else
2963
    {
2964
        // Frame type is SAME_LOCALS_1_STACK_FRAME. offset_delta is stored in the tag
2965
        m_u1FrameType = (u1)(m_u2OffsetDelta + 64); // this is safe since m_u2OffsetDelta <= 63
2966
        m_IsExtended = false;
2967
    }
2968
}
2969
2970
CStackMapFrameInfo*
2971
CStackMapSameLocals1StackItemFrameInfo::Clone() const
2972
{
2973
    return new CStackMapSameLocals1StackItemFrameInfo(*this);
2974
}
2975
2976
CStackMapSameLocals1StackItemFrameInfo::CStackMapSameLocals1StackItemFrameInfo(const CStackMapSameLocals1StackItemFrameInfo &i_Other)
2977
: CStackMapFrameInfo(i_Other), m_Stack(i_Other.m_Stack), m_IsExtended(i_Other.m_IsExtended)
2978
{
2979
}
2980
2981
//------------------------------------------------------------------------------
2982
CStackMapAppendFrameInfo::CStackMapAppendFrameInfo(u1 i_u1FrameType)
2983
: CStackMapFrameInfo(i_u1FrameType)
2984
{
2985
}
2986
2987
CStackMapAppendFrameInfo::~CStackMapAppendFrameInfo()
2988
{
2989
}
2990
2991
void
2992
CStackMapAppendFrameInfo::Read(CJStream& i_jstream)
2993
{
2994
    CStackMapFrameInfo::Read(i_jstream);
2995
    i_jstream >> m_u2OffsetDelta;
2996
    m_Locals.Read(i_jstream, GetFrameType() - 251);
2997
}
2998
2999
void
3000
CStackMapAppendFrameInfo::Write(CJStream& i_jstream) const
3001
{
3002
    CStackMapFrameInfo::Write(i_jstream);
3003
    i_jstream << m_u2OffsetDelta;
3004
    m_Locals.Write(i_jstream);
3005
}
3006
3007
u4
3008
CStackMapAppendFrameInfo::GetSize() const
3009
{
3010
    u4 u4Size = CStackMapFrameInfo::GetSize()
3011
        + sizeof(m_u2OffsetDelta)
3012
        + m_Locals.GetSize();
3013
    return u4Size;
3014
}
3015
3016
CStackMapFrameInfo*
3017
CStackMapAppendFrameInfo::Clone() const
3018
{
3019
    return new CStackMapAppendFrameInfo(*this);
3020
}
3021
3022
CStackMapAppendFrameInfo::CStackMapAppendFrameInfo(const CStackMapAppendFrameInfo &i_Other)
3023
: CStackMapFrameInfo(i_Other), m_Locals(i_Other.m_Locals)
3024
{
3025
}
3026
3027
//------------------------------------------------------------------------------
3028
CStackMapFullFrameInfo::CStackMapFullFrameInfo(u1 i_u1FrameType)
3029
: CStackMapFrameInfo(i_u1FrameType), m_u2NumberOfLocals(0), m_u2NumberOfStackItems(0)
3030
{
3031
}
3032
3033
CStackMapFullFrameInfo::~CStackMapFullFrameInfo()
3034
{
3035
}
3036
3037
void
3038
CStackMapFullFrameInfo::Read(CJStream& i_jstream)
3039
{
3040
    CStackMapFrameInfo::Read(i_jstream);
3041
    i_jstream >> m_u2OffsetDelta
3042
              >> m_u2NumberOfLocals;
3043
    m_Locals.Read(i_jstream, m_u2NumberOfLocals);
3044
    i_jstream >> m_u2NumberOfStackItems;
3045
    m_Stack.Read(i_jstream, m_u2NumberOfStackItems);
3046
}
3047
3048
void
3049
CStackMapFullFrameInfo::Write(CJStream& i_jstream) const
3050
{
3051
    CStackMapFrameInfo::Write(i_jstream);
3052
    i_jstream << m_u2OffsetDelta
3053
              << m_u2NumberOfLocals;
3054
    m_Locals.Write(i_jstream);
3055
    i_jstream << m_u2NumberOfStackItems;
3056
    m_Stack.Write(i_jstream);
3057
}
3058
3059
u4
3060
CStackMapFullFrameInfo::GetSize() const
3061
{
3062
    u4 u4Size = CStackMapFrameInfo::GetSize()
3063
        + sizeof(m_u2OffsetDelta)
3064
        + sizeof(m_u2NumberOfLocals)
3065
        + m_Locals.GetSize()
3066
        + sizeof(m_u2NumberOfStackItems)
3067
        + m_Stack.GetSize();
3068
    return u4Size;
3069
}
3070
3071
CStackMapFrameInfo*
3072
CStackMapFullFrameInfo::Clone() const
3073
{
3074
    return new CStackMapFullFrameInfo(*this);
3075
}
3076
3077
CStackMapFullFrameInfo::CStackMapFullFrameInfo(const CStackMapFullFrameInfo &i_Other)
3078
: CStackMapFrameInfo(i_Other), m_Locals(i_Other.m_Locals), m_Stack(i_Other.m_Stack),
3079
    m_u2NumberOfLocals(i_Other.m_u2NumberOfLocals), 
3080
    m_u2NumberOfStackItems(i_Other.m_u2NumberOfStackItems)
3081
{
3082
}
3083
3084
//------------------------------------------------------------------------------
3085
CStackMapTable::~CStackMapTable()
3086
{
3087
    for (iterator iter = begin(); iter != end(); iter++)
3088
    {
3089
        delete *iter;
3090
    }
3091
}
3092
3093
void
3094
CStackMapTable::Read(CJStream& i_jstream)
3095
{
3096
    u2 u2Size;
3097
    CStackMapFrameInfo* pCurrent;
3098
    int s2PrevFrameOffset = -1;
3099
3100
    i_jstream >> u2Size;
3101
    resize(u2Size);
3102
    for(u2 u2Ind = 0; u2Ind < u2Size; u2Ind++)
3103
    {
3104
        u1 u1FrameType;
3105
        i_jstream >> u1FrameType;
3106
        if (u1FrameType >= 0 && u1FrameType <= 63)
3107
        {
3108
            pCurrent = new CStackMapSameFrameInfo(u1FrameType, false);
3109
        }
3110
        else if (u1FrameType >= 64 && u1FrameType <= 127)
3111
        {
3112
            pCurrent = new CStackMapSameLocals1StackItemFrameInfo(u1FrameType, false);
3113
        }
3114
        else if (u1FrameType == SAME_LOCALS_1_STACK_ITEM_EXTENDED)
3115
        {
3116
            pCurrent = new CStackMapSameLocals1StackItemFrameInfo(u1FrameType, true);
3117
        }
3118
        else if (u1FrameType >= 248 && u1FrameType <= 250)
3119
        {
3120
            pCurrent = new CStackMapChopFrameInfo(u1FrameType);
3121
        }
3122
        else if (u1FrameType == SAME_FRAME_EXTENDED)
3123
        {
3124
            pCurrent = new CStackMapSameFrameInfo(u1FrameType, true);
3125
        }
3126
        else if (u1FrameType >= 252 && u1FrameType <= 254)
3127
        {
3128
            pCurrent = new CStackMapAppendFrameInfo(u1FrameType);
3129
        }
3130
        else if (u1FrameType == FULL_FRAME)
3131
        {
3132
            pCurrent = new CStackMapFullFrameInfo(u1FrameType);
3133
        }
3134
        else
3135
        {
3136
            // Unknown frame type
3137
            throw CJClassFileException(CJClassFileException::X_INTERNAL_ERROR);
3138
        }
3139
        
3140
        pCurrent->Read(i_jstream);
3141
        pCurrent->SetByteCodeOffset(s2PrevFrameOffset + 1 + pCurrent->m_u2OffsetDelta);
3142
        (*this)[u2Ind] = pCurrent;
3143
        s2PrevFrameOffset = pCurrent->GetByteCodeOffset();
3144
    }
3145
}
3146
3147
void
3148
CStackMapTable::AdjustOffsetDeltas()
3149
{
3150
    // Recalculate offset deltas for all frames. This function must be called before
3151
    // writing the Stack Map Table to the class file or calculating its size
3152
    CStackMapFrameInfo* pCurrent;
3153
    int s2PrevFrameOffset = -1;
3154
3155
    for (u2 u2Ind = 0; u2Ind < size(); u2Ind++)
3156
    {
3157
        pCurrent = (*this)[u2Ind];
3158
        pCurrent->AdjustOffsetDelta(s2PrevFrameOffset);
3159
        s2PrevFrameOffset = pCurrent->GetByteCodeOffset();
3160
    }
3161
}
3162
3163
CStackMapFrameInfo*
3164
CStackMapTable::GetFrameAtOffset(u2 i_u2Offset)
3165
{
3166
    bool found = false;
3167
    iterator it = begin();
3168
    for (; it != end(); ++it)
3169
    {
3170
        if ((*it)->GetByteCodeOffset() == i_u2Offset)
3171
        {
3172
            found = true;
3173
            break;
3174
        }
3175
    }
3176
3177
    if (found)
3178
    {
3179
        return (*it);
3180
    }
3181
    else
3182
    {
3183
        return NULL;
3184
    }
3185
}
3186
3187
void
3188
CStackMapTable::Write(CJStream& i_jstream) const
3189
{
3190
    i_jstream << (u2)size(); // the number_of_entries field
3191
3192
    CStackMapFrameInfo* pCurrent;
3193
    int s2PrevFrameOffset = -1;
3194
3195
    for (u2 u2Ind = 0; u2Ind < size(); u2Ind++)
3196
    {
3197
        pCurrent = (*this)[u2Ind];
3198
        pCurrent->Write(i_jstream);
3199
        s2PrevFrameOffset = pCurrent->GetByteCodeOffset();
3200
    }
3201
}
3202
3203
u4
3204
CStackMapTable::GetSize() const
3205
{
3206
    u4 u4Size = sizeof(u2); // the number_of_entries field
3207
    for (const_iterator iter = begin(); iter != end(); iter++)
3208
    {
3209
        u4Size += (*iter)->GetSize();
3210
    }
3211
    return u4Size;
3212
}
3213
3214
CStackMapTable& 
3215
CStackMapTable::operator = (const CStackMapTable& i_StackMaps)
3216
{
3217
	for(iterator iter = begin(); iter != end(); iter++)
3218
	{
3219
		delete *iter;
3220
	}
3221
	if(!i_StackMaps.empty())
3222
	{
3223
		const_iterator iterIn;
3224
		clear();
3225
		for(iterIn = i_StackMaps.begin(); iterIn != i_StackMaps.end(); iterIn++)
3226
		{
3227
			push_back((*iterIn)->Clone());
3228
		}
3229
	}
3230
	return *this;
3231
}
3232
3233
//------------------------------------------------------------------------------
3234
CStackMapTableAttribute::CStackMapTableAttribute(CJClassFile* i_pClassFile)
3235
: CAttributeInfo(i_pClassFile)
3236
{
3237
    u2 u2NameInd = i_pClassFile->GetConstPool()->Add(new CCPUtf8Info("StackMapTable"));
3238
    m_u2NameInd = u2NameInd;
3239
    m_StackMapTable.clear();
3240
}
3241
3242
CStackMapTableAttribute::~CStackMapTableAttribute()
3243
{
3244
}
3245
3246
void
3247
CStackMapTableAttribute::Read(CJStream& i_jstream)
3248
{
3249
	CAttributeInfo::Read(i_jstream);
3250
    m_StackMapTable.Read(i_jstream);
3251
}
3252
3253
void
3254
CStackMapTableAttribute::Write(CJStream& i_jstream) const
3255
{
3256
	const u4 u4Length = GetLength() - CAttributeInfo::SizeOf();
3257
	i_jstream	<<	m_u2NameInd
3258
				<<	u4Length;
3259
    m_StackMapTable.Write(i_jstream);
3260
}
3261
3262
u4
3263
CStackMapTableAttribute::GetSize() const
3264
{
3265
    return GetLength();
3266
}
3267
3268
u4
3269
CStackMapTableAttribute::GetLength() const
3270
{
3271
    u4 u4Length = CAttributeInfo::SizeOf()
3272
        + m_StackMapTable.GetSize();
3273
    return u4Length;
3274
}
3275
3276
void
3277
CStackMapTableAttribute::RereadFromBuffer(u1 *i_u1Tbl) 
3278
{
3279
	u2 u2skip = 0;
3280
	u4 u4attributeLenght = 0;
3281
	
3282
	if (i_u1Tbl == NULL) return;
3283
3284
	u2skip = i_u1Tbl[0];
3285
	u2skip <<= 8;
3286
	u2skip |= i_u1Tbl[1];
3287
3288
	u4attributeLenght = i_u1Tbl[2];
3289
	u4attributeLenght <<= 8;
3290
	u4attributeLenght |= i_u1Tbl[3];
3291
	u4attributeLenght <<= 8;
3292
	u4attributeLenght |= i_u1Tbl[4];
3293
	u4attributeLenght <<= 8;
3294
	u4attributeLenght |= i_u1Tbl[5];
3295
	m_u4Length = u4attributeLenght;
3296
	CJMemStream memstream;
3297
	memstream.Open(&i_u1Tbl[2], u4attributeLenght 
3298
		+ sizeof(u2) /*part of attribute header (its length)*/
3299
		+ 2 /*workaround for end buffer checking*/);
3300
	CJStream mem_jstream(&memstream);
3301
	//GetStackMapTable().RereadFromBuffer(&i_u1Tbl[6]);
3302
	this->Read(mem_jstream);
3303
}
3304
//==============================================================================
2503
// CJClassFile implementation
3305
// CJClassFile implementation
2504
//
3306
//
2505
3307
Lines 2544-2555 CJClassFile::Read(CJStream& i_jstream) Link Here
2544
	{
3346
	{
2545
		throw CJClassFileException(CJClassFileException::X_BAD_MAGIC);
3347
		throw CJClassFileException(CJClassFileException::X_BAD_MAGIC);
2546
	}
3348
	}
2547
	i_jstream	>>	m_u2MajorVersion;
2548
	if(CJClassFile::MajorVersion < m_u2MajorVersion)
2549
	{
2550
		throw CJClassFileException(CJClassFileException::X_BAD_VERSION);
2551
	}
2552
	i_jstream	>>	m_u2MinorVersion;
3349
	i_jstream	>>	m_u2MinorVersion;
3350
	i_jstream	>>	m_u2MajorVersion;
2553
	m_pConstPool->Read(i_jstream);
3351
	m_pConstPool->Read(i_jstream);
2554
	i_jstream	>>	m_u2AccessFlags
3352
	i_jstream	>>	m_u2AccessFlags
2555
				>>	m_u2ThisClass
3353
				>>	m_u2ThisClass
Lines 2565-2572 void Link Here
2565
CJClassFile::Write(CJStream& i_jstream) const
3363
CJClassFile::Write(CJStream& i_jstream) const
2566
{
3364
{
2567
	i_jstream	<<	m_u4Magic
3365
	i_jstream	<<	m_u4Magic
2568
				<<	m_u2MajorVersion
3366
				<<	m_u2MinorVersion
2569
				<<	m_u2MinorVersion;
3367
				<<	m_u2MajorVersion;
2570
	m_pConstPool->Write(i_jstream);
3368
	m_pConstPool->Write(i_jstream);
2571
	i_jstream	<<	m_u2AccessFlags
3369
	i_jstream	<<	m_u2AccessFlags
2572
				<<	m_u2ThisClass
3370
				<<	m_u2ThisClass
(-)src-native/BCI/JClass/JClassFile.h (-2 / +291 lines)
Lines 82-87 class CExceptionsAttribute; Link Here
82
class CLineNumberTableAttribute;
82
class CLineNumberTableAttribute;
83
class CLocalVariableTableAttribute;
83
class CLocalVariableTableAttribute;
84
class CLocalVariableTypeTableAttribute;
84
class CLocalVariableTypeTableAttribute;
85
class CStackMapTableAttribute;
85
86
86
//------------------------------------------------------------------------------
87
//------------------------------------------------------------------------------
87
// Container classes
88
// Container classes
Lines 182-189 public: Link Here
182
	const CCPUtf8Info& operator = (const CCPUtf8Info& i_utf8)
183
	const CCPUtf8Info& operator = (const CCPUtf8Info& i_utf8)
183
	{
184
	{
184
		m_u2Length = i_utf8.GetLength();
185
		m_u2Length = i_utf8.GetLength();
185
		m_pu1Bytes = new u1[m_u2Length];
186
		m_pu1Bytes = new u1[m_u2Length + 1];
186
		memcpy(m_pu1Bytes, i_utf8.GetBytes(), m_u2Length);
187
		memcpy(m_pu1Bytes, i_utf8.GetBytes(), m_u2Length);
188
		m_pu1Bytes[m_u2Length] = '\0';
187
		return *this;
189
		return *this;
188
	}
190
	}
189
	operator string ()
191
	operator string ()
Lines 672-677 public: Link Here
672
	CLineNumberTableAttribute* GetLineNumbers();
674
	CLineNumberTableAttribute* GetLineNumbers();
673
	CLocalVariableTableAttribute* GetLocalVariables();
675
	CLocalVariableTableAttribute* GetLocalVariables();
674
	CLocalVariableTypeTableAttribute* GetLocalVariableTypes();
676
	CLocalVariableTypeTableAttribute* GetLocalVariableTypes();
677
    CStackMapTableAttribute* GetStackMaps();
678
    CStackMapTableAttribute* GetOrCreateStackMaps();
679
675
680
676
protected:
681
protected:
677
	u2			m_u2MaxStack;
682
	u2			m_u2MaxStack;
Lines 899-904 private: Link Here
899
};
904
};
900
905
901
//------------------------------------------------------------------------------
906
//------------------------------------------------------------------------------
907
// Verification Type Information (new in Java 6)
908
//
909
// Represents the following verification types: Top, Integer, Float, Double, Long, Null,
910
// UninitializedThis
911
//
912
class CVerificationTypeInfo
913
{
914
public:
915
    CVerificationTypeInfo(u1 i_u1Tag);
916
    ~CVerificationTypeInfo();
917
    virtual void Read(CJStream& i_jstream);
918
	virtual u2 Read(u1* i_tbl);
919
	virtual void Write(CJStream& i_jstream) const;
920
	virtual u4	 GetSize() const;
921
    virtual CVerificationTypeInfo* Clone() const
922
    {
923
        return new CVerificationTypeInfo(*this);
924
    }
925
926
    u1 GetTag() { return m_u1Tag; }
927
928
private:
929
    u1 m_u1Tag;
930
};
931
932
//------------------------------------------------------------------------------
933
// Verification Type Information Vector
934
//
935
class CVerificationTypes : public vector<CVerificationTypeInfo*>
936
{
937
public:
938
    CVerificationTypes() { clear(); }
939
    CVerificationTypes(const CVerificationTypes &i_VerTypes);
940
	~CVerificationTypes();
941
942
    CVerificationTypes& operator = (const CVerificationTypes &i_VerTypes);
943
    
944
    virtual void	Read(CJStream& i_jstream, u2 i_u2EntriesToRead);
945
	virtual void	Write(CJStream& i_jstream) const;
946
	virtual u4	    GetSize() const;
947
948
private:
949
};
950
951
//------------------------------------------------------------------------------
952
// Verification Type Information: Object (new in Java 6)
953
//
954
class CVerificationTypeObjectInfo : public CVerificationTypeInfo
955
{
956
public:
957
    CVerificationTypeObjectInfo(u1 i_u1Tag);
958
    ~CVerificationTypeObjectInfo();
959
    virtual void Read(CJStream& i_jstream);
960
	virtual void Write(CJStream& i_jstream) const;
961
	virtual u4	 GetSize() const;
962
    virtual CVerificationTypeInfo* Clone() const
963
    {
964
        return new CVerificationTypeObjectInfo(*this);
965
    }
966
967
    u2   GetCpoolIndex() { return m_u2CpoolIndex; }
968
    void SetCpoolIndex(u2 i_u2CpoolIndex) { m_u2CpoolIndex = i_u2CpoolIndex; }
969
970
private:
971
    u2 m_u2CpoolIndex;
972
};
973
974
//------------------------------------------------------------------------------
975
// Verification Type Information: Uninitialized Variable (new in Java 6)
976
//
977
class CVerificationTypeUninitializedVariableInfo : public CVerificationTypeInfo
978
{
979
public:
980
    CVerificationTypeUninitializedVariableInfo(u1 i_u1Tag);
981
    ~CVerificationTypeUninitializedVariableInfo();
982
    virtual void Read(CJStream& i_jstream);
983
	virtual void Write(CJStream& i_jstream) const;
984
	virtual u4	 GetSize() const;
985
    virtual CVerificationTypeInfo* Clone() const
986
    {
987
        return new CVerificationTypeUninitializedVariableInfo(*this);
988
    }
989
990
    u2   GetOffset() { return m_u2Offset; }
991
    void SetOffset(u2 i_u2Offset) { m_u2Offset = i_u2Offset; }
992
993
private:
994
    u2 m_u2Offset;
995
};
996
997
998
//------------------------------------------------------------------------------
999
// Stack Map Frame Information (new in Java 6)
1000
//
1001
class CStackMapFrameInfo
1002
{
1003
    friend class CStackMapTable;
1004
public:
1005
    CStackMapFrameInfo(u1 i_u1FrameType);
1006
    CStackMapFrameInfo(const CStackMapFrameInfo &i_Other);
1007
    ~CStackMapFrameInfo();
1008
1009
    virtual void Read(CJStream& i_jstream);
1010
	virtual void Write(CJStream& i_jstream) const;
1011
	virtual u4	 GetSize() const;
1012
    virtual CStackMapFrameInfo* Clone() const = 0;
1013
    
1014
    u1 GetFrameType() const { return m_u1FrameType; }
1015
    u2 GetByteCodeOffset() { return m_u2ByteCodeOffset; }
1016
    void SetByteCodeOffset(u2 i_u2Offset);
1017
1018
protected:
1019
    virtual void AdjustOffsetDelta(int i_s2PrevFrameOffset);
1020
    
1021
    u2 m_u2ByteCodeOffset;
1022
    u2 m_u2OffsetDelta;
1023
    u1 m_u1FrameType;
1024
};
1025
1026
//------------------------------------------------------------------------------
1027
// Stack Map Frame Information: same_frame and same_frame_extended (new in Java 6)
1028
//
1029
class CStackMapSameFrameInfo : public CStackMapFrameInfo
1030
{
1031
    friend class CStackMapTable;
1032
public:
1033
    CStackMapSameFrameInfo(u1 i_u1FrameType, bool i_IsExtended);
1034
    ~CStackMapSameFrameInfo();
1035
1036
    virtual void Read(CJStream& i_jstream);
1037
	virtual void Write(CJStream& i_jstream) const;
1038
	virtual u4	 GetSize() const;
1039
    virtual CStackMapFrameInfo* Clone() const;
1040
1041
protected:
1042
    virtual void AdjustOffsetDelta(int i_s2PrevFrameOffset);
1043
1044
private:
1045
    bool m_IsExtended;
1046
};
1047
1048
//------------------------------------------------------------------------------
1049
// Stack Map Frame Information: chop_frame (new in Java 6)
1050
//
1051
class CStackMapChopFrameInfo : public CStackMapFrameInfo
1052
{
1053
public:
1054
    CStackMapChopFrameInfo(u1 i_u1FrameType);
1055
    ~CStackMapChopFrameInfo();
1056
1057
    virtual void Read(CJStream& i_jstream);
1058
	virtual void Write(CJStream& i_jstream) const;
1059
	virtual u4	 GetSize() const;
1060
    virtual CStackMapFrameInfo* Clone() const;
1061
1062
private:
1063
};
1064
1065
//------------------------------------------------------------------------------
1066
// Stack Map Frame Information: same_locals_1_stack_item_frame and 
1067
//                              same_locals_1_stack_item_frame_extended (new in Java 6)
1068
//
1069
class CStackMapSameLocals1StackItemFrameInfo : public CStackMapFrameInfo
1070
{
1071
    friend class CStackMapTable;
1072
public:
1073
    CStackMapSameLocals1StackItemFrameInfo(u1 i_u1FrameType, bool i_IsExtended);
1074
    CStackMapSameLocals1StackItemFrameInfo(const CStackMapSameLocals1StackItemFrameInfo &i_Other);
1075
    ~CStackMapSameLocals1StackItemFrameInfo();
1076
1077
    virtual void Read(CJStream& i_jstream);
1078
	virtual void Write(CJStream& i_jstream) const;
1079
	virtual u4	 GetSize() const;
1080
    virtual CStackMapFrameInfo* Clone() const;
1081
1082
    CVerificationTypes& GetStack() { return m_Stack; }
1083
1084
protected:
1085
    virtual void AdjustOffsetDelta(int i_s2PrevFrameOffset);
1086
1087
private:
1088
    CStackMapSameLocals1StackItemFrameInfo& operator = (CStackMapSameLocals1StackItemFrameInfo &i_Other);
1089
1090
    CVerificationTypes m_Stack;     // A vector with 1 entry
1091
    bool m_IsExtended;
1092
};
1093
1094
//------------------------------------------------------------------------------
1095
// Stack Map Frame Information: append_frame (new in Java 6)
1096
//
1097
class CStackMapAppendFrameInfo : public CStackMapFrameInfo
1098
{
1099
public:
1100
    CStackMapAppendFrameInfo(u1 i_u1FrameType);
1101
    CStackMapAppendFrameInfo(const CStackMapAppendFrameInfo &i_Other);
1102
    ~CStackMapAppendFrameInfo();
1103
1104
    virtual void Read(CJStream& i_jstream);
1105
	virtual void Write(CJStream& i_jstream) const;
1106
	virtual u4	 GetSize() const;
1107
    virtual CStackMapFrameInfo* Clone() const;
1108
1109
    CVerificationTypes& GetLocals() { return m_Locals; }
1110
1111
private:
1112
    CStackMapAppendFrameInfo& operator = (const CStackMapAppendFrameInfo &i_Other);
1113
1114
    CVerificationTypes m_Locals;
1115
};
1116
1117
//------------------------------------------------------------------------------
1118
// Stack Map Frame Information: full_frame (new in Java 6)
1119
//
1120
class CStackMapFullFrameInfo : public CStackMapFrameInfo
1121
{
1122
public:
1123
    CStackMapFullFrameInfo(u1 i_u1FrameType);
1124
    CStackMapFullFrameInfo(const CStackMapFullFrameInfo &i_Other);
1125
    ~CStackMapFullFrameInfo();
1126
1127
    virtual void Read(CJStream& i_jstream);
1128
	virtual void Write(CJStream& i_jstream) const;
1129
	virtual u4	 GetSize() const;
1130
    virtual CStackMapFrameInfo* Clone() const;
1131
1132
    CVerificationTypes& GetLocals() { return m_Locals; }
1133
    CVerificationTypes& GetStack()  { return m_Stack;  }
1134
    
1135
private:
1136
    CStackMapFullFrameInfo& operator = (const CStackMapFullFrameInfo &i_Other);
1137
1138
    u2 m_u2NumberOfLocals;
1139
    CVerificationTypes m_Locals;
1140
    u2 m_u2NumberOfStackItems;
1141
    CVerificationTypes m_Stack;
1142
};
1143
1144
1145
//------------------------------------------------------------------------------
1146
// Stack Map Table (new in Java 6)
1147
//
1148
class CStackMapTable : public vector<CStackMapFrameInfo*>
1149
{
1150
public:
1151
    CStackMapTable() { clear(); }
1152
	~CStackMapTable();
1153
	virtual void	Read(CJStream& i_jstream);
1154
	virtual void	Write(CJStream& i_jstream) const;
1155
	virtual u4	    GetSize() const;
1156
1157
    void                AdjustOffsetDeltas();
1158
    CStackMapFrameInfo* GetFrameAtOffset(u2 i_u2Offset);
1159
	
1160
    CStackMapTable& operator = (const CStackMapTable& i_StackMaps);
1161
};
1162
1163
//------------------------------------------------------------------------------
1164
// Stack Map Table Attribute (new in Java 6 - [4.8.4])
1165
//
1166
class CStackMapTableAttribute : public CAttributeInfo
1167
{
1168
	friend class CStackMapTable;
1169
public:
1170
    CStackMapTableAttribute(CJClassFile* i_pClassFile);
1171
    ~CStackMapTableAttribute();
1172
	virtual void	Read(CJStream& i_jstream);
1173
	virtual void	Write(CJStream& i_jstream) const;
1174
	virtual u4	    GetSize() const;
1175
	virtual u4		GetLength() const;
1176
1177
    CStackMapTable& GetStackMapTable() { return m_StackMapTable; }
1178
	void SetStackMapTable(const CStackMapTable& i_stackmap) {m_StackMapTable = i_stackmap;}
1179
	void RereadFromBuffer(u1 *i_u1Tbl);
1180
1181
private:
1182
    CStackMapTable m_StackMapTable;
1183
1184
    // Disable assignment operator.
1185
    // To enable, implement these functions as public
1186
    CStackMapTableAttribute& operator = (const CStackMapTableAttribute& i_other) {}
1187
};
1188
1189
//------------------------------------------------------------------------------
902
// Interface information
1190
// Interface information
903
//
1191
//
904
class CInterfaceInfo
1192
class CInterfaceInfo
Lines 999-1004 public: Link Here
999
	virtual u4	 GetSize() const;
1287
	virtual u4	 GetSize() const;
1000
1288
1001
	u2			GetAccessFlags() {return m_u2AccessFlags;}
1289
	u2			GetAccessFlags() {return m_u2AccessFlags;}
1290
    void        SetAccessFlags(u2 i_u2AccessFlags) {m_u2AccessFlags = i_u2AccessFlags;}
1002
	u2			GetNameInd() const {return m_u2NameInd;}
1291
	u2			GetNameInd() const {return m_u2NameInd;}
1003
	u2			GetDescriptorInd() const {return m_u2DescriptorInd;}
1292
	u2			GetDescriptorInd() const {return m_u2DescriptorInd;}
1004
	CJAttribs&	GetAttribs()	{return m_Attribs;}
1293
	CJAttribs&	GetAttribs()	{return m_Attribs;}
Lines 1070-1076 public: Link Here
1070
class CJClassFile  
1359
class CJClassFile  
1071
{
1360
{
1072
public:
1361
public:
1073
	enum {MajorVersion = 3, MinorVersion = 46};	// TODO: comment on version 
1362
	enum {MajorVersion = 46, MinorVersion = 3};	// J2SE 1.2
1074
	CJClassFile();
1363
	CJClassFile();
1075
	virtual ~CJClassFile();
1364
	virtual ~CJClassFile();
1076
1365

Return to bug 148629