_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q165400
ApkLoader.getCompileTimeSdkResourceTable
validation
@Nonnull synchronized public PackageResourceTable getCompileTimeSdkResourceTable() { if (compiletimeSdkResourceTable == null) { ResourceTableFactory resourceTableFactory = new ResourceTableFactory(); compiletimeSdkResourceTable = resourceTableFactory .newFrameworkResourceTable(new ResourcePath(android.R.class, null, null)); } return compiletimeSdkResourceTable; }
java
{ "resource": "" }
q165401
ShadowView.dump
validation
@SuppressWarnings("UnusedDeclaration") @Deprecated public static void dump(View view) { ShadowView shadowView = Shadow.extract(view); shadowView.dump(); }
java
{ "resource": "" }
q165402
ShadowView.innerText
validation
@SuppressWarnings("UnusedDeclaration") public static String innerText(View view) { ShadowView shadowView = Shadow.extract(view); return shadowView.innerText(); }
java
{ "resource": "" }
q165403
ShadowInstrumentation.getAppropriateWrappers
validation
private List<Wrapper> getAppropriateWrappers(Intent intent, String receiverPermission) { broadcastIntents.add(intent); List<Wrapper> result = new ArrayList<>(); List<Wrapper> copy = new ArrayList<>(); copy.addAll(registeredReceivers); String intentClass = intent.getComponent() != null ? intent.getComponent().getClassName() : null; for (Wrapper wrapper : copy) { if ((hasMatchingPermission(wrapper.broadcastPermission, receiverPermission) && wrapper.intentFilter.matchAction(intent.getAction())) || (intentClass != null && intentClass.equals(wrapper.broadcastReceiver.getClass().getName()))) { final int match = wrapper.intentFilter.matchData(intent.getType(), intent.getScheme(), intent.getData()); if (match != IntentFilter.NO_MATCH_DATA && match != IntentFilter.NO_MATCH_TYPE) { result.add(wrapper); } } } return result; }
java
{ "resource": "" }
q165404
ShadowInstrumentation.postIntent
validation
private ListenableFuture<BroadcastResultHolder> postIntent( final Wrapper wrapper, final Intent intent, ListenableFuture<BroadcastResultHolder> oldResult, final AtomicBoolean abort, final Context context) { final Handler scheduler = (wrapper.scheduler != null) ? wrapper.scheduler : getMainHandler(context); return Futures.transformAsync( oldResult, new AsyncFunction<BroadcastResultHolder, BroadcastResultHolder>() { @Override public ListenableFuture<BroadcastResultHolder> apply( BroadcastResultHolder broadcastResultHolder) throws Exception { final BroadcastReceiver.PendingResult result = ShadowBroadcastPendingResult.create( broadcastResultHolder.resultCode, broadcastResultHolder.resultData, broadcastResultHolder.resultExtras, true /*ordered */); wrapper.broadcastReceiver.setPendingResult(result); scheduler.post( () -> { ShadowBroadcastReceiver shadowBroadcastReceiver = Shadow.extract(wrapper.broadcastReceiver); shadowBroadcastReceiver.onReceive(context, intent, abort); }); return BroadcastResultHolder.transform(result); } }, directExecutor()); }
java
{ "resource": "" }
q165405
ShadowColor.RGBToHSV
validation
@Implementation protected static void RGBToHSV(int red, int green, int blue, float hsv[]) { java.awt.Color.RGBtoHSB(red, green, blue, hsv); hsv[0] = hsv[0] * 360; }
java
{ "resource": "" }
q165406
ShadowTrace.beginSection
validation
@Implementation(minSdk = JELLY_BEAN_MR2) protected static void beginSection(String sectionName) { if (Trace.isTagEnabled(TRACE_TAG_APP)) { if (crashOnIncorrectUsage) { if (sectionName.length() > MAX_SECTION_NAME_LEN) { throw new IllegalArgumentException("sectionName is too long"); } } else if (sectionName == null) { Log.w(TAG, "Section name cannot be null"); return; } else if (sectionName.length() > MAX_SECTION_NAME_LEN) { Log.w(TAG, "Section name is too long"); return; } synchronized (lock) { currentSections.addFirst(sectionName); } } }
java
{ "resource": "" }
q165407
ShadowTrace.endSection
validation
@Implementation(minSdk = JELLY_BEAN_MR2) protected static void endSection() { if (Trace.isTagEnabled(TRACE_TAG_APP)) { synchronized (lock) { if (currentSections.isEmpty()) { Log.e(TAG, "Trying to end a trace section that was never started"); return; } previousSections.offer(currentSections.removeFirst()); } } }
java
{ "resource": "" }
q165408
Injector.getProvider
validation
@SuppressWarnings("unchecked") @Nonnull private synchronized <T> Provider<T> getProvider(final Key<T> key) { // Previously-gotten providers (including those from subinjectors) will already be present. return (Provider<T>) providers.computeIfAbsent(key, k -> { // @AutoFactory requests are always handled by the top-level injector. if (key.isAutoFactory()) { return memoized(new ScopeBuilderProvider<>(key.getDependencyClass())); } // Find a provider locally. return findLocalProvider(key); }); }
java
{ "resource": "" }
q165409
FileMap.create
validation
boolean create(String origFileName, int fd, long offset, int length, boolean readOnly) { this.mFileName = origFileName; this.fd = fd; this.mDataOffset = offset; this.readOnly = readOnly; return true; }
java
{ "resource": "" }
q165410
PausedExecutorService.runAll
validation
public int runAll() { int numTasksRun = 0; if (Thread.currentThread().equals(executorThread)) { Logger.info("ignoring request to execute task - called from executor's own thread"); return numTasksRun; } while (hasQueuedTasks()) { runNext(); numTasksRun++; } return numTasksRun; }
java
{ "resource": "" }
q165411
PausedExecutorService.runNext
validation
public boolean runNext() { if (!hasQueuedTasks()) { return false; } if (Thread.currentThread().equals(executorThread)) { Logger.info("ignoring request to execute task - called from executor's own thread"); return false; } Runnable task = deferredTasks.poll(); task.run(); return true; }
java
{ "resource": "" }
q165412
ShadowAudioManager.requestAudioFocus
validation
@Implementation(minSdk = O) protected int requestAudioFocus(android.media.AudioFocusRequest audioFocusRequest) { lastAudioFocusRequest = new AudioFocusRequest(audioFocusRequest); return nextResponseValue; }
java
{ "resource": "" }
q165413
ShadowAudioManager.abandonAudioFocusRequest
validation
@Implementation(minSdk = O) protected int abandonAudioFocusRequest(android.media.AudioFocusRequest audioFocusRequest) { lastAbandonedAudioFocusRequest = audioFocusRequest; return nextResponseValue; }
java
{ "resource": "" }
q165414
ShadowMediaCodec.native_start
validation
@Implementation(minSdk = LOLLIPOP) protected void native_start() { // Currently only support async-mode. if (callback == null) { return; } // Report the format as changed, to simulate adding codec specific info before making input // buffers available. HashMap<String, Object> format = new HashMap<>(); format.put("csd-0", ByteBuffer.wrap(new byte[]{0x13, 0x10})); format.put("csd-1", ByteBuffer.wrap(new byte[0])); postFakeNativeEvent(EVENT_CALLBACK, CB_OUTPUT_FORMAT_CHANGE, 0, format); // Reset state. reachedEos = false; makeInputBufferAvailable(0); }
java
{ "resource": "" }
q165415
ShadowMediaCodec.getBuffer
validation
@Implementation(minSdk = LOLLIPOP) protected ByteBuffer getBuffer(boolean input, int index) { ByteBuffer[] buffers = input ? inputBuffers : outputBuffers; return (index >= 0 && index < buffers.length) ? buffers[index] : null; }
java
{ "resource": "" }
q165416
ShadowMediaCodec.native_queueInputBuffer
validation
@Implementation(minSdk = LOLLIPOP) protected void native_queueInputBuffer( int index, int offset, int size, long presentationTimeUs, int flags) { // Check if this should be the last buffer cycle. if ((flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) { reachedEos = true; } BufferInfo info = new BufferInfo(); info.set(offset, size, presentationTimeUs, flags); makeOutputBufferAvailable(index, info); }
java
{ "resource": "" }
q165417
ShadowMediaCodec.releaseOutputBuffer
validation
@Implementation(minSdk = LOLLIPOP) protected void releaseOutputBuffer(int index, boolean render, boolean updatePTS, long timeNs) { if (reachedEos) { return; } makeInputBufferAvailable(index); }
java
{ "resource": "" }
q165418
ShadowUsageStatsManager.simulateTimeChange
validation
public void simulateTimeChange(long offsetToAddInMillis) { ImmutableMap.Builder<Long, Event> eventMapBuilder = ImmutableMap.builder(); for (Event event : eventsByTimeStamp.values()) { long newTimestamp = event.getTimeStamp() + offsetToAddInMillis; eventMapBuilder.put( newTimestamp, EventBuilder.fromEvent(event).setTimeStamp(newTimestamp).build()); } eventsByTimeStamp.putAll(eventMapBuilder.build()); }
java
{ "resource": "" }
q165419
LegacyManifestParser.metaDataToBundle
validation
private static Bundle metaDataToBundle(Map<String, Object> meta) { if (meta.size() == 0) { return null; } Bundle bundle = new Bundle(); for (Map.Entry<String, Object> entry : meta.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (Boolean.class.isInstance(value)) { bundle.putBoolean(key, (Boolean) value); } else if (Float.class.isInstance(value)) { bundle.putFloat(key, (Float) value); } else if (Integer.class.isInstance(value)) { bundle.putInt(key, (Integer) value); } else { bundle.putString(key, value == null ? null : value.toString()); } } return bundle; }
java
{ "resource": "" }
q165420
ShadowSQLiteConnection.convertSQLWithLocalizedUnicodeCollator
validation
static String convertSQLWithLocalizedUnicodeCollator(String sql) { Matcher matcher = COLLATE_LOCALIZED_UNICODE_PATTERN.matcher(sql); return matcher.replaceAll(" COLLATE NOCASE"); }
java
{ "resource": "" }
q165421
ShadowApplicationPackageManager.newPackageInfo
validation
private static PackageInfo newPackageInfo(PackageInfo orig) { Parcel parcel = Parcel.obtain(); orig.writeToParcel(parcel, 0); parcel.setDataPosition(0); return PackageInfo.CREATOR.createFromParcel(parcel); }
java
{ "resource": "" }
q165422
ShadowApplicationPackageManager.isGrantedForBackwardsCompatibility
validation
private boolean isGrantedForBackwardsCompatibility(String pkgName, PackageInfo permissionsInfo) { // Note: it might be cleaner to auto-grant these permissions when the package is added to the // PackageManager. But many existing tests modify the requested permissions _after_ adding the // package to the PackageManager, without updating the requestedPermissionsFlags. return permissionsInfo.requestedPermissionsFlags == null // Robolectric uses the PackageParser to create the current test package's PackageInfo from // the manifest XML. The parser populates the requestedPermissionsFlags, but doesn't grant // the permissions. Several tests rely on the test package being granted all permissions, so // we treat this as a special case. || pkgName.equals(RuntimeEnvironment.application.getPackageName()); }
java
{ "resource": "" }
q165423
ShadowApplicationPackageManager.applyFlagsToComponentInfo
validation
private void applyFlagsToComponentInfo(ComponentInfo componentInfo, int flags) throws NameNotFoundException { componentInfo.name = (componentInfo.name == null) ? "" : componentInfo.name; ApplicationInfo applicationInfo = componentInfo.applicationInfo; boolean isApplicationEnabled = true; if (applicationInfo != null) { if (applicationInfo.packageName == null) { applicationInfo.packageName = componentInfo.packageName; } applyFlagsToApplicationInfo(componentInfo.applicationInfo, flags); componentInfo.packageName = applicationInfo.packageName; isApplicationEnabled = applicationInfo.enabled; } if ((flags & GET_META_DATA) == 0) { componentInfo.metaData = null; } boolean isComponentEnabled = isComponentEnabled(componentInfo); if ((flags & MATCH_ALL) != 0 && Build.VERSION.SDK_INT >= 23) { return; } // Android don't override the enabled field of component with the actual value. boolean isEnabledForFiltering = isComponentEnabled && (Build.VERSION.SDK_INT >= 24 ? isApplicationEnabled : true); if ((flags & MATCH_DISABLED_COMPONENTS) == 0 && !isEnabledForFiltering) { throw new NameNotFoundException("Disabled component: " + componentInfo); } if (isFlagSet(flags, PackageManager.MATCH_SYSTEM_ONLY)) { if (applicationInfo == null) { // TODO: for backwards compatibility just skip filtering. In future should just remove // invalid resolve infos from list } else { final int applicationFlags = applicationInfo.flags; if ((applicationFlags & ApplicationInfo.FLAG_SYSTEM) != ApplicationInfo.FLAG_SYSTEM) { throw new NameNotFoundException("Not system component: " + componentInfo); } } } if (!isFlagSet(flags, MATCH_UNINSTALLED_PACKAGES) && isValidComponentInfo(componentInfo) && hiddenPackages.contains(componentInfo.applicationInfo.packageName)) { throw new NameNotFoundException("Uninstalled package: " + componentInfo); } }
java
{ "resource": "" }
q165424
ShadowApplicationPackageManager.getPermissionIndex
validation
private int getPermissionIndex(PackageInfo packageInfo, String permissionName) { if (packageInfo.requestedPermissions != null) { for (int i = 0; i < packageInfo.requestedPermissions.length; i++) { if (permissionName.equals(packageInfo.requestedPermissions[i])) { return i; } } } return -1; }
java
{ "resource": "" }
q165425
ShadowApplicationPackageManager.getUserBadgedIcon
validation
@Implementation(minSdk = LOLLIPOP) protected Drawable getUserBadgedIcon(Drawable icon, UserHandle user) { return icon; }
java
{ "resource": "" }
q165426
ShadowApplicationPackageManager.hasProfileOwnerOrDeviceOwnerOnCurrentUser
validation
private boolean hasProfileOwnerOrDeviceOwnerOnCurrentUser() { DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); return devicePolicyManager.getProfileOwner() != null || (UserHandle.of(UserHandle.myUserId()).isSystem() && devicePolicyManager.getDeviceOwner() != null); }
java
{ "resource": "" }
q165427
StringResources.extractCodePoint
validation
private static char[] extractCodePoint(String codePoint) { try { return Character.toChars(Integer.valueOf(codePoint, 16)); } catch (IllegalArgumentException e) { // This may be caused by NumberFormatException of Integer.valueOf() or // IllegalArgumentException of Character.toChars(). throw new IllegalArgumentException("Invalid code point: \\u" + codePoint, e); } }
java
{ "resource": "" }
q165428
Reflector.reflector
validation
public static <T> T reflector(Class<T> iClass, Object target) { Class<?> targetClass = determineTargetClass(iClass); Constructor<? extends T> ctor = (Constructor<? extends T>) CACHE.get(iClass); try { if (ctor == null) { Class<? extends T> reflectorClass = createReflectorClass(iClass, targetClass); ctor = reflectorClass.getConstructor(targetClass); ctor.setAccessible(true); } CACHE.put(iClass, ctor); return ctor.newInstance(target); } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new IllegalStateException(e); } }
java
{ "resource": "" }
q165429
ShadowContentResolver.getStatus
validation
public static Status getStatus(Account account, String authority, boolean create) { Map<Account, Status> map = syncableAccounts.get(authority); if (map == null) { map = new HashMap<>(); syncableAccounts.put(authority, map); } Status status = map.get(account); if (status == null && create) { status = new Status(); map.put(account, status); } return status; }
java
{ "resource": "" }
q165430
ShadowContentResolver.getContentObservers
validation
public Collection<ContentObserver> getContentObservers(Uri uri) { ArrayList<ContentObserver> observers = new ArrayList<>(1); for (ContentObserverEntry entry : contentObservers) { if (entry.matches(uri)) { observers.add(entry.observer); } } return observers; }
java
{ "resource": "" }
q165431
ShadowDisplayManager.addDisplay
validation
public static int addDisplay(String qualifiersStr) { int id = getShadowDisplayManagerGlobal().addDisplay(createDisplayInfo(qualifiersStr, null)); shadowMainLooper().idle(); return id; }
java
{ "resource": "" }
q165432
ShadowDisplayManager.changeDisplay
validation
static void changeDisplay(int displayId, Consumer<DisplayConfig> consumer) { DisplayInfo displayInfo = DisplayManagerGlobal.getInstance().getDisplayInfo(displayId); if (displayInfo != null) { DisplayConfig displayConfig = new DisplayConfig(displayInfo); consumer.accept(displayConfig); displayConfig.copyTo(displayInfo); fixNominalDimens(displayInfo); } getShadowDisplayManagerGlobal().changeDisplay(displayId, displayInfo); }
java
{ "resource": "" }
q165433
ShadowDebug.fixTracePath
validation
private static String fixTracePath(String tracePath) { String defaultTraceBody = "dmtrace"; String defaultTraceExtension = ".trace"; if (tracePath == null || tracePath.charAt(0) != '/') { final File dir = RuntimeEnvironment.application.getExternalFilesDir(null); if (tracePath == null) { tracePath = new File(dir, defaultTraceBody).getAbsolutePath(); } else { tracePath = new File(dir, tracePath).getAbsolutePath(); } } if (!tracePath.endsWith(defaultTraceExtension)) { tracePath += defaultTraceExtension; } return tracePath; }
java
{ "resource": "" }
q165434
CronSequenceGenerator.findNext
validation
private int findNext(BitSet bits, int value, Calendar calendar, int field, int nextField, List<Integer> lowerOrders) { int nextValue = bits.nextSetBit(value); // roll over if needed if (nextValue == -1) { calendar.add(nextField, 1); reset(calendar, Arrays.asList(field)); nextValue = bits.nextSetBit(0); } if (nextValue != value) { calendar.set(field, nextValue); reset(calendar, lowerOrders); } return nextValue; }
java
{ "resource": "" }
q165435
CronSequenceGenerator.reset
validation
private void reset(Calendar calendar, List<Integer> fields) { for (int field : fields) { calendar.set(field, field == Calendar.DAY_OF_MONTH ? 1 : 0); } }
java
{ "resource": "" }
q165436
CronSequenceGenerator.parse
validation
private void parse(String expression) throws IllegalArgumentException { String[] fields = Strings.splitIgnoreBlank(expression, " "); if (fields.length != 6) { throw new IllegalArgumentException(String.format( "Cron expression must consist of 6 fields (found %d in \"%s\")", fields.length, expression)); } setNumberHits(this.seconds, fields[0], 0, 60); setNumberHits(this.minutes, fields[1], 0, 60); setNumberHits(this.hours, fields[2], 0, 24); setDaysOfMonth(this.daysOfMonth, fields[3]); setMonths(this.months, fields[4]); setDays(this.daysOfWeek, replaceOrdinals(fields[5], "SUN,MON,TUE,WED,THU,FRI,SAT"), 8); if (this.daysOfWeek.get(7)) { // Sunday can be represented as 0 or 7 this.daysOfWeek.set(0); this.daysOfWeek.clear(7); } }
java
{ "resource": "" }
q165437
GeneratorAdapter.getArgIndex
validation
private int getArgIndex(final int arg) { int index = (access & Opcodes.ACC_STATIC) == 0 ? 1 : 0; for (int i = 0; i < arg; i++) { index += argumentTypes[i].getSize(); } return index; }
java
{ "resource": "" }
q165438
GeneratorAdapter.loadInsn
validation
private void loadInsn(final Type type, final int index) { mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), index); }
java
{ "resource": "" }
q165439
GeneratorAdapter.storeInsn
validation
private void storeInsn(final Type type, final int index) { mv.visitVarInsn(type.getOpcode(Opcodes.ISTORE), index); }
java
{ "resource": "" }
q165440
GeneratorAdapter.loadArgs
validation
public void loadArgs(final int arg, final int count) { int index = getArgIndex(arg); for (int i = 0; i < count; ++i) { Type t = argumentTypes[arg + i]; loadInsn(t, index); index += t.getSize(); } }
java
{ "resource": "" }
q165441
GeneratorAdapter.loadArgArray
validation
public void loadArgArray() { push(argumentTypes.length); newArray(OBJECT_TYPE); for (int i = 0; i < argumentTypes.length; i++) { dup(); push(i); loadArg(i); box(argumentTypes[i]); arrayStore(OBJECT_TYPE); } }
java
{ "resource": "" }
q165442
GeneratorAdapter.loadLocal
validation
public void loadLocal(final int local, final Type type) { setLocalType(local, type); loadInsn(type, local); }
java
{ "resource": "" }
q165443
GeneratorAdapter.storeLocal
validation
public void storeLocal(final int local, final Type type) { setLocalType(local, type); storeInsn(type, local); }
java
{ "resource": "" }
q165444
GeneratorAdapter.swap
validation
public void swap(final Type prev, final Type type) { if (type.getSize() == 1) { if (prev.getSize() == 1) { swap(); // same as dupX1(), pop(); } else { dupX2(); pop(); } } else { if (prev.getSize() == 1) { dup2X1(); pop2(); } else { dup2X2(); pop2(); } } }
java
{ "resource": "" }
q165445
GeneratorAdapter.box
validation
public void box(final Type type) { if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) { return; } if (type == Type.VOID_TYPE) { push((String) null); } else { Type boxed = getBoxedType(type); newInstance(boxed); if (type.getSize() == 2) { // Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o dupX2(); dupX2(); pop(); } else { // p -> po -> opo -> oop -> o dupX1(); swap(); } invokeConstructor(boxed, new Method("<init>", Type.VOID_TYPE, new Type[] { type })); } }
java
{ "resource": "" }
q165446
GeneratorAdapter.unbox
validation
public void unbox(final Type type) { Type t = NUMBER_TYPE; Method sig = null; switch (type.getSort()) { case Type.VOID: return; case Type.CHAR: t = CHARACTER_TYPE; sig = CHAR_VALUE; break; case Type.BOOLEAN: t = BOOLEAN_TYPE; sig = BOOLEAN_VALUE; break; case Type.DOUBLE: sig = DOUBLE_VALUE; break; case Type.FLOAT: sig = FLOAT_VALUE; break; case Type.LONG: sig = LONG_VALUE; break; case Type.INT: case Type.SHORT: case Type.BYTE: sig = INT_VALUE; } if (sig == null) { checkCast(type); } else { checkCast(t); invokeVirtual(t, sig); } }
java
{ "resource": "" }
q165447
GeneratorAdapter.ifCmp
validation
public void ifCmp(final Type type, final int mode, final Label label) { switch (type.getSort()) { case Type.LONG: mv.visitInsn(Opcodes.LCMP); break; case Type.DOUBLE: mv.visitInsn(mode == GE || mode == GT ? Opcodes.DCMPL : Opcodes.DCMPG); break; case Type.FLOAT: mv.visitInsn(mode == GE || mode == GT ? Opcodes.FCMPL : Opcodes.FCMPG); break; case Type.ARRAY: case Type.OBJECT: switch (mode) { case EQ: mv.visitJumpInsn(Opcodes.IF_ACMPEQ, label); return; case NE: mv.visitJumpInsn(Opcodes.IF_ACMPNE, label); return; } throw new IllegalArgumentException("Bad comparison for type " + type); default: int intOp = -1; switch (mode) { case EQ: intOp = Opcodes.IF_ICMPEQ; break; case NE: intOp = Opcodes.IF_ICMPNE; break; case GE: intOp = Opcodes.IF_ICMPGE; break; case LT: intOp = Opcodes.IF_ICMPLT; break; case LE: intOp = Opcodes.IF_ICMPLE; break; case GT: intOp = Opcodes.IF_ICMPGT; break; } mv.visitJumpInsn(intOp, label); return; } mv.visitJumpInsn(mode, label); }
java
{ "resource": "" }
q165448
GeneratorAdapter.fieldInsn
validation
private void fieldInsn(final int opcode, final Type ownerType, final String name, final Type fieldType) { mv.visitFieldInsn(opcode, ownerType.getInternalName(), name, fieldType.getDescriptor()); }
java
{ "resource": "" }
q165449
GeneratorAdapter.getStatic
validation
public void getStatic(final Type owner, final String name, final Type type) { fieldInsn(Opcodes.GETSTATIC, owner, name, type); }
java
{ "resource": "" }
q165450
GeneratorAdapter.putStatic
validation
public void putStatic(final Type owner, final String name, final Type type) { fieldInsn(Opcodes.PUTSTATIC, owner, name, type); }
java
{ "resource": "" }
q165451
GeneratorAdapter.getField
validation
public void getField(final Type owner, final String name, final Type type) { fieldInsn(Opcodes.GETFIELD, owner, name, type); }
java
{ "resource": "" }
q165452
GeneratorAdapter.putField
validation
public void putField(final Type owner, final String name, final Type type) { fieldInsn(Opcodes.PUTFIELD, owner, name, type); }
java
{ "resource": "" }
q165453
GeneratorAdapter.invokeInsn
validation
private void invokeInsn(final int opcode, final Type type, final Method method, final boolean itf) { String owner = type.getSort() == Type.ARRAY ? type.getDescriptor() : type.getInternalName(); mv.visitMethodInsn(opcode, owner, method.getName(), method.getDescriptor(), itf); }
java
{ "resource": "" }
q165454
GeneratorAdapter.invokeVirtual
validation
public void invokeVirtual(final Type owner, final Method method) { invokeInsn(Opcodes.INVOKEVIRTUAL, owner, method, false); }
java
{ "resource": "" }
q165455
GeneratorAdapter.invokeConstructor
validation
public void invokeConstructor(final Type type, final Method method) { invokeInsn(Opcodes.INVOKESPECIAL, type, method, false); }
java
{ "resource": "" }
q165456
GeneratorAdapter.invokeStatic
validation
public void invokeStatic(final Type owner, final Method method) { invokeInsn(Opcodes.INVOKESTATIC, owner, method, false); }
java
{ "resource": "" }
q165457
GeneratorAdapter.invokeInterface
validation
public void invokeInterface(final Type owner, final Method method) { invokeInsn(Opcodes.INVOKEINTERFACE, owner, method, true); }
java
{ "resource": "" }
q165458
GeneratorAdapter.throwException
validation
public void throwException(final Type type, final String msg) { newInstance(type); dup(); push(msg); invokeConstructor(type, Method.getMethod("void <init> (String)")); throwException(); }
java
{ "resource": "" }
q165459
GeneratorAdapter.checkCast
validation
public void checkCast(final Type type) { if (!type.equals(OBJECT_TYPE)) { typeInsn(Opcodes.CHECKCAST, type); } }
java
{ "resource": "" }
q165460
MethodWriter.visitImplicitFirstFrame
validation
private void visitImplicitFirstFrame() { // There can be at most descriptor.length() + 1 locals int frameIndex = startFrame(0, descriptor.length() + 1, 0); if ((access & Opcodes.ACC_STATIC) == 0) { if ((access & ACC_CONSTRUCTOR) == 0) { frame[frameIndex++] = Frame.OBJECT | cw.addType(cw.thisName); } else { frame[frameIndex++] = 6; // Opcodes.UNINITIALIZED_THIS; } } int i = 1; loop: while (true) { int j = i; switch (descriptor.charAt(i++)) { case 'Z': case 'C': case 'B': case 'S': case 'I': frame[frameIndex++] = 1; // Opcodes.INTEGER; break; case 'F': frame[frameIndex++] = 2; // Opcodes.FLOAT; break; case 'J': frame[frameIndex++] = 4; // Opcodes.LONG; break; case 'D': frame[frameIndex++] = 3; // Opcodes.DOUBLE; break; case '[': while (descriptor.charAt(i) == '[') { ++i; } if (descriptor.charAt(i) == 'L') { ++i; while (descriptor.charAt(i) != ';') { ++i; } } frame[frameIndex++] = Frame.OBJECT | cw.addType(descriptor.substring(j, ++i)); break; case 'L': while (descriptor.charAt(i) != ';') { ++i; } frame[frameIndex++] = Frame.OBJECT | cw.addType(descriptor.substring(j + 1, i++)); break; default: break loop; } } frame[1] = frameIndex - 3; endFrame(); }
java
{ "resource": "" }
q165461
MethodWriter.startFrame
validation
private int startFrame(final int offset, final int nLocal, final int nStack) { int n = 3 + nLocal + nStack; if (frame == null || frame.length < n) { frame = new int[n]; } frame[0] = offset; frame[1] = nLocal; frame[2] = nStack; return 3; }
java
{ "resource": "" }
q165462
ClassWriter.newMethodItem
validation
Item newMethodItem(final String owner, final String name, final String desc, final boolean itf) { int type = itf ? IMETH : METH; key3.set(type, owner, name, desc); Item result = get(key3); if (result == null) { put122(type, newClass(owner), newNameType(name, desc)); result = new Item(index++, key3); put(result); } return result; }
java
{ "resource": "" }
q165463
ClassWriter.newFloat
validation
Item newFloat(final float value) { key.set(value); Item result = get(key); if (result == null) { pool.putByte(FLOAT).putInt(key.intVal); result = new Item(index++, key); put(result); } return result; }
java
{ "resource": "" }
q165464
ClassWriter.newString
validation
private Item newString(final String value) { key2.set(STR, value, null, null); Item result = get(key2); if (result == null) { pool.put12(STR, newUTF8(value)); result = new Item(index++, key2); put(result); } return result; }
java
{ "resource": "" }
q165465
ClassWriter.newNameTypeItem
validation
Item newNameTypeItem(final String name, final String desc) { key2.set(NAME_TYPE, name, desc, null); Item result = get(key2); if (result == null) { put122(NAME_TYPE, newUTF8(name), newUTF8(desc)); result = new Item(index++, key2); put(result); } return result; }
java
{ "resource": "" }
q165466
ClassWriter.get
validation
private Item get(final Item key) { Item i = items[key.hashCode % items.length]; while (i != null && (i.type != key.type || !key.isEqualTo(i))) { i = i.next; } return i; }
java
{ "resource": "" }
q165467
ClassWriter.put122
validation
private void put122(final int b, final int s1, final int s2) { pool.put12(b, s1).putShort(s2); }
java
{ "resource": "" }
q165468
ClassWriter.put112
validation
private void put112(final int b1, final int b2, final int s) { pool.put11(b1, b2).putShort(s); }
java
{ "resource": "" }
q165469
AnnotationVisitor.visitEnum
validation
public void visitEnum(String name, String desc, String value) { if (av != null) { av.visitEnum(name, desc, value); } }
java
{ "resource": "" }
q165470
AnnotationVisitor.visitAnnotation
validation
public AnnotationVisitor visitAnnotation(String name, String desc) { if (av != null) { return av.visitAnnotation(name, desc); } return null; }
java
{ "resource": "" }
q165471
Images.pos4twist
validation
private static int pos4twist(double rank, double phase, double period, int hOrW, int xOrY, int yOrX) { double dyOrX = Math.PI * rank * yOrX / hOrW + phase; double dxOrY = Math.sin(dyOrX); return xOrY + (int) (dxOrY * period); }
java
{ "resource": "" }
q165472
Images.createJPEG4
validation
private static BufferedImage createJPEG4(Raster raster) { int w = raster.getWidth(); int h = raster.getHeight(); byte[] rgb = new byte[w * h * 3]; float[] Y = raster.getSamples(0, 0, w, h, 0, (float[]) null); float[] Cb = raster.getSamples(0, 0, w, h, 1, (float[]) null); float[] Cr = raster.getSamples(0, 0, w, h, 2, (float[]) null); float[] K = raster.getSamples(0, 0, w, h, 3, (float[]) null); for (int i = 0, imax = Y.length, base = 0; i < imax; i++, base += 3) { float k = 220 - K[i], y = 255 - Y[i], cb = 255 - Cb[i], cr = 255 - Cr[i]; double val = y + 1.402 * (cr - 128) - k; val = (val - 128) * .65f + 128; rgb[base] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff : (byte) (val + 0.5); val = y - 0.34414 * (cb - 128) - 0.71414 * (cr - 128) - k; val = (val - 128) * .65f + 128; rgb[base + 1] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff : (byte) (val + 0.5); val = y + 1.772 * (cb - 128) - k; val = (val - 128) * .65f + 128; rgb[base + 2] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff : (byte) (val + 0.5); } raster = Raster.createInterleavedRaster(new DataBufferByte(rgb, rgb.length), w, h, w * 3, 3, new int[]{0, 1, 2}, null); ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); ColorModel cm = new ComponentColorModel(cs, false, true, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); return new BufferedImage(cm, (WritableRaster) raster, true, null); }
java
{ "resource": "" }
q165473
MethodVisitor.visitParameter
validation
public void visitParameter(String name, int access) { if (api < Opcodes.ASM5) { throw new RuntimeException(); } if (mv != null) { mv.visitParameter(name, access); } }
java
{ "resource": "" }
q165474
MethodVisitor.visitAnnotation
validation
public AnnotationVisitor visitAnnotation(String desc, boolean visible) { if (mv != null) { return mv.visitAnnotation(desc, visible); } return null; }
java
{ "resource": "" }
q165475
MethodVisitor.visitParameterAnnotation
validation
public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) { if (mv != null) { return mv.visitParameterAnnotation(parameter, desc, visible); } return null; }
java
{ "resource": "" }
q165476
MethodVisitor.visitTypeInsn
validation
public void visitTypeInsn(int opcode, String type) { if (mv != null) { mv.visitTypeInsn(opcode, type); } }
java
{ "resource": "" }
q165477
MethodVisitor.visitFieldInsn
validation
public void visitFieldInsn(int opcode, String owner, String name, String desc) { if (mv != null) { mv.visitFieldInsn(opcode, owner, name, desc); } }
java
{ "resource": "" }
q165478
MethodVisitor.visitMethodInsn
validation
@Deprecated public void visitMethodInsn(int opcode, String owner, String name, String desc) { if (api >= Opcodes.ASM5) { boolean itf = opcode == Opcodes.INVOKEINTERFACE; visitMethodInsn(opcode, owner, name, desc, itf); return; } if (mv != null) { mv.visitMethodInsn(opcode, owner, name, desc); } }
java
{ "resource": "" }
q165479
MethodVisitor.visitTableSwitchInsn
validation
public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels) { if (mv != null) { mv.visitTableSwitchInsn(min, max, dflt, labels); } }
java
{ "resource": "" }
q165480
MethodVisitor.visitLookupSwitchInsn
validation
public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) { if (mv != null) { mv.visitLookupSwitchInsn(dflt, keys, labels); } }
java
{ "resource": "" }
q165481
MethodVisitor.visitMultiANewArrayInsn
validation
public void visitMultiANewArrayInsn(String desc, int dims) { if (mv != null) { mv.visitMultiANewArrayInsn(desc, dims); } }
java
{ "resource": "" }
q165482
MethodVisitor.visitLocalVariableAnnotation
validation
public AnnotationVisitor visitLocalVariableAnnotation(int typeRef, TypePath typePath, Label[] start, Label[] end, int[] index, String desc, boolean visible) { if (api < Opcodes.ASM5) { throw new RuntimeException(); } if (mv != null) { return mv.visitLocalVariableAnnotation(typeRef, typePath, start, end, index, desc, visible); } return null; }
java
{ "resource": "" }
q165483
MethodVisitor.visitLineNumber
validation
public void visitLineNumber(int line, Label start) { if (mv != null) { mv.visitLineNumber(line, start); } }
java
{ "resource": "" }
q165484
ClassReader.readFrameType
validation
private int readFrameType(final Object[] frame, final int index, int v, final char[] buf, final Label[] labels) { int type = b[v++] & 0xFF; switch (type) { case 0: frame[index] = Opcodes.TOP; break; case 1: frame[index] = Opcodes.INTEGER; break; case 2: frame[index] = Opcodes.FLOAT; break; case 3: frame[index] = Opcodes.DOUBLE; break; case 4: frame[index] = Opcodes.LONG; break; case 5: frame[index] = Opcodes.NULL; break; case 6: frame[index] = Opcodes.UNINITIALIZED_THIS; break; case 7: // Object frame[index] = readClass(v, buf); v += 2; break; default: // Uninitialized frame[index] = readLabel(readUnsignedShort(v), labels); v += 2; } return v; }
java
{ "resource": "" }
q165485
Frame.set
validation
final void set(ClassWriter cw, final int nLocal, final Object[] local, final int nStack, final Object[] stack) { int i = convert(cw, nLocal, local, inputLocals); while (i < local.length) { inputLocals[i++] = TOP; } int nStackTop = 0; for (int j = 0; j < nStack; ++j) { if (stack[j] == Opcodes.LONG || stack[j] == Opcodes.DOUBLE) { ++nStackTop; } } inputStack = new int[nStack + nStackTop]; convert(cw, nStack, stack, inputStack); outputStackTop = 0; initializationCount = 0; }
java
{ "resource": "" }
q165486
Frame.get
validation
private int get(final int local) { if (outputLocals == null || local >= outputLocals.length) { // this local has never been assigned in this basic block, // so it is still equal to its value in the input frame return LOCAL | local; } else { int type = outputLocals[local]; if (type == 0) { // this local has never been assigned in this basic block, // so it is still equal to its value in the input frame type = outputLocals[local] = LOCAL | local; } return type; } }
java
{ "resource": "" }
q165487
Frame.set
validation
private void set(final int local, final int type) { // creates and/or resizes the output local variables array if necessary if (outputLocals == null) { outputLocals = new int[10]; } int n = outputLocals.length; if (local >= n) { int[] t = new int[Math.max(local + 1, 2 * n)]; System.arraycopy(outputLocals, 0, t, 0, n); outputLocals = t; } // sets the local variable outputLocals[local] = type; }
java
{ "resource": "" }
q165488
Frame.push
validation
private void push(final ClassWriter cw, final String desc) { int type = type(cw, desc); if (type != 0) { push(type); if (type == LONG || type == DOUBLE) { push(TOP); } } }
java
{ "resource": "" }
q165489
Frame.type
validation
private static int type(final ClassWriter cw, final String desc) { String t; int index = desc.charAt(0) == '(' ? desc.indexOf(')') + 1 : 0; switch (desc.charAt(index)) { case 'V': return 0; case 'Z': case 'C': case 'B': case 'S': case 'I': return INTEGER; case 'F': return FLOAT; case 'J': return LONG; case 'D': return DOUBLE; case 'L': // stores the internal name, not the descriptor! t = desc.substring(index + 1, desc.length() - 1); return OBJECT | cw.addType(t); // case '[': default: // extracts the dimensions and the element type int data; int dims = index + 1; while (desc.charAt(dims) == '[') { ++dims; } switch (desc.charAt(dims)) { case 'Z': data = BOOLEAN; break; case 'C': data = CHAR; break; case 'B': data = BYTE; break; case 'S': data = SHORT; break; case 'I': data = INTEGER; break; case 'F': data = FLOAT; break; case 'J': data = LONG; break; case 'D': data = DOUBLE; break; // case 'L': default: // stores the internal name, not the descriptor t = desc.substring(dims + 1, desc.length() - 1); data = OBJECT | cw.addType(t); } return (dims - index) << 28 | data; } }
java
{ "resource": "" }
q165490
Frame.pop
validation
private void pop(final int elements) { if (outputStackTop >= elements) { outputStackTop -= elements; } else { // if the number of elements to be popped is greater than the number // of elements in the output stack, clear it, and pops the remaining // elements from the input stack. owner.inputStackTop -= elements - outputStackTop; outputStackTop = 0; } }
java
{ "resource": "" }
q165491
Frame.pop
validation
private void pop(final String desc) { char c = desc.charAt(0); if (c == '(') { pop((Type.getArgumentsAndReturnSizes(desc) >> 2) - 1); } else if (c == 'J' || c == 'D') { pop(2); } else { pop(1); } }
java
{ "resource": "" }
q165492
Frame.init
validation
private void init(final int var) { // creates and/or resizes the initializations array if necessary if (initializations == null) { initializations = new int[2]; } int n = initializations.length; if (initializationCount >= n) { int[] t = new int[Math.max(initializationCount + 1, 2 * n)]; System.arraycopy(initializations, 0, t, 0, n); initializations = t; } // stores the type to be initialized initializations[initializationCount++] = var; }
java
{ "resource": "" }
q165493
Frame.init
validation
private int init(final ClassWriter cw, final int t) { int s; if (t == UNINITIALIZED_THIS) { s = OBJECT | cw.addType(cw.thisName); } else if ((t & (DIM | BASE_KIND)) == UNINITIALIZED) { String type = cw.typeTable[t & BASE_VALUE].strVal1; s = OBJECT | cw.addType(type); } else { return t; } for (int j = 0; j < initializationCount; ++j) { int u = initializations[j]; int dim = u & DIM; int kind = u & KIND; if (kind == LOCAL) { u = dim + inputLocals[u & VALUE]; } else if (kind == STACK) { u = dim + inputStack[inputStack.length - (u & VALUE)]; } if (t == u) { return s; } } return t; }
java
{ "resource": "" }
q165494
ClassVisitor.visitSource
validation
public void visitSource(String source, String debug) { if (cv != null) { cv.visitSource(source, debug); } }
java
{ "resource": "" }
q165495
ClassVisitor.visitOuterClass
validation
public void visitOuterClass(String owner, String name, String desc) { if (cv != null) { cv.visitOuterClass(owner, name, desc); } }
java
{ "resource": "" }
q165496
ClassVisitor.visitAnnotation
validation
public AnnotationVisitor visitAnnotation(String desc, boolean visible) { if (cv != null) { return cv.visitAnnotation(desc, visible); } return null; }
java
{ "resource": "" }
q165497
ClassVisitor.visitTypeAnnotation
validation
public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { if (api < Opcodes.ASM5) { throw new RuntimeException(); } if (cv != null) { return cv.visitTypeAnnotation(typeRef, typePath, desc, visible); } return null; }
java
{ "resource": "" }
q165498
Maths.extract
validation
public static int extract(int bs, int low, int high) { bs = bs >> low; int mask = 0; for (int i = 0; i < (high - low); i++) { mask += 1 << i; } return bs & mask; }
java
{ "resource": "" }
q165499
Type.getObjectType
validation
public static Type getObjectType(final String internalName) { char[] buf = internalName.toCharArray(); return new Type(buf[0] == '[' ? ARRAY : OBJECT, buf, 0, buf.length); }
java
{ "resource": "" }