For use by unit test code only
166987
static synchronized void clearTLDOverrides() {
        inUse = false;
        countryCodeTLDsPlus = MemoryReductionUtil.EMPTY_STRING_ARRAY;
        countryCodeTLDsMinus = MemoryReductionUtil.EMPTY_STRING_ARRAY;
        genericTLDsPlus = MemoryReductionUtil.EMPTY_STRING_ARRAY;
        genericTLDsMinus = MemoryReductionUtil.EMPTY_STRING_ARRAY;
    }
66470
private RuntimeException codeBug()
        throws RuntimeException
    {
        throw Kit.codeBug("ts.cursor=" + ts.cursor
                          + ", ts.tokenBeg=" + ts.tokenBeg
                          + ", currentToken=" + currentToken);
    }
581120
@Override
    public void visitClassContext(ClassContext classContext) {
        try {
            unusedParms = new BitSet();
            regToParm = new HashMap<>();
            stack = new OpcodeStack();
            super.visitClassContext(classContext);
        } finally {
            stack = null;
            regToParm = null;
            unusedParms.clear();
        }
    }
773962
@Override
    public void visitCode(Code obj) {

        try {
            XMethod xMethod = getXMethod();
            if (xMethod != null) {
                String[] tes = xMethod.getThrownExceptions();
                Set<String> thrownExceptions = new HashSet<>(Arrays.<String> asList((tes == null) ? new String[0] : tes));

                blocks = new ArrayList<>();
                inBlocks = new ArrayList<>();
                transitionPoints = new BitSet();

                CodeException[] ces = obj.getExceptionTable();
                for (CodeException ce : ces) {
                    TryBlock tb = new TryBlock(ce);
                    int existingBlock = blocks.indexOf(tb);
                    if (existingBlock >= 0) {
                        tb = blocks.get(existingBlock);
                        tb.addCatchType(ce);
                    } else {
                        blocks.add(tb);
                    }
                }

                Iterator<TryBlock> it = blocks.iterator();
                while (it.hasNext()) {
                    TryBlock block = it.next();
                    if (block.hasMultipleHandlers() || block.isFinally() || block.catchIsThrown(getConstantPool(), thrownExceptions)) {
                        it.remove();
                    }
                }

                if (blocks.size() > 1) {
                    stack.resetForMethodEntry(this);
                    super.visitCode(obj);

                    if (blocks.size() > 1) {

                        TryBlock firstBlock = blocks.get(0);
                        for (int i = 1; i < blocks.size(); i++) {
                            TryBlock secondBlock = blocks.get(i);

                            if (!blocksSplitAcrossTransitions(firstBlock, secondBlock) && (firstBlock.getCatchType() == secondBlock.getCatchType())
                                    && firstBlock.getThrowSignature().equals(secondBlock.getThrowSignature())
                                    && firstBlock.getMessage().equals(secondBlock.getMessage())
                                    && firstBlock.getExceptionSignature().equals(secondBlock.getExceptionSignature())) {
                                bugReporter.reportBug(new BugInstance(this, BugType.STB_STACKED_TRY_BLOCKS.name(), NORMAL_PRIORITY).addClass(this)
                                        .addMethod(this).addSourceLineRange(this, firstBlock.getStartPC(), firstBlock.getEndHandlerPC())
                                        .addSourceLineRange(this, secondBlock.getStartPC(), secondBlock.getEndHandlerPC()));
                            }

                            firstBlock = secondBlock;
                        }
                    }
                }
            }
        } finally {
            blocks = null;
            inBlocks = null;
            transitionPoints = null;
        }
    }
