Logo Search packages:      
Sourcecode: visualvm version File versions  Download package

Object [] org::netbeans::lib::profiler::instrumentation::CodeRegionMethodInstrumentor::createInstrumentedMethodPack15 (  )  [inline, private]

Creates the 1.5-style array of instrumented class files.

Definition at line 175 of file CodeRegionMethodInstrumentor.java.

References org::netbeans::lib::profiler::instrumentation::ConstantPoolExtension::getContents(), org::netbeans::lib::profiler::classfile::BaseClassInfo::getLoaderId(), org::netbeans::lib::profiler::classfile::ClassInfo::getMethodIndex(), org::netbeans::lib::profiler::classfile::DynamicClassInfo::getMethodInfo(), org::netbeans::lib::profiler::classfile::ClassInfo::getMethodNames(), org::netbeans::lib::profiler::classfile::BaseClassInfo::getName(), org::netbeans::lib::profiler::instrumentation::ConstantPoolExtension::getNEntries(), and org::netbeans::lib::profiler::classfile::DynamicClassInfo::setMethodInstrumented().

                                                      {
        String[] instrMethodClasses = new String[nInstrClasses];
        int[] instrClassLoaderIds = new int[nInstrClasses];
        byte[][] replacementClassFileBytes = new byte[nInstrClasses][];

        for (int j = 0; j < nInstrClasses; j++) {
            DynamicClassInfo clazz = (DynamicClassInfo) instrClasses.get(j);
            instrMethodClasses[j] = clazz.getName().replace('/', '.'); // NOI18N
            instrClassLoaderIds[j] = clazz.getLoaderId();

            CodeRegionBCI instrLocation = computeCodeRegionFromSourceCodeSelection(clazz);
            int mIdx = clazz.getMethodIndex(instrLocation.methodName, instrLocation.methodSignature); // TODO CHECK: local variable hides member variable
            clazz.setMethodInstrumented(mIdx);

            DynamicConstantPoolExtension ecp = DynamicConstantPoolExtension.getCPFragment(clazz, INJ_CODE_REGION);
            byte[] newMethodInfo = InstrumentationFactory.instrumentCodeRegion(clazz, mIdx, instrLocation.bci0, instrLocation.bci1);

            int nMethods = clazz.getMethodNames().length;
            byte[][] replacementMethodInfos = new byte[nMethods][];

            for (int i = 0; i < nMethods; i++) {
                replacementMethodInfos[i] = clazz.getMethodInfo(i);
            }

            replacementMethodInfos[mIdx] = newMethodInfo;

            int nAddedCPEntries = ecp.getNEntries();
            byte[] addedCPContents = ecp.getContents();
            replacementClassFileBytes[j] = ClassRewriter.rewriteClassFile(clazz, replacementMethodInfos, nAddedCPEntries,
                                                                          addedCPContents);
        }

        return new Object[] { instrMethodClasses, instrClassLoaderIds, replacementClassFileBytes };
    }


Generated by  Doxygen 1.6.0   Back to index