jaroslav@323: /**
jaroslav@323: * HTML via Java(tm) Language Bindings
jaroslav@323: * Copyright (C) 2013 Jaroslav Tulach
jaroslav@323: *
jaroslav@323: * This program is free software: you can redistribute it and/or modify
jaroslav@323: * it under the terms of the GNU General Public License as published by
jaroslav@323: * the Free Software Foundation, version 2 of the License.
jaroslav@323: *
jaroslav@323: * This program is distributed in the hope that it will be useful,
jaroslav@323: * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@323: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
jaroslav@323: * GNU General Public License for more details. apidesign.org
jaroslav@323: * designates this particular file as subject to the
jaroslav@323: * "Classpath" exception as provided by apidesign.org
jaroslav@323: * in the License file that accompanied this code.
jaroslav@323: *
jaroslav@323: * You should have received a copy of the GNU General Public License
jaroslav@323: * along with this program. Look for COPYING file in the top folder.
jaroslav@323: * If not, see http://wiki.apidesign.org/wiki/GPLwithClassPathException
jaroslav@323: */
jaroslav@323: package org.apidesign.html.boot.impl;
jaroslav@323:
jaroslav@323: import java.lang.instrument.ClassFileTransformer;
jaroslav@323: import java.lang.instrument.IllegalClassFormatException;
jaroslav@323: import java.lang.instrument.Instrumentation;
jaroslav@323: import java.security.ProtectionDomain;
jaroslav@323:
jaroslav@323: /**
jaroslav@323: *
jaroslav@323: * @author Jaroslav Tulach
jaroslav@323: */
jaroslav@323: public final class JsAgent implements ClassFileTransformer {
jaroslav@323: public static void agentmain(String args, Instrumentation instr) {
jaroslav@323: instr.addTransformer(new JsAgent());
jaroslav@323: }
jaroslav@323:
jaroslav@323: @Override
jaroslav@323: public byte[] transform(ClassLoader loader, String className, Class> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
jaroslav@323: try {
jaroslav@323: return FnUtils.transform(loader, classfileBuffer);
jaroslav@323: } catch (Exception ex) {
jaroslav@323: return classfileBuffer;
jaroslav@323: }
jaroslav@323: }
jaroslav@323: }