1 /* 2 * Copyright 2013, Google LLC 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google LLC nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 package com.android.tools.smali.dexlib2.writer; 32 33 import com.android.tools.smali.dexlib2.HiddenApiRestriction; 34 import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation; 35 import com.android.tools.smali.dexlib2.iface.ExceptionHandler; 36 import com.android.tools.smali.dexlib2.iface.TryBlock; 37 import com.android.tools.smali.dexlib2.iface.debug.DebugItem; 38 import com.android.tools.smali.dexlib2.iface.instruction.Instruction; 39 40 import javax.annotation.Nonnull; 41 import javax.annotation.Nullable; 42 import java.io.IOException; 43 import java.util.Collection; 44 import java.util.List; 45 import java.util.Map; 46 import java.util.Set; 47 48 public interface ClassSection<StringKey extends CharSequence, TypeKey extends CharSequence, TypeListKey, ClassKey, 49 FieldKey, MethodKey, AnnotationSetKey, EncodedArrayKey> extends IndexSection<ClassKey> { getSortedClasses()50 @Nonnull Collection<? extends ClassKey> getSortedClasses(); 51 getClassEntryByType(@ullable TypeKey key)52 @Nullable Map.Entry<? extends ClassKey, Integer> getClassEntryByType(@Nullable TypeKey key); 53 getType(@onnull ClassKey key)54 @Nonnull TypeKey getType(@Nonnull ClassKey key); getAccessFlags(@onnull ClassKey key)55 int getAccessFlags(@Nonnull ClassKey key); getSuperclass(@onnull ClassKey key)56 @Nullable TypeKey getSuperclass(@Nonnull ClassKey key); getInterfaces(@onnull ClassKey key)57 @Nullable TypeListKey getInterfaces(@Nonnull ClassKey key); getSourceFile(@onnull ClassKey key)58 @Nullable StringKey getSourceFile(@Nonnull ClassKey key); getStaticInitializers(@onnull ClassKey key)59 @Nullable EncodedArrayKey getStaticInitializers(@Nonnull ClassKey key); 60 getSortedStaticFields(@onnull ClassKey key)61 @Nonnull Collection<? extends FieldKey> getSortedStaticFields(@Nonnull ClassKey key); getSortedInstanceFields(@onnull ClassKey key)62 @Nonnull Collection<? extends FieldKey> getSortedInstanceFields(@Nonnull ClassKey key); getSortedFields(@onnull ClassKey key)63 @Nonnull Collection<? extends FieldKey> getSortedFields(@Nonnull ClassKey key); getSortedDirectMethods(@onnull ClassKey key)64 @Nonnull Collection<? extends MethodKey> getSortedDirectMethods(@Nonnull ClassKey key); getSortedVirtualMethods(@onnull ClassKey key)65 @Nonnull Collection<? extends MethodKey> getSortedVirtualMethods(@Nonnull ClassKey key); getSortedMethods(@onnull ClassKey key)66 @Nonnull Collection<? extends MethodKey> getSortedMethods(@Nonnull ClassKey key); 67 getFieldAccessFlags(@onnull FieldKey key)68 int getFieldAccessFlags(@Nonnull FieldKey key); getMethodAccessFlags(@onnull MethodKey key)69 int getMethodAccessFlags(@Nonnull MethodKey key); 70 getFieldHiddenApiRestrictions(@onnull FieldKey key)71 @Nonnull Set<HiddenApiRestriction> getFieldHiddenApiRestrictions(@Nonnull FieldKey key); getMethodHiddenApiRestrictions(@onnull MethodKey key)72 @Nonnull Set<HiddenApiRestriction> getMethodHiddenApiRestrictions(@Nonnull MethodKey key); 73 getClassAnnotations(@onnull ClassKey key)74 @Nullable AnnotationSetKey getClassAnnotations(@Nonnull ClassKey key); getFieldAnnotations(@onnull FieldKey key)75 @Nullable AnnotationSetKey getFieldAnnotations(@Nonnull FieldKey key); getMethodAnnotations(@onnull MethodKey key)76 @Nullable AnnotationSetKey getMethodAnnotations(@Nonnull MethodKey key); getParameterAnnotations(@onnull MethodKey key)77 @Nullable List<? extends AnnotationSetKey> getParameterAnnotations(@Nonnull MethodKey key); 78 getDebugItems(@onnull MethodKey key)79 @Nullable Iterable<? extends DebugItem> getDebugItems(@Nonnull MethodKey key); getParameterNames(@onnull MethodKey key)80 @Nullable Iterable<? extends StringKey> getParameterNames(@Nonnull MethodKey key); 81 getRegisterCount(@onnull MethodKey key)82 int getRegisterCount(@Nonnull MethodKey key); getInstructions(@onnull MethodKey key)83 @Nullable Iterable<? extends Instruction> getInstructions(@Nonnull MethodKey key); getTryBlocks(@onnull MethodKey key)84 @Nonnull List<? extends TryBlock<? extends ExceptionHandler>> getTryBlocks(@Nonnull MethodKey key); getExceptionType(@onnull ExceptionHandler handler)85 @Nullable TypeKey getExceptionType(@Nonnull ExceptionHandler handler); makeMutableMethodImplementation(@onnull MethodKey key)86 @Nonnull MutableMethodImplementation makeMutableMethodImplementation(@Nonnull MethodKey key); 87 setAnnotationDirectoryOffset(@onnull ClassKey key, int offset)88 void setAnnotationDirectoryOffset(@Nonnull ClassKey key, int offset); getAnnotationDirectoryOffset(@onnull ClassKey key)89 int getAnnotationDirectoryOffset(@Nonnull ClassKey key); 90 setAnnotationSetRefListOffset(@onnull MethodKey key, int offset)91 void setAnnotationSetRefListOffset(@Nonnull MethodKey key, int offset); getAnnotationSetRefListOffset(@onnull MethodKey key)92 int getAnnotationSetRefListOffset(@Nonnull MethodKey key); 93 setCodeItemOffset(@onnull MethodKey key, int offset)94 void setCodeItemOffset(@Nonnull MethodKey key, int offset); getCodeItemOffset(@onnull MethodKey key)95 int getCodeItemOffset(@Nonnull MethodKey key); 96 writeDebugItem(@onnull DebugWriter<StringKey, TypeKey> writer, DebugItem debugItem)97 void writeDebugItem(@Nonnull DebugWriter<StringKey, TypeKey> writer, DebugItem debugItem) throws IOException; 98 } 99