860809
function UnitCode(unitCode) {
	switch (typeof unitCode) {
	case "string":
		unitCode = parseInt(unitCode, 10);
		if (unitCode || unitCode === 0) {
			var index = unitCode - 1;
			if ((index >= 0) && (index <= (deviceCodes.length - 1))) {
				this.raw = deviceCodes[index];
			} else {
				throw new Error("Unit code string out of range.");
			}
		} else {
			throw new Error("Invalid unit code.");
		}
		break;
	default:
		if (deviceCodes.indexOf(unitCode) !== -1) {
			this.raw = unitCode;
		} else {
			throw new Error("Unit code number out of range.");
		}
		break;
	}
	return this.raw;
}
1322285
public void compile(String name, String code) throws CompilationFailedException {
        CompilationUnit unit = new CompilationUnit(configuration);
        unit.addSource(new SourceUnit(name, code, configuration, unit.getClassLoader(), unit.getErrorCollector()));
        unit.compile();
    }
406231
@Override
    public void visitCode(Code obj) {
        String nameAndSignature = getMethod().getName() + getMethod().getSignature();
        if (SignatureBuilder.SIG_READ_OBJECT.equals(nameAndSignature)) {
            inReadObject = true;
            inWriteObject = false;
        } else if (SIG_WRITE_OBJECT.equals(nameAndSignature)) {
            inReadObject = false;
            inWriteObject = true;
        }

        if (inReadObject || inWriteObject) {
            state = State.SEEN_NOTHING;
            super.visitCode(obj);
            if (state != State.SEEN_INVALID) {
                bugReporter.reportBug(new BugInstance(this, BugType.NCS_NEEDLESS_CUSTOM_SERIALIZATION.name(), NORMAL_PRIORITY).addClass(this).addMethod(this)
                        .addSourceLine(this, 1));
            }
        }
    }
316307
@Override
    public void visitCode(Code obj) {
        if (prescreen(getMethod())) {
            state = State.SAW_NOTHING;
            super.visitCode(obj);
        }
    }
287635
@Override
    public void visitCode(Code obj) {
        collectionGroups.clear();
        groupToIterator.clear();
        loops.clear();
        buildVariableEndScopeMap();

        super.visitCode(obj);
    }
311454
@Override
    public void sawOpcode(int seen) {
        if (isInitializer) {
            lookForCustomThreadFactoriesInConstructors(seen);
            return;
        }

        try {
            stack.precomputation(this);

            if ((seen == Const.INVOKEVIRTUAL) || (seen == Const.INVOKEINTERFACE)) {
                processInvoke();
            }
            // TODO Should not include private methods
            else if (seen == Const.ARETURN) {
                removeFieldsThatGetReturned();
            } else if (seen == Const.PUTFIELD) {
                XField f = getXFieldOperand();
                if (f != null) {
                    reportOverwrittenField(f);
                }
            } else if (seen == Const.IFNONNULL) {
                // indicates a null check, which means that we get an exemption
                // until the end of the branch
                OpcodeStack.Item nullCheckItem = stack.getStackItem(0);
                XField fieldWhichWasNullChecked = nullCheckItem.getXField();
                if (fieldWhichWasNullChecked != null) {
                    exemptExecutors.put(fieldWhichWasNullChecked, Integer.valueOf(getPC() + getBranchOffset()));
                }
            }
        } finally {
            stack.sawOpcode(this, seen);
        }
    }
419967
function onlyForApps(expectedPlatform) {
  const stack = new Error().stack || '';
  const re = /Appium.(\w+)/g;
  const caller = stack.split('\n')[2].trim();
  const m = re.exec(caller);

  if (!m) {
    throw new Error(`Invalid caller ${caller}`);
  }

  const callerName = m[1] || m[2];
  if (!expectedPlatform) {
    if (!this.platform) {
      throw new Error(`${callerName} method can be used only with apps`);
    }
  } else if (this.platform !== expectedPlatform.toLowerCase()) {
    throw new Error(`${callerName} method can be used only with ${expectedPlatform} apps`);
  }
}
840581
def addUnexpectedSuccess(self, test: unittest.case.TestCase) -> None:
        
        # noinspection PyTypeChecker
        self.add_result(TestState.unexpected_success, test)
