12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564 |
- /*
- * Javassist, a Java-bytecode translator toolkit.
- * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. Alternatively, the contents of this file may be used under
- * the terms of the GNU Lesser General Public License Version 2.1 or later,
- * or the Apache License Version 2.0.
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- */
-
- package javassist.bytecode;
-
- import java.io.ByteArrayOutputStream;
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.util.HashMap;
- import java.util.HashSet;
- import java.util.Map;
- import java.util.Set;
-
- import javassist.CtClass;
-
- /**
- * Constant pool table.
- */
- public final class ConstPool
- {
- LongVector items;
- int numOfItems;
- int thisClassInfo;
- Map<ConstInfo,ConstInfo> itemsCache;
-
- /**
- * <code>CONSTANT_Class</code>
- */
- public static final int CONST_Class = ClassInfo.tag;
-
- /**
- * <code>CONSTANT_Fieldref</code>
- */
- public static final int CONST_Fieldref = FieldrefInfo.tag;
-
- /**
- * <code>CONSTANT_Methodref</code>
- */
- public static final int CONST_Methodref = MethodrefInfo.tag;
-
- /**
- * <code>CONSTANT_InterfaceMethodref</code>
- */
- public static final int CONST_InterfaceMethodref
- = InterfaceMethodrefInfo.tag;
-
- /**
- * <code>CONSTANT_String</code>
- */
- public static final int CONST_String = StringInfo.tag;
-
- /**
- * <code>CONSTANT_Integer</code>
- */
- public static final int CONST_Integer = IntegerInfo.tag;
-
- /**
- * <code>CONSTANT_Float</code>
- */
- public static final int CONST_Float = FloatInfo.tag;
-
- /**
- * <code>CONSTANT_Long</code>
- */
- public static final int CONST_Long = LongInfo.tag;
-
- /**
- * <code>CONSTANT_Double</code>
- */
- public static final int CONST_Double = DoubleInfo.tag;
-
- /**
- * <code>CONSTANT_NameAndType</code>
- */
- public static final int CONST_NameAndType = NameAndTypeInfo.tag;
-
- /**
- * <code>CONSTANT_Utf8</code>
- */
- public static final int CONST_Utf8 = Utf8Info.tag;
-
- /**
- * <code>CONSTANT_MethodHandle</code>
- */
- public static final int CONST_MethodHandle = MethodHandleInfo.tag;
-
- /**
- * <code>CONSTANT_MethodHandle</code>
- */
- public static final int CONST_MethodType = MethodTypeInfo.tag;
-
- /**
- * <code>CONSTANT_MethodHandle</code>
- */
- public static final int CONST_InvokeDynamic = InvokeDynamicInfo.tag;
-
- /**
- * <code>CONSTANT_Module</code>
- */
- public static final int CONST_Module = ModuleInfo.tag;
-
- /**
- * <code>CONSTANT_Package</code>
- */
- public static final int CONST_Package = PackageInfo.tag;
-
- /**
- * Represents the class using this constant pool table.
- */
- public static final CtClass THIS = null;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_getField = 1;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_getStatic = 2;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_putField = 3;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_putStatic = 4;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_invokeVirtual = 5;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_invokeStatic = 6;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_invokeSpecial = 7;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_newInvokeSpecial = 8;
-
- /**
- * <code>reference_kind</code> of <code>CONSTANT_MethodHandle_info</code>.
- */
- public static final int REF_invokeInterface = 9;
-
- /**
- * Constructs a constant pool table.
- *
- * @param thisclass the name of the class using this constant
- * pool table
- */
- public ConstPool(String thisclass)
- {
- items = new LongVector();
- itemsCache = null;
- numOfItems = 0;
- addItem0(null); // index 0 is reserved by the JVM.
- thisClassInfo = addClassInfo(thisclass);
- }
-
- /**
- * Constructs a constant pool table from the given byte stream.
- *
- * @param in byte stream.
- */
- public ConstPool(DataInputStream in) throws IOException
- {
- itemsCache = null;
- thisClassInfo = 0;
- /* read() initializes items and numOfItems, and do addItem(null).
- */
- read(in);
- }
-
- void prune()
- {
- itemsCache = null;
- }
-
- /**
- * Returns the number of entries in this table.
- */
- public int getSize()
- {
- return numOfItems;
- }
-
- /**
- * Returns the name of the class using this constant pool table.
- */
- public String getClassName()
- {
- return getClassInfo(thisClassInfo);
- }
-
- /**
- * Returns the index of <code>CONSTANT_Class_info</code> structure
- * specifying the class using this constant pool table.
- */
- public int getThisClassInfo()
- {
- return thisClassInfo;
- }
-
- void setThisClassInfo(int i)
- {
- thisClassInfo = i;
- }
-
- ConstInfo getItem(int n)
- {
- return items.elementAt(n);
- }
-
- /**
- * Returns the <code>tag</code> field of the constant pool table
- * entry at the given index.
- *
- * @return either <code>CONST_Class</code>, <code>CONST_Fieldref</code>,
- * <code>CONST_Methodref</code>, or ...
- */
- public int getTag(int index)
- {
- return getItem(index).getTag();
- }
-
- /**
- * Reads <code>CONSTANT_Class_info</code> structure
- * at the given index.
- *
- * @return a fully-qualified class or interface name specified
- * by <code>name_index</code>. If the type is an array
- * type, this method returns an encoded name like
- * <code>[Ljava.lang.Object;</code> (note that the separators
- * are not slashes but dots).
- * @see javassist.ClassPool#getCtClass(String)
- */
- public String getClassInfo(int index)
- {
- ClassInfo c = (ClassInfo)getItem(index);
- if (c == null)
- return null;
- return Descriptor.toJavaName(getUtf8Info(c.name));
- }
-
- /**
- * Reads <code>CONSTANT_Class_info</code> structure
- * at the given index.
- *
- * @return the descriptor of the type specified
- * by <code>name_index</code>.
- * @see javassist.ClassPool#getCtClass(String)
- * @since 3.15
- */
- public String getClassInfoByDescriptor(int index)
- {
- ClassInfo c = (ClassInfo)getItem(index);
- if (c == null)
- return null;
- String className = getUtf8Info(c.name);
- if (className.charAt(0) == '[')
- return className;
- return Descriptor.of(className);
- }
-
- /**
- * Reads the <code>name_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * at the given index.
- */
- public int getNameAndTypeName(int index)
- {
- NameAndTypeInfo ntinfo = (NameAndTypeInfo)getItem(index);
- return ntinfo.memberName;
- }
-
- /**
- * Reads the <code>descriptor_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * at the given index.
- */
- public int getNameAndTypeDescriptor(int index)
- {
- NameAndTypeInfo ntinfo = (NameAndTypeInfo)getItem(index);
- return ntinfo.typeDescriptor;
- }
-
- /**
- * Reads the <code>class_index</code> field of the
- * <code>CONSTANT_Fieldref_info</code>,
- * <code>CONSTANT_Methodref_info</code>,
- * or <code>CONSTANT_Interfaceref_info</code>,
- * structure at the given index.
- *
- * @since 3.6
- */
- public int getMemberClass(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- return minfo.classIndex;
- }
-
- /**
- * Reads the <code>name_and_type_index</code> field of the
- * <code>CONSTANT_Fieldref_info</code>,
- * <code>CONSTANT_Methodref_info</code>,
- * or <code>CONSTANT_Interfaceref_info</code>,
- * structure at the given index.
- *
- * @since 3.6
- */
- public int getMemberNameAndType(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- return minfo.nameAndTypeIndex;
- }
-
- /**
- * Reads the <code>class_index</code> field of the
- * <code>CONSTANT_Fieldref_info</code> structure
- * at the given index.
- */
- public int getFieldrefClass(int index)
- {
- FieldrefInfo finfo = (FieldrefInfo)getItem(index);
- return finfo.classIndex;
- }
-
- /**
- * Reads the <code>class_index</code> field of the
- * <code>CONSTANT_Fieldref_info</code> structure
- * at the given index.
- *
- * @return the name of the class at that <code>class_index</code>.
- */
- public String getFieldrefClassName(int index)
- {
- FieldrefInfo f = (FieldrefInfo)getItem(index);
- if (f == null)
- return null;
- return getClassInfo(f.classIndex);
- }
-
- /**
- * Reads the <code>name_and_type_index</code> field of the
- * <code>CONSTANT_Fieldref_info</code> structure
- * at the given index.
- */
- public int getFieldrefNameAndType(int index)
- {
- FieldrefInfo finfo = (FieldrefInfo)getItem(index);
- return finfo.nameAndTypeIndex;
- }
-
- /**
- * Reads the <code>name_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to a <code>CONSTANT_Fieldref_info</code>.
- * @return the name of the field.
- */
- public String getFieldrefName(int index)
- {
- FieldrefInfo f = (FieldrefInfo)getItem(index);
- if (f == null)
- return null;
- NameAndTypeInfo n = (NameAndTypeInfo)getItem(f.nameAndTypeIndex);
- if(n == null)
- return null;
- return getUtf8Info(n.memberName);
- }
-
- /**
- * Reads the <code>descriptor_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to a <code>CONSTANT_Fieldref_info</code>.
- * @return the type descriptor of the field.
- */
- public String getFieldrefType(int index)
- {
- FieldrefInfo f = (FieldrefInfo)getItem(index);
- if (f == null)
- return null;
- NameAndTypeInfo n = (NameAndTypeInfo)getItem(f.nameAndTypeIndex);
- if(n == null)
- return null;
- return getUtf8Info(n.typeDescriptor);
- }
-
- /**
- * Reads the <code>class_index</code> field of the
- * <code>CONSTANT_Methodref_info</code> structure
- * at the given index.
- */
- public int getMethodrefClass(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- return minfo.classIndex;
- }
-
- /**
- * Reads the <code>class_index</code> field of the
- * <code>CONSTANT_Methodref_info</code> structure
- * at the given index.
- *
- * @return the name of the class at that <code>class_index</code>.
- */
- public String getMethodrefClassName(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- if (minfo == null)
- return null;
- return getClassInfo(minfo.classIndex);
- }
-
- /**
- * Reads the <code>name_and_type_index</code> field of the
- * <code>CONSTANT_Methodref_info</code> structure
- * at the given index.
- */
- public int getMethodrefNameAndType(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- return minfo.nameAndTypeIndex;
- }
-
- /**
- * Reads the <code>name_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to a <code>CONSTANT_Methodref_info</code>.
- * @return the name of the method.
- */
- public String getMethodrefName(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- if (minfo == null)
- return null;
- NameAndTypeInfo n
- = (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
- if(n == null)
- return null;
- return getUtf8Info(n.memberName);
- }
-
- /**
- * Reads the <code>descriptor_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to a <code>CONSTANT_Methodref_info</code>.
- * @return the descriptor of the method.
- */
- public String getMethodrefType(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- if (minfo == null)
- return null;
- NameAndTypeInfo n
- = (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
- if(n == null)
- return null;
- return getUtf8Info(n.typeDescriptor);
- }
-
- /**
- * Reads the <code>class_index</code> field of the
- * <code>CONSTANT_InterfaceMethodref_info</code> structure
- * at the given index.
- */
- public int getInterfaceMethodrefClass(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- return minfo.classIndex;
- }
-
- /**
- * Reads the <code>class_index</code> field of the
- * <code>CONSTANT_InterfaceMethodref_info</code> structure
- * at the given index.
- *
- * @return the name of the class at that <code>class_index</code>.
- */
- public String getInterfaceMethodrefClassName(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- return getClassInfo(minfo.classIndex);
- }
-
- /**
- * Reads the <code>name_and_type_index</code> field of the
- * <code>CONSTANT_InterfaceMethodref_info</code> structure
- * at the given index.
- */
- public int getInterfaceMethodrefNameAndType(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- return minfo.nameAndTypeIndex;
- }
-
- /**
- * Reads the <code>name_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to
- * a <code>CONSTANT_InterfaceMethodref_info</code>.
- * @return the name of the method.
- */
- public String getInterfaceMethodrefName(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- if (minfo == null)
- return null;
- NameAndTypeInfo n
- = (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
- if(n == null)
- return null;
- return getUtf8Info(n.memberName);
- }
-
- /**
- * Reads the <code>descriptor_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to
- * a <code>CONSTANT_InterfaceMethodref_info</code>.
- * @return the descriptor of the method.
- */
- public String getInterfaceMethodrefType(int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- if (minfo == null)
- return null;
- NameAndTypeInfo n
- = (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
- if(n == null)
- return null;
- return getUtf8Info(n.typeDescriptor);
- }
- /**
- * Reads <code>CONSTANT_Integer_info</code>, <code>_Float_info</code>,
- * <code>_Long_info</code>, <code>_Double_info</code>, or
- * <code>_String_info</code> structure.
- * These are used with the LDC instruction.
- *
- * @return a <code>String</code> value or a wrapped primitive-type
- * value.
- */
- public Object getLdcValue(int index)
- {
- ConstInfo constInfo = this.getItem(index);
- Object value = null;
- if (constInfo instanceof StringInfo)
- value = this.getStringInfo(index);
- else if (constInfo instanceof FloatInfo)
- value = Float.valueOf(getFloatInfo(index));
- else if (constInfo instanceof IntegerInfo)
- value = Integer.valueOf(getIntegerInfo(index));
- else if (constInfo instanceof LongInfo)
- value = Long.valueOf(getLongInfo(index));
- else if (constInfo instanceof DoubleInfo)
- value = Double.valueOf(getDoubleInfo(index));
-
- return value;
- }
-
- /**
- * Reads <code>CONSTANT_Integer_info</code> structure
- * at the given index.
- *
- * @return the value specified by this entry.
- */
- public int getIntegerInfo(int index)
- {
- IntegerInfo i = (IntegerInfo)getItem(index);
- return i.value;
- }
-
- /**
- * Reads <code>CONSTANT_Float_info</code> structure
- * at the given index.
- *
- * @return the value specified by this entry.
- */
- public float getFloatInfo(int index)
- {
- FloatInfo i = (FloatInfo)getItem(index);
- return i.value;
- }
-
- /**
- * Reads <code>CONSTANT_Long_info</code> structure
- * at the given index.
- *
- * @return the value specified by this entry.
- */
- public long getLongInfo(int index)
- {
- LongInfo i = (LongInfo)getItem(index);
- return i.value;
- }
-
- /**
- * Reads <code>CONSTANT_Double_info</code> structure
- * at the given index.
- *
- * @return the value specified by this entry.
- */
- public double getDoubleInfo(int index)
- {
- DoubleInfo i = (DoubleInfo)getItem(index);
- return i.value;
- }
-
- /**
- * Reads <code>CONSTANT_String_info</code> structure
- * at the given index.
- *
- * @return the string specified by <code>string_index</code>.
- */
- public String getStringInfo(int index)
- {
- StringInfo si = (StringInfo)getItem(index);
- return getUtf8Info(si.string);
- }
-
- /**
- * Reads <code>CONSTANT_utf8_info</code> structure
- * at the given index.
- *
- * @return the string specified by this entry.
- */
- public String getUtf8Info(int index)
- {
- Utf8Info utf = (Utf8Info)getItem(index);
- return utf.string;
- }
-
- /**
- * Reads the <code>reference_kind</code> field of the
- * <code>CONSTANT_MethodHandle_info</code> structure
- * at the given index.
- *
- * @see #REF_getField
- * @see #REF_getStatic
- * @see #REF_invokeInterface
- * @see #REF_invokeSpecial
- * @see #REF_invokeStatic
- * @see #REF_invokeVirtual
- * @see #REF_newInvokeSpecial
- * @see #REF_putField
- * @see #REF_putStatic
- * @since 3.17
- */
- public int getMethodHandleKind(int index)
- {
- MethodHandleInfo mhinfo = (MethodHandleInfo)getItem(index);
- return mhinfo.refKind;
- }
-
- /**
- * Reads the <code>reference_index</code> field of the
- * <code>CONSTANT_MethodHandle_info</code> structure
- * at the given index.
- *
- * @since 3.17
- */
- public int getMethodHandleIndex(int index)
- {
- MethodHandleInfo mhinfo = (MethodHandleInfo)getItem(index);
- return mhinfo.refIndex;
- }
-
- /**
- * Reads the <code>descriptor_index</code> field of the
- * <code>CONSTANT_MethodType_info</code> structure
- * at the given index.
- *
- * @since 3.17
- */
- public int getMethodTypeInfo(int index)
- {
- MethodTypeInfo mtinfo = (MethodTypeInfo)getItem(index);
- return mtinfo.descriptor;
- }
-
- /**
- * Reads the <code>bootstrap_method_attr_index</code> field of the
- * <code>CONSTANT_InvokeDynamic_info</code> structure
- * at the given index.
- *
- * @since 3.17
- */
- public int getInvokeDynamicBootstrap(int index)
- {
- InvokeDynamicInfo iv = (InvokeDynamicInfo)getItem(index);
- return iv.bootstrap;
- }
-
- /**
- * Reads the <code>name_and_type_index</code> field of the
- * <code>CONSTANT_InvokeDynamic_info</code> structure
- * at the given index.
- *
- * @since 3.17
- */
- public int getInvokeDynamicNameAndType(int index)
- {
- InvokeDynamicInfo iv = (InvokeDynamicInfo)getItem(index);
- return iv.nameAndType;
- }
-
- /**
- * Reads the <code>descriptor_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to a <code>CONSTANT_InvokeDynamic_info</code>.
- * @return the descriptor of the method.
- * @since 3.17
- */
- public String getInvokeDynamicType(int index)
- {
- InvokeDynamicInfo iv = (InvokeDynamicInfo)getItem(index);
- if (iv == null)
- return null;
- NameAndTypeInfo n = (NameAndTypeInfo)getItem(iv.nameAndType);
- if(n == null)
- return null;
- return getUtf8Info(n.typeDescriptor);
- }
-
- /**
- * Reads the <code>bootstrap_method_attr_index</code> field of the
- * <code>CONSTANT_Dynamic_info</code> structure
- * at the given index.
- *
- * @since 3.17
- */
- public int getDynamicBootstrap(int index)
- {
- DynamicInfo iv = (DynamicInfo)getItem(index);
- return iv.bootstrap;
- }
-
- /**
- * Reads the <code>name_and_type_index</code> field of the
- * <code>CONSTANT_Dynamic_info</code> structure
- * at the given index.
- *
- * @since 3.17
- */
- public int getDynamicNameAndType(int index)
- {
- DynamicInfo iv = (DynamicInfo)getItem(index);
- return iv.nameAndType;
- }
-
- /**
- * Reads the <code>descriptor_index</code> field of the
- * <code>CONSTANT_NameAndType_info</code> structure
- * indirectly specified by the given index.
- *
- * @param index an index to a <code>CONSTANT_Dynamic_info</code>.
- * @return the descriptor of the method.
- * @since 3.17
- */
- public String getDynamicType(int index)
- {
- DynamicInfo iv = (DynamicInfo)getItem(index);
- if (iv == null)
- return null;
- NameAndTypeInfo n = (NameAndTypeInfo)getItem(iv.nameAndType);
- if(n == null)
- return null;
- return getUtf8Info(n.typeDescriptor);
- }
-
- /**
- * Reads the <code>name_index</code> field of the
- * <code>CONSTANT_Module_info</code> structure at the given index.
- *
- * @return the module name at <code>name_index</code>.
- * @since 3.22
- */
- public String getModuleInfo(int index)
- {
- ModuleInfo mi = (ModuleInfo)getItem(index);
- return getUtf8Info(mi.name);
- }
-
- /**
- * Reads the <code>name_index</code> field of the
- * <code>CONSTANT_Package_info</code> structure at the given index.
- *
- * @return the package name at <code>name_index</code>. It is a slash-
- * separated name such as com/oracle/net.
- * @since 3.22
- */
- public String getPackageInfo(int index)
- {
- PackageInfo mi = (PackageInfo)getItem(index);
- return getUtf8Info(mi.name);
- }
-
- /**
- * Determines whether <code>CONSTANT_Methodref_info</code>
- * structure at the given index represents the constructor
- * of the given class.
- *
- * @return the <code>descriptor_index</code> specifying
- * the type descriptor of the that constructor.
- * If it is not that constructor,
- * <code>isConstructor()</code> returns 0.
- */
- public int isConstructor(String classname, int index)
- {
- return isMember(classname, MethodInfo.nameInit, index);
- }
-
- /**
- * Determines whether <code>CONSTANT_Methodref_info</code>,
- * <code>CONSTANT_Fieldref_info</code>, or
- * <code>CONSTANT_InterfaceMethodref_info</code> structure
- * at the given index represents the member with the specified
- * name and declaring class.
- *
- * @param classname the class declaring the member
- * @param membername the member name
- * @param index the index into the constant pool table
- *
- * @return the <code>descriptor_index</code> specifying
- * the type descriptor of that member.
- * If it is not that member,
- * <code>isMember()</code> returns 0.
- */
- public int isMember(String classname, String membername, int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- if (getClassInfo(minfo.classIndex).equals(classname)) {
- NameAndTypeInfo ntinfo
- = (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
- if (getUtf8Info(ntinfo.memberName).equals(membername))
- return ntinfo.typeDescriptor;
- }
-
- return 0; // false
- }
-
- /**
- * Determines whether <code>CONSTANT_Methodref_info</code>,
- * <code>CONSTANT_Fieldref_info</code>, or
- * <code>CONSTANT_InterfaceMethodref_info</code> structure
- * at the given index has the name and the descriptor
- * given as the arguments.
- *
- * @param membername the member name
- * @param desc the descriptor of the member.
- * @param index the index into the constant pool table
- *
- * @return the name of the target class specified by
- * the <code>..._info</code> structure
- * at <code>index</code>.
- * Otherwise, null if that structure does not
- * match the given member name and descriptor.
- */
- public String eqMember(String membername, String desc, int index)
- {
- MemberrefInfo minfo = (MemberrefInfo)getItem(index);
- NameAndTypeInfo ntinfo
- = (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
- if (getUtf8Info(ntinfo.memberName).equals(membername)
- && getUtf8Info(ntinfo.typeDescriptor).equals(desc))
- return getClassInfo(minfo.classIndex);
- return null; // false
- }
-
- private int addItem0(ConstInfo info)
- {
- items.addElement(info);
- return numOfItems++;
- }
-
- private int addItem(ConstInfo info)
- {
- if (itemsCache == null)
- itemsCache = makeItemsCache(items);
-
- ConstInfo found = itemsCache.get(info);
- if (found != null)
- return found.index;
- items.addElement(info);
- itemsCache.put(info, info);
- return numOfItems++;
- }
-
- /**
- * Copies the n-th item in this ConstPool object into the destination
- * ConstPool object.
- * The class names that the item refers to are renamed according
- * to the given map.
- *
- * @param n the <i>n</i>-th item
- * @param dest destination constant pool table
- * @param classnames the map or null.
- * @return the index of the copied item into the destination ClassPool.
- */
- public int copy(int n, ConstPool dest, Map<String,String> classnames)
- {
- if (n == 0)
- return 0;
-
- ConstInfo info = getItem(n);
- return info.copy(this, dest, classnames);
- }
-
- int addConstInfoPadding() {
- return addItem0(new ConstInfoPadding(numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Class_info</code> structure.
- *
- * <p>This also adds a <code>CONSTANT_Utf8_info</code> structure
- * for storing the class name.
- *
- * @return the index of the added entry.
- */
- public int addClassInfo(CtClass c)
- {
- if (c == THIS)
- return thisClassInfo;
- else if (!c.isArray())
- return addClassInfo(c.getName());
- else {
- // an array type is recorded in the hashtable with
- // the key "[L<classname>;" instead of "<classname>".
- //
- // note: toJvmName(toJvmName(c)) is equal to toJvmName(c).
-
- return addClassInfo(Descriptor.toJvmName(c));
- }
- }
-
- /**
- * Adds a new <code>CONSTANT_Class_info</code> structure.
- *
- * <p>This also adds a <code>CONSTANT_Utf8_info</code> structure
- * for storing the class name.
- *
- * @param qname a fully-qualified class name
- * (or the JVM-internal representation of that name).
- * @return the index of the added entry.
- */
- public int addClassInfo(String qname)
- {
- int utf8 = addUtf8Info(Descriptor.toJvmName(qname));
- return addItem(new ClassInfo(utf8, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_NameAndType_info</code> structure.
- *
- * <p>This also adds <code>CONSTANT_Utf8_info</code> structures.
- *
- * @param name <code>name_index</code>
- * @param type <code>descriptor_index</code>
- * @return the index of the added entry.
- */
- public int addNameAndTypeInfo(String name, String type)
- {
- return addNameAndTypeInfo(addUtf8Info(name), addUtf8Info(type));
- }
-
- /**
- * Adds a new <code>CONSTANT_NameAndType_info</code> structure.
- *
- * @param name <code>name_index</code>
- * @param type <code>descriptor_index</code>
- * @return the index of the added entry.
- */
- public int addNameAndTypeInfo(int name, int type)
- {
- return addItem(new NameAndTypeInfo(name, type, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Fieldref_info</code> structure.
- *
- * <p>This also adds a new <code>CONSTANT_NameAndType_info</code>
- * structure.
- *
- * @param classInfo <code>class_index</code>
- * @param name <code>name_index</code>
- * of <code>CONSTANT_NameAndType_info</code>.
- * @param type <code>descriptor_index</code>
- * of <code>CONSTANT_NameAndType_info</code>.
- * @return the index of the added entry.
- */
- public int addFieldrefInfo(int classInfo, String name, String type)
- {
- int nt = addNameAndTypeInfo(name, type);
- return addFieldrefInfo(classInfo, nt);
- }
-
- /**
- * Adds a new <code>CONSTANT_Fieldref_info</code> structure.
- *
- * @param classInfo <code>class_index</code>
- * @param nameAndTypeInfo <code>name_and_type_index</code>.
- * @return the index of the added entry.
- */
- public int addFieldrefInfo(int classInfo, int nameAndTypeInfo)
- {
- return addItem(new FieldrefInfo(classInfo, nameAndTypeInfo,
- numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Methodref_info</code> structure.
- *
- * <p>This also adds a new <code>CONSTANT_NameAndType_info</code>
- * structure.
- *
- * @param classInfo <code>class_index</code>
- * @param name <code>name_index</code>
- * of <code>CONSTANT_NameAndType_info</code>.
- * @param type <code>descriptor_index</code>
- * of <code>CONSTANT_NameAndType_info</code>.
- * @return the index of the added entry.
- */
- public int addMethodrefInfo(int classInfo, String name, String type)
- {
- int nt = addNameAndTypeInfo(name, type);
- return addMethodrefInfo(classInfo, nt);
- }
-
- /**
- * Adds a new <code>CONSTANT_Methodref_info</code> structure.
- *
- * @param classInfo <code>class_index</code>
- * @param nameAndTypeInfo <code>name_and_type_index</code>.
- * @return the index of the added entry.
- */
- public int addMethodrefInfo(int classInfo, int nameAndTypeInfo)
- {
- return addItem(new MethodrefInfo(classInfo,
- nameAndTypeInfo, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_InterfaceMethodref_info</code>
- * structure.
- *
- * <p>This also adds a new <code>CONSTANT_NameAndType_info</code>
- * structure.
- *
- * @param classInfo <code>class_index</code>
- * @param name <code>name_index</code>
- * of <code>CONSTANT_NameAndType_info</code>.
- * @param type <code>descriptor_index</code>
- * of <code>CONSTANT_NameAndType_info</code>.
- * @return the index of the added entry.
- */
- public int addInterfaceMethodrefInfo(int classInfo,
- String name,
- String type)
- {
- int nt = addNameAndTypeInfo(name, type);
- return addInterfaceMethodrefInfo(classInfo, nt);
- }
-
- /**
- * Adds a new <code>CONSTANT_InterfaceMethodref_info</code>
- * structure.
- *
- * @param classInfo <code>class_index</code>
- * @param nameAndTypeInfo <code>name_and_type_index</code>.
- * @return the index of the added entry.
- */
- public int addInterfaceMethodrefInfo(int classInfo,
- int nameAndTypeInfo)
- {
- return addItem(new InterfaceMethodrefInfo(classInfo,
- nameAndTypeInfo,
- numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_String_info</code>
- * structure.
- *
- * <p>This also adds a new <code>CONSTANT_Utf8_info</code>
- * structure.
- *
- * @return the index of the added entry.
- */
- public int addStringInfo(String str)
- {
- int utf = addUtf8Info(str);
- return addItem(new StringInfo(utf, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Integer_info</code>
- * structure.
- *
- * @return the index of the added entry.
- */
- public int addIntegerInfo(int i)
- {
- return addItem(new IntegerInfo(i, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Float_info</code>
- * structure.
- *
- * @return the index of the added entry.
- */
- public int addFloatInfo(float f)
- {
- return addItem(new FloatInfo(f, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Long_info</code>
- * structure.
- *
- * @return the index of the added entry.
- */
- public int addLongInfo(long l)
- {
- int i = addItem(new LongInfo(l, numOfItems));
- if (i == numOfItems - 1) // if not existing
- addConstInfoPadding();
-
- return i;
- }
-
- /**
- * Adds a new <code>CONSTANT_Double_info</code>
- * structure.
- *
- * @return the index of the added entry.
- */
- public int addDoubleInfo(double d)
- {
- int i = addItem(new DoubleInfo(d, numOfItems));
- if (i == numOfItems - 1) // if not existing
- addConstInfoPadding();
-
- return i;
- }
-
- /**
- * Adds a new <code>CONSTANT_Utf8_info</code>
- * structure.
- *
- * @return the index of the added entry.
- */
- public int addUtf8Info(String utf8)
- {
- return addItem(new Utf8Info(utf8, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_MethodHandle_info</code>
- * structure.
- *
- * @param kind <code>reference_kind</code>
- * such as {@link #REF_invokeStatic <code>REF_invokeStatic</code>}.
- * @param index <code>reference_index</code>.
- * @return the index of the added entry.
- *
- * @since 3.17
- */
- public int addMethodHandleInfo(int kind, int index)
- {
- return addItem(new MethodHandleInfo(kind, index, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_MethodType_info</code>
- * structure.
- *
- * @param desc <code>descriptor_index</code>.
- * @return the index of the added entry.
- *
- * @since 3.17
- */
- public int addMethodTypeInfo(int desc)
- {
- return addItem(new MethodTypeInfo(desc, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_InvokeDynamic_info</code>
- * structure.
- *
- * @param bootstrap <code>bootstrap_method_attr_index</code>.
- * @param nameAndType <code>name_and_type_index</code>.
- * @return the index of the added entry.
- *
- * @since 3.17
- */
- public int addInvokeDynamicInfo(int bootstrap, int nameAndType)
- {
- return addItem(new InvokeDynamicInfo(bootstrap, nameAndType, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Dynamic_info</code> structure.
- *
- * @param bootstrap <code>bootstrap_method_attr_index</code>.
- * @param nameAndType <code>name_and_type_index</code>.
- * @return the index of the added entry.
- * @since 3.17
- */
- public int addDynamicInfo(int bootstrap, int nameAndType) {
- return addItem(new DynamicInfo(bootstrap, nameAndType, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Module_info</code>
- * @param nameIndex the index of the Utf8 entry.
- * @return the index of the added entry.
- * @since 3.22
- */
- public int addModuleInfo(int nameIndex)
- {
- return addItem(new ModuleInfo(nameIndex, numOfItems));
- }
-
- /**
- * Adds a new <code>CONSTANT_Package_info</code>
- * @param nameIndex the index of the Utf8 entry.
- * @return the index of the added entry.
- * @since 3.22
- */
- public int addPackageInfo(int nameIndex)
- {
- return addItem(new PackageInfo(nameIndex, numOfItems));
- }
-
- /**
- * Get all the class names.
- *
- * @return a set of class names (<code>String</code> objects).
- */
- public Set<String> getClassNames()
- {
- Set<String> result = new HashSet<String>();
- LongVector v = items;
- int size = numOfItems;
- for (int i = 1; i < size; ++i) {
- String className = v.elementAt(i).getClassName(this);
- if (className != null)
- result.add(className);
- }
- return result;
- }
-
- /**
- * Replaces all occurrences of a class name.
- *
- * @param oldName the replaced name (JVM-internal representation).
- * @param newName the substituted name (JVM-internal representation).
- */
- public void renameClass(String oldName, String newName)
- {
- LongVector v = items;
- int size = numOfItems;
- for (int i = 1; i < size; ++i) {
- ConstInfo ci = v.elementAt(i);
- ci.renameClass(this, oldName, newName, itemsCache);
- }
- }
-
- /**
- * Replaces all occurrences of class names.
- *
- * @param classnames specifies pairs of replaced and substituted
- * name.
- */
- public void renameClass(Map<String,String> classnames)
- {
- LongVector v = items;
- int size = numOfItems;
- for (int i = 1; i < size; ++i) {
- ConstInfo ci = v.elementAt(i);
- ci.renameClass(this, classnames, itemsCache);
- }
- }
-
- private void read(DataInputStream in) throws IOException
- {
- int n = in.readUnsignedShort();
-
- items = new LongVector(n);
- numOfItems = 0;
- addItem0(null); // index 0 is reserved by the JVM.
-
- while (--n > 0) { // index 0 is reserved by JVM
- int tag = readOne(in);
- if ((tag == LongInfo.tag) || (tag == DoubleInfo.tag)) {
- addConstInfoPadding();
- --n;
- }
- }
- }
-
- private static Map<ConstInfo,ConstInfo> makeItemsCache(LongVector items)
- {
- Map<ConstInfo,ConstInfo> cache = new HashMap<ConstInfo,ConstInfo>();
- int i = 1;
- while (true) {
- ConstInfo info = items.elementAt(i++);
- if (info == null)
- break;
- cache.put(info, info);
- }
-
- return cache;
- }
-
- private int readOne(DataInputStream in) throws IOException
- {
- ConstInfo info;
- int tag = in.readUnsignedByte();
- switch (tag) {
- case Utf8Info.tag : // 1
- info = new Utf8Info(in, numOfItems);
- break;
- case IntegerInfo.tag : // 3
- info = new IntegerInfo(in, numOfItems);
- break;
- case FloatInfo.tag : // 4
- info = new FloatInfo(in, numOfItems);
- break;
- case LongInfo.tag : // 5
- info = new LongInfo(in, numOfItems);
- break;
- case DoubleInfo.tag : // 6
- info = new DoubleInfo(in, numOfItems);
- break;
- case ClassInfo.tag : // 7
- info = new ClassInfo(in, numOfItems);
- break;
- case StringInfo.tag : // 8
- info = new StringInfo(in, numOfItems);
- break;
- case FieldrefInfo.tag : // 9
- info = new FieldrefInfo(in, numOfItems);
- break;
- case MethodrefInfo.tag : // 10
- info = new MethodrefInfo(in, numOfItems);
- break;
- case InterfaceMethodrefInfo.tag : // 11
- info = new InterfaceMethodrefInfo(in, numOfItems);
- break;
- case NameAndTypeInfo.tag : // 12
- info = new NameAndTypeInfo(in, numOfItems);
- break;
- case MethodHandleInfo.tag : // 15
- info = new MethodHandleInfo(in, numOfItems);
- break;
- case MethodTypeInfo.tag : // 16
- info = new MethodTypeInfo(in, numOfItems);
- break;
- case DynamicInfo.tag : // 17
- info = new DynamicInfo(in, numOfItems);
- break;
- case InvokeDynamicInfo.tag : // 18
- info = new InvokeDynamicInfo(in, numOfItems);
- break;
- case ModuleInfo.tag : // 19
- info = new ModuleInfo(in, numOfItems);
- break;
- case PackageInfo.tag : // 20
- info = new PackageInfo(in, numOfItems);
- break;
- default :
- throw new IOException("invalid constant type: "
- + tag + " at " + numOfItems);
- }
-
- addItem0(info);
- return tag;
- }
-
- /**
- * Writes the contents of the constant pool table.
- */
- public void write(DataOutputStream out) throws IOException
- {
- out.writeShort(numOfItems);
- LongVector v = items;
- int size = numOfItems;
- for (int i = 1; i < size; ++i)
- v.elementAt(i).write(out);
- }
-
- /**
- * Prints the contents of the constant pool table.
- */
- public void print()
- {
- print(new PrintWriter(System.out, true));
- }
-
- /**
- * Prints the contents of the constant pool table.
- */
- public void print(PrintWriter out)
- {
- int size = numOfItems;
- for (int i = 1; i < size; ++i) {
- out.print(i);
- out.print(" ");
- items.elementAt(i).print(out);
- }
- }
- }
-
- abstract class ConstInfo
- {
- int index;
-
- public ConstInfo(int i) { index = i; }
-
- public abstract int getTag();
-
- public String getClassName(ConstPool cp) { return null; }
- public void renameClass(ConstPool cp, String oldName, String newName,
- Map<ConstInfo,ConstInfo> cache) {}
- public void renameClass(ConstPool cp, Map<String,String> classnames,
- Map<ConstInfo,ConstInfo> cache) {}
- public abstract int copy(ConstPool src, ConstPool dest,
- Map<String, String> classnames);
- // ** classnames is a mapping between JVM names.
-
- public abstract void write(DataOutputStream out) throws IOException;
- public abstract void print(PrintWriter out);
-
- @Override
- public String toString() {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- PrintWriter out = new PrintWriter(bout);
- print(out);
- return bout.toString();
- }
- }
-
- /* padding following DoubleInfo or LongInfo.
- */
- class ConstInfoPadding extends ConstInfo
- {
- public ConstInfoPadding(int i) { super(i); }
-
- @Override
- public int getTag() { return 0; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- return dest.addConstInfoPadding();
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException {}
-
- @Override
- public void print(PrintWriter out)
- {
- out.println("padding");
- }
- }
-
- class ClassInfo extends ConstInfo
- {
- static final int tag = 7;
- int name;
-
- public ClassInfo(int className, int index)
- {
- super(index);
- name = className;
- }
-
- public ClassInfo(DataInputStream in, int index) throws IOException
- {
- super(index);
- name = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return name; }
-
- @Override
- public boolean equals(Object obj)
- {
- return obj instanceof ClassInfo && ((ClassInfo)obj).name == name;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public String getClassName(ConstPool cp)
- {
- return cp.getUtf8Info(name);
- }
-
- @Override
- public void renameClass(ConstPool cp, String oldName, String newName,
- Map<ConstInfo,ConstInfo> cache)
- {
- String nameStr = cp.getUtf8Info(name);
- String newNameStr = null;
- if (nameStr.equals(oldName))
- newNameStr = newName;
- else if (nameStr.charAt(0) == '[') {
- String s = Descriptor.rename(nameStr, oldName, newName);
- if (nameStr != s)
- newNameStr = s;
- }
-
- if (newNameStr != null)
- if (cache == null)
- name = cp.addUtf8Info(newNameStr);
- else {
- cache.remove(this);
- name = cp.addUtf8Info(newNameStr);
- cache.put(this, this);
- }
- }
-
- @Override
- public void renameClass(ConstPool cp, Map<String,String> map,
- Map<ConstInfo,ConstInfo> cache)
- {
- String oldName = cp.getUtf8Info(name);
- String newName = null;
- if (oldName.charAt(0) == '[') {
- String s = Descriptor.rename(oldName, map);
- if (oldName != s)
- newName = s;
- }
- else {
- String s = map.get(oldName);
- if (s != null && !s.equals(oldName))
- newName = s;
- }
-
- if (newName != null) {
- if (cache == null)
- name = cp.addUtf8Info(newName);
- else {
- cache.remove(this);
- name = cp.addUtf8Info(newName);
- cache.put(this, this);
- }
- }
- }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- String classname = src.getUtf8Info(name);
- if (map != null) {
- String newname = map.get(classname);
- if (newname != null)
- classname = newname;
- }
-
- return dest.addClassInfo(classname);
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeShort(name);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print("Class #");
- out.println(name);
- }
- }
-
- class NameAndTypeInfo extends ConstInfo
- {
- static final int tag = 12;
- int memberName;
- int typeDescriptor;
-
- public NameAndTypeInfo(int name, int type, int index)
- {
- super(index);
- memberName = name;
- typeDescriptor = type;
- }
-
- public NameAndTypeInfo(DataInputStream in, int index) throws IOException
- {
- super(index);
- memberName = in.readUnsignedShort();
- typeDescriptor = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return (memberName << 16) ^ typeDescriptor; }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof NameAndTypeInfo) {
- NameAndTypeInfo nti = (NameAndTypeInfo)obj;
- return nti.memberName == memberName
- && nti.typeDescriptor == typeDescriptor;
- }
- return false;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public void renameClass(ConstPool cp, String oldName, String newName,
- Map<ConstInfo,ConstInfo> cache)
- {
- String type = cp.getUtf8Info(typeDescriptor);
- String type2 = Descriptor.rename(type, oldName, newName);
- if (type != type2)
- if (cache == null)
- typeDescriptor = cp.addUtf8Info(type2);
- else {
- cache.remove(this);
- typeDescriptor = cp.addUtf8Info(type2);
- cache.put(this, this);
- }
- }
-
- @Override
- public void renameClass(ConstPool cp, Map<String,String> map,
- Map<ConstInfo,ConstInfo> cache)
- {
- String type = cp.getUtf8Info(typeDescriptor);
- String type2 = Descriptor.rename(type, map);
- if (type != type2)
- if (cache == null)
- typeDescriptor = cp.addUtf8Info(type2);
- else {
- cache.remove(this);
- typeDescriptor = cp.addUtf8Info(type2);
- cache.put(this, this);
- }
- }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- String mname = src.getUtf8Info(memberName);
- String tdesc = src.getUtf8Info(typeDescriptor);
- tdesc = Descriptor.rename(tdesc, map);
- return dest.addNameAndTypeInfo(dest.addUtf8Info(mname),
- dest.addUtf8Info(tdesc));
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException {
- out.writeByte(tag);
- out.writeShort(memberName);
- out.writeShort(typeDescriptor);
- }
-
- @Override
- public void print(PrintWriter out) {
- out.print("NameAndType #");
- out.print(memberName);
- out.print(", type #");
- out.println(typeDescriptor);
- }
- }
-
- abstract class MemberrefInfo extends ConstInfo
- {
- int classIndex;
- int nameAndTypeIndex;
-
- public MemberrefInfo(int cindex, int ntindex, int thisIndex)
- {
- super(thisIndex);
- classIndex = cindex;
- nameAndTypeIndex = ntindex;
- }
-
- public MemberrefInfo(DataInputStream in, int thisIndex)
- throws IOException
- {
- super(thisIndex);
- classIndex = in.readUnsignedShort();
- nameAndTypeIndex = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return (classIndex << 16) ^ nameAndTypeIndex; }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof MemberrefInfo) {
- MemberrefInfo mri = (MemberrefInfo)obj;
- return mri.classIndex == classIndex
- && mri.nameAndTypeIndex == nameAndTypeIndex
- && mri.getClass() == this.getClass();
- }
- return false;
- }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- int classIndex2 = src.getItem(classIndex).copy(src, dest, map);
- int ntIndex2 = src.getItem(nameAndTypeIndex).copy(src, dest, map);
- return copy2(dest, classIndex2, ntIndex2);
- }
-
- abstract protected int copy2(ConstPool dest, int cindex, int ntindex);
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(getTag());
- out.writeShort(classIndex);
- out.writeShort(nameAndTypeIndex);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print(getTagName() + " #");
- out.print(classIndex);
- out.print(", name&type #");
- out.println(nameAndTypeIndex);
- }
-
- public abstract String getTagName();
- }
-
- class FieldrefInfo extends MemberrefInfo
- {
- static final int tag = 9;
-
- public FieldrefInfo(int cindex, int ntindex, int thisIndex)
- {
- super(cindex, ntindex, thisIndex);
- }
-
- public FieldrefInfo(DataInputStream in, int thisIndex)
- throws IOException
- {
- super(in, thisIndex);
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public String getTagName() { return "Field"; }
-
- @Override
- protected int copy2(ConstPool dest, int cindex, int ntindex)
- {
- return dest.addFieldrefInfo(cindex, ntindex);
- }
- }
-
- class MethodrefInfo extends MemberrefInfo
- {
- static final int tag = 10;
-
- public MethodrefInfo(int cindex, int ntindex, int thisIndex)
- {
- super(cindex, ntindex, thisIndex);
- }
-
- public MethodrefInfo(DataInputStream in, int thisIndex)
- throws IOException
- {
- super(in, thisIndex);
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public String getTagName() { return "Method"; }
-
- @Override
- protected int copy2(ConstPool dest, int cindex, int ntindex)
- {
- return dest.addMethodrefInfo(cindex, ntindex);
- }
- }
-
- class InterfaceMethodrefInfo extends MemberrefInfo
- {
- static final int tag = 11;
-
- public InterfaceMethodrefInfo(int cindex, int ntindex, int thisIndex)
- {
- super(cindex, ntindex, thisIndex);
- }
-
- public InterfaceMethodrefInfo(DataInputStream in, int thisIndex)
- throws IOException
- {
- super(in, thisIndex);
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public String getTagName() { return "Interface"; }
-
- @Override
- protected int copy2(ConstPool dest, int cindex, int ntindex)
- {
- return dest.addInterfaceMethodrefInfo(cindex, ntindex);
- }
- }
-
- class StringInfo extends ConstInfo
- {
- static final int tag = 8;
- int string;
-
- public StringInfo(int str, int index)
- {
- super(index);
- string = str;
- }
-
- public StringInfo(DataInputStream in, int index) throws IOException
- {
- super(index);
- string = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return string; }
-
- @Override
- public boolean equals(Object obj)
- {
- return obj instanceof StringInfo && ((StringInfo)obj).string == string;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- return dest.addStringInfo(src.getUtf8Info(string));
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeShort(string);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print("String #");
- out.println(string);
- }
- }
-
- class IntegerInfo extends ConstInfo
- {
- static final int tag = 3;
- int value;
-
- public IntegerInfo(int v, int index)
- {
- super(index);
- value = v;
- }
-
- public IntegerInfo(DataInputStream in, int index) throws IOException
- {
- super(index);
- value = in.readInt();
- }
-
- @Override
- public int hashCode() { return value; }
-
- @Override
- public boolean equals(Object obj)
- {
- return obj instanceof IntegerInfo && ((IntegerInfo)obj).value == value;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- return dest.addIntegerInfo(value);
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeInt(value);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print("Integer ");
- out.println(value);
- }
- }
-
- class FloatInfo extends ConstInfo
- {
- static final int tag = 4;
- float value;
-
- public FloatInfo(float f, int index)
- {
- super(index);
- value = f;
- }
-
- public FloatInfo(DataInputStream in, int index) throws IOException
- {
- super(index);
- value = in.readFloat();
- }
-
- @Override
- public int hashCode() { return Float.floatToIntBits(value); }
-
- @Override
- public boolean equals(Object obj)
- {
- return obj instanceof FloatInfo && ((FloatInfo)obj).value == value;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- return dest.addFloatInfo(value);
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeFloat(value);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print("Float ");
- out.println(value);
- }
- }
-
- class LongInfo extends ConstInfo
- {
- static final int tag = 5;
- long value;
-
- public LongInfo(long l, int index)
- {
- super(index);
- value = l;
- }
-
- public LongInfo(DataInputStream in, int index) throws IOException
- {
- super(index);
- value = in.readLong();
- }
-
- @Override
- public int hashCode() { return (int)(value ^ (value >>> 32)); }
-
- @Override
- public boolean equals(Object obj) {
- return obj instanceof LongInfo && ((LongInfo)obj).value == value;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- return dest.addLongInfo(value);
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeLong(value);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print("Long ");
- out.println(value);
- }
- }
-
- class DoubleInfo extends ConstInfo
- {
- static final int tag = 6;
- double value;
-
- public DoubleInfo(double d, int index)
- {
- super(index);
- value = d;
- }
-
- public DoubleInfo(DataInputStream in, int index) throws IOException
- {
- super(index);
- value = in.readDouble();
- }
-
- @Override
- public int hashCode() {
- long v = Double.doubleToLongBits(value);
- return (int)(v ^ (v >>> 32));
- }
-
- @Override
- public boolean equals(Object obj)
- {
- return obj instanceof DoubleInfo
- && ((DoubleInfo)obj).value == value;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- return dest.addDoubleInfo(value);
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeDouble(value);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print("Double ");
- out.println(value);
- }
- }
-
- class Utf8Info extends ConstInfo
- {
- static final int tag = 1;
- String string;
-
- public Utf8Info(String utf8, int index)
- {
- super(index);
- string = utf8;
- }
-
- public Utf8Info(DataInputStream in, int index)
- throws IOException
- {
- super(index);
- string = in.readUTF();
- }
-
- @Override
- public int hashCode() {
- return string.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- return obj instanceof Utf8Info
- && ((Utf8Info)obj).string.equals(string);
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest,
- Map<String,String> map)
- {
- return dest.addUtf8Info(string);
- }
-
- @Override
- public void write(DataOutputStream out)
- throws IOException
- {
- out.writeByte(tag);
- out.writeUTF(string);
- }
-
- @Override
- public void print(PrintWriter out) {
- out.print("UTF8 \"");
- out.print(string);
- out.println("\"");
- }
- }
-
- class MethodHandleInfo extends ConstInfo {
- static final int tag = 15;
- int refKind, refIndex;
-
- public MethodHandleInfo(int kind, int referenceIndex, int index) {
- super(index);
- refKind = kind;
- refIndex = referenceIndex;
- }
-
- public MethodHandleInfo(DataInputStream in, int index)
- throws IOException
- {
- super(index);
- refKind = in.readUnsignedByte();
- refIndex = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return (refKind << 16) ^ refIndex; }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof MethodHandleInfo) {
- MethodHandleInfo mh = (MethodHandleInfo)obj;
- return mh.refKind == refKind && mh.refIndex == refIndex;
- }
- return false;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest,
- Map<String,String> map)
- {
- return dest.addMethodHandleInfo(refKind,
- src.getItem(refIndex).copy(src, dest, map));
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeByte(refKind);
- out.writeShort(refIndex);
- }
-
- @Override
- public void print(PrintWriter out) {
- out.print("MethodHandle #");
- out.print(refKind);
- out.print(", index #");
- out.println(refIndex);
- }
- }
-
- class MethodTypeInfo extends ConstInfo
- {
- static final int tag = 16;
- int descriptor;
-
- public MethodTypeInfo(int desc, int index)
- {
- super(index);
- descriptor = desc;
- }
-
- public MethodTypeInfo(DataInputStream in, int index)
- throws IOException
- {
- super(index);
- descriptor = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return descriptor; }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof MethodTypeInfo)
- return ((MethodTypeInfo)obj).descriptor == descriptor;
- return false;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public void renameClass(ConstPool cp, String oldName, String newName,
- Map<ConstInfo,ConstInfo> cache)
- {
- String desc = cp.getUtf8Info(descriptor);
- String desc2 = Descriptor.rename(desc, oldName, newName);
- if (desc != desc2)
- if (cache == null)
- descriptor = cp.addUtf8Info(desc2);
- else {
- cache.remove(this);
- descriptor = cp.addUtf8Info(desc2);
- cache.put(this, this);
- }
- }
-
- @Override
- public void renameClass(ConstPool cp, Map<String,String> map,
- Map<ConstInfo,ConstInfo> cache)
- {
- String desc = cp.getUtf8Info(descriptor);
- String desc2 = Descriptor.rename(desc, map);
- if (desc != desc2)
- if (cache == null)
- descriptor = cp.addUtf8Info(desc2);
- else {
- cache.remove(this);
- descriptor = cp.addUtf8Info(desc2);
- cache.put(this, this);
- }
- }
-
- @Override
- public int copy(ConstPool src, ConstPool dest, Map<String,String> map)
- {
- String desc = src.getUtf8Info(descriptor);
- desc = Descriptor.rename(desc, map);
- return dest.addMethodTypeInfo(dest.addUtf8Info(desc));
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeShort(descriptor);
- }
-
- @Override
- public void print(PrintWriter out) {
- out.print("MethodType #");
- out.println(descriptor);
- }
- }
-
- class InvokeDynamicInfo extends ConstInfo
- {
- static final int tag = 18;
- int bootstrap, nameAndType;
-
- public InvokeDynamicInfo(int bootstrapMethod,
- int ntIndex, int index)
- {
- super(index);
- bootstrap = bootstrapMethod;
- nameAndType = ntIndex;
- }
-
- public InvokeDynamicInfo(DataInputStream in, int index)
- throws IOException
- {
- super(index);
- bootstrap = in.readUnsignedShort();
- nameAndType = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return (bootstrap << 16) ^ nameAndType; }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof InvokeDynamicInfo) {
- InvokeDynamicInfo iv = (InvokeDynamicInfo)obj;
- return iv.bootstrap == bootstrap
- && iv.nameAndType == nameAndType;
- }
- return false;
- }
-
- @Override
- public int getTag() { return tag; }
-
- @Override
- public int copy(ConstPool src, ConstPool dest,
- Map<String,String> map)
- {
- return dest.addInvokeDynamicInfo(bootstrap,
- src.getItem(nameAndType).copy(src, dest, map));
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeShort(bootstrap);
- out.writeShort(nameAndType);
- }
-
- @Override
- public void print(PrintWriter out) {
- out.print("InvokeDynamic #");
- out.print(bootstrap);
- out.print(", name&type #");
- out.println(nameAndType);
- }
- }
-
- class DynamicInfo extends ConstInfo {
-
- static final int tag = 17;
- int bootstrap, nameAndType;
-
- public DynamicInfo(int bootstrapMethod,
- int ntIndex, int index) {
- super(index);
- bootstrap = bootstrapMethod;
- nameAndType = ntIndex;
- }
-
- public DynamicInfo(DataInputStream in, int index)
- throws IOException {
- super(index);
- bootstrap = in.readUnsignedShort();
- nameAndType = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() {
- return (bootstrap << 16) ^ nameAndType;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof DynamicInfo) {
- DynamicInfo iv = (DynamicInfo) obj;
- return iv.bootstrap == bootstrap
- && iv.nameAndType == nameAndType;
- }
- return false;
- }
-
- @Override
- public int getTag() {
- return tag;
- }
-
- @Override
- public int copy(ConstPool src, ConstPool dest,
- Map<String, String> map) {
- return dest.addDynamicInfo(bootstrap,
- src.getItem(nameAndType).copy(src, dest, map));
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException {
- out.writeByte(tag);
- out.writeShort(bootstrap);
- out.writeShort(nameAndType);
- }
-
- @Override
- public void print(PrintWriter out) {
- out.print("Dynamic #");
- out.print(bootstrap);
- out.print(", name&type #");
- out.println(nameAndType);
- }
- }
-
- class ModuleInfo extends ConstInfo
- {
- static final int tag = 19;
- int name;
-
- public ModuleInfo(int moduleName, int index)
- {
- super(index);
- name = moduleName;
- }
-
- public ModuleInfo(DataInputStream in, int index)
- throws IOException
- {
- super(index);
- name = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return name; }
-
- @Override
- public boolean equals(Object obj)
- {
- return obj instanceof ModuleInfo
- && ((ModuleInfo)obj).name == name;
- }
-
- @Override
- public int getTag() { return tag; }
-
- public String getModuleName(ConstPool cp)
- {
- return cp.getUtf8Info(name);
- }
-
- @Override
- public int copy(ConstPool src, ConstPool dest,
- Map<String,String> map)
- {
- String moduleName = src.getUtf8Info(name);
- int newName = dest.addUtf8Info(moduleName);
- return dest.addModuleInfo(newName);
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeShort(name);
- }
-
- @Override
- public void print(PrintWriter out) {
- out.print("Module #");
- out.println(name);
- }
- }
-
- class PackageInfo extends ConstInfo
- {
- static final int tag = 20;
- int name;
-
- public PackageInfo(int moduleName, int index)
- {
- super(index);
- name = moduleName;
- }
-
- public PackageInfo(DataInputStream in, int index)
- throws IOException
- {
- super(index);
- name = in.readUnsignedShort();
- }
-
- @Override
- public int hashCode() { return name; }
-
- @Override
- public boolean equals(Object obj) {
- return obj instanceof PackageInfo
- && ((PackageInfo)obj).name == name;
- }
-
- @Override
- public int getTag() { return tag; }
-
- public String getPackageName(ConstPool cp)
- {
- return cp.getUtf8Info(name);
- }
-
- @Override
- public int copy(ConstPool src, ConstPool dest,
- Map<String,String> map)
- {
- String packageName = src.getUtf8Info(name);
- int newName = dest.addUtf8Info(packageName);
- return dest.addModuleInfo(newName);
- }
-
- @Override
- public void write(DataOutputStream out) throws IOException
- {
- out.writeByte(tag);
- out.writeShort(name);
- }
-
- @Override
- public void print(PrintWriter out)
- {
- out.print("Package #");
- out.println(name);
- }
- }
|