mirror of
https://github.com/revanced/smali.git
synced 2025-05-09 10:54:29 +02:00
Add some missing nullness attributes
This commit is contained in:
parent
9581b16739
commit
8daecd0246
@ -41,7 +41,7 @@ import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class DexBackedAnnotation implements Annotation {
|
||||
public final DexFile dexFile;
|
||||
@Nonnull public final DexFile dexFile;
|
||||
|
||||
public final int visibility;
|
||||
@Nonnull public final String type;
|
||||
@ -67,6 +67,7 @@ public class DexBackedAnnotation implements Annotation {
|
||||
final int size = reader.readSmallUleb128();
|
||||
|
||||
return new VariableSizeList<AnnotationElement>(dexFile, reader.getOffset()) {
|
||||
@Nonnull
|
||||
@Override
|
||||
protected AnnotationElement readItem(DexFileReader dexFileReader, int index) {
|
||||
return new DexBackedAnnotationElement(dexFileReader);
|
||||
|
@ -65,7 +65,7 @@ public class DexBackedClassDef implements ClassDef {
|
||||
private static final int CLASS_DATA_OFFSET = 24;
|
||||
private static final int STATIC_INITIAL_VALUES_OFFSET = 28;
|
||||
|
||||
public DexBackedClassDef(DexFile dexFile,
|
||||
public DexBackedClassDef(@Nonnull DexFile dexFile,
|
||||
int classDefOffset) {
|
||||
this.dexFile = dexFile;
|
||||
|
||||
|
@ -43,7 +43,7 @@ import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class DexBackedField implements Field {
|
||||
public final DexFile dexFile;
|
||||
@Nonnull public final DexFile dexFile;
|
||||
|
||||
@Nonnull public final String name;
|
||||
@Nonnull public final String type;
|
||||
|
@ -69,6 +69,7 @@ public class DexBackedTryBlock implements TryBlock {
|
||||
if (encodedSize > 0) {
|
||||
//no catch-all
|
||||
return new VariableSizeList<ExceptionHandler>(dexFile, reader.getOffset()) {
|
||||
@Nonnull
|
||||
@Override
|
||||
protected ExceptionHandler readItem(DexFileReader dexFileReader, int index) {
|
||||
return new DexBackedExceptionHandler(dexFileReader);
|
||||
@ -79,6 +80,7 @@ public class DexBackedTryBlock implements TryBlock {
|
||||
//with catch-all
|
||||
final int sizeWithCatchAll = (-1 * encodedSize) + 1;
|
||||
return new VariableSizeList<ExceptionHandler>(dexFile, reader.getOffset()) {
|
||||
@Nonnull
|
||||
@Override
|
||||
protected ExceptionHandler readItem(DexFileReader dexFileReader, int index) {
|
||||
if (index == sizeWithCatchAll-1) {
|
||||
|
@ -36,6 +36,7 @@ import org.jf.dexlib2.DexFileReader;
|
||||
import org.jf.dexlib2.dexbacked.value.DexBackedEncodedValue;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class StaticInitialValueIterator {
|
||||
public static final StaticInitialValueIterator EMPTY = new StaticInitialValueIterator() {
|
||||
@ -43,9 +44,10 @@ public abstract class StaticInitialValueIterator {
|
||||
@Override public void skipNext() {}
|
||||
};
|
||||
|
||||
public abstract DexBackedEncodedValue getNextOrNull();
|
||||
@Nullable public abstract DexBackedEncodedValue getNextOrNull();
|
||||
public abstract void skipNext();
|
||||
|
||||
@Nonnull
|
||||
public static StaticInitialValueIterator newOrEmpty(@Nonnull DexFile dexFile, int offset) {
|
||||
if (offset == 0) {
|
||||
return EMPTY;
|
||||
@ -63,6 +65,7 @@ public abstract class StaticInitialValueIterator {
|
||||
this.size = reader.readSmallUleb128();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public DexBackedEncodedValue getNextOrNull() {
|
||||
if (index < size) {
|
||||
index++;
|
||||
|
@ -35,6 +35,7 @@ import org.jf.dexlib2.DexFile;
|
||||
import org.jf.dexlib2.DexFileReader;
|
||||
import org.jf.util.AbstractListIterator;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.AbstractSequentialList;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
@ -43,20 +44,22 @@ import java.util.NoSuchElementException;
|
||||
* @param <T> The type of the item that this list contains
|
||||
*/
|
||||
public abstract class VariableSizeList<T> extends AbstractSequentialList<T> {
|
||||
private final DexFile dexFile;
|
||||
@Nonnull private final DexFile dexFile;
|
||||
private final int offset;
|
||||
|
||||
public VariableSizeList(DexFile dexFile, int offset) {
|
||||
public VariableSizeList(@Nonnull DexFile dexFile, int offset) {
|
||||
this.dexFile = dexFile;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected abstract T readItem(DexFileReader dexFileReader, int index);
|
||||
|
||||
protected void skipItem(DexFileReader dexFileReader, int index) {
|
||||
readItem(dexFileReader, index);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator listIterator(int startIndex) {
|
||||
Iterator iterator = listIterator();
|
||||
@ -69,6 +72,7 @@ public abstract class VariableSizeList<T> extends AbstractSequentialList<T> {
|
||||
return iterator;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator listIterator() {
|
||||
return new Iterator();
|
||||
@ -76,11 +80,12 @@ public abstract class VariableSizeList<T> extends AbstractSequentialList<T> {
|
||||
|
||||
public class Iterator extends AbstractListIterator<T> {
|
||||
private int index = 0;
|
||||
private final DexFileReader dexFileReader = dexFile.readerAt(offset);
|
||||
@Nonnull private final DexFileReader dexFileReader = dexFile.readerAt(offset);
|
||||
|
||||
@Override public boolean hasNext() { return index < size(); }
|
||||
@Override public int nextIndex() { return index; }
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public T next() {
|
||||
if (index >= size()) {
|
||||
|
@ -66,7 +66,7 @@ public abstract class VariableSizeListWithContext<T> extends AbstractSequentialL
|
||||
|
||||
public abstract class Iterator extends AbstractListIterator<T> {
|
||||
private int index = 0;
|
||||
private final DexFileReader reader;
|
||||
@Nonnull private final DexFileReader reader;
|
||||
|
||||
public Iterator(DexFile dexFile, int offset) {
|
||||
this.reader = dexFile.readerAt(offset);
|
||||
|
Loading…
x
Reference in New Issue
Block a user