965626
@Override
    public void visitCode(Code obj) {
        try {
            possibleParmRegs.clear();
            Method m = getMethod();
            String methodSignature = m.getSignature();
            String retSignature = SignatureUtils.getReturnSignature(methodSignature);
            JavaClass returnClass = null;
            int[] parmRegs = null;

            if (retSignature.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX) && !knownImmutables.contains(retSignature)) {
                List<String> parmTypes = SignatureUtils.getParameterSignatures(methodSignature);
                for (int p = 0; p < parmTypes.size(); p++) {
                    String parmSignature = parmTypes.get(p);
                    if (parmSignature.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX) && !knownImmutables.contains(parmSignature)) {
                        if (returnClass == null) {
                            returnClass = Repository.lookupClass(SignatureUtils.trimSignature(retSignature));
                            parmRegs = RegisterUtils.getParameterRegisters(m);
                        }

                        if (parmRegs != null) {
                            JavaClass parmClass = Repository.lookupClass(SignatureUtils.stripSignature(parmSignature));
                            if (parmClass.instanceOf(returnClass)) {
                                possibleParmRegs.put(Integer.valueOf(parmRegs[p]), new ParmUsage());
                            }
                        }
                    }
                }

                if (!possibleParmRegs.isEmpty()) {
                    try {
                        stack.resetForMethodEntry(this);
                        super.visitCode(obj);
                        for (ParmUsage pu : possibleParmRegs.values()) {
                            if ((pu.returnPC >= 0) && (pu.alteredPC >= 0) && (pu.returnPC > pu.alteredPC)) {
                                bugReporter.reportBug(new BugInstance(this, BugType.CFS_CONFUSING_FUNCTION_SEMANTICS.name(), NORMAL_PRIORITY).addClass(this)
                                        .addMethod(this).addSourceLine(this, pu.returnPC).addSourceLine(this, pu.alteredPC));
                            }
                        }
                    } catch (StopOpcodeParsingException e) {
                        // no parm regs left
                    }
                }
            }
        } catch (ClassNotFoundException cnfe) {
            bugReporter.reportMissingClass(cnfe);
        }
    }
1209548
public static void replaceUnit(/*String group, String unitName, */ Unit newUnit) {
        String group = newUnit.getGroup().getName(), unitName = newUnit.getName();
        readWriteLock.writeLock().lock();
        try {
            //unitMap
            List<Unit> unitList = unitMap.get(group);
            unitList.removeIf(unitToRemove -> Objects.equals(unitToRemove.getName(), unitName));
            unitList.add(newUnit);

            //searchUnitByClassMap
            Map<Class<? extends Unit>, Unit> tmp = new HashMap<>();
            for (Map.Entry<Class<? extends Unit>, Unit> classUnitEntry : searchUnitByClass.entrySet()) {
                Unit unit = classUnitEntry.getValue();
                if (unit.getGroup().getName().equals(group) && unit.getName().equals(unitName)) {
                    tmp.put(classUnitEntry.getKey(), newUnit);
                    break;
                }
            }
            searchUnitByClass.putAll(tmp);

            //searchUnitMap
            searchUnitMap.put(Unit.fullName(group, unitName), newUnit);
        } finally {
            readWriteLock.writeLock().unlock();
        }
    }
