public void testIdeadev14081() throws Exception { // NOTE: That doesn't really reproduce the bug as it's dependent on a particular instrumentation // sequence used during form preview // (the nested form is instrumented with a new AsmCodeGenerator instance directly in the middle // of instrumentation of the current form) final String testDataPath = PluginPathManager.getPluginHomePath("ui-designer") + File.separatorChar + "testData" + File.separatorChar + File.separatorChar + "formEmbedding" + File.separatorChar + "Ideadev14081" + File.separatorChar; AsmCodeGenerator embeddedClassGenerator = initCodeGenerator("Embedded.form", "Embedded", testDataPath); byte[] embeddedPatchedData = getVerifiedPatchedData(embeddedClassGenerator); myClassFinder.addClassDefinition("Embedded", embeddedPatchedData); myNestedFormLoader.registerNestedForm("Embedded.form", testDataPath + "Embedded.form"); AsmCodeGenerator mainClassGenerator = initCodeGenerator("Main.form", "Main", testDataPath); byte[] mainPatchedData = getVerifiedPatchedData(mainClassGenerator); /* FileOutputStream fos = new FileOutputStream("C:\\yole\\FormPreview27447\\MainPatched.class"); fos.write(mainPatchedData); fos.close(); */ myClassFinder.addClassDefinition("Main", mainPatchedData); final Class mainClass = myClassFinder.getLoader().loadClass("Main"); Object instance = mainClass.newInstance(); assert instance != null : mainClass; }
private Class loadAndPatchClass(final String formFileName, final String className) throws Exception { final AsmCodeGenerator codeGenerator = initCodeGenerator(formFileName, className); byte[] patchedData = getVerifiedPatchedData(codeGenerator); /* FileOutputStream fos = new FileOutputStream("C:\\yole\\FormPreview27447\\MainPatched.class"); fos.write(patchedData); fos.close(); */ myClassFinder.addClassDefinition(className, patchedData); return myClassFinder.getLoader().loadClass(className); }