/*
This method is only visible for testing.
163353
public static String _iriCompactionStep5point4(String iri, Object value, String compactIRI,
            final String candidate, Map<String, Object> termDefinitions) {

        final boolean condition1 = (compactIRI == null
                || compareShortestLeast(candidate, compactIRI) < 0);

        final boolean condition2 = (!termDefinitions.containsKey(candidate) || (iri
                .equals(((Map<String, Object>) termDefinitions.get(candidate)).get(JsonLdConsts.ID))
                && value == null));

        if (condition1 && condition2) {
            compactIRI = candidate;
        }
        return compactIRI;
    }
353408
public static void main(String[] s) {
		WindowListener l = new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		};

		JFrame frame = new JFrame("JCalendar Demo");
		frame.addWindowListener(l);

		JCalendarDemo demo = new JCalendarDemo();
		demo.init();
		frame.getContentPane().add(demo);
		frame.pack();
		frame.setBounds(200, 200, (int) frame.getPreferredSize().getWidth() + 20, (int) frame
				.getPreferredSize().getHeight() + 180);
		frame.setVisible(true);
	}
727730
@Override
    public void onXml(ClientProperties cp)
    {
        hsmd.onInitialize();
        if (cp != null)
        {
            hsmd.setClientProperties(cp);
        }
    }
409681
@Override
    public void update() {
        mTotalValue = 0;
        for (PieModel slice : mPieData) {
            mTotalValue += slice.getValue();
        }
        onDataChanged();
    }
148920
@Override
  public TwoPhaseIterator asTwoPhaseIterator() {
    if (spans1 == null || spans2 == null || !query.twoPhaseIteratorAllowed()) {
      return null;
    } else {
      // TODO
      return null;
    }
  }
1161715
@Override
    public void visitClassContext(ClassContext classContext) {
        try {
            stack = new OpcodeStack();
            storeToUserValue = new HashMap<>();
            allocLocation = new HashMap<>();
            allocToAddPCs = new HashMap<>();
            optionalRanges = new ArrayList<>();
            super.visitClassContext(classContext);
        } finally {
            stack = null;
            storeToUserValue = null;
            allocLocation = null;
            allocToAddPCs = null;
            optionalRanges = null;
        }
    }
349664
public final void show() {
		if (firstTime) {
			firstTime = false;
			if (SwingUtilities.isEventDispatchThread()) {
				showIntern();
			} else {
				try {
					SwingUtilities.invokeAndWait(new Runnable() {
						public void run() {
							showIntern();
						}
					});
				} catch (final Exception ex) {
					ignore();
				}
			}
		} else {
			throw new IllegalStateException("This object cannot be reused!");
		}
	}
1374198
private void init() {
        cacheable = null;
        status = SC_OK;
        cachedResponse = cached.createCachedResponse();
        streamDelegate = new ServletResponseStreamDelegate(this) {
            protected OutputStream createOutputStream() throws IOException {
                // Test if this request is really cacheable, otherwise,
                // just write through to underlying response, and don't cache
                if (isCacheable()) {
                    return cachedResponse.getOutputStream();
                }
                else {
                    cachedResponse.setStatus(status);
                    cachedResponse.writeHeadersTo(CacheResponseWrapper.this.response);
                    return super.getOutputStream();
                }
            }
        };
    }
511173
@Override
	public void update() {
		synchronized (this) {
			long currentTime = System.currentTimeMillis();
			if (currentTime - lastUpdateTime > updateInterval) {
				lastUpdateTime = currentTime;
				fetchMetrics();
			}
		}
	}
1353988
private void created() {
        String t = getTheme();
        if (t != null && !t.isEmpty()) setTheme(t);
    }
1240334
@SuppressLint({
      "LogNotTimber", //
      "StringFormatInTimber", //
      "ThrowableNotAtBeginning", //
      "BinaryOperationInTimber", //
      "TimberArgCount", //
      "TimberArgTypes", //
      "TimberTagLength", //
      "TimberExceptionLogging" //
  }) //
  @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // LogNotTimber
    Log.d("TAG", "msg");
    Log.d("TAG", "msg", new Exception());
    android.util.Log.d("TAG", "msg");
    android.util.Log.d("TAG", "msg", new Exception());

    // StringFormatInTimber
    Timber.w(String.format("%s", getString()));
    Timber.w(format("%s", getString()));

    // ThrowableNotAtBeginning
    Timber.d("%s", new Exception());

    // BinaryOperationInTimber
    String foo = "foo";
    String bar = "bar";
    Timber.d("foo" + "bar");
    Timber.d("foo" + bar);
    Timber.d(foo + "bar");
    Timber.d(foo + bar);

    // TimberArgCount
    Timber.d("%s %s", "arg0");
    Timber.d("%s", "arg0", "arg1");
    Timber.tag("tag").d("%s %s", "arg0");
    Timber.tag("tag").d("%s", "arg0", "arg1");

    // TimberArgTypes
    Timber.d("%d", "arg0");
    Timber.tag("tag").d("%d", "arg0");

    // TimberTagLength
    Timber.tag("abcdefghijklmnopqrstuvwx");
    Timber.tag("abcdefghijklmnopqrstuvw" + "x");

    // TimberExceptionLogging
    Timber.d(new Exception(), new Exception().getMessage());
    Timber.d(new Exception(), "");
    Timber.d(new Exception(), null);
    Timber.d(new Exception().getMessage());
  }
168113
@Override
  public void aggregate()
  {
    final IndexedInts keys = keySelector.getRow();
    for (int i = 0; i < valueSelectors.length; i++) {
      values[i] = valueSelectors[i].getDouble();
    }
    synchronized (this) {
      for (int i = 0, keysSize = keys.size(); i < keysSize; i++) {
        final String key = keySelector.lookupName(keys.get(i));
        sketch.update(key, values);
      }
    }
  }
985384
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (getArguments() != null) {
            images = getArguments().getStringArrayList(KEY_IMAGES);
            title = getArguments().getString(KEY_TITLE);
        }

    }
494900
@Override
    public void visitVariables(VariableVisitor visitor) {
        // build a collection of live variables in a synchronized block
        final List<Variable> variablesCopy;
        synchronized (variables) {
            variablesCopy = Lists.newArrayListWithExpectedSize(variables.size());
            final Iterator<Variable> iterator = variables.values().iterator();
            while (iterator.hasNext()) {
                final Variable v = iterator.next();
                if (v.isLive()) {
                    variablesCopy.add(v);
                } else {
                    // remove-on-read of variables that are no longer live
                    // javadoc says this removes from the mapping from the map
                    iterator.remove();
                }
            }
        }

        for (Variable v : variablesCopy) {
            if (v.isExpandable()) {
                Map<?, ?> map = v.expand();
                try {
                    for (final Map.Entry entry : map.entrySet()) {
                        visitor.visit(new EntryVariable(entry, v, namespace));
                    }
                } catch (ConcurrentModificationException e) {
                    log.warn("Failed to iterate map entry set for variable " + v.getName(), e);
                    Map.Entry<String, String> errorEntry = new AbstractMap.SimpleEntry<String, String>("error", e.getMessage());
                    visitor.visit(new EntryVariable(errorEntry, v, namespace));
                }
            } else {
                visitor.visit(v);
            }
        }
        if (variablesCopy.size() > 0 && startTime != null) {
            visitor.visit(startTime);
        }
    }
1147173
@Override
    public void visitAnnotation(Annotations arg0) {
        for (AnnotationEntry ae : arg0.getAnnotationEntries()) {
            boolean runtimeVisible = ae.isRuntimeVisible();
            String name = ClassName.fromFieldSignature(ae.getAnnotationType());
            if (name == null) {
                continue;
            }
            name = ClassName.toDottedClassName(name);
            Map<String, ElementValue> map = new HashMap<>();
            for (ElementValuePair ev : ae.getElementValuePairs()) {
                map.put(ev.getNameString(), ev.getValue());
            }
            visitAnnotation(name, map, runtimeVisible);

        }

    }
163804
public static void main(String[] s) {
		JFrame frame = new JFrame("JCalendar");

		JCalendar jcalendar = new JCalendar();
		frame.getContentPane().add(jcalendar);
		frame.pack();
		frame.setVisible(true);
	}
296703
@Override
	public void sawOpcode(int seen) {
		String userValue = null;

		try {
			stack.precomputation(this);

			int pc = getPC();
			if (branchTargets.get(pc)) {
				localMethodCalls.clear();
				fieldMethodCalls.clear();
				branchTargets.clear(pc);
			}

			if (((seen >= Const.IFEQ) && (seen <= Const.GOTO)) || ((seen >= Const.IFNULL) && (seen <= Const.GOTO_W))) {
				branchTargets.set(getBranchTarget());
			} else if ((seen == Const.TABLESWITCH) || (seen == Const.LOOKUPSWITCH)) {
				int[] offsets = getSwitchOffsets();
				for (int offset : offsets) {
					branchTargets.set(offset + pc);
				}
				branchTargets.set(getDefaultSwitchOffset() + pc);
			} else if (OpcodeUtils.isAStore(seen)) {
				localMethodCalls.remove(Integer.valueOf(RegisterUtils.getAStoreReg(this, seen)));
			} else if (seen == Const.PUTFIELD) {
				String fieldSource = "";

				if (stack.getStackDepth() > 0) {
					OpcodeStack.Item item = stack.getStackItem(0);
					fieldSource = (String) item.getUserValue();
					if (fieldSource == null) {
						fieldSource = "";
					}
				}
				fieldMethodCalls.remove(new FieldInfo(fieldSource, getNameConstantOperand()));
			} else if (seen == Const.GETFIELD) {
				if (stack.getStackDepth() > 0) {
					OpcodeStack.Item item = stack.getStackItem(0);
					userValue = (String) item.getUserValue();
					if (userValue == null) {
						int reg = item.getRegisterNumber();
						if (reg >= 0) {
							userValue = String.valueOf(reg);
						} else {
							XField xf = item.getXField();
							if (xf != null) {
								userValue = xf.getName();
							}
						}
					}
				}
			} else if ((seen == Const.INVOKEVIRTUAL) || (seen == Const.INVOKEINTERFACE)
					|| (seen == Const.INVOKESTATIC)) {

				String className = getClassConstantOperand();
				String methodName = getNameConstantOperand();
				String signature = getSigConstantOperand();
				int parmCount = SignatureUtils.getNumParameters(signature);

				int reg = -1;
				XField field = null;
				MethodCall mc = null;
				String fieldSource = null;
				if (seen == Const.INVOKESTATIC) {
					XMethod xm = XFactory.createXMethod(getDottedClassConstantOperand(), methodName, signature, true);
					String genericSignature = xm.getSourceSignature();
					if ((genericSignature != null) && genericSignature.endsWith(">;")) {
						return;
					}
				} else if (stack.getStackDepth() > parmCount) {
					OpcodeStack.Item obj = stack.getStackItem(parmCount);
					reg = obj.getRegisterNumber();
					field = obj.getXField();

					if (reg >= 0) {
						mc = localMethodCalls.get(Integer.valueOf(reg));
						MethodInfo mi = Statistics.getStatistics().getMethodStatistics(className,
								getNameConstantOperand(), signature);
						if ((mi != null) && mi.getModifiesState()) {
							clearFieldMethods(String.valueOf(reg));
							return;
						}
					} else if (field != null) {
						fieldSource = (String) obj.getUserValue();
						if (fieldSource == null) {
							fieldSource = "";
						}
						mc = fieldMethodCalls.get(new FieldInfo(fieldSource, field.getName()));
						MethodInfo mi = Statistics.getStatistics().getMethodStatistics(className,
								getNameConstantOperand(), signature);
						if ((mi != null) && mi.getModifiesState()) {
							clearFieldMethods(fieldSource);
							return;
						}
					}
				}

				int neededStackSize = parmCount + ((seen == Const.INVOKESTATIC) ? 0 : 1);
				if (stack.getStackDepth() >= neededStackSize) {
					Object[] parmConstants = new Object[parmCount];
					for (int i = 0; i < parmCount; i++) {
						OpcodeStack.Item parm = stack.getStackItem(i);
						parmConstants[i] = parm.getConstant();
						if (parm.getSignature().startsWith(Values.SIG_ARRAY_PREFIX)) {
							if (!Values.ZERO.equals(parm.getConstant())) {
								return;
							}
							XField f = parm.getXField();
							if (f != null) {
								// Two different fields holding a 0 length array should be considered different
								parmConstants[i] = f.getName() + ':' + parmConstants[i];
							}
						}

						if (parmConstants[i] == null) {
							return;
						}
					}

					if (seen == Const.INVOKESTATIC) {
						mc = staticMethodCalls.get(className);
					} else if ((reg < 0) && (field == null)) {
						return;
					}

					if (mc != null) {
						if (!signature.endsWith(Values.SIG_VOID) && methodName.equals(mc.getName())
								&& signature.equals(mc.getSignature()) && !isRiskyName(className, methodName)
								&& !commonMethods.contains(new FQMethod(className, methodName, signature))) {
							Object[] parms = mc.getParms();
							if (Arrays.equals(parms, parmConstants)) {
								int ln = getLineNumber(pc);

								if ((ln != mc.getLineNumber()) || (Math.abs(pc - mc.getPC()) < 10)) {
									Statistics statistics = Statistics.getStatistics();
									MethodInfo mi = statistics.getMethodStatistics(className, methodName, signature);

									bugReporter.reportBug(
											new BugInstance(this, BugType.PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS.name(),
													getBugPriority(methodName, mi)).addClass(this).addMethod(this)
															.addSourceLine(this).addString(methodName + signature));
								}
							}
						}

						if (seen == Const.INVOKESTATIC) {
							staticMethodCalls.remove(className);
						} else {
							if (reg >= 0) {
								localMethodCalls.remove(Integer.valueOf(reg));
							} else if (fieldSource != null) {
								fieldMethodCalls.remove(new FieldInfo(fieldSource, field.getName()));
							}
						}
					} else {
						int ln = getLineNumber(pc);
						if (seen == Const.INVOKESTATIC) {
							staticMethodCalls.put(className,
									new MethodCall(methodName, signature, parmConstants, pc, ln));
						} else {
							if (reg >= 0) {
								localMethodCalls.put(Integer.valueOf(reg),
										new MethodCall(methodName, signature, parmConstants, pc, ln));
							} else if (field != null) {
								OpcodeStack.Item obj = stack.getStackItem(parmCount);
								fieldSource = (String) obj.getUserValue();
								if (fieldSource == null) {
									fieldSource = "";
								}
								fieldMethodCalls.put(new FieldInfo(fieldSource, field.getName()),
										new MethodCall(methodName, signature, parmConstants, pc, ln));
							}
						}
					}
				}
			} else if (OpcodeUtils.isReturn(seen)) {
				localMethodCalls.clear();
				fieldMethodCalls.clear();
				branchTargets.clear(pc);
			}
		} finally {
			stack.sawOpcode(this, seen);
			if ((userValue != null) && (stack.getStackDepth() > 0)) {
				OpcodeStack.Item item = stack.getStackItem(0);
				item.setUserValue(userValue);
			}
		}
	}