973432
@Override
    public void visitCode(Code obj) {
        try {
            Method m = getMethod();
            if ((!m.isPublic() && !m.isProtected()) || m.isAbstract() || m.isSynthetic()) {
                return;
            }

            CodeInfo superCode = superclassCode.remove(curMethodInfo);
            if (superCode != null) {
                if (sameAccess(getMethod().getAccessFlags(), superCode.getAccess()) && codeEquals(obj, superCode.getCode())) {
                    bugReporter.reportBug(new BugInstance(this, BugType.COM_COPIED_OVERRIDDEN_METHOD.name(), NORMAL_PRIORITY).addClass(this).addMethod(this)
                            .addSourceLine(classContext, this, getPC()));
                    return;
                }

                if ((getMethod().getAccessFlags() & Const.ACC_SYNCHRONIZED) != (superCode.getAccess() & Const.ACC_SYNCHRONIZED)) {
                    return;
                }

                parmTypes = getMethod().getArgumentTypes();
                nextParmIndex = 0;
                nextParmOffset = getMethod().isStatic() ? 0 : 1;
                sawAload0 = nextParmOffset == 0;
                sawParentCall = false;
                super.visitCode(obj);
            }
        } catch (StopOpcodeParsingException e) {
            // method is unique
        }

    }
325544
@Override
    public void sawOpcode(int seen) {
        boolean sawCreate = false;
        Integer itemPC = null;

        try {
            stack.precomputation(this);

            if (seen == Const.INVOKEINTERFACE) {
                String className = getClassConstantOperand();
                String methodInfo = getNameConstantOperand() + ':' + getSigConstantOperand();
                if ("org/w3c/dom/Document".equals(className) && domCreationMethods.contains(methodInfo)) {
                    sawCreate = true;
                    itemPC = Integer.valueOf(getPC());
                }
            } else if (OpcodeUtils.isAStore(seen)) {
                Integer pc = findDOMNodeCreationPoint(0);
                int reg = RegisterUtils.getAStoreReg(this, seen);
                if (pc != null) {
                    nodeStores.put(Integer.valueOf(reg), pc);
                } else {
                    nodeStores.remove(Integer.valueOf(reg));
                }
            } else if (seen == Const.PUTFIELD) {
                // Stores to member variables are assumed ok
                findDOMNodeCreationPoint(0);
            } else if (OpcodeUtils.isALoad(seen)) {
                int reg = RegisterUtils.getALoadReg(this, seen);
                itemPC = nodeStores.get(Integer.valueOf(reg));
                if (itemPC != null) {
                    sawCreate = true;
                }
            } else if ((seen == Const.ARETURN) && (stack.getStackDepth() > 0)) {
                OpcodeStack.Item itm = stack.getStackItem(0);
                int reg = itm.getRegisterNumber();
                nodeCreations.remove(itm);
                nodeStores.remove(Integer.valueOf(reg));
            }

            if (!sawCreate
                    && ((seen == Const.INVOKEINTERFACE) || (seen == Const.INVOKEVIRTUAL) || (seen == Const.INVOKESTATIC) || (seen == Const.INVOKESPECIAL))) {
                String methodSig = getSigConstantOperand();
                int argCount = SignatureUtils.getNumParameters(methodSig);
                if (stack.getStackDepth() >= argCount) {
                    for (int a = 0; a < argCount; a++) {
                        OpcodeStack.Item itm = stack.getStackItem(a);
                        if (nodeCreations.containsKey(itm)) {
                            int reg = itm.getRegisterNumber();
                            nodeCreations.remove(itm);
                            nodeStores.remove(Integer.valueOf(reg));
                        }
                    }
                    if ((seen != Const.INVOKESTATIC) && (stack.getStackDepth() > argCount)) {
                        nodeCreations.remove(stack.getStackItem(argCount));
                    }
                }
            }
        } finally {
            stack.sawOpcode(this, seen);
            if (sawCreate && (stack.getStackDepth() > 0)) {
                nodeCreations.put(stack.getStackItem(0), itemPC);
            }
        }
    }
863582
@Override
    public void visitCode(final Code obj) {
        try {
            localCollections = new HashMap<>();
            localScopeEnds = new HashMap<>();
            localSourceLineAnnotations = new HashMap<>();
            stack.resetForMethodEntry(this);
            super.visitCode(obj);
        } finally {
            localCollections = null;
            localScopeEnds = null;
            localSourceLineAnnotations = null;
        }
    }