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