diff --git a/jadx-core/src/main/java/jadx/api/ResourceType.java b/jadx-core/src/main/java/jadx/api/ResourceType.java index a0d3b606..dae2805b 100644 --- a/jadx-core/src/main/java/jadx/api/ResourceType.java +++ b/jadx-core/src/main/java/jadx/api/ResourceType.java @@ -10,7 +10,7 @@ public enum ResourceType { LIB(".so"), UNKNOWN; - private String[] exts; + private final String[] exts; ResourceType(String... exts) { this.exts = exts; diff --git a/jadx-core/src/main/java/jadx/api/ResourcesLoader.java b/jadx-core/src/main/java/jadx/api/ResourcesLoader.java index 9257f141..681eea3a 100644 --- a/jadx-core/src/main/java/jadx/api/ResourcesLoader.java +++ b/jadx-core/src/main/java/jadx/api/ResourcesLoader.java @@ -28,7 +28,7 @@ public final class ResourcesLoader { private static final int READ_BUFFER_SIZE = 8 * 1024; private static final int LOAD_SIZE_LIMIT = 10 * 1024 * 1024; - private JadxDecompiler jadxRef; + private final JadxDecompiler jadxRef; ResourcesLoader(JadxDecompiler jadxRef) { this.jadxRef = jadxRef; diff --git a/jadx-core/src/main/java/jadx/core/codegen/ConditionGen.java b/jadx-core/src/main/java/jadx/core/codegen/ConditionGen.java index 8e77f7a7..6f1f5e9b 100644 --- a/jadx-core/src/main/java/jadx/core/codegen/ConditionGen.java +++ b/jadx-core/src/main/java/jadx/core/codegen/ConditionGen.java @@ -162,10 +162,7 @@ public class ConditionGen extends InsnGen { if (condition.isCompare()) { return false; } - if (condition.getMode() != Mode.NOT) { - return true; - } - return false; + return condition.getMode() != Mode.NOT; } private static boolean isArgWrapNeeded(InsnArg arg) { diff --git a/jadx-core/src/main/java/jadx/core/dex/attributes/nodes/EnumMapAttr.java b/jadx-core/src/main/java/jadx/core/dex/attributes/nodes/EnumMapAttr.java index 54130fdf..20efada1 100644 --- a/jadx-core/src/main/java/jadx/core/dex/attributes/nodes/EnumMapAttr.java +++ b/jadx-core/src/main/java/jadx/core/dex/attributes/nodes/EnumMapAttr.java @@ -10,7 +10,7 @@ import java.util.Map; public class EnumMapAttr implements IAttribute { public static class KeyValueMap { - private Map map = new HashMap(); + private final Map map = new HashMap(); public Object get(Object key) { return map.get(key); @@ -21,7 +21,7 @@ public class EnumMapAttr implements IAttribute { } } - private Map fieldsMap = new HashMap(); + private final Map fieldsMap = new HashMap(); public KeyValueMap getMap(FieldNode field) { return fieldsMap.get(field); diff --git a/jadx-core/src/main/java/jadx/core/dex/info/AccessInfo.java b/jadx-core/src/main/java/jadx/core/dex/info/AccessInfo.java index c68dcdee..c89058e8 100644 --- a/jadx-core/src/main/java/jadx/core/dex/info/AccessInfo.java +++ b/jadx-core/src/main/java/jadx/core/dex/info/AccessInfo.java @@ -32,9 +32,9 @@ public class AccessInfo { } public AccessInfo getVisibility() { - int f = (accFlags & AccessFlags.ACC_PUBLIC) - | (accFlags & AccessFlags.ACC_PROTECTED) - | (accFlags & AccessFlags.ACC_PRIVATE); + int f = accFlags & AccessFlags.ACC_PUBLIC + | accFlags & AccessFlags.ACC_PROTECTED + | accFlags & AccessFlags.ACC_PRIVATE; return new AccessInfo(f, type); } diff --git a/jadx-core/src/main/java/jadx/core/dex/info/MethodInfo.java b/jadx-core/src/main/java/jadx/core/dex/info/MethodInfo.java index 6f93493e..7859e87c 100644 --- a/jadx-core/src/main/java/jadx/core/dex/info/MethodInfo.java +++ b/jadx-core/src/main/java/jadx/core/dex/info/MethodInfo.java @@ -111,16 +111,9 @@ public final class MethodInfo { return false; } MethodInfo other = (MethodInfo) obj; - if (!shortId.equals(other.shortId)) { - return false; - } - if (!retType.equals(other.retType)) { - return false; - } - if (!declClass.equals(other.declClass)) { - return false; - } - return true; + return shortId.equals(other.shortId) + && retType.equals(other.retType) + && declClass.equals(other.declClass); } @Override diff --git a/jadx-core/src/main/java/jadx/core/dex/instructions/args/LiteralArg.java b/jadx-core/src/main/java/jadx/core/dex/instructions/args/LiteralArg.java index 13651c9a..e684e251 100644 --- a/jadx-core/src/main/java/jadx/core/dex/instructions/args/LiteralArg.java +++ b/jadx-core/src/main/java/jadx/core/dex/instructions/args/LiteralArg.java @@ -47,7 +47,7 @@ public final class LiteralArg extends InsnArg { @Override public int hashCode() { - return (int) (literal ^ (literal >>> 32)) + 31 * getType().hashCode(); + return (int) (literal ^ literal >>> 32) + 31 * getType().hashCode(); } @Override diff --git a/jadx-core/src/main/java/jadx/core/dex/instructions/args/TypeImmutableArg.java b/jadx-core/src/main/java/jadx/core/dex/instructions/args/TypeImmutableArg.java index 3722b1d8..e9915155 100644 --- a/jadx-core/src/main/java/jadx/core/dex/instructions/args/TypeImmutableArg.java +++ b/jadx-core/src/main/java/jadx/core/dex/instructions/args/TypeImmutableArg.java @@ -1,5 +1,7 @@ package jadx.core.dex.instructions.args; +import org.jetbrains.annotations.NotNull; + public class TypeImmutableArg extends RegisterArg { private boolean isThis; @@ -36,7 +38,7 @@ public class TypeImmutableArg extends RegisterArg { } @Override - void setSVar(SSAVar sVar) { + void setSVar(@NotNull SSAVar sVar) { if (isThis) { sVar.setName("this"); } diff --git a/jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java b/jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java index 08d8a0ae..7a7efac5 100644 --- a/jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java +++ b/jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java @@ -282,7 +282,7 @@ public class ClassNode extends LineAttrNode implements ILoadable { field = cn.constFields.get(obj); } while (field == null - && (cn.clsInfo.getParentClass() != null) + && cn.clsInfo.getParentClass() != null && (cn = dex.resolveClass(cn.clsInfo.getParentClass())) != null); if (field == null && searchGlobal) { diff --git a/jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java b/jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java index a9dfe94a..af4d0752 100644 --- a/jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java +++ b/jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java @@ -74,7 +74,8 @@ public class InsnNode extends LineAttrNode { public boolean containsArg(RegisterArg arg) { for (InsnArg a : arguments) { - if (a == arg || (a.isRegister() && ((RegisterArg) a).getRegNum() == arg.getRegNum())) { + if (a == arg + || a.isRegister() && ((RegisterArg) a).getRegNum() == arg.getRegNum()) { return true; } } diff --git a/jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java b/jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java index ec4d8e43..3b2a578c 100644 --- a/jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java +++ b/jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java @@ -75,8 +75,8 @@ public class MethodNode extends LineAttrNode implements ILoadable { this.mthInfo = MethodInfo.fromDex(classNode.dex(), mthData.getMethodIndex()); this.parentClass = classNode; this.accFlags = new AccessInfo(mthData.getAccessFlags(), AFType.METHOD); - this.noCode = (mthData.getCodeOffset() == 0); - this.methodData = (noCode ? null : mthData); + this.noCode = mthData.getCodeOffset() == 0; + this.methodData = noCode ? null : mthData; } @Override @@ -527,7 +527,7 @@ public class MethodNode extends LineAttrNode implements ILoadable { defaultArgCount = 1; } } - result = (argsList == null) || (argsList.size() == defaultArgCount); + result = argsList == null || argsList.size() == defaultArgCount; } return result; } diff --git a/jadx-core/src/main/java/jadx/core/dex/nodes/parser/DebugInfoParser.java b/jadx-core/src/main/java/jadx/core/dex/nodes/parser/DebugInfoParser.java index eae2b786..67ba5871 100644 --- a/jadx-core/src/main/java/jadx/core/dex/nodes/parser/DebugInfoParser.java +++ b/jadx-core/src/main/java/jadx/core/dex/nodes/parser/DebugInfoParser.java @@ -149,7 +149,7 @@ public class DebugInfoParser { int adjustedOpcode = c - DBG_FIRST_SPECIAL; int addrInc = adjustedOpcode / DBG_LINE_RANGE; addr = addrChange(addr, addrInc, line); - line += DBG_LINE_BASE + (adjustedOpcode % DBG_LINE_RANGE); + line += DBG_LINE_BASE + adjustedOpcode % DBG_LINE_RANGE; setLine(addr, line); } else { throw new DecodeException("Unknown debug insn code: " + c); @@ -263,8 +263,8 @@ public class DebugInfoParser { int localStart = var.getStartAddr(); int localEnd = var.getEndAddr(); - boolean isIntersected = !((localEnd < ssaStart) || (ssaEnd < localStart)); - if (isIntersected && (ssaEnd <= localEnd)) { + boolean isIntersected = !(localEnd < ssaStart || ssaEnd < localStart); + if (isIntersected && ssaEnd <= localEnd) { mergeRequired = true; } } else { diff --git a/jadx-core/src/main/java/jadx/core/dex/visitors/CodeShrinker.java b/jadx-core/src/main/java/jadx/core/dex/visitors/CodeShrinker.java index 654cd66d..ca0886f9 100644 --- a/jadx-core/src/main/java/jadx/core/dex/visitors/CodeShrinker.java +++ b/jadx-core/src/main/java/jadx/core/dex/visitors/CodeShrinker.java @@ -210,7 +210,7 @@ public class CodeShrinker extends AbstractVisitor { // } SSAVar sVar = arg.getSVar(); // allow inline only one use arg or 'this' - if (sVar == null || (sVar.getVariableUseCount() != 1 && !arg.isThis())) { + if (sVar == null || sVar.getVariableUseCount() != 1 && !arg.isThis()) { continue; } InsnNode assignInsn = sVar.getAssign().getParentInsn(); diff --git a/jadx-core/src/main/java/jadx/core/dex/visitors/SimplifyVisitor.java b/jadx-core/src/main/java/jadx/core/dex/visitors/SimplifyVisitor.java index 17f7cb1d..e09862e7 100644 --- a/jadx-core/src/main/java/jadx/core/dex/visitors/SimplifyVisitor.java +++ b/jadx-core/src/main/java/jadx/core/dex/visitors/SimplifyVisitor.java @@ -249,7 +249,7 @@ public class SimplifyVisitor extends AbstractVisitor { } InsnNode wrap = ((InsnWrapArg) arg).getWrapInsn(); InsnType wrapType = wrap.getType(); - if ((wrapType != InsnType.ARITH && wrapType != InsnType.STR_CONCAT) + if (wrapType != InsnType.ARITH && wrapType != InsnType.STR_CONCAT || !wrap.getArg(0).isInsnWrap()) { return null; } diff --git a/jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/BlockSplitter.java b/jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/BlockSplitter.java index 95ccaa0c..b65ae22d 100644 --- a/jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/BlockSplitter.java +++ b/jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/BlockSplitter.java @@ -194,7 +194,7 @@ public class BlockSplitter extends AbstractVisitor { private static boolean isDoWhile(Map blocksMap, BlockNode curBlock, InsnNode insn) { // split 'do-while' block (last instruction: 'if', target this block) if (insn.getType() == InsnType.IF) { - IfNode ifs = (IfNode) (insn); + IfNode ifs = (IfNode) insn; BlockNode targetBlock = blocksMap.get(ifs.getTarget()); if (targetBlock == curBlock) { return true; diff --git a/jadx-core/src/main/java/jadx/core/dex/visitors/regions/LoopRegionVisitor.java b/jadx-core/src/main/java/jadx/core/dex/visitors/regions/LoopRegionVisitor.java index 450e36d1..4722f79c 100644 --- a/jadx-core/src/main/java/jadx/core/dex/visitors/regions/LoopRegionVisitor.java +++ b/jadx-core/src/main/java/jadx/core/dex/visitors/regions/LoopRegionVisitor.java @@ -195,7 +195,7 @@ public class LoopRegionVisitor extends AbstractVisitor implements IRegionVisitor CodeShrinker.shrinkMethod(mth); if (arrGetInsn.contains(AFlag.WRAPPED)) { InsnArg wrapArg = BlockUtils.searchWrappedInsnParent(mth, arrGetInsn); - if (wrapArg != null) { + if (wrapArg != null && wrapArg.getParentInsn() != null) { wrapArg.getParentInsn().replaceArg(wrapArg, iterVar); } else { LOG.debug(" checkArrayForEach: Wrapped insn not found: {}, mth: {}", arrGetInsn, mth); @@ -233,7 +233,7 @@ public class LoopRegionVisitor extends AbstractVisitor implements IRegionVisitor RegisterArg iterVar = nextCall.getResult(); if (nextCall.contains(AFlag.WRAPPED)) { InsnArg wrapArg = BlockUtils.searchWrappedInsnParent(mth, nextCall); - if (wrapArg != null) { + if (wrapArg != null && wrapArg.getParentInsn() != null) { InsnNode parentInsn = wrapArg.getParentInsn(); if (parentInsn.getType() != InsnType.CHECK_CAST) { parentInsn.replaceArg(wrapArg, iterVar); diff --git a/jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java b/jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java index 23381d3f..1ce9a5e2 100644 --- a/jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java +++ b/jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java @@ -203,7 +203,7 @@ public class RegionMaker { BlockNode out; if (loopRegion.isConditionAtEnd()) { BlockNode thenBlock = condInfo.getThenBlock(); - out = (thenBlock == loopStart ? condInfo.getElseBlock() : thenBlock); + out = thenBlock == loopStart ? condInfo.getElseBlock() : thenBlock; loopStart.remove(AType.LOOP); loop.getEnd().add(AFlag.SKIP); stack.addExit(loop.getEnd()); @@ -922,13 +922,7 @@ public class RegionMaker { if (b1 == null || b2 == null) { return false; } - if (isReturnBlocks(b1, b2)) { - return true; - } - if (isSyntheticPath(b1, b2)) { - return true; - } - return false; + return isReturnBlocks(b1, b2) || isSyntheticPath(b1, b2); } private static boolean isSyntheticPath(BlockNode b1, BlockNode b2) { diff --git a/jadx-core/src/main/java/jadx/core/utils/DebugUtils.java b/jadx-core/src/main/java/jadx/core/utils/DebugUtils.java index 7a4e52e9..2df200bd 100644 --- a/jadx-core/src/main/java/jadx/core/utils/DebugUtils.java +++ b/jadx-core/src/main/java/jadx/core/utils/DebugUtils.java @@ -103,7 +103,7 @@ public class DebugUtils { } for (InsnArg arg : insn.getArguments()) { if (arg instanceof RegisterArg) { - checkSSAVar(mth, insn, ((RegisterArg) arg)); + checkSSAVar(mth, insn, (RegisterArg) arg); } } } @@ -131,7 +131,7 @@ public class DebugUtils { List phis = new ArrayList(); for (InsnNode insn : block.getInstructions()) { if (insn.getType() == InsnType.PHI) { - PhiInsn phi = ((PhiInsn) insn); + PhiInsn phi = (PhiInsn) insn; phis.add(phi); if (phi.getArgsCount() != phi.getBlockBinds().size()) { throw new JadxRuntimeException("Incorrect args and binds in PHI"); diff --git a/jadx-core/src/main/java/jadx/core/utils/RegionUtils.java b/jadx-core/src/main/java/jadx/core/utils/RegionUtils.java index ed2286bc..2ebdb32e 100644 --- a/jadx-core/src/main/java/jadx/core/utils/RegionUtils.java +++ b/jadx-core/src/main/java/jadx/core/utils/RegionUtils.java @@ -189,7 +189,7 @@ public class RegionUtils { for (IContainer b : r.getSubBlocks()) { // process try block CatchAttr cb = b.get(AType.CATCH_BLOCK); - if (cb != null && (b instanceof IRegion)) { + if (cb != null && b instanceof IRegion) { TryCatchBlock tb = cb.getTryBlock(); for (ExceptionHandler eh : tb.getHandlers()) { if (isRegionContainsRegion(eh.getHandlerRegion(), region)) { diff --git a/jadx-core/src/main/java/jadx/core/utils/Utils.java b/jadx-core/src/main/java/jadx/core/utils/Utils.java index 94d43290..9ac9609a 100644 --- a/jadx-core/src/main/java/jadx/core/utils/Utils.java +++ b/jadx-core/src/main/java/jadx/core/utils/Utils.java @@ -85,6 +85,9 @@ public class Utils { } public static String getStackTrace(Throwable throwable) { + if (throwable == null) { + return ""; + } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw, true); throwable.printStackTrace(pw); @@ -92,6 +95,6 @@ public class Utils { } public static int compare(int x, int y) { - return (x < y) ? -1 : ((x == y) ? 0 : 1); + return x < y ? -1 : x == y ? 0 : 1; } } diff --git a/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java b/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java index 4d35a7ab..a4087bfd 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java @@ -209,7 +209,7 @@ public class BinaryXMLParser extends CommonBinaryParser { for (int i = 0; i < attributeCount; i++) { parseAttribute(i); writer.add('"'); - if ((i + 1) < attributeCount) { + if (i + 1 < attributeCount) { writer.add(" "); } } @@ -267,7 +267,7 @@ public class BinaryXMLParser extends CommonBinaryParser { } } else { String str = valuesParser.decodeValue(attrValDataType, attrValData); - writer.add(str); + writer.add(str != null ? str : "null"); } } diff --git a/jadx-core/src/main/java/jadx/core/xmlgen/CommonBinaryParser.java b/jadx-core/src/main/java/jadx/core/xmlgen/CommonBinaryParser.java index 63b7e49d..61f8a082 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/CommonBinaryParser.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/CommonBinaryParser.java @@ -61,7 +61,7 @@ public class CommonBinaryParser extends ParserConstants { return ""; } if ((len & 0x80) != 0) { - len = ((len & 0x7F) << 8) | (strArray[start++] & 0xFF); + len = (len & 0x7F) << 8 | strArray[start++] & 0xFF; } byte[] arr = Arrays.copyOfRange(strArray, start, start + len); return new String(arr, ParserStream.STRING_CHARSET_UTF8); diff --git a/jadx-core/src/main/java/jadx/core/xmlgen/ManifestAttributes.java b/jadx-core/src/main/java/jadx/core/xmlgen/ManifestAttributes.java index 1438d768..30dd07f0 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/ManifestAttributes.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/ManifestAttributes.java @@ -49,9 +49,16 @@ public class ManifestAttributes { private final Map attrMap = new HashMap(); public ManifestAttributes() throws Exception { - InputStream xmlStream = ManifestAttributes.class.getResourceAsStream(MANIFEST_ATTR_XML); - DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - doc = dBuilder.parse(xmlStream); + InputStream xmlStream = null; + try { + xmlStream = ManifestAttributes.class.getResourceAsStream(MANIFEST_ATTR_XML); + DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + doc = dBuilder.parse(xmlStream); + } finally { + if (xmlStream != null) { + xmlStream.close(); + } + } } public void parse() { diff --git a/jadx-core/src/main/java/jadx/core/xmlgen/ParserConstants.java b/jadx-core/src/main/java/jadx/core/xmlgen/ParserConstants.java index 36e9e710..33b2ab07 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/ParserConstants.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/ParserConstants.java @@ -150,11 +150,11 @@ public class ParserConstants { protected static final int ATTR_MANY = ResMakeInternal(9); private static int ResMakeInternal(int entry) { - return 0x01000000 | (entry & 0xFFFF); + return 0x01000000 | entry & 0xFFFF; } protected static boolean isResInternalId(int resid) { - return ((resid & 0xFFFF0000) != 0 && (resid & 0xFF0000) == 0); + return (resid & 0xFFFF0000) != 0 && (resid & 0xFF0000) == 0; } // Bit mask of allowed types, for use with ATTR_TYPE. diff --git a/jadx-core/src/main/java/jadx/core/xmlgen/ParserStream.java b/jadx-core/src/main/java/jadx/core/xmlgen/ParserStream.java index 22454a58..3c1edb72 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/ParserStream.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/ParserStream.java @@ -34,7 +34,7 @@ public class ParserStream { readPos += 2; int b1 = input.read(); int b2 = input.read(); - return (b2 & 0xFF) << 8 | (b1 & 0xFF); + return (b2 & 0xFF) << 8 | b1 & 0xFF; } public int readInt32() throws IOException { @@ -44,7 +44,7 @@ public class ParserStream { int b2 = in.read(); int b3 = in.read(); int b4 = in.read(); - return b4 << 24 | (b3 & 0xFF) << 16 | (b2 & 0xFF) << 8 | (b1 & 0xFF); + return b4 << 24 | (b3 & 0xFF) << 16 | (b2 & 0xFF) << 8 | b1 & 0xFF; } public long readUInt32() throws IOException { diff --git a/jadx-core/src/main/java/jadx/core/xmlgen/entry/ValuesParser.java b/jadx-core/src/main/java/jadx/core/xmlgen/entry/ValuesParser.java index da3f7260..ed47c26a 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/entry/ValuesParser.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/entry/ValuesParser.java @@ -113,8 +113,8 @@ public class ValuesParser extends ParserConstants { } private String decodeComplex(int data, boolean isFraction) { - double value = (data & (COMPLEX_MANTISSA_MASK << COMPLEX_MANTISSA_SHIFT)) - * RADIX_MULTS[(data >> COMPLEX_RADIX_SHIFT) & COMPLEX_RADIX_MASK]; + double value = (data & COMPLEX_MANTISSA_MASK << COMPLEX_MANTISSA_SHIFT) + * RADIX_MULTS[data >> COMPLEX_RADIX_SHIFT & COMPLEX_RADIX_MASK]; int unitType = data & COMPLEX_UNIT_MASK; String unit; if (isFraction) { diff --git a/jadx-gui/src/main/java/jadx/gui/ui/ContentArea.java b/jadx-gui/src/main/java/jadx/gui/ui/ContentArea.java index 6152f70c..b94353ac 100644 --- a/jadx-gui/src/main/java/jadx/gui/ui/ContentArea.java +++ b/jadx-gui/src/main/java/jadx/gui/ui/ContentArea.java @@ -13,6 +13,7 @@ import javax.swing.text.BadLocationException; import javax.swing.text.Caret; import javax.swing.text.DefaultCaret; import java.awt.Color; +import java.awt.Dimension; import java.awt.Point; import java.awt.Rectangle; @@ -135,9 +136,13 @@ class ContentArea extends RSyntaxTextArea { return; } int extentHeight = viewport.getExtentSize().height; - int viewHeight = viewport.getViewSize().height; + Dimension viewSize = viewport.getViewSize(); + if (viewSize == null) { + return; + } + int viewHeight = viewSize.height; - int y = Math.max(0, r.y - (extentHeight / 2)); + int y = Math.max(0, r.y - extentHeight / 2); y = Math.min(y, viewHeight - extentHeight); viewport.setViewPosition(new Point(0, y));