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/BCIEng.dsp (-1 / +3 lines)
Lines 23-28 CFG=BCIEng - Win32 Debug Link Here
23
23
24
# Begin Project
24
# Begin Project
25
# PROP AllowPerConfigDependencies 0
25
# PROP AllowPerConfigDependencies 0
26
# PROP Scc_ProjName ""
27
# PROP Scc_LocalPath ""
26
CPP=cl.exe
28
CPP=cl.exe
27
RSC=rc.exe
29
RSC=rc.exe
28
30
Lines 62-68 LIB32=link.exe -lib Link Here
62
# PROP Intermediate_Dir "Debug"
64
# PROP Intermediate_Dir "Debug"
63
# PROP Target_Dir ""
65
# PROP Target_Dir ""
64
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
66
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
65
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Common" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
67
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Common" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /GZ /c
66
# ADD BASE RSC /l 0x409 /d "_DEBUG"
68
# ADD BASE RSC /l 0x409 /d "_DEBUG"
67
# ADD RSC /l 0x409 /d "_DEBUG"
69
# ADD RSC /l 0x409 /d "_DEBUG"
68
BSC32=bscmake.exe
70
BSC32=bscmake.exe
(-)src-native/BCI/BCIEng/BCIEng.dsw (-8 / +8 lines)
Lines 3-9 Microsoft Developer Studio Workspace Fil Link Here
3
3
4
###############################################################################
4
###############################################################################
5
5
6
Project: "BCIEng"=.\BCIEng.dsp - Package Owner=<4>
6
Project: "BCIEng"=".\BCIEng.dsp" - Package Owner=<4>
7
7
8
Package=<5>
8
Package=<5>
9
{{{
9
{{{
Lines 15-21 Package=<4> Link Here
15
15
16
###############################################################################
16
###############################################################################
17
17
18
Project: "BCIEngJ"=.\BCIEngJ\BCIEngJ.dsp - Package Owner=<4>
18
Project: "BCIEngJ"=".\BCIEngJ\BCIEngJ.dsp" - Package Owner=<4>
19
19
20
Package=<5>
20
Package=<5>
21
{{{
21
{{{
Lines 30-36 Package=<4> Link Here
30
30
31
###############################################################################
31
###############################################################################
32
32
33
Project: "BCIEngProbe"=.\BCIEngProbe\BCIEngProbe.dsp - Package Owner=<4>
33
Project: "BCIEngProbe"=".\BCIEngProbe\BCIEngProbe.dsp" - Package Owner=<4>
34
34
35
Package=<5>
35
Package=<5>
36
{{{
36
{{{
Lines 48-54 Package=<4> Link Here
48
48
49
###############################################################################
49
###############################################################################
50
50
51
Project: "BciEngJTest"=.\BCIEngJ\BciEngJTest\BciEngJTest.dsp - Package Owner=<4>
51
Project: "BciEngJTest"=".\BCIEngJ\BciEngJTest\BciEngJTest.dsp" - Package Owner=<4>
52
52
53
Package=<5>
53
Package=<5>
54
{{{
54
{{{
Lines 60-66 Package=<4> Link Here
60
60
61
###############################################################################
61
###############################################################################
62
62
63
Project: "JClassStat"=..\JClass\JClassStat.dsp - Package Owner=<4>
63
Project: "JClassStat"="..\JClass\JClassStat.dsp" - Package Owner=<4>
64
64
65
Package=<5>
65
Package=<5>
66
{{{
66
{{{
Lines 72-78 Package=<4> Link Here
72
72
73
###############################################################################
73
###############################################################################
74
74
75
Project: "JDump"=..\JDump\JDump.dsp - Package Owner=<4>
75
Project: "JDump"="..\JDump\JDump.dsp" - Package Owner=<4>
76
76
77
Package=<5>
77
Package=<5>
78
{{{
78
{{{
Lines 90-96 Package=<4> Link Here
90
90
91
###############################################################################
91
###############################################################################
92
92
93
Project: "ProbeInstrumenter"=.\BCIEngProbe\ProbeInstrumenter\ProbeInstrumenter.dsp - Package Owner=<4>
93
Project: "ProbeInstrumenter"=".\BCIEngProbe\ProbeInstrumenter\ProbeInstrumenter.dsp" - Package Owner=<4>
94
94
95
Package=<5>
95
Package=<5>
96
{{{
96
{{{
Lines 105-111 Package=<4> Link Here
105
105
106
###############################################################################
106
###############################################################################
107
107
108
Project: "ProbeUnitTests"=.\ProbeUnitTests\ProbeUnitTests.dsp - Package Owner=<4>
108
Project: "ProbeUnitTests"=".\ProbeUnitTests\ProbeUnitTests.dsp" - Package Owner=<4>
109
109
110
Package=<5>
110
Package=<5>
111
{{{
111
{{{
(-)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 / +1 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;}
(-)src-native/BCI/BCIEng/BCIEngJ/BCIEngJ.dsp (-2 / +15 lines)
Lines 41-47 RSC=rc.exe Link Here
41
# PROP Intermediate_Dir "Release"
41
# PROP Intermediate_Dir "Release"
42
# PROP Target_Dir ""
42
# PROP Target_Dir ""
43
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
43
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
44
# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /I "..\\" /I "..\..\jclass" /I "..\..\..\sun" /I "..\..\common" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
44
# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /I "..\..\common" /I "${JAVA_HOME}\include" /I "${JAVA_HOME}\include\win32" /I "${HARMONY_VERIFIER}\open\include" /I "${HARMONY_VERIFIER}\verifier-3363\x_verifier" /I "%HARMONY_VERIFIER%\include" /I "..\..\Common" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "..\\" /I "..\..\jclass" /I "..\..\..\sun" /I "..\..\..\..\..\org.apache.harmony_vmcore_verifier\src\vmcore\src\verifier-3363" /I "..\..\..\..\..\org.apache.harmony_vmcore_verifier\src\include" /I "..\..\..\..\..\org.apache.harmony_vmcore_verifier\src\vmcore\include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /YX /FD /c
45
# ADD BASE RSC /l 0x409 /d "NDEBUG"
45
# ADD BASE RSC /l 0x409 /d "NDEBUG"
46
# ADD RSC /l 0x409 /d "NDEBUG"
46
# ADD RSC /l 0x409 /d "NDEBUG"
47
BSC32=bscmake.exe
47
BSC32=bscmake.exe
Lines 64-70 LIB32=link.exe -lib Link Here
64
# PROP Intermediate_Dir "Debug"
64
# PROP Intermediate_Dir "Debug"
65
# PROP Target_Dir ""
65
# PROP Target_Dir ""
66
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
66
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
67
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Common" /I "..\\" /I "..\..\jclass" /I "..\..\..\sun" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /GZ /c
67
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Common" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "..\\" /I "..\..\jclass" /I "..\..\..\sun" /I "..\..\..\..\..\org.apache.harmony_vmcore_verifier\src\vmcore\src\verifier-3363" /I "..\..\..\..\..\org.apache.harmony_vmcore_verifier\src\include" /I "..\..\..\..\..\org.apache.harmony_vmcore_verifier\src\vmcore\include" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /FR /FD /GZ /c
68
# SUBTRACT CPP /YX
68
# ADD BASE RSC /l 0x409 /d "_DEBUG"
69
# ADD BASE RSC /l 0x409 /d "_DEBUG"
69
# ADD RSC /l 0x409 /d "_DEBUG"
70
# ADD RSC /l 0x409 /d "_DEBUG"
70
BSC32=bscmake.exe
71
BSC32=bscmake.exe
Lines 85-90 LIB32=link.exe -lib Link Here
85
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
86
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
86
# Begin Source File
87
# Begin Source File
87
88
89
SOURCE=.\class_interface.cpp
90
# End Source File
91
# Begin Source File
92
88
SOURCE=.\ExtRefJ_Interface.cpp
93
SOURCE=.\ExtRefJ_Interface.cpp
89
# End Source File
94
# End Source File
90
# Begin Source File
95
# Begin Source File
Lines 105-110 SOURCE=.\ModuleJ.cpp Link Here
105
# PROP Default_Filter "h;hpp;hxx;hm;inl"
110
# PROP Default_Filter "h;hpp;hxx;hm;inl"
106
# Begin Source File
111
# Begin Source File
107
112
113
SOURCE=.\class_inerface_int.h
114
# End Source File
115
# Begin Source File
116
117
SOURCE=.\class_interface_x.h
118
# End Source File
119
# Begin Source File
120
108
SOURCE=.\ExtRefJ_Interface.h
121
SOURCE=.\ExtRefJ_Interface.h
109
# End Source File
122
# End Source File
110
# Begin Source File
123
# Begin Source File
(-)src-native/BCI/BCIEng/BCIEngJ/ModuleJ.cpp (-6 / +98 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
		free(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
			if (status != VF_OK) {
273
				fprintf(stderr, "class was skiped: %s\n", m_strName.c_str());
274
				return (1); /*skip*/
275
			}
276
			fprintf(stderr, "class was instrumented: %s\n", m_strName.c_str());
277
			((CMethodJ *)(*iterm))->SetMethodHandler(m_methodContexts[ind]);
278
		}
235
	}
279
	}
280
	return (0);
236
}
281
}
237
282
238
//------------------------------------------------------------------------------
283
//------------------------------------------------------------------------------
Lines 385-392 CMethodJ::Emit() Link Here
385
	m_pMtdExTable->Emit();
430
	m_pMtdExTable->Emit();
386
431
387
	//-------
432
	//-------
388
	// Loop over instructions and patch the local variable info table
433
	// Loop over instructions and patch the local variable info table, 
434
    // local variable type table (Java 5.0) and stack map table (Java 6.0)
389
	//
435
	//
436
	
437
	
390
438
391
	// Local variable table LVT
439
	// Local variable table LVT
392
	CLocalVariableTableAttribute* pLclAttr = m_pCodeAttr->GetLocalVariables();
440
	CLocalVariableTableAttribute* pLclAttr = m_pCodeAttr->GetLocalVariables();
Lines 403-408 CMethodJ::Emit() Link Here
403
	CLocalVariableTypeTable  LclTypeTableSav;
451
	CLocalVariableTypeTable  LclTypeTableSav;
404
	CLocalVariableTypeTable::iterator itrLclType, itrLclTypeSav; // LVTT Iterator
452
	CLocalVariableTypeTable::iterator itrLclType, itrLclTypeSav; // LVTT Iterator
405
453
454
    // The smtNull variable is for reference initialization in case the method does not have
455
    // a Stack Map Table attribute
456
    CStackMapTable smtNull;
457
    CStackMapTableAttribute* pSmtAttr = m_pCodeAttr->GetStackMaps();
458
    CStackMapTable& StackMapTable = pSmtAttr?pSmtAttr->GetStackMapTable():smtNull;
459
    CStackMapTable::iterator itrStackMapFrame = StackMapTable.begin();
460
406
	CInsBlocks::iterator iterBlocks;
461
	CInsBlocks::iterator iterBlocks;
407
	IP_t ip = 0;
462
	IP_t ip = 0;
408
463
Lines 458-463 CMethodJ::Emit() Link Here
458
					}
513
					}
459
				}
514
				}
460
			}
515
			}
516
			
517
            // Scan for a relevant entry in the Stack Map Table and fix it
518
            while (itrStackMapFrame != StackMapTable.end()
519
                && (*itrStackMapFrame)->GetByteCodeOffset() < ipOrig)
520
            {
521
                ++itrStackMapFrame;
522
            }
523
            if (itrStackMapFrame != StackMapTable.end()
524
                && (*itrStackMapFrame)->GetByteCodeOffset() == ipOrig)
525
            {
526
                (*itrStackMapFrame)->SetByteCodeOffset(ip);
527
            }
461
528
462
			// Advance ip
529
			// Advance ip
463
			ip += (*iterIns)->GetSize(ip);
530
			ip += (*iterIns)->GetSize(ip);
Lines 503-513 CMethodJ::Emit() Link Here
503
			}
570
			}
504
		}
571
		}
505
	}
572
	}
573
	// Replace the method body
574
	m_pCodeAttr->SetCode(m_pBody->GetCodeSize(), m_pBody->GiveAvayCode());
506
575
576
	// Calculate new stack depth
507
	CalcStackDepth();
577
	CalcStackDepth();
508
578
509
	// Replace the method body
579
	if (((CModuleJ *)GetModule())->GetClassBuilder().GetMajorVersion() >= 50 
510
	m_pCodeAttr->SetCode(m_pBody->GetCodeSize(), m_pBody->GiveAvayCode());
580
		&& ((CModuleJ *)GetModule())->IsStackMapCalculationUsed()) {
581
	
582
		u1 *tbl;
583
		vf_Result status;
584
		status = recompute_stackmaptable((uint8 **)&tbl, m_methodHandler, ((CModuleJ *)GetModule())->GetVerificationContext());
585
		if (status != VF_OK) {
586
			assert(!"verification failed");
587
		}
588
		else {
589
			//CStackMapTable smt (tbl);
590
			CStackMapTableAttribute* smta = GetCodeAttribute()->GetOrCreateStackMaps();
591
			if (tbl != NULL) {
592
				smta->RereadFromBuffer(tbl); //skiping name
593
				smta->GetStackMapTable().AdjustOffsetDeltas();
594
			}
595
		}
596
	}
597
    // Final Stack Map Table handling: adjust offset deltas
598
    //StackMapTable.AdjustOffsetDeltas();
599
600
    
601
511
602
512
}
603
}
513
604
Lines 628-633 CMtdExTableJ::Emit() Link Here
628
				}
719
				}
629
			}
720
			}
630
		}
721
		}
722
		
631
		CJException jex = CJException(uType, ipStart, ipRealEnd, ipHandler); 
723
		CJException jex = CJException(uType, ipStart, ipRealEnd, ipHandler); 
632
		extblj.push_back(jex);
724
		extblj.push_back(jex);
633
	}
725
	}
(-)src-native/BCI/BCIEng/BCIEngJ/ModuleJ.h (-2 / +14 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
		
103
112
104
		// Set the "hasThis" attribute, which is accessible to all CMethod users
113
		// Set the "hasThis" attribute, which is accessible to all CMethod users
105
		SetHasThis(!(m_u2AccessFlags & ACC_STATIC));
114
		SetHasThis(!(m_u2AccessFlags & ACC_STATIC));
Lines 110-115 public: Link Here
110
	CSTR	GetSignature() const {return m_strSignature.c_str();}
119
	CSTR	GetSignature() const {return m_strSignature.c_str();}
111
	bool IsAbstract() { return ((m_u2AccessFlags & ACC_ABSTRACT) != 0); };
120
	bool IsAbstract() { return ((m_u2AccessFlags & ACC_ABSTRACT) != 0); };
112
    u2 GetAccessFlags() const { return m_u2AccessFlags; }
121
    u2 GetAccessFlags() const { return m_u2AccessFlags; }
122
	void SetMethodHandler(method_handler i_methodHandler) {m_methodHandler = i_methodHandler;}
123
	method_handler GetMethodHandler() {return m_methodHandler;}
113
124
114
	virtual void Parse();
125
	virtual void Parse();
115
	virtual void Emit();
126
	virtual void Emit();
Lines 121-126 private: Link Here
121
	CCodeAttribute*		m_pCodeAttr;		// Code attribute from CJClassFile
132
	CCodeAttribute*		m_pCodeAttr;		// Code attribute from CJClassFile
122
	u2					m_u2AccessFlags;	// Method access flags
133
	u2					m_u2AccessFlags;	// Method access flags
123
	IP_t				m_origCodeLength;	// Saved code length from Parse to Emit
134
	IP_t				m_origCodeLength;	// Saved code length from Parse to Emit
135
	method_handler		m_methodHandler;
124
};
136
};
125
137
126
138
(-)src-native/BCI/BCIEng/BCIEngJ/class_inerface_int.h (+41 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
39
int initialize_static();
40
41
#endif
(-)src-native/BCI/BCIEng/BCIEngJ/class_interface.cpp (+1240 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
33
static jclass m_j_l_class;
34
static jclass m_j_l_classloader;
35
static jmethodID m_j_l_class_getName; /*()Ljava/lang/String;*/
36
static jmethodID m_j_l_class_isInterface;/* ()Z */
37
static jmethodID m_j_l_class_getClassLoader; /*()Ljava/lang/ClassLoader;*/
38
static jmethodID m_j_l_classloader_findLoadedClass; /*(Ljava/lang/String;)Ljava/lang/Class;*/
39
static jmethodID m_j_l_classloader_getSystemClassLoader; /*()Ljava/lang/ClassLoader;*/
40
static jobject m_system_classloader;
41
/**
42
 * Define class handler
43
 */
44
/*[0xdead0001 - simplefied, 0xdead0002 - instrumented, 0xdead0000 - none]*/
45
#define CLASS_HANDLER_MASK 0xdeadffff
46
#define CLASS_HANDLER_SIMPLEFIED 0xdead0001
47
#define CLASS_HANDLER_INSTRUMENTED 0xdead0002
48
#define CLASS_HANDLER_NONE 0xdead0000
49
#define IS_CLASS_INSTRUMENTED(x) (((x)->magic & CLASS_HANDLER_MASK) == CLASS_HANDLER_INSTRUMENTED)
50
struct Class{
51
	int magic; 
52
	struct {
53
		class CModuleJ *instrumented_class;
54
		void *simplefied_class;
55
	} X; /*XXX: possible union here will be more applieble */
56
	int loaded;
57
	const char *class_name; /*used if loaded = 0*/
58
	struct Class *super_class;
59
};
60
61
typedef std::map<std::string,class_handler> name2ch_t;
62
static name2ch_t m_name2ch;
63
64
#define MEHTOD_HANDLER_MASK 0xbabeffff
65
#define METHOD_HANDLER_SELF 0xbabe0001
66
#define METHOD_HANDLER_EXT 0xbabe0002
67
#define METHOD_HANDLER_NONE 0xbabe0000
68
struct Method {
69
	int magic; 
70
	struct {
71
		class CMethodJ *instrumented_method;
72
		void *simplefied_method;
73
	} X; /*XXX: possible union here will be more applieble */
74
	class_handler class_owner;
75
	const char *method_name; /*used for METHOD_HANDLER_EXT only*/
76
	const char *method_descriptor; /*used for METHOD_HANDLER_EXT only*/
77
};
78
79
static struct Class *m_j_l_object_ch; 
80
/**
81
 * Define field handler
82
 */
83
typedef struct Field_ * field_handler;
84
85
/**
86
 * Define method handler
87
 */
88
//typedef struct Method_ * method_handler;
89
90
/**
91
 * Define class loader handler
92
 */
93
typedef struct ClassLoader_ * classloader_handler;
94
95
static int 
96
create_class_handler(class_handler *pch, int flag, const char *class_name, int loaded, void *dsk)
97
{
98
	class_handler ch0 = m_name2ch[class_name]; /*for debug*/
99
	if (m_name2ch[class_name] != NULL 
100
		&& m_name2ch[class_name]->magic == flag) {
101
			*pch = m_name2ch[class_name];
102
			return (0);
103
	} 
104
	class_handler ch = (class_handler)malloc(sizeof(struct Class));
105
	memset(ch, 0, sizeof(struct Class));
106
	assert(ch);
107
	ch->loaded = loaded;
108
	if (loaded == 0) {
109
		ch->class_name = class_name;
110
	}
111
	ch->magic = flag;
112
	switch(flag) {
113
	case (CLASS_HANDLER_SIMPLEFIED):
114
		ch->X.simplefied_class = dsk;
115
		if (loaded == 0) {
116
			ch->class_name = class_name;
117
		}
118
		ch->loaded = loaded;
119
		break;
120
	case (CLASS_HANDLER_INSTRUMENTED):
121
		ch->X.instrumented_class = (CModuleJ *)dsk;
122
		break;
123
	default:
124
		assert(!"shouldn't be here!!!");
125
	}
126
	*pch = ch;
127
	m_name2ch[class_name] = ch;
128
	return (0);
129
}
130
131
extern "C" int
132
create_method_handler(method_handler *pmh, class_handler ch, int flag, void *dsk) 
133
{
134
	method_handler mh = (method_handler)malloc(sizeof(struct Method));
135
	assert(mh);
136
	memset(mh, 0, sizeof(struct Method));
137
	switch (flag) {
138
	case METHOD_HANDLER_SELF:
139
		mh->X.instrumented_method = (class CMethodJ *)dsk;
140
		break;
141
	case METHOD_HANDLER_EXT:
142
		mh->X.simplefied_method = dsk;
143
		break;
144
	default:
145
		assert(!"shouldn't enter here");
146
	}
147
	mh->magic = (IS_CLASS_INSTRUMENTED(ch))?METHOD_HANDLER_SELF:flag;
148
	mh->class_owner = ch;
149
	*pmh = mh;
150
	return (0);
151
}
152
/**
153
 * Class interface
154
 */
155
156
/**
157
 * Function returns class major version.
158
 * @param klass - class handler
159
 * @return Class name bytes.
160
 * @note Assertion is raised if klass is equal to null.
161
 */
162
extern "C" unsigned short 
163
class_get_version( class_handler klass ) {
164
	if (IS_CLASS_INSTRUMENTED(klass)) {
165
		return klass->X.instrumented_class->GetClassBuilder().GetMajorVersion();
166
	} else {
167
		assert (!"not implemented yet!");
168
	}
169
	return (0);
170
}
171
172
/** 
173
 * Function returns class name.
174
 * @param klass - class handler
175
 * @return Class name bytes.
176
 * @note Assertion is raised if klass is equal to null.
177
 */
178
extern "C" const char *
179
class_get_name( class_handler klass ) 
180
{
181
	JNIEnv *env;
182
	jstring class_name;
183
	if (IS_CLASS_INSTRUMENTED(klass)) {
184
		return klass->X.instrumented_class->GetName();
185
	} 
186
	else {
187
		if (klass->loaded == 0) {
188
			return(klass->class_name);
189
		}
190
		env = m_get_vm_pointer((void **)&env);
191
		class_name = (jstring)env->CallObjectMethod((jobject)klass->X.simplefied_class, m_j_l_class_getName);
192
		if (class_name == NULL)
193
			return (NULL);
194
		char *class_name_simple = (char *)env->GetStringUTFChars(class_name, NULL);
195
		char *ch = strchr(class_name_simple, '.');
196
		while (ch != NULL) {
197
			*ch = '/';
198
			ch = strchr(ch, '.');
199
		}
200
		return(class_name_simple);
201
	
202
	}
203
	return (NULL);
204
}
205
206
/** 
207
 * Function returns class loader.
208
 * @param klass - class handler
209
 * @return Class class loader handler.
210
 * @note Assertion is raised if klass is equal to null.
211
 */
212
extern "C" classloader_handler
213
class_get_class_loader( class_handler klass )
214
{
215
	if (IS_CLASS_INSTRUMENTED(klass)) {
216
		return (0);
217
	} else {
218
		assert(!"simplefied");
219
	}
220
	return (NULL);
221
}
222
223
/** 
224
 * Function returns super class of current class.
225
 * @param klass - class handler
226
 * @return Super class of current class.
227
 * @note Assertion is raised if klass is equal to null.
228
 */
229
extern "C" class_handler
230
class_get_super_class( class_handler klass )
231
{
232
233
	const char *class_name;
234
	const char *super_class_name = NULL;
235
	jobject this_class = NULL;
236
	jobject super_class;
237
	JNIEnv *env = NULL;
238
	env = m_get_vm_pointer((void **)&env);
239
	assert(env);
240
	int loaded = 1;
241
	if (klass->loaded == 0 && strcmp(klass->class_name,"java/lang/Object") == 0) return (NULL);
242
	if (klass->super_class != NULL) return (klass->super_class);
243
	
244
	if (IS_CLASS_INSTRUMENTED(klass)) {
245
		class_name = klass->X.instrumented_class->GetName();
246
		CConstPool* cpool = klass->X.instrumented_class->GetClass().GetConstPool();
247
		CCPUtf8Info* utfinfo = cpool->GetClass(klass->X.instrumented_class->GetClass().GetSuperClass());
248
		super_class_name = (const char *)utfinfo->GetBytes();
249
		assert(super_class_name);	
250
		super_class = (jclass)env->FindClass(super_class_name);		
251
	} 
252
	else {
253
		if (klass->loaded == 0) {
254
			assert(klass->class_name);
255
			this_class = (jclass)env->FindClass(klass->class_name);
256
			if (this_class == NULL && env->ExceptionCheck()) {
257
				env->ExceptionDescribe();
258
				env->ExceptionClear();
259
				//XXX: class wasn't found or loaded
260
				return (m_j_l_object_ch);
261
				//return (NULL);
262
			}
263
		}
264
		this_class = this_class?this_class:(jobject)klass->X.simplefied_class;
265
		super_class = (jobject)env->GetSuperclass((jclass)this_class);
266
	}
267
268
	if (super_class == NULL) {
269
		if (env->ExceptionCheck()) {
270
			env->ExceptionDescribe();
271
			env->ExceptionClear();
272
			//XXX: class wasn't found or loaded
273
			loaded = 0;
274
			//return (NULL);
275
		}
276
		else {
277
			klass->super_class = m_j_l_object_ch;
278
			return (m_j_l_object_ch);
279
			//return (NULL); /*it happends when klass is java.lang.Object*/
280
		}
281
	}
282
	else {
283
		jstring jclass_name = (jstring)env->CallObjectMethod(super_class, m_j_l_class_getName);
284
		if (jclass_name == NULL) {
285
			return (m_j_l_object_ch);
286
		}
287
		char *class_name_simple = (char *)env->GetStringUTFChars(jclass_name, NULL);
288
		assert (class_name_simple);
289
		char *ch = strchr(class_name_simple, '.');
290
		while (ch != NULL) {
291
			*ch = '/';
292
			ch = strchr(ch, '.');
293
		}
294
		super_class_name = class_name_simple;
295
	}
296
	
297
	//assert(super_class);
298
	class_handler ch;
299
	int status = create_class_handler(&ch, CLASS_HANDLER_SIMPLEFIED, super_class_name, loaded, super_class);
300
	assert(status == 0);
301
	return (ch);
302
}
303
304
/** 
305
 * Function checks if classes are equal.
306
 * @param klass1 - class handler
307
 * @param klass2 - class handler
308
 * @return If classes are equal returns <code>true</code>, else returns <code>false</code>.
309
 * @note Assertion is raised if klass1 or klass2 are equal to null.
310
 */
311
extern "C" unsigned
312
class_is_same_class( class_handler klass1, class_handler klass2 )
313
{
314
	assert(!"verifier entered!!");
315
	return 0;
316
}
317
318
static char* 
319
package_name(const char* kname)
320
{
321
	char *tokp;
322
	char *tok0;
323
	tokp = tok0 = (char *)&kname[0];
324
	tok0 = strchr(kname, '/');
325
	while (tok0 != NULL) {
326
		tokp = tok0;
327
		tok0 = strchr(tok0 + 1, '/');
328
	}
329
	return (tokp);
330
}
331
332
/** 
333
 * Function checks if classes have the same package.
334
 * @param klass1 - class handler
335
 * @param klass2 - class handler
336
 * @return If classes have the same package returns <code>true</code>, else returns <code>false</code>.
337
 * @note Assertion is raised if klass1 or klass2 are equal to null.
338
 */
339
extern "C" unsigned
340
class_is_same_package( class_handler klass1, class_handler klass2 ) 
341
{
342
	if (klass1 == klass2) {
343
		return (1);
344
	}
345
	else {
346
		const char *klass1_name = class_get_name(klass1);
347
		const char *klass2_name = class_get_name(klass2);
348
		char* package1 = package_name(klass1_name);
349
		char* package2 = package_name(klass2_name);
350
		int package1_len = (package1 - klass1_name);
351
		int package2_len = (package2 - klass2_name);
352
		if (package1_len != package2_len)
353
			return (0);
354
		return(strncmp(klass1_name, klass2_name, package2_len) == 0);
355
		assert(!"verifier entered!!");
356
	}
357
	return (0);
358
}
359
360
/**
361
 * Function checks if current class is interface.
362
 * @param klass - class handler
363
 * @return If class is interface returns <code>true</code>, else returns <code>false</code>.
364
 * @note Assertion is raised if klass is equal to null.
365
 */
366
// FIXME - There is a macro class_is_interface in Class.h
367
extern "C" unsigned
368
class_is_interface( class_handler klass ) 
369
{
370
	JNIEnv *env;
371
	env = m_get_vm_pointer((void **)&env);
372
	assert(env);
373
	if (IS_CLASS_INSTRUMENTED(klass)) {
374
		return (0);
375
	} 
376
	else {
377
		return (unsigned)(env->CallBooleanMethod((jobject)klass->X.simplefied_class, m_j_l_class_isInterface));
378
	}
379
	
380
	return (0);
381
}
382
383
/**
384
 * Function checks if current class is array.
385
 * @param klass - class handler
386
 * @return If class is array returns <code>true</code>, else returns <code>false</code>.
387
 * @note Assertion is raised if klass is equal to null.
388
 */
389
extern "C" unsigned
390
class_is_array( class_handler klass ) 
391
{
392
	assert(!"verifier entered!!");
393
	return (0);
394
}
395
396
/**
397
 * Function checks if current class is final.
398
 * @param klass - class handler
399
 * @return If class is final returns <code>true</code>, else returns <code>false</code>.
400
 * @note Assertion is raised if klass is equal to null.
401
 */
402
// FIXME - There is a macro class_is_final in Class.h
403
extern "C" unsigned
404
class_is_final_( class_handler klass ) 
405
{
406
	assert(!"verifier entered!!");
407
	return (0);
408
}
409
410
/**
411
 * Function receives number of super interfaces of class.
412
 * @param klass - class handler
413
 * @return Number of super interfaces of class.
414
 * @note Assertion is raised if klass is equal to null.
415
 */
416
extern "C" unsigned short
417
class_get_superinterface_number( class_handler klass )
418
{
419
	assert(!"verifier entered!!");
420
	return (0);
421
}
422
423
/**
424
 * Function receives super interface of class.
425
 * @param klass - class handler
426
 * @param index - super interface number
427
 * @return Super interface of class.
428
 * @note Assertion is raised if klass is equal to null or index is out of range.
429
 */
430
extern "C" class_handler
431
class_get_superinterface( class_handler klass, unsigned short index )
432
{
433
	assert(!"verifier entered!!");
434
	return (NULL);
435
}
436
437
/**
438
 * Function receives element class of array class.
439
 * @param klass - class handler
440
 * @return Element class of array class.
441
 * @note Assertion is raised if klass is equal to null or isn't array class.
442
 */
443
extern "C" class_handler
444
class_get_array_element_class( class_handler klass )
445
{
446
	assert(!"verifier entered!!");
447
	return (NULL);
448
}
449
450
451
/**
452
 * Function checks if class extends current class with given name.
453
 * @param klass      - checked klass
454
 * @param super_name - parent class name
455
 * @return If given class extends current class with given name,
456
 *         function returns its class handler, else function returns 0.
457
 * @note Assertion is raised if <i>klass</i> or <i>super_name</i> are equal to null.
458
 */
459
extern "C" class_handler
460
class_get_extended_class( class_handler klass, const char *super_name )
461
{
462
	return (NULL);
463
}
464
465
/**
466
 * Function returns number of methods for current class.
467
 * @param klass - class handler
468
 * @return Number of methods for class.
469
 * @note Assertion is raised if klass is equal to null.
470
 */
471
extern "C" unsigned short
472
class_get_method_number( class_handler klass )
473
{
474
	assert(!"verifier entered!!");
475
	return (0);
476
}
477
478
/** 
479
 * Function returns method of current class.
480
 * @param klass - class handler
481
 * @param index - method index
482
 * @return Method handler.
483
 * @note Assertion is raised if klass is equal to null or index is out of range.
484
 */
485
extern "C" method_handler
486
class_get_method( class_handler klass, unsigned short index )
487
{
488
	assert(!"verifier entered!!");
489
	return (NULL);
490
}
491
492
493
/**
494
 * Constant pool inteface
495
 */
496
497
/** 
498
 * Function returns class constant pool size.
499
 * @param klass - class handler
500
 * @return constant pool size
501
 * @note Assertion is raised if klass is equal to null.
502
 */
503
extern "C" unsigned short
504
class_cp_get_size( class_handler klass )
505
{
506
	if (IS_CLASS_INSTRUMENTED(klass)) {
507
		assert(klass->X.instrumented_class);
508
		assert(klass->X.instrumented_class->GetClassBuilder().GetConstPool());
509
		return klass->X.instrumented_class->GetClassBuilder().GetConstPool()->GetSize();
510
	} else {
511
		assert (!"not implemented yet!");
512
	}
513
	assert(!"verifier entered!!");
514
	return (0);
515
}
516
517
518
/** 
519
 * Function returns constant pool entry tag.
520
 * @param klass - class handler
521
 * @param index - constant pool entry index
522
 * @return constant pool entry tag
523
 * @note Assertion is raised if klass is equal to null or index is out of range.
524
 */
525
extern "C" unsigned char
526
class_cp_get_tag( class_handler klass, unsigned short index )
527
{
528
	if (IS_CLASS_INSTRUMENTED(klass)) {
529
		return (*klass->X.instrumented_class->GetClassBuilder().GetConstPool())[index]->GetTag();
530
	} else {
531
		assert (!"not implemented yet!");
532
	}
533
	return (0);
534
}
535
536
/** 
537
 * Function returns class name entry index in constant pool.
538
 * @param klass - class handler
539
 * @param index - constant pool entry index
540
 * @return class name entry index
541
 * @note Function is legal only for constant pool entry with CONSTANT_Class tags.
542
 * @note Assertion is raised if klass is equal to null or index is out of range.
543
 */
544
extern "C" unsigned short
545
class_cp_get_class_name_index( class_handler klass, unsigned short index )
546
{
547
	if (IS_CLASS_INSTRUMENTED(klass)) {
548
		CCPInfo * ccinfo = (*klass->X.instrumented_class->GetClassBuilder().GetConstPool())[index];
549
		assert(ccinfo->GetTag() == CONSTANT_Class);
550
		return ((CCPClassInfo *)ccinfo)->GetClassInd();
551
	} else {
552
		assert (!"not implemented yet!");
553
	}
554
	return (0);
555
}
556
557
/** 
558
 * Function returns class name entry index in constant pool.
559
 * @param klass - class handler
560
 * @param index - constant pool entry index
561
 * @return class name entry index
562
 * @note Function is legal for constant pool entry with 
563
 *       CONSTANT_Fieldref, CONSTANT_Methodref and CONSTANT_InterfaceMethodref tags.
564
 * @note Assertion is raised if klass is equal to null or index is out of range.
565
 */
566
extern "C" unsigned short
567
class_cp_get_ref_class_index( class_handler klass, unsigned short index )
568
{
569
	if (IS_CLASS_INSTRUMENTED(klass)) {
570
		CCPInfo * ccinfo = (*klass->X.instrumented_class->GetClassBuilder().GetConstPool())[index];
571
		unsigned char tag = ccinfo->GetTag();
572
		switch(tag) {
573
		case CONSTANT_Fieldref:
574
			return ((CCPFieldrefInfo *)ccinfo)->GetClassInd();
575
		break;
576
		case CONSTANT_Methodref:
577
			return ((CCPMethodrefInfo *)ccinfo)->GetClassInd();
578
		break;
579
		case CONSTANT_InterfaceMethodref:
580
			return ((CCPInterfaceMethodrefInfo *)ccinfo)->GetClassInd();
581
		break;
582
		default:
583
			assert(!"unsupported tag");
584
		}
585
	} else {
586
		assert (!"not implemented yet!");
587
	}
588
	return (0);
589
}
590
591
/** 
592
 * Function returns name_and_type entry index in constant pool.
593
 * @param klass - class handler
594
 * @param index - constant pool entry index
595
 * @return name_and_type entry index
596
 * @note Function is legal for constant pool entry with 
597
 *       CONSTANT_Fieldref, CONSTANT_Methodref and CONSTANT_InterfaceMethodref tags.
598
 * @note Assertion is raised if klass is equal to null or index is out of range.
599
 */
600
extern "C" unsigned short
601
class_cp_get_ref_name_and_type_index( class_handler klass, unsigned short index )
602
{
603
	if (IS_CLASS_INSTRUMENTED(klass)) {
604
		CCPInfo * ccinfo = (*klass->X.instrumented_class->GetClassBuilder().GetConstPool())[index];
605
		unsigned char tag = ccinfo->GetTag();
606
		switch(tag) {
607
		case CONSTANT_Fieldref:
608
			return ((CCPFieldrefInfo *)ccinfo)->GetNameAndTypeInd();
609
		break;
610
		case CONSTANT_Methodref:
611
			return ((CCPMethodrefInfo *)ccinfo)->GetNameAndTypeInd();
612
		break;
613
		case CONSTANT_InterfaceMethodref:
614
			return ((CCPInterfaceMethodrefInfo *)ccinfo)->GetNameAndTypeInd();
615
		break;
616
		default:
617
			assert(!"unsupported tag");
618
		}
619
	} else {
620
		assert (!"not implemented yet!");
621
	}
622
	return (0);
623
}
624
625
/** 
626
 * Function returns string entry index in constant pool.
627
 * @param klass - class handler
628
 * @param index - constant pool entry index
629
 * @return string entry index
630
 * @note Function is legal for constant pool entry with CONSTANT_String tags.
631
 * @note Assertion is raised if klass is equal to null or index is out of range.
632
 */
633
extern "C" unsigned short
634
class_cp_get_string_index( class_handler klass, unsigned short index )
635
{
636
	assert(!"verifier entered!!");
637
	return (0);
638
}
639
640
/** 
641
 * Function returns name entry index in constant pool.
642
 * @param klass - class handler
643
 * @param index - constant pool entry index
644
 * @return name entry index
645
 * @note Function is legal for constant pool entry with CONSTANT_NameAndType tags.
646
 * @note Assertion is raised if klass is equal to null or index is out of range.
647
 */
648
extern "C" unsigned short
649
class_cp_get_name_index( class_handler klass, unsigned short index )
650
{
651
	if (IS_CLASS_INSTRUMENTED(klass)) {
652
		CCPInfo * ccinfo = (*klass->X.instrumented_class->GetClassBuilder().GetConstPool())[index];
653
		unsigned char tag = ccinfo->GetTag();
654
		assert(tag == CONSTANT_NameAndType);
655
		return ((CCPNameAndTypeInfo *)ccinfo)->GetNameInd();
656
	} else {
657
		assert (!"not implemented yet!");
658
	}
659
	return (0);
660
}
661
662
/** 
663
 * Function returns descriptor entry index in constant pool.
664
 * @param klass - class handler
665
 * @param index - constant pool entry index
666
 * @return descriptor entry index
667
 * @note Function is legal for constant pool entry with CONSTANT_NameAndType tags.
668
 * @note Assertion is raised if klass is equal to null or index is out of range.
669
 */
670
extern "C" unsigned short
671
class_cp_get_descriptor_index( class_handler klass, unsigned short index )
672
{
673
	if (IS_CLASS_INSTRUMENTED(klass)) {
674
		CCPInfo * ccinfo = (*klass->X.instrumented_class->GetClassBuilder().GetConstPool())[index];
675
		unsigned char tag = ccinfo->GetTag();
676
		assert(tag == CONSTANT_NameAndType);
677
		return ((CCPNameAndTypeInfo *)ccinfo)->GetDescriptorInd();
678
	} else {
679
		assert (!"not implemented yet!");
680
	}
681
	return (0);
682
}
683
684
/** 
685
 * Function returns bytes for UTF8 constant pool entry.
686
 * @param klass - class handler
687
 * @param index - constant pool entry index
688
 * @return bytes for UTF8 constant pool entry
689
 * @note Function is legal for constant pool entry with CONSTANT_UTF8 tags.
690
 * @note Assertion is raised if klass is equal to null or index is out of range.
691
 */
692
extern "C" const char *
693
class_cp_get_utf8_bytes( class_handler klass, unsigned short index )
694
{
695
	if (IS_CLASS_INSTRUMENTED(klass)) {
696
		return (const char *)((CCPUtf8Info *)(*klass->X.instrumented_class->GetClassBuilder().GetConstPool())[index])->GetBytes();
697
	} else {
698
		assert (!"not implemented yet!");
699
	}
700
	return (0);
701
}
702
703
/**
704
 * Function sets verify data to a given class.
705
 * @param klass     - class handler
706
 * @param data      - verify data
707
 * @note Assertion is raised if class is equal to null.
708
 * @note Function makes non thread save operation and 
709
 *       must be called in thread safe point.
710
 */
711
extern "C" void
712
class_set_verify_data_ptr( class_handler klass, void *data )
713
{
714
	assert(!"verifier entered!!");
715
	return;
716
}
717
718
/**
719
 * Function returns verify data for a given class.
720
 * @param klass - class handler
721
 * @return Verify data for a given class.
722
 * @note Assertion is raised if klass is equal to null.
723
 */
724
extern "C" void *
725
class_get_verify_data_ptr( class_handler klass )
726
{
727
	assert(!"verifier entered!!");
728
	return (NULL);
729
}
730
731
/**
732
 * Function resolves class nonstatic method for constant pool entry.
733
 *
734
 * @param klass - class handle
735
 * @param index - constant pool entry index
736
 * @param exc   - pointer to exception
737
 *
738
 * @return Return nonstatic method resolved for constant pool entry.
739
 */
740
extern "C" method_handler
741
class_resolve_method( class_handler klass, unsigned short index )
742
{
743
	assert(!"verifier entered!!");
744
	return (NULL);
745
}
746
747
/**
748
 * Function resolves class nonstatic field for constant pool entry.
749
 *
750
 * @param klass - class handle
751
 * @param index - constant pool entry index
752
 * @param exc   - pointer to exception
753
 *
754
 * @return Return nonstatic field resolved for constant pool entry.
755
 */
756
extern "C" field_handler
757
class_resolve_nonstatic_field( class_handler klass, unsigned short index )
758
{
759
	assert(!"verifier entered!!");
760
	return (NULL);
761
}
762
763
/**
764
 * Method interface
765
 */
766
767
/**
768
 * Function returns a class in which the method is declared.
769
 * @param method - method handler
770
 * @return Return a class in which the method is declared.
771
 * @note Assertion is raised if <i>method</i> is equal to null.
772
 */
773
extern "C" class_handler
774
method_get_class( method_handler hmethod )
775
{
776
	if (hmethod == NULL) return (NULL);
777
	if (hmethod->magic == METHOD_HANDLER_SELF) {
778
		if (hmethod->X.instrumented_method) return (NULL);
779
		return (((CModuleJ *)hmethod->X.instrumented_method->GetModule())->GetClassHandler());
780
	}
781
	else {
782
		assert(!"verifier entered!!");
783
	}
784
	return (NULL);
785
}
786
787
/**
788
 * Function returns method name.
789
 * @param method - method handler
790
 * @return Method name bytes.
791
 * @note Assertion is raised if method is equal to null.
792
 */
793
extern "C" const char *
794
method_get_name( method_handler method )
795
{
796
	if (method->magic == METHOD_HANDLER_SELF) {
797
		return (method->X.instrumented_method->GetName());
798
	}
799
	else {
800
		assert(!"verifier entered!!");
801
	}
802
	return (NULL);
803
}
804
805
/**
806
 * Function returns method descriptor.
807
 * @param method - method handler
808
 * @return Method descriptor bytes.
809
 * @note Assertion is raised if method is equal to null.
810
 */
811
extern "C" const char *
812
method_get_descriptor( method_handler method )
813
{
814
	if (method->magic == METHOD_HANDLER_SELF) {
815
		return (method->X.instrumented_method->GetSignature());
816
	}
817
	else {
818
		assert(!"verifier entered!!");
819
	}
820
	return (NULL);
821
}
822
823
/**
824
 * Function returns method code length.
825
 * @param method - method handler
826
 * @return Method code length.
827
 * @note Assertion is raised if method is equal to null.
828
 */
829
extern "C" unsigned
830
method_get_bytecode_length( method_handler method )
831
{
832
	/*insert check about instrumentation*/
833
	if (method->magic == METHOD_HANDLER_SELF) {
834
		unsigned size = 0;
835
		CInstructions::const_iterator insIterator;
836
		if (method->X.instrumented_method->GetCodeAttribute() == NULL) return (0);
837
		return (method->X.instrumented_method->GetCodeAttribute()->GetCodeLength());
838
	}
839
	else {
840
		assert(!"verifier entered!!");
841
	}
842
	return (0);	
843
}
844
845
/**
846
 * Function returns method bytecode array.
847
 * @param method - method handler
848
 * @return Method bytecode array.
849
 * @note Assertion is raised if method is equal to null.
850
 */
851
extern "C" unsigned char *
852
method_get_bytecode( method_handler method )
853
{
854
	if (method->magic == METHOD_HANDLER_SELF) {
855
		return (method->X.instrumented_method->GetCodeAttribute()->GetCode());
856
	}
857
	else {
858
		assert(!"verifier entered!!");
859
	}
860
	return (NULL);	
861
}
862
863
/**
864
 * Function returns maximal local variables number of method.
865
 * @param method - method handler
866
 * @return Maximal local variables number of method.
867
 * @note Assertion is raised if method is equal to null.
868
 */
869
extern "C" unsigned
870
method_get_max_locals( method_handler method )
871
{
872
	if (method->magic == METHOD_HANDLER_SELF) {
873
		/*XXX: add check for instrumented method*/
874
		CMethodJ * jmethod = (CMethodJ *)(method->X.instrumented_method);
875
		return (jmethod->GetCodeAttribute()->GetMaxLocals());
876
	}
877
	else {
878
		assert(!"verifier entered!!");
879
	}
880
	return (0);	
881
	
882
}
883
884
/**
885
 * Function returns maximal stack deep of method.
886
 * @param method - method handler
887
 * @return Maximal stack deep of method.
888
 * @note Assertion is raised if method is equal to null.
889
 */
890
extern "C" unsigned 
891
method_get_max_stack( method_handler method )
892
{
893
	if (method->magic == METHOD_HANDLER_SELF) {
894
		CMethodJ * jmethod = (CMethodJ *)(method->X.instrumented_method);
895
		return (jmethod->GetCodeAttribute()->GetMaxStack());
896
	}
897
	else {
898
		assert(!"verifier entered!!");
899
	}
900
	return (0);	
901
}
902
903
/**
904
 * Function checks if method is static.
905
 * @param method - method handler
906
 * @return If method is static, function returns <code>true</code>,
907
 *         else returns <code>false</code>.
908
 * @note Assertion is raised if method is equal to null.
909
 */
910
extern "C" unsigned
911
method_is_static( method_handler method )
912
{
913
	if (method->magic == METHOD_HANDLER_SELF) {
914
		return (method->X.instrumented_method->GetAccessFlags() & ACC_STATIC);
915
	}
916
	else {
917
		//assert(!"verifier entered!!");
918
		return (0); /*we're assuming that this function called after class_resolve_method and couldn't return static methods*/
919
	}
920
	return (0);	
921
	
922
}
923
924
/**
925
 * Function checks if a given method is protected.
926
 *
927
 * @param method - method handle
928
 *
929
 * @return Return <code>TRUE</code> if a given method is protected.
930
 *
931
 * @note Assertion is raised if <i>method</i> is equal to null.
932
 */
933
extern "C" unsigned
934
method_is_protected( method_handler method )
935
{
936
	assert(!"verifier entered!!");
937
	return (0);
938
}
939
940
/**
941
 * Method exception handler
942
 */
943
944
/**
945
 * Function returns number of method exception handlers.
946
 * @param method - method handler
947
 * @return Number of method exception handlers.
948
 * @note Assertion is raised if method is equal to null.
949
 */
950
extern "C" unsigned short
951
method_get_exc_handler_number( method_handler method )
952
{
953
	return (method->X.instrumented_method->GetExTable()->size());
954
}
955
956
/**
957
 * Function obtains method exception handler info.
958
 * @param method     - method handler
959
 * @param index      - exception handler index number
960
 * @param start_pc   - resulting pointer to exception handler start program count
961
 * @param end_pc     - resulting pointer to exception handler end program count
962
 * @param handler_pc - resulting pointer to exception handler program count
963
 * @param catch_type - resulting pointer to constant pool entry index
964
 * @note Assertion is raised if method is equal to null or
965
 *       exception handler index is out of range or
966
 *       any pointer is equal to null.
967
 */
968
extern "C" void
969
method_get_exc_handler_info( method_handler method, unsigned short index,
970
                             unsigned short *start_pc, unsigned short *end_pc,
971
                             unsigned short *handler_pc, unsigned short *catch_type )
972
{
973
	class CExTable& exc = method->X.instrumented_method->GetCodeAttribute()->GetExTable();
974
	*start_pc = exc[index].GetStartPC();
975
	*end_pc = exc[index].GetEndPC();
976
	*handler_pc = exc[index].GetHandlerPC();
977
	*catch_type = exc[index].GetCatchtype();
978
979
	return;
980
}
981
982
/**
983
 * Gets number of exceptions a method can throw.
984
 * Parameter <i>hmethod</i> must not equal to <code>NULL</code>.
985
 *
986
 * @param hmethod   method handle
987
 *
988
 * @return          number of exceptions
989
 */
990
extern "C" unsigned short
991
method_get_number_exc_method_can_throw( method_handler hmethod )
992
{
993
	assert(!"verifier entered!!");
994
	return (0);
995
}
996
997
/**
998
 * Gets name of exception a method can throw.
999
 * Parameter <i>hmethod</i> must not equal to <code>NULL</code>.
1000
 * If parameter <i>index</i> is out of range, returns <code>NULL</code>.
1001
 *
1002
 * @param hmethod   method handle
1003
 * @param index     index of exception
1004
 *
1005
 * @return          name of exception
1006
 */
1007
extern "C" const char *
1008
method_get_exc_method_can_throw( method_handler hmethod, unsigned short index )
1009
{
1010
	assert(!"verifier entered!!");
1011
	return (NULL);
1012
}
1013
1014
1015
/**
1016
 * Gets StackMapTable attribute.
1017
 * Parameter <i>hmethod</i> must not equal to <code>NULL</code>.
1018
 * If parameter <i>index</i> is out of range, returns <code>NULL</code>.
1019
 *
1020
 * @param hmethod   method handle
1021
 *
1022
 * @return          StackMapTable bytes
1023
 */
1024
extern "C" unsigned char *
1025
method_get_stackmaptable( method_handler hmethod )
1026
{
1027
	
1028
	CStackMapTableAttribute *attr = hmethod->X.instrumented_method->GetCodeAttribute()->GetStackMaps();
1029
	if (attr == NULL)
1030
		return (NULL);
1031
	u4 length = attr->GetLength();
1032
	u1 *stackmap = (u1 *)malloc(length);
1033
	CJMemStream mem_stream;
1034
	mem_stream.Open(stackmap, length);
1035
	CJStream stream(&mem_stream);
1036
	attr->Write(stream);
1037
	//return (attr->GetInfo());
1038
	return (stackmap);
1039
}
1040
1041
1042
//modifies start_pc, end_pc 
1043
extern "C" void 
1044
method_modify_exc_handler_info(method_handler method, 
1045
                                    unsigned short idx, 
1046
                                    unsigned short start_pc,
1047
                                    unsigned short end_pc, 
1048
                                    unsigned short handler_pc, 
1049
                                    unsigned short handler_cp_index )
1050
{
1051
1052
	assert(!"verifier entered!!");
1053
	return;
1054
}
1055
1056
// removes given exception handler (handlers with greater indexes shift)
1057
extern "C" void 
1058
method_remove_exc_handler( method_handler method, unsigned short idx )
1059
{
1060
	assert(!"verifier entered!!");
1061
	return;
1062
}
1063
1064
/**
1065
 * Class loader interface
1066
 */
1067
1068
/**
1069
 * Function sets verify data in class loader.
1070
 * @param classloader - class loader handler
1071
 * @param data        - verify data
1072
 * @note Assertion is raised if classloader is equal to null.
1073
 * @note Function makes non thread save operation and 
1074
 *       must be called in thread safe point.
1075
 */
1076
extern "C" void
1077
class_loader_set_verifier_data_ptr( classloader_handler classloader, void *data )
1078
{
1079
	assert(!"verifier entered!!");
1080
	return;
1081
}
1082
1083
/**
1084
 * Function returns verify data in class loader.
1085
 * @param classloader - class loader handler
1086
 * @return Verify data in class loader.
1087
 * @note Assertion is raised if classloader is equal to null.
1088
 */
1089
extern "C" void *
1090
class_loader_get_verifier_data_ptr( classloader_handler classloader )
1091
{
1092
	assert(!"verifier entered!!");
1093
	return (NULL);
1094
}
1095
1096
/**
1097
 * Function locks class loader.
1098
 * @param classloader - class loader handler
1099
 * @note Assertion is raised if classloader is equal to null.
1100
 */
1101
extern "C" void
1102
class_loader_lock( classloader_handler classloader )
1103
{
1104
	assert(!"verifier entered!!");
1105
	return;
1106
}
1107
1108
/**
1109
 * Function releases class loader.
1110
 * @param classloader - class loader handler
1111
 * @note Assertion is raised if classloader is equal to null.
1112
 */
1113
extern "C" void
1114
class_loader_unlock( classloader_handler classloader )
1115
{
1116
	assert(!"verifier entered!!");
1117
	return;
1118
}
1119
1120
/**
1121
 * Function returns loaded class in class loader.
1122
 * @param classloader - class loader handler
1123
 * @param name        - class name
1124
 * @return Loaded class in classloader or null if class isn't loaded in class loader.
1125
 * @note Assertion is raised if classloader or name are equal to null.
1126
 */
1127
extern "C" class_handler
1128
class_loader_lookup_class( classloader_handler classloader, const char *name )
1129
{
1130
	if (m_name2ch[name] != NULL && IS_CLASS_INSTRUMENTED(m_name2ch[name])) 
1131
		return (m_name2ch[name]);
1132
	else
1133
		return (NULL);
1134
}
1135
1136
/**
1137
 * Function returns loaded class in class loader.
1138
 * @param classloader - class loader handler
1139
 * @param name        - class name
1140
 * @return Loaded class in classloader if class isn't loaded in class loader 
1141
 *         function loads it.
1142
 * @note Assertion is raised if classloader or name are equal to null.
1143
 */
1144
extern "C" class_handler
1145
class_loader_load_class( classloader_handler classloader, const char *name )
1146
{
1147
	assert(!"verifier entered!!");
1148
	return (NULL);
1149
}
1150
1151
/**
1152
 * Function checks if the field is protected.
1153
 * @param field - field handler
1154
 * @return Returns <code>TRUE</code> if the field is protected.
1155
 */
1156
extern "C" unsigned
1157
field_is_protected( field_handler field )
1158
{
1159
	assert(!"verifier entered!!");
1160
	return (0);
1161
}
1162
1163
class_handler
1164
get_class_handler_from_builder(class CModuleJ *module) 
1165
{
1166
	class_handler ch;
1167
1168
	m_name2ch.clear();
1169
	int status = create_class_handler(&m_j_l_object_ch, CLASS_HANDLER_SIMPLEFIED, "java/lang/Object", 0, NULL);
1170
	assert(!status);
1171
	
1172
	status = create_class_handler(&ch, CLASS_HANDLER_INSTRUMENTED, module->GetName(), 1, module);
1173
	assert(!status);
1174
	return (ch);
1175
}
1176
1177
method_handler 
1178
get_method_handler_for_cmethod(class CMethod *method)
1179
{
1180
	class_handler ch = NULL;
1181
	method_handler mh = NULL;
1182
	int status;
1183
	status = create_class_handler(&ch, CLASS_HANDLER_INSTRUMENTED, (const char *)method->GetModule()->GetName(), 1, method->GetModule());
1184
	assert(!status);
1185
	status = create_method_handler(&mh, ch, METHOD_HANDLER_SELF, method);
1186
	assert(!status);
1187
	return (mh);
1188
}
1189
1190
extern "C" unsigned short
1191
class_cp_get_class_entry(class_handler klass, const char* name)
1192
{
1193
1194
	
1195
	CCPClassInfo *cinfo;
1196
	if (IS_CLASS_INSTRUMENTED(klass)) {
1197
		/*for this class we'll have entry somewhere in some future */
1198
		if (strcmp(klass->X.instrumented_class->GetName(), name) == 0) {
1199
			return (klass->X.instrumented_class->GetClass().GetThisClass());
1200
		}
1201
		assert(name);
1202
		cinfo = (klass->X.instrumented_class->GetClassBuilder().FindClass(name));
1203
		if (cinfo == NULL) {
1204
			/*should be created new class antry */
1205
			cinfo = *klass->X.instrumented_class->GetClassBuilder().CreateClassConstant(name);
1206
			assert(cinfo);
1207
		} 
1208
		return(cinfo->GetCpIndex());
1209
	} else {
1210
		assert (!"not implemented yet!");
1211
	}
1212
	return (0);
1213
}
1214
1215
int
1216
initialize_dynamic(get_vm_pointer_t a_get_vm_pointer)
1217
{
1218
	m_get_vm_pointer = (JNIEnv *(*)(void **))a_get_vm_pointer;
1219
	JNIEnv *env;
1220
	env = m_get_vm_pointer((void **)&env);
1221
	assert(env);
1222
	if (m_j_l_class) return (0);
1223
	
1224
	m_j_l_class = env->FindClass("java/lang/Class");
1225
	assert(m_j_l_class);
1226
	m_j_l_class_getName = env->GetMethodID(m_j_l_class, "getName", "()Ljava/lang/String;");
1227
	assert(m_j_l_class_getName);
1228
	m_j_l_class_getClassLoader = env->GetMethodID(m_j_l_class, "getClassLoader", "()Ljava/lang/ClassLoader;");
1229
	assert(m_j_l_class_getClassLoader);
1230
	m_j_l_class_isInterface = env->GetMethodID(m_j_l_class, "isInterface", "()Z");
1231
	assert(m_j_l_class_isInterface);
1232
	
1233
	m_j_l_classloader = env->FindClass("java/lang/ClassLoader");
1234
	assert(m_j_l_classloader);
1235
	m_j_l_classloader_findLoadedClass = env->GetMethodID(m_j_l_classloader, "findLoadedClass", "(Ljava/lang/String;)Ljava/lang/Class;"); 
1236
	assert(m_j_l_classloader_findLoadedClass);
1237
1238
	return (0);
1239
}
1240
(-)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.dsp (-4 / +5 lines)
Lines 43-49 RSC=rc.exe Link Here
43
# PROP Ignore_Export_Lib 0
43
# PROP Ignore_Export_Lib 0
44
# PROP Target_Dir ""
44
# PROP Target_Dir ""
45
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BCIENGPROBE_EXPORTS" /YX /FD /c
45
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BCIENGPROBE_EXPORTS" /YX /FD /c
46
# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /I "..\..\BCIEng\\" /I "..\..\BCIEng\BCIEngJ" /I "..\..\JClass" /I "..\..\common" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
46
# ADD CPP /nologo /MT /W3 /GX /Zd /O2 /I "..\..\..\..\..\verifier\include" /I "..\..\..\..\..\verifier\open\include" /I "..\..\..\..\..\harmony-verifier\include" /I "..\..\..\..\..\harmony-verifier\open\include" /I "..\..\..\..\..\recomp" /I "..\..\..\..\..\harmony-verifier\verifier-3363\x_verifier" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "..\..\BCIEng\\" /I "..\..\BCIEng\BCIEngJ" /I "..\..\JClass" /I "..\..\common" /I "..\..\..\..\..\org.apache.harmony_vmcore_verifier\src\vmcore\src\verifier-3363" /I "..\..\..\..\..\org.apache.harmony_vmcore_verifier\src\include" /I "..\..\..\..\..\org.apache.harmony_vmcore_verifier\src\vmcore\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VERIFIER_STANDALONE" /YX /FD /c
47
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
47
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
48
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
48
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
49
# ADD BASE RSC /l 0x409 /d "NDEBUG"
49
# ADD BASE RSC /l 0x409 /d "NDEBUG"
Lines 53-59 BSC32=bscmake.exe Link Here
53
# ADD BSC32 /nologo
53
# ADD BSC32 /nologo
54
LINK32=link.exe
54
LINK32=link.exe
55
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
55
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
56
# ADD LINK32 kernel32.lib bciengj.lib /nologo /dll /debug /machine:I386 /libpath:"..\..\..\bci\jclass\release" /libpath:"..\..\..\bci\bcieng\bciengj\release"
56
# ADD LINK32 bciengj.lib kernel32.lib verifier.lib /nologo /dll /debug /machine:I386 /libpath:"..\..\..\bci\jclass\release" /libpath:"..\..\..\bci\bcieng\bciengj\release" /libpath:"..\..\..\..\..\org.apache.harmony_vmcore_verifier\lib\windows\release\IA-32"
57
57
58
!ELSEIF  "$(CFG)" == "BCIEngProbe - Win32 Debug"
58
!ELSEIF  "$(CFG)" == "BCIEngProbe - Win32 Debug"
59
59
Lines 69-75 LINK32=link.exe Link Here
69
# PROP Ignore_Export_Lib 0
69
# PROP Ignore_Export_Lib 0
70
# PROP Target_Dir ""
70
# PROP Target_Dir ""
71
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BCIENGPROBE_EXPORTS" /YX /FD /GZ /c
71
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BCIENGPROBE_EXPORTS" /YX /FD /GZ /c
72
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\BCIEng\\" /I "..\..\BCIEng\BCIEngJ" /I "..\..\JClass" /I "..\..\common" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR /YX /FD /GZ /c
72
# ADD CPP /nologo /MDd /W3 /GX /Zd /Od /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "..\..\BCIEng\\" /I "..\..\BCIEng\BCIEngJ" /I "..\..\JClass" /I "..\..\common" /I "..\..\..\..\..\org.apache.harmony_vmcore_verifier\src\vmcore\src\verifier-3363" /I "..\..\..\..\..\org.apache.harmony_vmcore_verifier\src\include" /I "..\..\..\..\..\org.apache.harmony_vmcore_verifier\src\vmcore\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "VERIFIER_STANDALONE" /FR /YX /FD /GZ /c
73
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
73
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
74
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
74
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
75
# ADD BASE RSC /l 0x409 /d "_DEBUG"
75
# ADD BASE RSC /l 0x409 /d "_DEBUG"
Lines 79-85 BSC32=bscmake.exe Link Here
79
# ADD BSC32 /nologo
79
# ADD BSC32 /nologo
80
LINK32=link.exe
80
LINK32=link.exe
81
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
81
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
82
# ADD LINK32 bciengj.lib kernel32.lib /nologo /dll /incremental:no /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\bci\jclass\debug" /libpath:"..\..\..\bci\bcieng\bciengj\debug"
82
# ADD LINK32 verifier.lib bciengj.lib kernel32.lib /nologo /dll /incremental:no /debug /machine:I386 /out:"Debug/BCIEngProbe.dll " /pdbtype:sept /libpath:"..\..\..\bci\jclass\debug" /libpath:"..\..\..\bci\bcieng\bciengj\debug" /libpath:"..\..\..\..\..\org.apache.harmony_vmcore_verifier\lib\windows\debug\IA-32"
83
# SUBTRACT LINK32 /verbose
83
84
84
!ENDIF 
85
!ENDIF 
85
86
(-)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/BCIEng/BCIEngProbe/ProbeInstrumenter/ProbeInstrumenter.dsp (-2 / +2 lines)
Lines 42-48 RSC=rc.exe Link Here
42
# PROP Ignore_Export_Lib 0
42
# PROP Ignore_Export_Lib 0
43
# PROP Target_Dir ""
43
# PROP Target_Dir ""
44
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
44
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
45
# ADD CPP /nologo /W3 /GX /Zi /O2 /I "..\..\..\Common" /I "..\..\..\jclass" /I "..\..\..\bcieng" /I "..\..\..\bcieng\bciengj" /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR"..\Release\\" /YX /FD /c
45
# ADD CPP /nologo /W3 /GX /Zi /O2 /I "..\..\..\..\org.apache.harmony_vmcore_verifier\include" /I "..\..\..\Common" /I "..\..\..\jclass" /I "..\..\..\bcieng" /I "..\..\..\bcieng\bciengj" /I ".." /I "..\..\..\..\..\..\org.apache.harmony_vmcore_verifier\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR"..\Release\\" /YX /FD /c
46
# ADD BASE RSC /l 0x409 /d "NDEBUG"
46
# ADD BASE RSC /l 0x409 /d "NDEBUG"
47
# ADD RSC /l 0x409 /d "NDEBUG"
47
# ADD RSC /l 0x409 /d "NDEBUG"
48
BSC32=bscmake.exe
48
BSC32=bscmake.exe
Lines 66-72 LINK32=link.exe Link Here
66
# PROP Ignore_Export_Lib 0
66
# PROP Ignore_Export_Lib 0
67
# PROP Target_Dir ""
67
# PROP Target_Dir ""
68
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
68
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
69
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\Common" /I "..\..\..\jclass" /I "..\..\..\bcieng" /I "..\..\..\bcieng\bciengj" /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
69
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\..\org.apache.harmony_vmcore_verifier\include" /I "..\..\..\Common" /I "..\..\..\jclass" /I "..\..\..\bcieng" /I "..\..\..\bcieng\bciengj" /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
70
# ADD BASE RSC /l 0x409 /d "_DEBUG"
70
# ADD BASE RSC /l 0x409 /d "_DEBUG"
71
# ADD RSC /l 0x409 /d "_DEBUG"
71
# ADD RSC /l 0x409 /d "_DEBUG"
72
BSC32=bscmake.exe
72
BSC32=bscmake.exe
(-)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 (-9 / +806 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 259-266 CCPUtf8Info::~CCPUtf8Info() Link Here
259
void
262
void
260
CCPUtf8Info::Read(CJStream& i_jstream)
263
CCPUtf8Info::Read(CJStream& i_jstream)
261
{
264
{
262
	i_jstream >> m_u2Length;
265
	i_jstream >> m_u2Length; 
263
	m_pu1Bytes = new u1[m_u2Length];
266
	m_pu1Bytes = new u1[m_u2Length + 1];
267
	m_pu1Bytes[m_u2Length] = 0; /*Helps standard string functions find end of the string*/
264
	i_jstream.ReadUtf8((void*)m_pu1Bytes, m_u2Length);
268
	i_jstream.ReadUtf8((void*)m_pu1Bytes, m_u2Length);
265
}
269
}
266
270
Lines 1738-1743 CJAttribs::Read(CJStream& i_jstream) Link Here
1738
		{
1742
		{
1739
			pCurrent = new CLocalVariableTypeTableAttribute(m_pClassFile);
1743
			pCurrent = new CLocalVariableTypeTableAttribute(m_pClassFile);
1740
		}
1744
		}
1745
 		else if(*pcpUtf8 == "StackMapTable")
1746
		{
1747
			pCurrent = new CStackMapTableAttribute(m_pClassFile);
1748
		}
1741
		else if(*pcpUtf8 == "Exceptions")
1749
		else if(*pcpUtf8 == "Exceptions")
1742
		{
1750
		{
1743
			pCurrent = new CExceptionsAttribute(m_pClassFile);
1751
			pCurrent = new CExceptionsAttribute(m_pClassFile);
Lines 2119-2124 CCodeAttribute::GetLocalVariableTypes() Link Here
2119
	return NULL;
2127
	return NULL;
2120
}
2128
}
2121
2129
2130
//------------------------------------------------------------------------------
2131
CStackMapTableAttribute* 
2132
CCodeAttribute::GetStackMaps()
2133
{
2134
	for(CJAttribs::iterator iter = m_Attribs.begin(); iter < m_Attribs.end(); iter++)
2135
	{
2136
		if(*(*iter)->GetName() == "StackMapTable")
2137
			return (CStackMapTableAttribute*)*iter;
2138
	}
2139
	return NULL;
2140
}
2141
2142
//------------------------------------------------------------------------------
2143
CStackMapTableAttribute* 
2144
CCodeAttribute::GetOrCreateStackMaps()
2145
{
2146
    // Return the StackMapTable attribute of this Code attribute, creating a new one
2147
    // if such an attribute does not exist
2148
2149
    CStackMapTableAttribute* result = NULL;
2150
	for(CJAttribs::iterator iter = m_Attribs.begin(); iter < m_Attribs.end(); iter++)
2151
	{
2152
		if(*(*iter)->GetName() == "StackMapTable")
2153
        {
2154
			result = (CStackMapTableAttribute*)*iter;
2155
        }
2156
	}
2157
2158
    if (result == NULL)
2159
    {
2160
        result = new CStackMapTableAttribute(m_pClassFile);
2161
        m_Attribs.push_back(result);
2162
    }
2163
    return result;
2164
}
2122
2165
2123
//==============================================================================
2166
//==============================================================================
2124
// CExceptionsAttribute implementation
2167
// CExceptionsAttribute implementation
Lines 2500-2505 CSourceDirAttribute::CSourceDirAttribute Link Here
2500
{}
2543
{}
2501
2544
2502
//==============================================================================
2545
//==============================================================================
2546
// CStackMapTableAttribute implementation
2547
//
2548
CVerificationTypeInfo::CVerificationTypeInfo(u1 i_u1Tag)
2549
: m_u1Tag(i_u1Tag)
2550
{
2551
}
2552
2553
CVerificationTypeInfo::~CVerificationTypeInfo()
2554
{
2555
}
2556
2557
void
2558
CVerificationTypeInfo::Read(CJStream& i_jstream)
2559
{
2560
    // m_u1Tag is read by the CVerificationTypes container.
2561
}
2562
2563
u2
2564
CVerificationTypeInfo::Read(u1 *i_tbl)
2565
{
2566
    // m_u1Tag is read by the CVerificationTypes container.
2567
	return 0;
2568
}
2569
2570
void
2571
CVerificationTypeInfo::Write(CJStream& i_jstream) const
2572
{
2573
    i_jstream << m_u1Tag;
2574
}
2575
2576
u4
2577
CVerificationTypeInfo::GetSize() const
2578
{
2579
    return sizeof(m_u1Tag);
2580
}
2581
2582
//------------------------------------------------------------------------------
2583
CVerificationTypes::~CVerificationTypes()
2584
{
2585
    for (iterator iter = begin(); iter != end(); iter++)
2586
    {
2587
        delete *iter;
2588
    }
2589
}
2590
2591
CVerificationTypes::CVerificationTypes(const CVerificationTypes &i_VerTypes)
2592
{
2593
    *this = i_VerTypes;
2594
}
2595
2596
CVerificationTypes&
2597
CVerificationTypes::operator =(const CVerificationTypes &i_VerTypes)
2598
{
2599
	for(iterator iter = begin(); iter != end(); iter++)
2600
	{
2601
		delete *iter;
2602
	}
2603
	if(!i_VerTypes.empty())
2604
	{
2605
		const_iterator iterIn;
2606
		clear();
2607
		for(iterIn = i_VerTypes.begin(); iterIn != i_VerTypes.end(); iterIn++)
2608
		{
2609
			push_back((*iterIn)->Clone());
2610
		}
2611
	}
2612
	return *this;
2613
}
2614
2615
void
2616
CVerificationTypes::Read(CJStream& i_jstream, u2 i_u2EntriesToRead)
2617
{
2618
    CVerificationTypeInfo* pCurrent;
2619
    
2620
    resize(i_u2EntriesToRead);
2621
    for(u2 u2Ind = 0; u2Ind < i_u2EntriesToRead; u2Ind++)
2622
    {
2623
        u1 u1Tag;
2624
        i_jstream >> u1Tag;
2625
        switch (u1Tag)
2626
        {
2627
        case ITEM_Top:
2628
        case ITEM_Integer:
2629
        case ITEM_Float:
2630
        case ITEM_Double:
2631
        case ITEM_Long:
2632
        case ITEM_Null:
2633
        case ITEM_UninitializedThis:
2634
            pCurrent = new CVerificationTypeInfo(u1Tag);
2635
            break;
2636
        case ITEM_Object:
2637
            pCurrent = new CVerificationTypeObjectInfo(u1Tag);
2638
            break;
2639
        case ITEM_Uninitialized:
2640
            pCurrent = new CVerificationTypeUninitializedVariableInfo(u1Tag);
2641
            break;
2642
        default:
2643
            throw CJClassFileException(CJClassFileException::X_INTERNAL_ERROR);
2644
        }
2645
2646
        pCurrent->Read(i_jstream);
2647
        (*this)[u2Ind] = pCurrent;
2648
    }
2649
}
2650
2651
void 
2652
CVerificationTypes::Write(CJStream& i_jstream) const
2653
{
2654
    for (u2 u2Ind = 0; u2Ind < size(); u2Ind++)
2655
    {
2656
        (*this)[u2Ind]->Write(i_jstream);
2657
    }
2658
}
2659
2660
u4
2661
CVerificationTypes::GetSize() const
2662
{
2663
    u4 u4Size = 0;
2664
	for (const_iterator iter = begin(); iter != end(); iter++)
2665
	{
2666
		u4Size += (*iter)->GetSize();
2667
	}
2668
    return u4Size;
2669
}
2670
2671
//------------------------------------------------------------------------------
2672
CVerificationTypeObjectInfo::CVerificationTypeObjectInfo(u1 i_u1Tag)
2673
: CVerificationTypeInfo(i_u1Tag)
2674
{
2675
}
2676
2677
CVerificationTypeObjectInfo::~CVerificationTypeObjectInfo()
2678
{
2679
}
2680
2681
void
2682
CVerificationTypeObjectInfo::Read(CJStream& i_jstream)
2683
{
2684
    CVerificationTypeInfo::Read(i_jstream);
2685
    i_jstream >> m_u2CpoolIndex;
2686
}
2687
2688
void
2689
CVerificationTypeObjectInfo::Write(CJStream& i_jstream) const
2690
{
2691
    CVerificationTypeInfo::Write(i_jstream);
2692
    i_jstream << m_u2CpoolIndex;
2693
}
2694
2695
u4
2696
CVerificationTypeObjectInfo::GetSize() const
2697
{
2698
    u4 u4Size = CVerificationTypeInfo::GetSize()
2699
        + sizeof(m_u2CpoolIndex);
2700
    return u4Size;
2701
}
2702
2703
//------------------------------------------------------------------------------
2704
CVerificationTypeUninitializedVariableInfo::CVerificationTypeUninitializedVariableInfo(u1 i_u1Tag)
2705
: CVerificationTypeInfo(i_u1Tag)
2706
{
2707
}
2708
2709
CVerificationTypeUninitializedVariableInfo::~CVerificationTypeUninitializedVariableInfo()
2710
{
2711
}
2712
2713
void
2714
CVerificationTypeUninitializedVariableInfo::Read(CJStream& i_jstream)
2715
{
2716
    CVerificationTypeInfo::Read(i_jstream);
2717
    i_jstream >> m_u2Offset;
2718
}
2719
2720
void
2721
CVerificationTypeUninitializedVariableInfo::Write(CJStream& i_jstream) const
2722
{
2723
    CVerificationTypeInfo::Write(i_jstream);
2724
    i_jstream << m_u2Offset;
2725
}
2726
2727
u4
2728
CVerificationTypeUninitializedVariableInfo::GetSize() const
2729
{
2730
    u4 u4Size = CVerificationTypeInfo::GetSize()
2731
        + sizeof(m_u2Offset);
2732
    return u4Size;
2733
}
2734
2735
//------------------------------------------------------------------------------
2736
CStackMapFrameInfo::CStackMapFrameInfo(u1 i_u1FrameType)
2737
: m_u1FrameType(i_u1FrameType)
2738
{
2739
    m_u2ByteCodeOffset = 0;
2740
    m_u2OffsetDelta = 0;
2741
}
2742
2743
CStackMapFrameInfo::~CStackMapFrameInfo()
2744
{
2745
}
2746
2747
void
2748
CStackMapFrameInfo::Read(CJStream& i_jstream)
2749
{
2750
    // m_u1FrameType is read by the CStackMapTable container
2751
}
2752
2753
void
2754
CStackMapFrameInfo::Write(CJStream& i_jstream) const
2755
{
2756
    i_jstream << m_u1FrameType;
2757
}
2758
2759
u4
2760
CStackMapFrameInfo::GetSize() const
2761
{
2762
    return sizeof(m_u1FrameType);
2763
}
2764
2765
void 
2766
CStackMapFrameInfo::SetByteCodeOffset(u2 i_u2Offset) 
2767
{ 
2768
    m_u2ByteCodeOffset = i_u2Offset; 
2769
}
2770
2771
void
2772
CStackMapFrameInfo::AdjustOffsetDelta(int i_s2PrevFrameOffset)
2773
{
2774
    int newOffsetDelta = m_u2ByteCodeOffset - 1 - i_s2PrevFrameOffset;
2775
    if (newOffsetDelta < 0)
2776
    {
2777
        // Frame order was changed. This is not supported
2778
        throw CJClassFileException(CJClassFileException::X_INTERNAL_ERROR);
2779
    }
2780
    m_u2OffsetDelta = (u2)newOffsetDelta; // this is a safe cast since newDelta >= 1
2781
}
2782
2783
CStackMapFrameInfo::CStackMapFrameInfo(const CStackMapFrameInfo &i_Other)
2784
: m_u2ByteCodeOffset(i_Other.m_u2ByteCodeOffset), m_u2OffsetDelta(i_Other.m_u2OffsetDelta),
2785
    m_u1FrameType(i_Other.m_u1FrameType)
2786
{
2787
}
2788
2789
//------------------------------------------------------------------------------
2790
CStackMapSameFrameInfo::CStackMapSameFrameInfo(u1 i_u1FrameType, bool i_IsExtended)
2791
: CStackMapFrameInfo(i_u1FrameType), m_IsExtended(i_IsExtended)
2792
{
2793
}
2794
2795
CStackMapSameFrameInfo::~CStackMapSameFrameInfo()
2796
{
2797
}
2798
2799
void
2800
CStackMapSameFrameInfo::Read(CJStream& i_jstream)
2801
{
2802
    CStackMapFrameInfo::Read(i_jstream);
2803
    if (m_IsExtended)
2804
    {
2805
        // SAME_FRAME_EXTENDED type
2806
        i_jstream >> m_u2OffsetDelta;
2807
    }
2808
    else        
2809
    {
2810
        // SAME frame type. offset_delta is stored in the tag
2811
        m_u2OffsetDelta = GetFrameType();
2812
    }
2813
}
2814
2815
void
2816
CStackMapSameFrameInfo::Write(CJStream& i_jstream) const
2817
{
2818
    CStackMapFrameInfo::Write(i_jstream);
2819
    if (m_IsExtended)
2820
    {
2821
        // SAME_FRAME_EXTENDED type
2822
        i_jstream << m_u2OffsetDelta;
2823
    }
2824
}
2825
2826
u4
2827
CStackMapSameFrameInfo::GetSize() const
2828
{
2829
    u4 u4Size = CStackMapFrameInfo::GetSize();
2830
    if (m_IsExtended)
2831
    {
2832
        u4Size += sizeof(m_u2OffsetDelta);
2833
    }
2834
    return u4Size;
2835
}
2836
2837
void
2838
CStackMapSameFrameInfo::AdjustOffsetDelta(int i_s2PrevFrameOffset)
2839
{
2840
    CStackMapFrameInfo::AdjustOffsetDelta(i_s2PrevFrameOffset);
2841
    if (m_u2OffsetDelta > 63)
2842
    {
2843
        // Frame type is SAME_FRAME_EXTENDED
2844
        m_u1FrameType = SAME_FRAME_EXTENDED;
2845
        m_IsExtended = true;
2846
    }
2847
    else
2848
    {
2849
        // Frame type is SAME_FRAME. offset_delta is stored in the tag
2850
        m_u1FrameType = (u1)m_u2OffsetDelta; // this is safe since m_u2OffsetDelta <= 63
2851
        m_IsExtended = false;
2852
    }
2853
}
2854
2855
CStackMapFrameInfo*
2856
CStackMapSameFrameInfo::Clone() const
2857
{
2858
    return new CStackMapSameFrameInfo(*this);
2859
}
2860
2861
//------------------------------------------------------------------------------
2862
CStackMapChopFrameInfo::CStackMapChopFrameInfo(u1 i_u1FrameType)
2863
: CStackMapFrameInfo(i_u1FrameType)
2864
{
2865
}
2866
2867
CStackMapChopFrameInfo::~CStackMapChopFrameInfo()
2868
{
2869
}
2870
2871
void
2872
CStackMapChopFrameInfo::Read(CJStream& i_jstream)
2873
{
2874
    CStackMapFrameInfo::Read(i_jstream);
2875
    i_jstream >> m_u2OffsetDelta;
2876
}
2877
2878
void
2879
CStackMapChopFrameInfo::Write(CJStream& i_jstream) const
2880
{
2881
    CStackMapFrameInfo::Write(i_jstream);
2882
    i_jstream << m_u2OffsetDelta;
2883
}
2884
2885
u4
2886
CStackMapChopFrameInfo::GetSize() const
2887
{
2888
    u4 u4Size = CStackMapFrameInfo::GetSize()
2889
        + sizeof(m_u2OffsetDelta);
2890
    return u4Size;
2891
}
2892
2893
CStackMapFrameInfo*
2894
CStackMapChopFrameInfo::Clone() const
2895
{
2896
    return new CStackMapChopFrameInfo(*this);
2897
}
2898
2899
//------------------------------------------------------------------------------
2900
CStackMapSameLocals1StackItemFrameInfo::CStackMapSameLocals1StackItemFrameInfo(u1 i_u1FrameType, 
2901
                                                                               bool i_IsExtended)
2902
: CStackMapFrameInfo(i_u1FrameType), m_IsExtended(i_IsExtended)
2903
{
2904
}
2905
2906
CStackMapSameLocals1StackItemFrameInfo::~CStackMapSameLocals1StackItemFrameInfo()
2907
{
2908
}
2909
2910
void
2911
CStackMapSameLocals1StackItemFrameInfo::Read(CJStream& i_jstream)
2912
{
2913
    CStackMapFrameInfo::Read(i_jstream);
2914
    if (m_IsExtended)
2915
    {
2916
        // SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED type
2917
        i_jstream >> m_u2OffsetDelta;
2918
    }
2919
    else        
2920
    {
2921
        // SAME_LOCALS_1_STACK_ITEM_FRAME frame type
2922
        m_u2OffsetDelta = GetFrameType() - 64;
2923
    }
2924
    m_Stack.Read(i_jstream, 1); // must hold exactly one stack item
2925
}
2926
2927
void
2928
CStackMapSameLocals1StackItemFrameInfo::Write(CJStream& i_jstream) const
2929
{
2930
    CStackMapFrameInfo::Write(i_jstream);
2931
    if (m_IsExtended)
2932
    {
2933
        // SAME_FRAME_EXTENDED type
2934
        i_jstream << m_u2OffsetDelta;
2935
    }
2936
    m_Stack.Write(i_jstream);
2937
}
2938
2939
u4
2940
CStackMapSameLocals1StackItemFrameInfo::GetSize() const
2941
{
2942
    u4 u4Size = CStackMapFrameInfo::GetSize();
2943
    if (m_IsExtended)
2944
    {
2945
        u4Size += sizeof(m_u2OffsetDelta);
2946
    }
2947
    u4Size += m_Stack.GetSize();
2948
    return u4Size;
2949
}
2950
2951
void
2952
CStackMapSameLocals1StackItemFrameInfo::AdjustOffsetDelta(int i_s2PrevFrameOffset)
2953
{
2954
    CStackMapFrameInfo::AdjustOffsetDelta(i_s2PrevFrameOffset);
2955
    if (m_u2OffsetDelta + 64 > 127)
2956
    {
2957
        // Frame type is SAME_LOCALS_1_STACK_FRAME_EXTENDED
2958
        m_u1FrameType = SAME_LOCALS_1_STACK_ITEM_EXTENDED;
2959
        m_IsExtended = true;
2960
    }
2961
    else
2962
    {
2963
        // Frame type is SAME_LOCALS_1_STACK_FRAME. offset_delta is stored in the tag
2964
        m_u1FrameType = (u1)(m_u2OffsetDelta + 64); // this is safe since m_u2OffsetDelta <= 63
2965
        m_IsExtended = false;
2966
    }
2967
}
2968
2969
CStackMapFrameInfo*
2970
CStackMapSameLocals1StackItemFrameInfo::Clone() const
2971
{
2972
    return new CStackMapSameLocals1StackItemFrameInfo(*this);
2973
}
2974
2975
CStackMapSameLocals1StackItemFrameInfo::CStackMapSameLocals1StackItemFrameInfo(const CStackMapSameLocals1StackItemFrameInfo &i_Other)
2976
: CStackMapFrameInfo(i_Other), m_Stack(i_Other.m_Stack), m_IsExtended(i_Other.m_IsExtended)
2977
{
2978
}
2979
2980
//------------------------------------------------------------------------------
2981
CStackMapAppendFrameInfo::CStackMapAppendFrameInfo(u1 i_u1FrameType)
2982
: CStackMapFrameInfo(i_u1FrameType)
2983
{
2984
}
2985
2986
CStackMapAppendFrameInfo::~CStackMapAppendFrameInfo()
2987
{
2988
}
2989
2990
void
2991
CStackMapAppendFrameInfo::Read(CJStream& i_jstream)
2992
{
2993
    CStackMapFrameInfo::Read(i_jstream);
2994
    i_jstream >> m_u2OffsetDelta;
2995
    m_Locals.Read(i_jstream, GetFrameType() - 251);
2996
}
2997
2998
void
2999
CStackMapAppendFrameInfo::Write(CJStream& i_jstream) const
3000
{
3001
    CStackMapFrameInfo::Write(i_jstream);
3002
    i_jstream << m_u2OffsetDelta;
3003
    m_Locals.Write(i_jstream);
3004
}
3005
3006
u4
3007
CStackMapAppendFrameInfo::GetSize() const
3008
{
3009
    u4 u4Size = CStackMapFrameInfo::GetSize()
3010
        + sizeof(m_u2OffsetDelta)
3011
        + m_Locals.GetSize();
3012
    return u4Size;
3013
}
3014
3015
CStackMapFrameInfo*
3016
CStackMapAppendFrameInfo::Clone() const
3017
{
3018
    return new CStackMapAppendFrameInfo(*this);
3019
}
3020
3021
CStackMapAppendFrameInfo::CStackMapAppendFrameInfo(const CStackMapAppendFrameInfo &i_Other)
3022
: CStackMapFrameInfo(i_Other), m_Locals(i_Other.m_Locals)
3023
{
3024
}
3025
3026
//------------------------------------------------------------------------------
3027
CStackMapFullFrameInfo::CStackMapFullFrameInfo(u1 i_u1FrameType)
3028
: CStackMapFrameInfo(i_u1FrameType), m_u2NumberOfLocals(0), m_u2NumberOfStackItems(0)
3029
{
3030
}
3031
3032
CStackMapFullFrameInfo::~CStackMapFullFrameInfo()
3033
{
3034
}
3035
3036
void
3037
CStackMapFullFrameInfo::Read(CJStream& i_jstream)
3038
{
3039
    CStackMapFrameInfo::Read(i_jstream);
3040
    i_jstream >> m_u2OffsetDelta
3041
              >> m_u2NumberOfLocals;
3042
    m_Locals.Read(i_jstream, m_u2NumberOfLocals);
3043
    i_jstream >> m_u2NumberOfStackItems;
3044
    m_Stack.Read(i_jstream, m_u2NumberOfStackItems);
3045
}
3046
3047
void
3048
CStackMapFullFrameInfo::Write(CJStream& i_jstream) const
3049
{
3050
    CStackMapFrameInfo::Write(i_jstream);
3051
    i_jstream << m_u2OffsetDelta
3052
              << m_u2NumberOfLocals;
3053
    m_Locals.Write(i_jstream);
3054
    i_jstream << m_u2NumberOfStackItems;
3055
    m_Stack.Write(i_jstream);
3056
}
3057
3058
u4
3059
CStackMapFullFrameInfo::GetSize() const
3060
{
3061
    u4 u4Size = CStackMapFrameInfo::GetSize()
3062
        + sizeof(m_u2OffsetDelta)
3063
        + sizeof(m_u2NumberOfLocals)
3064
        + m_Locals.GetSize()
3065
        + sizeof(m_u2NumberOfStackItems)
3066
        + m_Stack.GetSize();
3067
    return u4Size;
3068
}
3069
3070
CStackMapFrameInfo*
3071
CStackMapFullFrameInfo::Clone() const
3072
{
3073
    return new CStackMapFullFrameInfo(*this);
3074
}
3075
3076
CStackMapFullFrameInfo::CStackMapFullFrameInfo(const CStackMapFullFrameInfo &i_Other)
3077
: CStackMapFrameInfo(i_Other), m_Locals(i_Other.m_Locals), m_Stack(i_Other.m_Stack),
3078
    m_u2NumberOfLocals(i_Other.m_u2NumberOfLocals), 
3079
    m_u2NumberOfStackItems(i_Other.m_u2NumberOfStackItems)
3080
{
3081
}
3082
3083
//------------------------------------------------------------------------------
3084
CStackMapTable::~CStackMapTable()
3085
{
3086
    for (iterator iter = begin(); iter != end(); iter++)
3087
    {
3088
        delete *iter;
3089
    }
3090
}
3091
3092
void
3093
CStackMapTable::Read(CJStream& i_jstream)
3094
{
3095
    u2 u2Size;
3096
    CStackMapFrameInfo* pCurrent;
3097
    int s2PrevFrameOffset = -1;
3098
3099
    i_jstream >> u2Size;
3100
    resize(u2Size);
3101
    for(u2 u2Ind = 0; u2Ind < u2Size; u2Ind++)
3102
    {
3103
        u1 u1FrameType;
3104
        i_jstream >> u1FrameType;
3105
        if (u1FrameType >= 0 && u1FrameType <= 63)
3106
        {
3107
            pCurrent = new CStackMapSameFrameInfo(u1FrameType, false);
3108
        }
3109
        else if (u1FrameType >= 64 && u1FrameType <= 127)
3110
        {
3111
            pCurrent = new CStackMapSameLocals1StackItemFrameInfo(u1FrameType, false);
3112
        }
3113
        else if (u1FrameType == SAME_LOCALS_1_STACK_ITEM_EXTENDED)
3114
        {
3115
            pCurrent = new CStackMapSameLocals1StackItemFrameInfo(u1FrameType, true);
3116
        }
3117
        else if (u1FrameType >= 248 && u1FrameType <= 250)
3118
        {
3119
            pCurrent = new CStackMapChopFrameInfo(u1FrameType);
3120
        }
3121
        else if (u1FrameType == SAME_FRAME_EXTENDED)
3122
        {
3123
            pCurrent = new CStackMapSameFrameInfo(u1FrameType, true);
3124
        }
3125
        else if (u1FrameType >= 252 && u1FrameType <= 254)
3126
        {
3127
            pCurrent = new CStackMapAppendFrameInfo(u1FrameType);
3128
        }
3129
        else if (u1FrameType == FULL_FRAME)
3130
        {
3131
            pCurrent = new CStackMapFullFrameInfo(u1FrameType);
3132
        }
3133
        else
3134
        {
3135
            // Unknown frame type
3136
            throw CJClassFileException(CJClassFileException::X_INTERNAL_ERROR);
3137
        }
3138
        
3139
        pCurrent->Read(i_jstream);
3140
        pCurrent->SetByteCodeOffset(s2PrevFrameOffset + 1 + pCurrent->m_u2OffsetDelta);
3141
        (*this)[u2Ind] = pCurrent;
3142
        s2PrevFrameOffset = pCurrent->GetByteCodeOffset();
3143
    }
3144
}
3145
3146
void
3147
CStackMapTable::AdjustOffsetDeltas()
3148
{
3149
    // Recalculate offset deltas for all frames. This function must be called before
3150
    // writing the Stack Map Table to the class file or calculating its size
3151
    CStackMapFrameInfo* pCurrent;
3152
    int s2PrevFrameOffset = -1;
3153
3154
    for (u2 u2Ind = 0; u2Ind < size(); u2Ind++)
3155
    {
3156
        pCurrent = (*this)[u2Ind];
3157
        pCurrent->AdjustOffsetDelta(s2PrevFrameOffset);
3158
        s2PrevFrameOffset = pCurrent->GetByteCodeOffset();
3159
    }
3160
}
3161
3162
CStackMapFrameInfo*
3163
CStackMapTable::GetFrameAtOffset(u2 i_u2Offset)
3164
{
3165
    bool found = false;
3166
    iterator it = begin();
3167
    for (; it != end(); ++it)
3168
    {
3169
        if ((*it)->GetByteCodeOffset() == i_u2Offset)
3170
        {
3171
            found = true;
3172
            break;
3173
        }
3174
    }
3175
3176
    if (found)
3177
    {
3178
        return (*it);
3179
    }
3180
    else
3181
    {
3182
        return NULL;
3183
    }
3184
}
3185
3186
void
3187
CStackMapTable::Write(CJStream& i_jstream) const
3188
{
3189
    i_jstream << (u2)size(); // the number_of_entries field
3190
3191
    CStackMapFrameInfo* pCurrent;
3192
    int s2PrevFrameOffset = -1;
3193
3194
    for (u2 u2Ind = 0; u2Ind < size(); u2Ind++)
3195
    {
3196
        pCurrent = (*this)[u2Ind];
3197
        pCurrent->Write(i_jstream);
3198
        s2PrevFrameOffset = pCurrent->GetByteCodeOffset();
3199
    }
3200
}
3201
3202
u4
3203
CStackMapTable::GetSize() const
3204
{
3205
    u4 u4Size = sizeof(u2); // the number_of_entries field
3206
    for (const_iterator iter = begin(); iter != end(); iter++)
3207
    {
3208
        u4Size += (*iter)->GetSize();
3209
    }
3210
    return u4Size;
3211
}
3212
3213
CStackMapTable& 
3214
CStackMapTable::operator = (const CStackMapTable& i_StackMaps)
3215
{
3216
	for(iterator iter = begin(); iter != end(); iter++)
3217
	{
3218
		delete *iter;
3219
	}
3220
	if(!i_StackMaps.empty())
3221
	{
3222
		const_iterator iterIn;
3223
		clear();
3224
		for(iterIn = i_StackMaps.begin(); iterIn != i_StackMaps.end(); iterIn++)
3225
		{
3226
			push_back((*iterIn)->Clone());
3227
		}
3228
	}
3229
	return *this;
3230
}
3231
3232
//------------------------------------------------------------------------------
3233
CStackMapTableAttribute::CStackMapTableAttribute(CJClassFile* i_pClassFile)
3234
: CAttributeInfo(i_pClassFile)
3235
{
3236
    u2 u2NameInd = i_pClassFile->GetConstPool()->Add(new CCPUtf8Info("StackMapTable"));
3237
    m_u2NameInd = u2NameInd;
3238
    m_StackMapTable.clear();
3239
}
3240
3241
CStackMapTableAttribute::~CStackMapTableAttribute()
3242
{
3243
}
3244
3245
void
3246
CStackMapTableAttribute::Read(CJStream& i_jstream)
3247
{
3248
	CAttributeInfo::Read(i_jstream);
3249
    m_StackMapTable.Read(i_jstream);
3250
}
3251
3252
void
3253
CStackMapTableAttribute::Write(CJStream& i_jstream) const
3254
{
3255
	const u4 u4Length = GetLength() - CAttributeInfo::SizeOf();
3256
	i_jstream	<<	m_u2NameInd
3257
				<<	u4Length;
3258
    m_StackMapTable.Write(i_jstream);
3259
}
3260
3261
u4
3262
CStackMapTableAttribute::GetSize() const
3263
{
3264
    return GetLength();
3265
}
3266
3267
u4
3268
CStackMapTableAttribute::GetLength() const
3269
{
3270
    u4 u4Length = CAttributeInfo::SizeOf()
3271
        + m_StackMapTable.GetSize();
3272
    return u4Length;
3273
}
3274
3275
void
3276
CStackMapTableAttribute::RereadFromBuffer(u1 *i_u1Tbl) 
3277
{
3278
	u2 u2skip = 0;
3279
	u4 u4attributeLenght = 0;
3280
	
3281
	if (i_u1Tbl == NULL) return;
3282
3283
	u2skip = i_u1Tbl[0];
3284
	u2skip <<= 8;
3285
	u2skip |= i_u1Tbl[1];
3286
3287
	u4attributeLenght = i_u1Tbl[2];
3288
	u4attributeLenght <<= 8;
3289
	u4attributeLenght |= i_u1Tbl[3];
3290
	u4attributeLenght <<= 8;
3291
	u4attributeLenght |= i_u1Tbl[4];
3292
	u4attributeLenght <<= 8;
3293
	u4attributeLenght |= i_u1Tbl[5];
3294
	m_u4Length = u4attributeLenght;
3295
	CJMemStream memstream;
3296
	memstream.Open(&i_u1Tbl[2], u4attributeLenght 
3297
		+ sizeof(u2) /*part of attribute header (its length)*/
3298
		+ 2 /*workaround for end buffer checking*/);
3299
	CJStream mem_jstream(&memstream);
3300
	//GetStackMapTable().RereadFromBuffer(&i_u1Tbl[6]);
3301
	this->Read(mem_jstream);
3302
}
3303
//==============================================================================
2503
// CJClassFile implementation
3304
// CJClassFile implementation
2504
//
3305
//
2505
3306
Lines 2544-2555 CJClassFile::Read(CJStream& i_jstream) Link Here
2544
	{
3345
	{
2545
		throw CJClassFileException(CJClassFileException::X_BAD_MAGIC);
3346
		throw CJClassFileException(CJClassFileException::X_BAD_MAGIC);
2546
	}
3347
	}
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;
3348
	i_jstream	>>	m_u2MinorVersion;
3349
	i_jstream	>>	m_u2MajorVersion;
2553
	m_pConstPool->Read(i_jstream);
3350
	m_pConstPool->Read(i_jstream);
2554
	i_jstream	>>	m_u2AccessFlags
3351
	i_jstream	>>	m_u2AccessFlags
2555
				>>	m_u2ThisClass
3352
				>>	m_u2ThisClass
Lines 2565-2572 void Link Here
2565
CJClassFile::Write(CJStream& i_jstream) const
3362
CJClassFile::Write(CJStream& i_jstream) const
2566
{
3363
{
2567
	i_jstream	<<	m_u4Magic
3364
	i_jstream	<<	m_u4Magic
2568
				<<	m_u2MajorVersion
3365
				<<	m_u2MinorVersion
2569
				<<	m_u2MinorVersion;
3366
				<<	m_u2MajorVersion;
2570
	m_pConstPool->Write(i_jstream);
3367
	m_pConstPool->Write(i_jstream);
2571
	i_jstream	<<	m_u2AccessFlags
3368
	i_jstream	<<	m_u2AccessFlags
2572
				<<	m_u2ThisClass
3369
				<<	m_u2ThisClass
(-)src-native/BCI/JClass/JClassFile.h (-1 / +289 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 672-677 public: Link Here
672
	CLineNumberTableAttribute* GetLineNumbers();
673
	CLineNumberTableAttribute* GetLineNumbers();
673
	CLocalVariableTableAttribute* GetLocalVariables();
674
	CLocalVariableTableAttribute* GetLocalVariables();
674
	CLocalVariableTypeTableAttribute* GetLocalVariableTypes();
675
	CLocalVariableTypeTableAttribute* GetLocalVariableTypes();
676
    CStackMapTableAttribute* GetStackMaps();
677
    CStackMapTableAttribute* GetOrCreateStackMaps();
678
675
679
676
protected:
680
protected:
677
	u2			m_u2MaxStack;
681
	u2			m_u2MaxStack;
Lines 899-904 private: Link Here
899
};
903
};
900
904
901
//------------------------------------------------------------------------------
905
//------------------------------------------------------------------------------
906
// Verification Type Information (new in Java 6)
907
//
908
// Represents the following verification types: Top, Integer, Float, Double, Long, Null,
909
// UninitializedThis
910
//
911
class CVerificationTypeInfo
912
{
913
public:
914
    CVerificationTypeInfo(u1 i_u1Tag);
915
    ~CVerificationTypeInfo();
916
    virtual void Read(CJStream& i_jstream);
917
	virtual u2 Read(u1* i_tbl);
918
	virtual void Write(CJStream& i_jstream) const;
919
	virtual u4	 GetSize() const;
920
    virtual CVerificationTypeInfo* Clone() const
921
    {
922
        return new CVerificationTypeInfo(*this);
923
    }
924
925
    u1 GetTag() { return m_u1Tag; }
926
927
private:
928
    u1 m_u1Tag;
929
};
930
931
//------------------------------------------------------------------------------
932
// Verification Type Information Vector
933
//
934
class CVerificationTypes : public vector<CVerificationTypeInfo*>
935
{
936
public:
937
    CVerificationTypes() { clear(); }
938
    CVerificationTypes(const CVerificationTypes &i_VerTypes);
939
	~CVerificationTypes();
940
941
    CVerificationTypes& operator = (const CVerificationTypes &i_VerTypes);
942
    
943
    virtual void	Read(CJStream& i_jstream, u2 i_u2EntriesToRead);
944
	virtual void	Write(CJStream& i_jstream) const;
945
	virtual u4	    GetSize() const;
946
947
private:
948
};
949
950
//------------------------------------------------------------------------------
951
// Verification Type Information: Object (new in Java 6)
952
//
953
class CVerificationTypeObjectInfo : public CVerificationTypeInfo
954
{
955
public:
956
    CVerificationTypeObjectInfo(u1 i_u1Tag);
957
    ~CVerificationTypeObjectInfo();
958
    virtual void Read(CJStream& i_jstream);
959
	virtual void Write(CJStream& i_jstream) const;
960
	virtual u4	 GetSize() const;
961
    virtual CVerificationTypeInfo* Clone() const
962
    {
963
        return new CVerificationTypeObjectInfo(*this);
964
    }
965
966
    u2   GetCpoolIndex() { return m_u2CpoolIndex; }
967
    void SetCpoolIndex(u2 i_u2CpoolIndex) { m_u2CpoolIndex = i_u2CpoolIndex; }
968
969
private:
970
    u2 m_u2CpoolIndex;
971
};
972
973
//------------------------------------------------------------------------------
974
// Verification Type Information: Uninitialized Variable (new in Java 6)
975
//
976
class CVerificationTypeUninitializedVariableInfo : public CVerificationTypeInfo
977
{
978
public:
979
    CVerificationTypeUninitializedVariableInfo(u1 i_u1Tag);
980
    ~CVerificationTypeUninitializedVariableInfo();
981
    virtual void Read(CJStream& i_jstream);
982
	virtual void Write(CJStream& i_jstream) const;
983
	virtual u4	 GetSize() const;
984
    virtual CVerificationTypeInfo* Clone() const
985
    {
986
        return new CVerificationTypeUninitializedVariableInfo(*this);
987
    }
988
989
    u2   GetOffset() { return m_u2Offset; }
990
    void SetOffset(u2 i_u2Offset) { m_u2Offset = i_u2Offset; }
991
992
private:
993
    u2 m_u2Offset;
994
};
995
996
997
//------------------------------------------------------------------------------
998
// Stack Map Frame Information (new in Java 6)
999
//
1000
class CStackMapFrameInfo
1001
{
1002
    friend class CStackMapTable;
1003
public:
1004
    CStackMapFrameInfo(u1 i_u1FrameType);
1005
    CStackMapFrameInfo(const CStackMapFrameInfo &i_Other);
1006
    ~CStackMapFrameInfo();
1007
1008
    virtual void Read(CJStream& i_jstream);
1009
	virtual void Write(CJStream& i_jstream) const;
1010
	virtual u4	 GetSize() const;
1011
    virtual CStackMapFrameInfo* Clone() const = 0;
1012
    
1013
    u1 GetFrameType() const { return m_u1FrameType; }
1014
    u2 GetByteCodeOffset() { return m_u2ByteCodeOffset; }
1015
    void SetByteCodeOffset(u2 i_u2Offset);
1016
1017
protected:
1018
    virtual void AdjustOffsetDelta(int i_s2PrevFrameOffset);
1019
    
1020
    u2 m_u2ByteCodeOffset;
1021
    u2 m_u2OffsetDelta;
1022
    u1 m_u1FrameType;
1023
};
1024
1025
//------------------------------------------------------------------------------
1026
// Stack Map Frame Information: same_frame and same_frame_extended (new in Java 6)
1027
//
1028
class CStackMapSameFrameInfo : public CStackMapFrameInfo
1029
{
1030
    friend class CStackMapTable;
1031
public:
1032
    CStackMapSameFrameInfo(u1 i_u1FrameType, bool i_IsExtended);
1033
    ~CStackMapSameFrameInfo();
1034
1035
    virtual void Read(CJStream& i_jstream);
1036
	virtual void Write(CJStream& i_jstream) const;
1037
	virtual u4	 GetSize() const;
1038
    virtual CStackMapFrameInfo* Clone() const;
1039
1040
protected:
1041
    virtual void AdjustOffsetDelta(int i_s2PrevFrameOffset);
1042
1043
private:
1044
    bool m_IsExtended;
1045
};
1046
1047
//------------------------------------------------------------------------------
1048
// Stack Map Frame Information: chop_frame (new in Java 6)
1049
//
1050
class CStackMapChopFrameInfo : public CStackMapFrameInfo
1051
{
1052
public:
1053
    CStackMapChopFrameInfo(u1 i_u1FrameType);
1054
    ~CStackMapChopFrameInfo();
1055
1056
    virtual void Read(CJStream& i_jstream);
1057
	virtual void Write(CJStream& i_jstream) const;
1058
	virtual u4	 GetSize() const;
1059
    virtual CStackMapFrameInfo* Clone() const;
1060
1061
private:
1062
};
1063
1064
//------------------------------------------------------------------------------
1065
// Stack Map Frame Information: same_locals_1_stack_item_frame and 
1066
//                              same_locals_1_stack_item_frame_extended (new in Java 6)
1067
//
1068
class CStackMapSameLocals1StackItemFrameInfo : public CStackMapFrameInfo
1069
{
1070
    friend class CStackMapTable;
1071
public:
1072
    CStackMapSameLocals1StackItemFrameInfo(u1 i_u1FrameType, bool i_IsExtended);
1073
    CStackMapSameLocals1StackItemFrameInfo(const CStackMapSameLocals1StackItemFrameInfo &i_Other);
1074
    ~CStackMapSameLocals1StackItemFrameInfo();
1075
1076
    virtual void Read(CJStream& i_jstream);
1077
	virtual void Write(CJStream& i_jstream) const;
1078
	virtual u4	 GetSize() const;
1079
    virtual CStackMapFrameInfo* Clone() const;
1080
1081
    CVerificationTypes& GetStack() { return m_Stack; }
1082
1083
protected:
1084
    virtual void AdjustOffsetDelta(int i_s2PrevFrameOffset);
1085
1086
private:
1087
    CStackMapSameLocals1StackItemFrameInfo& operator = (CStackMapSameLocals1StackItemFrameInfo &i_Other);
1088
1089
    CVerificationTypes m_Stack;     // A vector with 1 entry
1090
    bool m_IsExtended;
1091
};
1092
1093
//------------------------------------------------------------------------------
1094
// Stack Map Frame Information: append_frame (new in Java 6)
1095
//
1096
class CStackMapAppendFrameInfo : public CStackMapFrameInfo
1097
{
1098
public:
1099
    CStackMapAppendFrameInfo(u1 i_u1FrameType);
1100
    CStackMapAppendFrameInfo(const CStackMapAppendFrameInfo &i_Other);
1101
    ~CStackMapAppendFrameInfo();
1102
1103
    virtual void Read(CJStream& i_jstream);
1104
	virtual void Write(CJStream& i_jstream) const;
1105
	virtual u4	 GetSize() const;
1106
    virtual CStackMapFrameInfo* Clone() const;
1107
1108
    CVerificationTypes& GetLocals() { return m_Locals; }
1109
1110
private:
1111
    CStackMapAppendFrameInfo& operator = (const CStackMapAppendFrameInfo &i_Other);
1112
1113
    CVerificationTypes m_Locals;
1114
};
1115
1116
//------------------------------------------------------------------------------
1117
// Stack Map Frame Information: full_frame (new in Java 6)
1118
//
1119
class CStackMapFullFrameInfo : public CStackMapFrameInfo
1120
{
1121
public:
1122
    CStackMapFullFrameInfo(u1 i_u1FrameType);
1123
    CStackMapFullFrameInfo(const CStackMapFullFrameInfo &i_Other);
1124
    ~CStackMapFullFrameInfo();
1125
1126
    virtual void Read(CJStream& i_jstream);
1127
	virtual void Write(CJStream& i_jstream) const;
1128
	virtual u4	 GetSize() const;
1129
    virtual CStackMapFrameInfo* Clone() const;
1130
1131
    CVerificationTypes& GetLocals() { return m_Locals; }
1132
    CVerificationTypes& GetStack()  { return m_Stack;  }
1133
    
1134
private:
1135
    CStackMapFullFrameInfo& operator = (const CStackMapFullFrameInfo &i_Other);
1136
1137
    u2 m_u2NumberOfLocals;
1138
    CVerificationTypes m_Locals;
1139
    u2 m_u2NumberOfStackItems;
1140
    CVerificationTypes m_Stack;
1141
};
1142
1143
1144
//------------------------------------------------------------------------------
1145
// Stack Map Table (new in Java 6)
1146
//
1147
class CStackMapTable : public vector<CStackMapFrameInfo*>
1148
{
1149
public:
1150
    CStackMapTable() { clear(); }
1151
	~CStackMapTable();
1152
	virtual void	Read(CJStream& i_jstream);
1153
	virtual void	Write(CJStream& i_jstream) const;
1154
	virtual u4	    GetSize() const;
1155
1156
    void                AdjustOffsetDeltas();
1157
    CStackMapFrameInfo* GetFrameAtOffset(u2 i_u2Offset);
1158
	
1159
    CStackMapTable& operator = (const CStackMapTable& i_StackMaps);
1160
};
1161
1162
//------------------------------------------------------------------------------
1163
// Stack Map Table Attribute (new in Java 6 - [4.8.4])
1164
//
1165
class CStackMapTableAttribute : public CAttributeInfo
1166
{
1167
	friend class CStackMapTable;
1168
public:
1169
    CStackMapTableAttribute(CJClassFile* i_pClassFile);
1170
    ~CStackMapTableAttribute();
1171
	virtual void	Read(CJStream& i_jstream);
1172
	virtual void	Write(CJStream& i_jstream) const;
1173
	virtual u4	    GetSize() const;
1174
	virtual u4		GetLength() const;
1175
1176
    CStackMapTable& GetStackMapTable() { return m_StackMapTable; }
1177
	void SetStackMapTable(const CStackMapTable& i_stackmap) {m_StackMapTable = i_stackmap;}
1178
	void RereadFromBuffer(u1 *i_u1Tbl);
1179
1180
private:
1181
    CStackMapTable m_StackMapTable;
1182
1183
    // Disable assignment operator.
1184
    // To enable, implement these functions as public
1185
    CStackMapTableAttribute& operator = (const CStackMapTableAttribute& i_other) {}
1186
};
1187
1188
//------------------------------------------------------------------------------
902
// Interface information
1189
// Interface information
903
//
1190
//
904
class CInterfaceInfo
1191
class CInterfaceInfo
Lines 999-1004 public: Link Here
999
	virtual u4	 GetSize() const;
1286
	virtual u4	 GetSize() const;
1000
1287
1001
	u2			GetAccessFlags() {return m_u2AccessFlags;}
1288
	u2			GetAccessFlags() {return m_u2AccessFlags;}
1289
    void        SetAccessFlags(u2 i_u2AccessFlags) {m_u2AccessFlags = i_u2AccessFlags;}
1002
	u2			GetNameInd() const {return m_u2NameInd;}
1290
	u2			GetNameInd() const {return m_u2NameInd;}
1003
	u2			GetDescriptorInd() const {return m_u2DescriptorInd;}
1291
	u2			GetDescriptorInd() const {return m_u2DescriptorInd;}
1004
	CJAttribs&	GetAttribs()	{return m_Attribs;}
1292
	CJAttribs&	GetAttribs()	{return m_Attribs;}
Lines 1070-1076 public: Link Here
1070
class CJClassFile  
1358
class CJClassFile  
1071
{
1359
{
1072
public:
1360
public:
1073
	enum {MajorVersion = 3, MinorVersion = 46};	// TODO: comment on version 
1361
	enum {MajorVersion = 46, MinorVersion = 3};	// J2SE 1.2
1074
	CJClassFile();
1362
	CJClassFile();
1075
	virtual ~CJClassFile();
1363
	virtual ~CJClassFile();
1076
1364

Return to bug 148629