author | Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
Wed, 06 Nov 2013 15:15:54 +0100 | |
changeset 323 | 86aabecda7a3 |
child 352 | 67d1fd89cc80 |
child 358 | 80702021b851 |
permissions | -rw-r--r-- |
jaroslav@323 | 1 |
/** |
jaroslav@323 | 2 |
* HTML via Java(tm) Language Bindings |
jaroslav@323 | 3 |
* Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
jaroslav@323 | 4 |
* |
jaroslav@323 | 5 |
* This program is free software: you can redistribute it and/or modify |
jaroslav@323 | 6 |
* it under the terms of the GNU General Public License as published by |
jaroslav@323 | 7 |
* the Free Software Foundation, version 2 of the License. |
jaroslav@323 | 8 |
* |
jaroslav@323 | 9 |
* This program is distributed in the hope that it will be useful, |
jaroslav@323 | 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
jaroslav@323 | 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
jaroslav@323 | 12 |
* GNU General Public License for more details. apidesign.org |
jaroslav@323 | 13 |
* designates this particular file as subject to the |
jaroslav@323 | 14 |
* "Classpath" exception as provided by apidesign.org |
jaroslav@323 | 15 |
* in the License file that accompanied this code. |
jaroslav@323 | 16 |
* |
jaroslav@323 | 17 |
* You should have received a copy of the GNU General Public License |
jaroslav@323 | 18 |
* along with this program. Look for COPYING file in the top folder. |
jaroslav@323 | 19 |
* If not, see http://wiki.apidesign.org/wiki/GPLwithClassPathException |
jaroslav@323 | 20 |
*/ |
jaroslav@323 | 21 |
package org.apidesign.html.boot.impl; |
jaroslav@323 | 22 |
|
jaroslav@323 | 23 |
import java.lang.instrument.ClassFileTransformer; |
jaroslav@323 | 24 |
import java.lang.instrument.IllegalClassFormatException; |
jaroslav@323 | 25 |
import java.lang.instrument.Instrumentation; |
jaroslav@323 | 26 |
import java.security.ProtectionDomain; |
jaroslav@323 | 27 |
|
jaroslav@323 | 28 |
/** |
jaroslav@323 | 29 |
* |
jaroslav@323 | 30 |
* @author Jaroslav Tulach <jtulach@netbeans.org> |
jaroslav@323 | 31 |
*/ |
jaroslav@323 | 32 |
public final class JsAgent implements ClassFileTransformer { |
jaroslav@323 | 33 |
public static void agentmain(String args, Instrumentation instr) { |
jaroslav@323 | 34 |
instr.addTransformer(new JsAgent()); |
jaroslav@323 | 35 |
} |
jaroslav@323 | 36 |
|
jaroslav@323 | 37 |
@Override |
jaroslav@323 | 38 |
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { |
jaroslav@323 | 39 |
try { |
jaroslav@323 | 40 |
return FnUtils.transform(loader, classfileBuffer); |
jaroslav@323 | 41 |
} catch (Exception ex) { |
jaroslav@323 | 42 |
return classfileBuffer; |
jaroslav@323 | 43 |
} |
jaroslav@323 | 44 |
} |
jaroslav@323 | 45 |
} |