Path: blob/master/src/java.instrument/share/classes/java/lang/instrument/ClassDefinition.java
41159 views
/*1* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.lang.instrument;2627/*28* Copyright 2003 Wily Technology, Inc.29*/3031/**32* This class serves as a parameter block to the <code>Instrumentation.redefineClasses</code> method.33* Serves to bind the <code>Class</code> that needs redefining together with the new class file bytes.34*35* @see java.lang.instrument.Instrumentation#redefineClasses36* @since 1.537*/38public final class ClassDefinition {39/**40* The class to redefine41*/42private final Class<?> mClass;4344/**45* The replacement class file bytes46*/47private final byte[] mClassFile;4849/**50* Creates a new <code>ClassDefinition</code> binding using the supplied51* class and class file bytes. Does not copy the supplied buffer, just captures a reference to it.52*53* @param theClass the <code>Class</code> that needs redefining54* @param theClassFile the new class file bytes55*56* @throws java.lang.NullPointerException if the supplied class or array is <code>null</code>.57*/58public59ClassDefinition( Class<?> theClass,60byte[] theClassFile) {61if (theClass == null || theClassFile == null) {62throw new NullPointerException();63}64mClass = theClass;65mClassFile = theClassFile;66}6768/**69* Returns the class.70*71* @return the <code>Class</code> object referred to.72*/73public Class<?>74getDefinitionClass() {75return mClass;76}7778/**79* Returns the array of bytes that contains the new class file.80*81* @return the class file bytes.82*/83public byte[]84getDefinitionClassFile() {85return mClassFile;86}87}888990