mirror of
https://github.com/revanced/multidexlib2.git
synced 2025-05-09 19:04:29 +02:00
Fix AbstractMultiDexContainer
This commit is contained in:
parent
9f8ecb03c4
commit
903e3ed9fb
@ -15,7 +15,6 @@ import java.util.Collections;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcodes;
|
|
||||||
import org.jf.dexlib2.iface.DexFile;
|
import org.jf.dexlib2.iface.DexFile;
|
||||||
import org.jf.dexlib2.iface.MultiDexContainer;
|
import org.jf.dexlib2.iface.MultiDexContainer;
|
||||||
|
|
||||||
@ -23,24 +22,15 @@ public abstract class AbstractMultiDexContainer<T extends DexFile> implements Mu
|
|||||||
|
|
||||||
private Map<String, T> entryMap;
|
private Map<String, T> entryMap;
|
||||||
private List<String> entryNames;
|
private List<String> entryNames;
|
||||||
private Opcodes resolvedOpcodes;
|
|
||||||
|
|
||||||
protected AbstractMultiDexContainer() {}
|
protected AbstractMultiDexContainer() {}
|
||||||
|
|
||||||
protected void initialize(Map<String, T> entryMap, Opcodes opcodes) {
|
protected void initialize(Map<String, T> entryMap) {
|
||||||
if (entryMap == null) throw new NullPointerException("entryMap");
|
if (entryMap == null) throw new NullPointerException("entryMap");
|
||||||
if (this.entryMap != null) throw new IllegalStateException("Already initialized");
|
if (this.entryMap != null) throw new IllegalStateException("Already initialized");
|
||||||
this.entryMap = entryMap;
|
this.entryMap = entryMap;
|
||||||
// See: https://github.com/JesusFreke/smali/issues/458
|
// See: https://github.com/JesusFreke/smali/issues/458
|
||||||
entryNames = Collections.unmodifiableList(new ArrayList<>(entryMap.keySet()));
|
entryNames = Collections.unmodifiableList(new ArrayList<>(entryMap.keySet()));
|
||||||
if (opcodes == null) {
|
|
||||||
//opcodes = getNewestOpcodes();
|
|
||||||
for (T entry : entryMap.values()) {
|
|
||||||
opcodes = OpcodeUtils.getNewestOpcodes(opcodes, entry.getOpcodes(), true);
|
|
||||||
}
|
|
||||||
//if (opcodes == null) throw nullOpcodes();
|
|
||||||
}
|
|
||||||
resolvedOpcodes = opcodes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -53,12 +43,6 @@ public abstract class AbstractMultiDexContainer<T extends DexFile> implements Mu
|
|||||||
return entryMap.get(entryName);
|
return entryMap.get(entryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Opcodes getOpcodes() {
|
|
||||||
//if (resolvedOpcodes == null) throw nullOpcodes();
|
|
||||||
return resolvedOpcodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public Opcodes getNewestOpcodes() {
|
public Opcodes getNewestOpcodes() {
|
||||||
Opcodes opcodes = null;
|
Opcodes opcodes = null;
|
||||||
|
@ -32,7 +32,7 @@ public class DirectoryDexContainer extends AbstractMultiDexContainer<WrappingMul
|
|||||||
if (entryMap.put(entryName, multiDexFile) != null) throwDuplicateEntryName(entryName);
|
if (entryMap.put(entryName, multiDexFile) != null) throwDuplicateEntryName(entryName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
initialize(entryMap, opcodes);
|
initialize(entryMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ package lanchon.multidexlib2;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jf.dexlib2.Opcodes;
|
|
||||||
import org.jf.dexlib2.iface.DexFile;
|
import org.jf.dexlib2.iface.DexFile;
|
||||||
|
|
||||||
public class SingletonDexContainer<D extends DexFile> extends AbstractMultiDexContainer<WrappingMultiDexFile<D>> {
|
public class SingletonDexContainer<D extends DexFile> extends AbstractMultiDexContainer<WrappingMultiDexFile<D>> {
|
||||||
@ -31,10 +30,9 @@ public class SingletonDexContainer<D extends DexFile> extends AbstractMultiDexCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SingletonDexContainer(String entryName, D dexFile) {
|
public SingletonDexContainer(String entryName, D dexFile) {
|
||||||
Opcodes opcodes = dexFile.getOpcodes();
|
|
||||||
WrappingMultiDexFile<D> multiDexFile = new BasicMultiDexFile<>(this, entryName, dexFile);
|
WrappingMultiDexFile<D> multiDexFile = new BasicMultiDexFile<>(this, entryName, dexFile);
|
||||||
Map<String, WrappingMultiDexFile<D>> entryMap = Collections.singletonMap(entryName, multiDexFile);
|
Map<String, WrappingMultiDexFile<D>> entryMap = Collections.singletonMap(entryName, multiDexFile);
|
||||||
initialize(entryMap, opcodes);
|
initialize(entryMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public class ZipFileDexContainer extends AbstractMultiDexContainer<WrappingMulti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
initialize(entryMap, opcodes);
|
initialize(entryMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user