devxlogo

August 16, 2005

Structs with Care: Boxing

Consider an employee service, say in an SOA-based implementation, which exposes the following method: Employee getEmployeeInfo(int employeeId) Looking at this signature, Employee can be defined as struct because it would

Call a Private Method of a Class

Use this polymorphic technique to cheat the compiler and expose private information: See the code below.class A{public: virtual void f2() { printf(“in A::f2 “); }};class B: public A{private: void f2(int

Release Virtual Machine Resources

Failing to release virtual machine resources results in a ‘memory leak.’ The following example is missing the ReleaseIntArrayElements call: jint * tempArray = env->GetIntArrayElements(jiArray, false);if (tempArray ){ return;}if (…) //