root/trunk/ProjectFortress/src/com/sun/fortress/compiler/nativeInterface/FortressTransformer.java
@
3290
| Revision 3290, 1.5 KB (checked in by chf, 11 months ago) |
|---|
| Line | |
|---|---|
| 1 | /******************************************************************************* |
| 2 | Copyright 2009 Sun Microsystems, Inc., |
| 3 | 4150 Network Circle, Santa Clara, California 95054, U.S.A. |
| 4 | All rights reserved. |
| 5 | |
| 6 | U.S. Government Rights - Commercial software. |
| 7 | Government users are subject to the Sun Microsystems, Inc. standard |
| 8 | license agreement and applicable provisions of the FAR and its supplements. |
| 9 | |
| 10 | Use is subject to license terms. |
| 11 | |
| 12 | This distribution may include materials developed by third parties. |
| 13 | |
| 14 | Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered |
| 15 | trademarks of Sun Microsystems, Inc. in the U.S. and other countries. |
| 16 | ******************************************************************************/ |
| 17 | |
| 18 | package com.sun.fortress.compiler.nativeInterface; |
| 19 | |
| 20 | import java.lang.reflect.Method; |
| 21 | import java.io.FileOutputStream; |
| 22 | import org.objectweb.asm.*; |
| 23 | |
| 24 | public class FortressTransformer { |
| 25 | @SuppressWarnings("unchecked") |
| 26 | |
| 27 | |
| 28 | public static Class transform(MyClassLoader loader, String fileName) { |
| 29 | Class result = null; |
| 30 | try { |
| 31 | ClassReader cr = new ClassReader(fileName); |
| 32 | ClassWriter cw = new ClassWriter(1); |
| 33 | FortressMethodAdapter fa = new FortressMethodAdapter(cw); |
| 34 | cr.accept(fa, 0); |
| 35 | byte[] b2 = cw.toByteArray(); |
| 36 | loader.writeClass(fileName, b2); |
| 37 | Class c = loader.findClass(fileName); |
| 38 | result = c; |
| 39 | |
| 40 | } catch (Throwable e) { |
| 41 | e.printStackTrace(); |
| 42 | } |
| 43 | return result; |
| 44 | } |
| 45 | |
| 46 | } |
Note: See TracBrowser
for help on using the browser.

