/** * Notifies this <tt>Conference</tt> that the ordered list of <tt>Endpoint</tt>s of {@link * #speechActivity} i.e. the dominant speaker history has changed. * * <p>This instance notifies the video <tt>Channel</tt>s about the change so that they may update * their last-n lists and report to this instance which <tt>Endpoint</tt>s are to be asked for * video keyframes. */ private void speechActivityEndpointsChanged() { List<Endpoint> endpoints = null; for (Content content : getContents()) { if (MediaType.VIDEO.equals(content.getMediaType())) { Set<Endpoint> endpointsToAskForKeyframes = null; endpoints = speechActivity.getEndpoints(); for (Channel channel : content.getChannels()) { if (!(channel instanceof RtpChannel)) continue; RtpChannel rtpChannel = (RtpChannel) channel; List<Endpoint> channelEndpointsToAskForKeyframes = rtpChannel.speechActivityEndpointsChanged(endpoints); if ((channelEndpointsToAskForKeyframes != null) && !channelEndpointsToAskForKeyframes.isEmpty()) { if (endpointsToAskForKeyframes == null) { endpointsToAskForKeyframes = new HashSet<>(); } endpointsToAskForKeyframes.addAll(channelEndpointsToAskForKeyframes); } } if ((endpointsToAskForKeyframes != null) && !endpointsToAskForKeyframes.isEmpty()) { content.askForKeyframes(endpointsToAskForKeyframes); } } } }
public Set<String> listResources(String subdir) { try { Set<String> result = new HashSet<String>(); if (resourceURL != null) { String protocol = resourceURL.getProtocol(); if (protocol.equals("jar")) { String resPath = resourceURL.getPath(); int pling = resPath.lastIndexOf("!"); URL jarURL = new URL(resPath.substring(0, pling)); String resDirInJar = resPath.substring(pling + 2); String prefix = resDirInJar + subdir + "/"; // System.out.printf("BaseMod.listResources: looking for names starting with %s\n", // prefix); JarFile jar = new JarFile(new File(jarURL.toURI())); Enumeration<JarEntry> entries = jar.entries(); while (entries.hasMoreElements()) { String name = entries.nextElement().getName(); if (name.startsWith(prefix) && !name.endsWith("/") && !name.contains("/.")) { // System.out.printf("BaseMod.listResources: name = %s\n", name); result.add(name.substring(prefix.length())); } } } else throw new RuntimeException("Resource URL protocol " + protocol + " not supported"); } return result; } catch (Exception e) { throw new RuntimeException(e); } }
public synchronized Collection<GarbageCollectorMXBean> getGarbageCollectorMXBeans() throws IOException { // TODO: How to deal with changes to the list?? if (garbageCollectorMBeans == null) { ObjectName gcName = null; try { gcName = new ObjectName(GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*"); } catch (MalformedObjectNameException e) { // should not reach here assert (false); } Set<ObjectName> mbeans = server.queryNames(gcName, null); if (mbeans != null) { garbageCollectorMBeans = new ArrayList<GarbageCollectorMXBean>(); Iterator<ObjectName> iterator = mbeans.iterator(); while (iterator.hasNext()) { ObjectName on = (ObjectName) iterator.next(); String name = GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",name=" + on.getKeyProperty("name"); GarbageCollectorMXBean mBean = newPlatformMXBeanProxy(server, name, GarbageCollectorMXBean.class); garbageCollectorMBeans.add(mBean); } } } return garbageCollectorMBeans; }
/** * Returns a map of MBeans with ObjectName as the key and MBeanInfo value of a given domain. If * domain is <tt>null</tt>, all MBeans are returned. If no MBean found, an empty map is returned. */ public Map<ObjectName, MBeanInfo> getMBeans(String domain) throws IOException { ObjectName name = null; if (domain != null) { try { name = new ObjectName(domain + ":*"); } catch (MalformedObjectNameException e) { // should not reach here assert (false); } } Set<ObjectName> mbeans = server.queryNames(name, null); Map<ObjectName, MBeanInfo> result = new HashMap<ObjectName, MBeanInfo>(mbeans.size()); Iterator<ObjectName> iterator = mbeans.iterator(); while (iterator.hasNext()) { Object object = iterator.next(); if (object instanceof ObjectName) { ObjectName o = (ObjectName) object; try { MBeanInfo info = server.getMBeanInfo(o); result.put(o, info); } catch (IntrospectionException e) { // TODO: should log the error } catch (InstanceNotFoundException e) { // TODO: should log the error } catch (ReflectionException e) { // TODO: should log the error } } } return result; }
/** * Compute the set of all IA32 opcodes that have emit methods in the Assembler. This method uses * the stylized form of all emit method names in the Assembler to extract the opcode of each one. * It returns a set of all such distinct names, as a set of Strings. * * @param emitters the set of all emit methods in the Assembler * @return the set of all opcodes handled by the Assembler */ private static Set<String> getOpcodes(Method[] emitters) { Set<String> s = new HashSet<String>(); for (int i = 0; i < emitters.length; i++) { String name = emitters[i].getName(); if (DEBUG) System.err.println(name); if (name.startsWith("emit")) { int posOf_ = name.indexOf('_'); if (posOf_ != -1) { String opcode = name.substring(4, posOf_); if (!excludedOpcodes.contains(opcode)) { s.add(opcode); } } else { String opcode = name.substring(4); // make sure it is an opcode if (opcode.equals(opcode.toUpperCase(Locale.getDefault()))) { if (!excludedOpcodes.contains(opcode)) { s.add(opcode); } } } } } return s; }
private void checkStartup( Map<String, ServiceData> map, List<ServiceData> start, ServiceData sd, Set<ServiceData> cyclic) { if (sd.after.isEmpty() || start.contains(sd)) return; if (cyclic.contains(sd)) { reporter.error("Cyclic dependency for " + sd.name); return; } cyclic.add(sd); for (String dependsOn : sd.after) { if (dependsOn.equals("boot")) continue; ServiceData deps = map.get(dependsOn); if (deps == null) { reporter.error("No such service " + dependsOn + " but " + sd.name + " depends on it"); } else { checkStartup(map, start, deps, cyclic); } } start.add(sd); }
/** * Returns the children name associated with this config instance. This is by definition a subset * of the element names as known to the model {#see ConfigModel.getElementNames(). @Return list of * elements names associated with this config instance */ public Set<String> getElementNames() { Set<String> names = new HashSet<String>(); for (Child child : children) { names.add(child.name); } return names; }
/* package */ void ensureConstraints(List<Child> children) { Set<String> nullElements = new HashSet<String>(model.getElementNames()); for (Child child : children) { nullElements.remove(child.name); } for (String s : nullElements) { ConfigModel.Property p = model.getElement(s); for (String annotation : p.getAnnotations()) { if (annotation.equals(NotNull.class.getName())) { if (p instanceof ConfigModel.Node) { ConfigModel childModel = ((ConfigModel.Node) p).model; Dom child = document.make(getHabitat(), null, this, childModel); child.register(); children.add(new Dom.NodeChild(s, child)); // recursive call to ensure the children constraints are also respected List<Child> grandChildren = new ArrayList<Child>(); child.ensureConstraints(grandChildren); if (!grandChildren.isEmpty()) { child.setChildren(grandChildren); } child.initializationCompleted(); } } } } }
private static void check(String what, MBeanNotificationInfo[] mbnis) { System.out.print(what + ": checking notification info: "); if (mbnis.length == 0) { System.out.println("NONE (suspicious)"); suspicious.add(what); return; } // Each MBeanNotificationInfo.getName() should be an existent // Java class that is Notification or a subclass of it for (int j = 0; j < mbnis.length; j++) { String notifClassName = mbnis[j].getName(); Class notifClass; try { notifClass = Class.forName(notifClassName); } catch (Exception e) { System.out.print("FAILED(" + notifClassName + ": " + e + ") "); failed.add(what); continue; } if (!Notification.class.isAssignableFrom(notifClass)) { System.out.print("FAILED(" + notifClassName + ": not a Notification) "); failed.add(what); continue; } System.out.print("OK(" + notifClassName + ") "); } System.out.println(); }
public Set<String> getOperatorClasses(String parent, String searchTerm) throws ClassNotFoundException { if (CollectionUtils.isEmpty(operatorClassNames)) { loadOperatorClass(); } if (parent == null) { parent = Operator.class.getName(); } else { if (!typeGraph.isAncestor(Operator.class.getName(), parent)) { throw new IllegalArgumentException("Argument must be a subclass of Operator class"); } } Set<String> filteredClass = Sets.filter( operatorClassNames, new Predicate<String>() { @Override public boolean apply(String className) { OperatorClassInfo oci = classInfo.get(className); return oci == null || !oci.tags.containsKey("@omitFromUI"); } }); if (searchTerm == null && parent.equals(Operator.class.getName())) { return filteredClass; } if (searchTerm != null) { searchTerm = searchTerm.toLowerCase(); } Set<String> result = new HashSet<String>(); for (String clazz : filteredClass) { if (parent.equals(Operator.class.getName()) || typeGraph.isAncestor(parent, clazz)) { if (searchTerm == null) { result.add(clazz); } else { if (clazz.toLowerCase().contains(searchTerm)) { result.add(clazz); } else { OperatorClassInfo oci = classInfo.get(clazz); if (oci != null) { if (oci.comment != null && oci.comment.toLowerCase().contains(searchTerm)) { result.add(clazz); } else { for (Map.Entry<String, String> entry : oci.tags.entrySet()) { if (entry.getValue().toLowerCase().contains(searchTerm)) { result.add(clazz); break; } } } } } } } } return result; }
void showDiagnostics(boolean showAll) { Set<JCDiagnostic.Kind> kinds = EnumSet.allOf(JCDiagnostic.Kind.class); if (!showAll) { // suppress errors, which are all presumed to be transient resolve errors kinds.remove(JCDiagnostic.Kind.ERROR); } log.reportDeferredDiagnostics(kinds); }
private <T> CachedRuleSource doExtract(final Class<T> source) { final ModelType<T> type = ModelType.of(source); DefaultMethodModelRuleExtractionContext context = new DefaultMethodModelRuleExtractionContext(type, this); // TODO - exceptions thrown here should point to some extensive documentation on the concept of // class rule sources StructSchema<T> schema = getSchema(source, context); if (schema == null) { throw new InvalidModelRuleDeclarationException(context.problems.format()); } // sort for determinism Set<Method> methods = new TreeSet<Method>(Ordering.usingToString()); methods.addAll(Arrays.asList(source.getDeclaredMethods())); ImmutableList.Builder<ModelProperty<?>> implicitInputs = ImmutableList.builder(); ModelProperty<?> target = null; for (ModelProperty<?> property : schema.getProperties()) { if (property.isAnnotationPresent(RuleTarget.class)) { target = property; } else if (property.isAnnotationPresent(RuleInput.class) && !(property.getSchema() instanceof ScalarValueSchema)) { implicitInputs.add(property); } for (WeaklyTypeReferencingMethod<?, ?> method : property.getAccessors()) { methods.remove(method.getMethod()); } } ImmutableList.Builder<ExtractedRuleDetails> rules = ImmutableList.builder(); for (Method method : methods) { MethodRuleDefinition<?, ?> ruleDefinition = DefaultMethodRuleDefinition.create(source, method); ExtractedModelRule rule = getMethodHandler(ruleDefinition, method, context); if (rule != null) { rules.add(new ExtractedRuleDetails(ruleDefinition, rule)); } } if (context.hasProblems()) { throw new InvalidModelRuleDeclarationException(context.problems.format()); } StructBindings<T> bindings = structBindingsStore.getBindings(schema); if (schema.getProperties().isEmpty()) { return new StatelessRuleSource( rules.build(), Modifier.isAbstract(source.getModifiers()) ? new AbstractRuleSourceFactory<T>(schema, bindings, proxyFactory) : new ConcreteRuleSourceFactory<T>(type)); } else { return new ParameterizedRuleSource( rules.build(), target, implicitInputs.build(), schema, bindings, proxyFactory); } }
/** * Adds <tt>listener</tt> to the list of {@link CapsVerListener}s that we notify when new features * occur and the version hash needs to be regenerated. The method would also notify * <tt>listener</tt> if our current caps version has been generated and is different than * <tt>null</tt>. * * @param listener the {@link CapsVerListener} we'd like to register. */ public void addCapsVerListener(CapsVerListener listener) { synchronized (capsVerListeners) { if (capsVerListeners.contains(listener)) return; capsVerListeners.add(listener); if (currentCapsVersion != null) listener.capsVerUpdated(currentCapsVersion); } }
/** * Returns a string array containing the default JMX domains of all available MBeanServers in this * JVM. * * @return a string array of JMX default domains */ public static String[] getMBeanServerDomains() { Set<String> domains = new HashSet<String>(); for (MBeanServer mbs : MBeanServerFactory.findMBeanServer(null)) { String domain = mbs.getDefaultDomain(); if (domain == null) domain = "DefaultDomain"; domains.add(domain); } return domains.toArray(new String[domains.size()]); }
boolean closeAndRemoveResourcesInSet(Set s, Method closeMethod) { boolean okay = true; Set temp; synchronized (s) { temp = new HashSet(s); } for (Iterator ii = temp.iterator(); ii.hasNext(); ) { Object rsrc = ii.next(); try { closeMethod.invoke(rsrc, CLOSE_ARGS); } catch (Exception e) { Throwable t = e; if (t instanceof InvocationTargetException) t = ((InvocationTargetException) e).getTargetException(); logger.log(MLevel.WARNING, "An exception occurred while cleaning up a resource.", t); // t.printStackTrace(); okay = false; } finally { s.remove(rsrc); } } // We had to abandon the idea of simply iterating over s directly, because // our resource close methods sometimes try to remove the resource from // its parent Set. This is important (when the user closes the resources // directly), but leads to ConcurrenModificationExceptions while we are // iterating over the Set to close. So, now we iterate over a copy, but remove // from the original Set. Since removal is idempotent, it don't matter if // the close method already provoked a remove. Sucks that we have to copy // the set though. // // Original (direct iteration) version: // // synchronized (s) // { // for (Iterator ii = s.iterator(); ii.hasNext(); ) // { // Object rsrc = ii.next(); // try // { closeMethod.invoke(rsrc, CLOSE_ARGS); } // catch (Exception e) // { // Throwable t = e; // if (t instanceof InvocationTargetException) // t = ((InvocationTargetException) e).getTargetException(); // t.printStackTrace(); // okay = false; // } // finally // { ii.remove(); } // } // } return okay; }
/** * Given an IA32 opcode, return the set of opt compiler IA32_ operators that translate to it. * There is, by and large, a one-to-one mapping in each each IA332_ opt operator represents an * IA32 opcde, so this method might seem useless. However, there are some special cases, notably * for operand size. In this case, an opt operator of the form ADD__B would mean use the ADD IA32 * opcode with a byte operand size. */ private static Set<String> getMatchingOperators(String lowLevelOpcode) { Iterator<String> e = OperatorFormatTables.getOpcodes(); Set<String> matchingOperators = new HashSet<String>(); while (e.hasNext()) { String o = (String) e.next(); if (o.equals(lowLevelOpcode) || o.startsWith(lowLevelOpcode + "__")) matchingOperators.add(o); } return matchingOperators; }
/** * returns a list of all IA32_ opt compiler operators that do not correspond to real IA32 opcodes * handled by the assembler. These are all supposed to have been removed by the time the assembler * is called, so the assembler actually seeing such an opcode is an internal compiler error. This * set is used during generating of error checking code. * * @param emittedOpcodes the set of IA32 opcodes the assembler understands. * @return the set of IA32 opt operators that the assembler does not understand. */ private static Set<String> getErrorOpcodes(Set<String> emittedOpcodes) { Iterator<String> e = OperatorFormatTables.getOpcodes(); Set<String> errorOpcodes = new HashSet<String>(); while (e.hasNext()) { String opcode = (String) e.next(); if (!emittedOpcodes.contains(opcode)) errorOpcodes.add(opcode); } return errorOpcodes; }
public static void main(String[] args) throws Exception { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); final Boolean isNotificationSupported = AccessController.doPrivileged( new PrivilegedAction<Boolean>() { public Boolean run() { try { Class cl = Class.forName("sun.management.VMManagementImpl"); Field f = cl.getDeclaredField("gcNotificationSupport"); f.setAccessible(true); return f.getBoolean(null); } catch (ClassNotFoundException e) { return false; } catch (NoSuchFieldException e) { return false; } catch (IllegalAccessException e) { return false; } } }); if (!isNotificationSupported) { System.out.println("GC Notification not supported by the JVM, test skipped"); return; } final ObjectName gcMXBeanPattern = new ObjectName("java.lang:type=GarbageCollector,*"); Set<ObjectName> names = mbs.queryNames(gcMXBeanPattern, null); if (names.isEmpty()) throw new Exception("Test incorrect: no GC MXBeans"); number = names.size(); for (ObjectName n : names) { if (mbs.isInstanceOf(n, "javax.management.NotificationEmitter")) { listenerInvoked.put(n.getCanonicalName(), null); GcListener listener = new GcListener(); mbs.addNotificationListener(n, listener, null, null); } } // Invocation of System.gc() to trigger major GC System.gc(); // Allocation of many short living and small objects to trigger minor GC Object data[] = new Object[32]; for (int i = 0; i < 100000000; i++) { data[i % 32] = new int[8]; } int wakeup = 0; synchronized (synchronizer) { while (count != number) { synchronizer.wait(10000); wakeup++; if (wakeup > 10) break; } } for (GarbageCollectionNotificationInfo notif : listenerInvoked.values()) { checkGarbageCollectionNotificationInfoContent(notif); } System.out.println("Test passed"); }
/** * Returns an array containing all installed providers that satisfy the specified* selection * criteria, or null if no such providers have been installed. The returned providers are ordered * according to their <a href= "#insertProviderAt(java.security.Provider, int)">preference * order</a>. * * <p>The selection criteria are represented by a map. Each map entry represents a selection * criterion. A provider is selected iff it satisfies all selection criteria. The key for any * entry in such a map must be in one of the following two formats: * * <ul> * <li><i><crypto_service>.<algorithm_or_type></i> * <p>The cryptographic service name must not contain any dots. * <p>The value associated with the key must be an empty string. * <p>A provider satisfies this selection criterion iff the provider implements the * specified algorithm or type for the specified cryptographic service. * <li><i><crypto_service>.<algorithm_or_type> <attribute_name></i> * <p>The cryptographic service name must not contain any dots. There must be one or more * space charaters between the <i><algorithm_or_type></i> and the * <i><attribute_name></i>. * <p>The value associated with the key must be a non-empty string. A provider satisfies * this selection criterion iff the provider implements the specified algorithm or type for * the specified cryptographic service and its implementation meets the constraint expressed * by the specified attribute name/value pair. * </ul> * * <p>See Appendix A in the <a href= "../../../guide/security/CryptoSpec.html#AppA"> Java * Cryptogaphy Architecture API Specification & Reference </a> for information about standard * cryptographic service names, standard algorithm names and standard attribute names. * * @param filter the criteria for selecting providers. The filter is case-insensitive. * @return all the installed providers that satisfy the selection criteria, or null if no such * providers have been installed. * @throws InvalidParameterException if the filter is not in the required format * @throws NullPointerException if filter is null * @see #getProviders(java.lang.String) */ public static Provider[] getProviders(Map<String, String> filter) { // Get all installed providers first. // Then only return those providers who satisfy the selection criteria. Provider[] allProviders = Security.getProviders(); Set keySet = filter.keySet(); LinkedHashSet candidates = new LinkedHashSet(5); // Returns all installed providers // if the selection criteria is null. if ((keySet == null) || (allProviders == null)) { return allProviders; } boolean firstSearch = true; // For each selection criterion, remove providers // which don't satisfy the criterion from the candidate set. for (Iterator ite = keySet.iterator(); ite.hasNext(); ) { String key = (String) ite.next(); String value = (String) filter.get(key); LinkedHashSet newCandidates = getAllQualifyingCandidates(key, value, allProviders); if (firstSearch) { candidates = newCandidates; firstSearch = false; } if ((newCandidates != null) && !newCandidates.isEmpty()) { // For each provider in the candidates set, if it // isn't in the newCandidate set, we should remove // it from the candidate set. for (Iterator cansIte = candidates.iterator(); cansIte.hasNext(); ) { Provider prov = (Provider) cansIte.next(); if (!newCandidates.contains(prov)) { cansIte.remove(); } } } else { candidates = null; break; } } if ((candidates == null) || (candidates.isEmpty())) return null; Object[] candidatesArray = candidates.toArray(); Provider[] result = new Provider[candidatesArray.length]; for (int i = 0; i < result.length; i++) { result[i] = (Provider) candidatesArray[i]; } return result; }
private void handleRtpPacket(RawPacket pkt) { if (pkt != null && pkt.getPayloadType() == vp8PayloadType) { int ssrc = pkt.getSSRC(); if (!activeVideoSsrcs.contains(ssrc & 0xffffffffL)) { synchronized (activeVideoSsrcs) { if (!activeVideoSsrcs.contains(ssrc & 0xffffffffL)) { activeVideoSsrcs.add(ssrc & 0xffffffffL); rtcpFeedbackSender.sendFIR(ssrc); } } } } }
public ObjectPropertyAssertion<T> ignoreFields(String... field) { Set<String> ignoredFields = new HashSet<String>(this.ignoredFields); ignoredFields.addAll(Arrays.asList(field)); return new ObjectPropertyAssertion<T>( type, generator, refinement, creator, skipSynthetic, skipToString, optionalToStringRegex, ignoredFields); }
private static void netxsurgery() throws Exception { /* Force off NetX codebase classloading. */ Class<?> nxc; try { nxc = Class.forName("net.sourceforge.jnlp.runtime.JNLPClassLoader"); } catch (ClassNotFoundException e1) { try { nxc = Class.forName("netx.jnlp.runtime.JNLPClassLoader"); } catch (ClassNotFoundException e2) { throw (new Exception("No known NetX on classpath")); } } ClassLoader cl = MainFrame.class.getClassLoader(); if (!nxc.isInstance(cl)) { throw (new Exception("Not running from a NetX classloader")); } Field cblf, lf; try { cblf = nxc.getDeclaredField("codeBaseLoader"); lf = nxc.getDeclaredField("loaders"); } catch (NoSuchFieldException e) { throw (new Exception("JNLPClassLoader does not conform to its known structure")); } cblf.setAccessible(true); lf.setAccessible(true); Set<Object> loaders = new HashSet<Object>(); Stack<Object> open = new Stack<Object>(); open.push(cl); while (!open.empty()) { Object cur = open.pop(); if (loaders.contains(cur)) continue; loaders.add(cur); Object curl; try { curl = lf.get(cur); } catch (IllegalAccessException e) { throw (new Exception("Reflection accessibility not available even though set")); } for (int i = 0; i < Array.getLength(curl); i++) { Object other = Array.get(curl, i); if (nxc.isInstance(other)) open.push(other); } } for (Object cur : loaders) { try { cblf.set(cur, null); } catch (IllegalAccessException e) { throw (new Exception("Reflection accessibility not available even though set")); } } }
private static Set<String> findStandardMBeansFromJar(URL codeBase) throws Exception { InputStream is = codeBase.openStream(); JarInputStream jis = new JarInputStream(is); Set<String> names = new TreeSet<String>(); JarEntry entry; while ((entry = jis.getNextJarEntry()) != null) { String name = entry.getName(); if (!name.endsWith(".class")) continue; name = name.substring(0, name.length() - 6); name = name.replace('/', '.'); names.add(name); } return names; }
private static String[] findStandardMBeans(URL codeBase) throws Exception { Set<String> names; if (codeBase.getProtocol().equalsIgnoreCase("file") && codeBase.toString().endsWith("/")) names = findStandardMBeansFromDir(codeBase); else names = findStandardMBeansFromJar(codeBase); Set<String> standardMBeanNames = new TreeSet<String>(); for (String name : names) { if (name.endsWith("MBean")) { String prefix = name.substring(0, name.length() - 5); if (names.contains(prefix)) standardMBeanNames.add(prefix); } } return standardMBeanNames.toArray(new String[0]); }
/** * This method inserts a default value for the standard java types, else it inserts the text name * of the expected class type. It acts to give a clue as to the input type. */ public static String getDefaultValue(String type) { if (numericalTypes.contains(type) || extraNumericalTypes.contains(type)) { return "0"; } if (booleanTypes.contains(type)) { return "true"; } type = getReadableClassName(type); int i = type.lastIndexOf('.'); if (i > 0) { return type.substring(i + 1, type.length()); } else { return type; } }
private void restoreDefinition(@Nonnull Class<?> redefinedClass) { if (redefinedClassesWithNativeMethods.contains(redefinedClass.getName())) { reregisterNativeMethodsForRestoredClass(redefinedClass); } removeMockedClass(redefinedClass); }
/** * Write the Java code required for error checking and calling the emit method represented by a * singleton EmitterSet. A singleton EmiiterSet will typically be the result of a series of * splits of bigger sets, where the splits represent emitted queries of operand types and sizes. * (See emitSet) However, there may be cases when some operand has only one possible options, so * the splitting will not have generated any tests for it. In this case, we will emit assertions * that guarantee the operand is of the expected type. Note that the answers to queries * alrrready performed by splitting are known to be fine, so no additional error checking is * needed for cases they cover. * * @see #emitSet * @param opcode the IA32 opcode to generate * @param testsPerformed the set of queries already performed by splitting. * @param level level of indentation for prett printing */ private void emitSingleton(String opcode, boolean[][] testsPerformed, int level) { EmitterDescriptor ed = (EmitterDescriptor) emitters.iterator().next(); ArgumentType[] args = ed.getArgs(); int count = ed.getCount(); for (int i = 0; i < count; i++) if (!testsPerformed[i][args[i].ordinal()]) emitVerify(i, args[i], level); ArgumentType size = ed.getSize(); if (size != null) { boolean needed = true; for (int i = 0; i < count; i++) if (testsPerformed[i][size.ordinal()]) needed = false; if (needed) emitVerify(0, size, level); if (size == ArgumentType.Byte) for (int i = 0; i < count; i++) if (args[i] == ArgumentType.GPRegister) if (currentOpcode.indexOf("MOVZX") == -1 && currentOpcode.indexOf("MOVSX") == -1) { emitTab(level); emit("if (VM.VerifyAssertions) opt_assert("); emitArgs(i, ArgumentType.GPRegister); emit(".isValidAs8bitRegister());\n"); } } emitEmitCall(opcode, args, count, level, ed.getSize()); }
void restoreTransformedClasses(@Nonnull Set<ClassIdentification> previousTransformedClasses) { if (!transformedClasses.isEmpty()) { Set<ClassIdentification> classesToRestore; if (previousTransformedClasses.isEmpty()) { classesToRestore = transformedClasses.keySet(); } else { classesToRestore = getTransformedClasses(); classesToRestore.removeAll(previousTransformedClasses); } if (!classesToRestore.isEmpty()) { restoreAndRemoveTransformedClasses(classesToRestore); } } }
/** * ** Prints all the default values from <code>RTKey</code> and {@link RTConfig} ** to the * specified <code>PrintStream</code>. Used for debugging/testing ** @param out The <code> * PrintStream</code> */ public static void printDefaults(PrintStream out) { /* print standard runtime entries */ Set<String> keyList = new OrderedSet<String>(); String keyGrp = null; for (Iterator<Entry> v = RTKey.getRuntimeEntryMap().values().iterator(); v.hasNext(); ) { Entry rtk = v.next(); if (rtk.isHelp()) { out.println(""); out.println("# ===== " + rtk.getHelp()); } else { Object dft = rtk.getDefault(); out.println("# --- " + rtk.getHelp()); out.println("# " + rtk.toString(dft)); String key = rtk.getKey(); keyList.add(key); if (!key.equals(CONFIG_FILE) && RTConfig.hasProperty(key)) { String val = RTConfig.getString(key, null); // if ((val != null) && ((dft == null) || !val.equals(dft.toString()))) { out.println(rtk.toString(val)); // } } } } /* orphaned entries */ RTProperties cmdLineProps = RTConfig.getConfigFileProperties(); if (cmdLineProps != null) { boolean orphanHeader = false; for (Iterator i = cmdLineProps.keyIterator(); i.hasNext(); ) { Object k = i.next(); if (!k.equals(COMMAND_LINE_CONF) && !keyList.contains(k)) { if (!orphanHeader) { out.println(""); out.println("# ===== Other entries"); orphanHeader = true; } Object v = cmdLineProps.getProperty(k, null); out.println(k + "=" + ((v != null) ? v : NULL_VALUE)); } } } /* final blank line */ out.println(""); }
@Override public Set<TypeElement> scan(Element e, Set<TypeElement> p) { for (AnnotationMirror annotationMirror : elements.getAllAnnotationMirrors(e)) { Element e2 = annotationMirror.getAnnotationType().asElement(); p.add((TypeElement) e2); } return super.scan(e, p); }