Process an exception for a static class.

@param sourceClass of the source object.
@param methodName where the FFDC is being requested from.
@param throwable the cause of the exception.
@param probe identifying the source of the exception.
179611
public void processException(Class sourceClass,
                                 String methodName,
                                 Throwable throwable,
                                 String probe) {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(cclass,
                        "processException",
                        new Object[] { sourceClass,
                                      methodName,
                                      throwable,
                                      probe });
        print(null,
              sourceClass,
              methodName,
              throwable,
              probe,
              null,
              null);

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(cclass,
                       "processException");

    }
559289
final void fireProbe(long probeId, @Sensitive Object instance, @Sensitive Object target, @Sensitive Object payload) {
        try {
            //new Exception().printStackTrace();
            ProbeImpl probe = activeProbesById.get(probeId);
            ConcurrentMap<ProbeImpl, Set<ProbeListener>> listenersByProbe = this.listenersByProbe;
            if (shuttingDown || listenersByProbe == null || probe == null) {
                return;
            }
            Set<ProbeListener> listeners = listenersByProbe.get(probe);
            if (listeners == null) {
                return;
            }
            for (ProbeListener listener : listeners) {
                try {
                    Method method = listener.getTargetMethod();
                    //Class<?>[] parameterTypes = method.getParameterTypes();
                    Class<?>[] parameterTypes = listener.getParameterTypes();
                    //Annotation[][] parameterAnnotations = method.getParameterAnnotations();
                    //Annotation[][] parameterAnnotations = listener.getparameterannotations();//Performance Improvement
                    Object[] args = listener.getdefaultvalues();
                    if (args != null)
                        args = Arrays.copyOf(args, args.length);
                    boolean validated = listener.isValidated();
                    ArrayList<Integer> annList = listener.getAnnotationsList();
                    for (int i = 0; i < parameterTypes.length; i++) {

                        switch (annList.get(i)) {
                            case MonitorConstants.This:
                                if (validated || parameterTypes[i].isInstance(instance)) {
                                    args[i] = instance;
                                }
                                break;
                            case MonitorConstants.Args:
                                if (validated || Object[].class.isInstance(payload)) {
                                    args[i] = payload;
                                }
                                break;
                            case MonitorConstants.Elapsed:
                                break;
                            case MonitorConstants.Returned:
                                if (validated || parameterTypes[i].isInstance(payload)) {
                                    args[i] = payload;
                                }
                                break;
                            case MonitorConstants.FieldValue:
                                if (parameterTypes[i].isInstance(payload)) {
                                    args[i] = payload;
                                }
                                break;
                            case MonitorConstants.TargetInstance:
                                if (parameterTypes[i].isInstance(target)) {
                                    args[i] = target;
                                }
                                break;
                            case MonitorConstants.TargetMember:
                                break;
                            case MonitorConstants.Thrown:
                                if (Throwable.class.isInstance(payload) && parameterTypes[i].isInstance(payload)) {
                                    args[i] = payload;
                                }
                                break;
                            case MonitorConstants.Arg:
                                break;
                            default:
                                break;
                        }
//Below code causes performance overhead ..specifically the instanceof tag is causing overhead hence using switch case which is based on
//                        structures built the ProbeListener constructor
//                        Annotation[] annotations = parameterAnnotations[i];
//                        for (Annotation a : annotations) {
//                            if (a instanceof This) {
//                                if (parameterTypes[i].isInstance(instance)) {
//                                    System.out.println("i is " + i + " ins is This");
//                                    args[i] = instance;
//                                }
//                            } else if (a instanceof Args) { // @Args
//                                // payload instance of Object[] and Object[] can be assigned to parameter
//                                if (Object[].class.isInstance(payload) && parameterTypes[i].isAssignableFrom(Object[].class)) {
//                                    args[i] = payload;
//                                }
//                            }
//                            else if (a instanceof Elapsed) {
//                                // TODO
//                                System.out.println("elapsed");
//                                //args[i] = getDefaultValue(parameterTypes[i]);
//                            } else if (a instanceof Returned) {
//                                System.out.println("Returned");
//                                if (parameterTypes[i].isInstance(payload)) {
//                                    args[i] = payload;
//                                }
//                            } else if (a instanceof FieldValue) {
//                                System.out.println("FieldValue");
//                                if (parameterTypes[i].isInstance(payload)) {
//                                    args[i] = payload;
//                                }
//                            } else if (a instanceof TargetInstance) {
//                                System.out.println("TargetInstance");
//                                if (parameterTypes[i].isInstance(target)) {
//                                    args[i] = target;
//                                }
//                            } else if (a instanceof TargetMember) {
//                                System.out.println("TargetInstance");
//                                // TODO
//                                // args[i] = getDefaultValue(parameterTypes[i]);
//                            } else if (a instanceof Thrown) {
//                                System.out.println("Thrown");
//                                if (Throwable.class.isInstance(payload) && parameterTypes[i].isInstance(payload)) {
//                                    args[i] = payload;
//                                }
//                            } else if (a instanceof Arg) { // @Arg(n)
//                                System.out.println("Arg");
//                                Arg arg = (Arg) a;
//                                int index = arg.value() - 1;
//                                Object[] params = null;
//                                if (Object[].class.isInstance(payload)) {
//                                    params = (Object[]) payload;
//                                    if (params.length >= index && parameterTypes[i].isInstance(params[index])) {
//                                        args[i] = params[index];
//                                    }
//                                }
//                            }
//                        }
//                    }
                    }
                    listener.setValidated(true);
                    method.invoke(listener.getProbeTarget(), args);
                } catch (Throwable t) {
                    if (tc.isDebugEnabled()) {
                        Tr.debug(tc, t.getMessage());
                    }
                }
            }
        } catch (Throwable t) {
            Tr.error(tc, "PMI9999E", t.toString());
        }
    }
940612
@Override
    public void throwing(String sourceClass, String sourceMethod, Throwable thrown) {
        if (isLoggable(Level.FINER)) {
            LogRecord logRecord = createLogRecord(Level.FINER, "THROW", null, sourceClass, sourceMethod, null, thrown);
            log(logRecord);
        }
    }
403549
public boolean tryProbe(BaseRow record) throws IOException {
		if (!this.probeIterator.hasSource()) {
			// set the current probe value when probeIterator is null at the begging.
			this.probeIterator.setInstance(record);
		}
		// calculate the hash
		BinaryRow probeKey = probeSideProjection.apply(record);
		final int hash = hash(probeKey.hashCode(), this.currentRecursionDepth);

		BinaryHashPartition p = this.partitionsBeingBuilt.get(hash % partitionsBeingBuilt.size());

		// for an in-memory partition, process set the return iterators, else spill the probe records
		if (p.isInMemory()) {
			this.probeKey = probeKey;
			this.probeRow = record;
			p.bucketArea.startLookup(hash);
			return true;
		} else {
			if (p.testHashBloomFilter(hash)) {
				BinaryRow row = originProbeSideSerializer.baseRowToBinary(record);
				p.insertIntoProbeBuffer(row);
			}
			return false;
		}
	}
548046
public void onThrowable(Throwable cause) {
        this.cause = cause;
        getSelf().tell(RequestWorkerMsgType.PROCESS_ON_EXCEPTION, getSelf());

    }
279905
@Override
    public void visitInsn(int opcode) {
        if (opcode == ATHROW && !enabledListeners.isEmpty()) {
            String key = createKey();
            ProbeImpl probe = getProbe(key);
            long probeId = probe.getIdentifier();

            setProbeInProgress(true);
            visitInsn(DUP); // throwable throwable
            visitLdcInsn(Long.valueOf(probeId)); // throwable throwable long1 long2
            visitInsn(DUP2_X1); // throwable long1 long2 throwable long1 long2
            visitInsn(POP2); // throwable long1 long2 throwable
            if (isStatic()) {
                visitInsn(ACONST_NULL); // throwable long1 long2 throwable this
            } else {
                visitVarInsn(ALOAD, 0); // throwable long1 long2 throwable this
            }
            visitInsn(SWAP); // throwable long1 long2 this throwable
            visitInsn(ACONST_NULL); // throwable long1 long2 this throwable null
            visitInsn(SWAP); // throwable long1 long2 this null throwable
            visitFireProbeInvocation(); // throwable
            setProbeInProgress(false);

            setProbeListeners(probe, enabledListeners);
        }

        super.visitInsn(opcode);
    }
1194698
@Override
    public void processClass (File source, Class<?> oclass)
        throws Exception
    {
        // make sure we extend distributed object
        if (!_doclass.isAssignableFrom(oclass) || _doclass.equals(oclass)) {
            // System.err.println("Skipping " + oclass.getName() + "...");
            return;
        }

        // determine which fields we need to deal with
        ArrayList<Field> flist = Lists.newArrayList();
        Field[] fields = oclass.getDeclaredFields();
        for (Field f : fields) {
            int mods = f.getModifiers();
            if (!Modifier.isPublic(mods) ||
                Modifier.isStatic(mods) ||
                Modifier.isTransient(mods)) {
                continue;
            }
            flist.add(f);
        }

        // slurp our source file into newline separated strings
        SourceFile sfile = new SourceFile();
        sfile.readFrom(source);

        // generate our fields section and our methods section
        StringBuilder fsection = new StringBuilder();
        StringBuilder msection = new StringBuilder();
        for (int ii = 0; ii < flist.size(); ii++) {
            Field f = flist.get(ii);
            Class<?> ftype = f.getType();
            String fname = f.getName();

            // create a map to hold our template data
            Map<String, Object> data = new HashMap<String, Object>();
            data.put("field", fname);
            data.put("generated", GenUtil.getGeneratedAnnotation(getClass(), 4, false));
            data.put("type", GenUtil.simpleName(f));
            data.put("wrapfield", GenUtil.boxArgument(ftype, "value"));
            data.put("wrapofield", GenUtil.boxArgument(ftype, "ovalue"));
            data.put("clonefield", GenUtil.cloneArgument(_dsclass, f, "value"));
            data.put("capfield", StringUtil.unStudlyName(fname).toUpperCase());
            data.put("upfield", StringUtil.capitalize(fname));

            // determine the type of transport
            TransportHint hint = f.getAnnotation(TransportHint.class);
            if (hint == null) {
                // inherit hint from class annotation
                hint = f.getDeclaringClass().getAnnotation(TransportHint.class);
            }
            String transport;
            if (hint == null) {
                transport = "";
            } else {
                transport = ",\n" +
                    "            com.threerings.presents.net.Transport.getInstance(\n" +
                    "                com.threerings.presents.net.Transport.Type." +
                        hint.type().name() + ", " + hint.channel() + ")";
            }
            data.put("transport", transport);

            // if this field is an array, we need its component types
            boolean array = ftype.isArray();
            data.put("have_elem", array);
            if (array) {
                Class<?> etype = ftype.getComponentType();
                data.put("elemtype", GenUtil.simpleName(etype));
                data.put("wrapelem", GenUtil.boxArgument(etype, "value"));
                data.put("wrapoelem", GenUtil.boxArgument(etype, "ovalue"));
            }

            // if this field is a generic DSet, we need its bound type
            if (_dsclass.isAssignableFrom(ftype)) {
                Type t = f.getGenericType();
                // we need to walk up the heirarchy until we get to the parameterized DSet
                while (t instanceof Class<?>) {
                    t = ((Class<?>)t).getGenericSuperclass();
                }
                if (t instanceof ParameterizedType) {
                    ParameterizedType pt = (ParameterizedType)t;
                    if (pt.getActualTypeArguments().length > 0) {
                        data.put("etype", GenUtil.simpleName(pt.getActualTypeArguments()[0]));
                    }
                } else {
                    data.put("etype", "DSet.Entry");
                }
            }

            // now figure out which template to use
            String tname = "field.tmpl";
            if (_dsclass.isAssignableFrom(ftype)) {
                tname = "set.tmpl";
            } else if (_olclass.isAssignableFrom(ftype)) {
                tname = "oidlist.tmpl";
            }

            // append the merged templates as appropriate to the string buffers
            if (ii > 0) {
                fsection.append(EOL);
                msection.append(EOL);
            }
            fsection.append(mergeTemplate(NAME_TMPL, data));
            msection.append(mergeTemplate(BASE_TMPL + tname, data));
        }

        // now bolt everything back together into a class declaration
        writeFile(source.getAbsolutePath(), sfile.generate(fsection.toString(), msection.toString()));
    }
823683
@Override
    @FFDCIgnore(ClassNotFoundException.class)
    protected final Class<?> findClass(String name) throws ClassNotFoundException {
        if (transformers.isEmpty()) {
            Class<?> clazz = null;
            Object token = ThreadIdentityManager.runAsServer();
            try {
                synchronized (getClassLoadingLock(name)) {
                    // This method may be invoked directly instead of via loadClass
                    // (e.g. when doing a "shallow" scan of the common library classloaders).
                    // So we first must check whether we've already defined/loaded the class.
                    // Otherwise we'll get a LinkageError on the second findClass call because
                    // it will attempt to define the class a 2nd time.
                    clazz = findLoadedClass(name);
                    if (clazz == null) {
                        ByteResourceInformation byteResInfo = this.findClassBytes(name);
                        clazz = definePackageAndClass(name, byteResInfo, byteResInfo.getBytes());
                    }
                }
            } catch (ClassNotFoundException cnfe) {
                // Check the common libraries.
                clazz = findClassCommonLibraryClassLoaders(name);
            } finally {
                ThreadIdentityManager.reset(token);
            }
            return clazz;
        }

        ByteResourceInformation byteResourceInformation;
        try {
            byteResourceInformation = findClassBytes(name);
        } catch (ClassNotFoundException cnfe) {
            // Check the common libraries.
            return findClassCommonLibraryClassLoaders(name);
        }

        byte[] bytes = transformClassBytes(byteResourceInformation.getBytes(), name);
        

        return definePackageAndClass(name, byteResourceInformation, bytes);
    }
678688
public static void sendExceptionToClient(Throwable throwable, String probeId,
                                             Conversation conversation, int requestNumber) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "sendExceptionToClient",
                        new Object[]
                        {
                         throwable,
                         probeId,
                         conversation,
                         requestNumber
                        });

        CommsByteBuffer buffer = poolManager.allocate();
        buffer.putException(throwable, probeId, conversation);
        // defect 99984 checking whether jmsServer feature is intact or its removed 
        if (CommsServerServiceFacade.getJsAdminService() != null)
        {
            try {
                conversation.send(buffer,
                                  JFapChannelConstants.SEG_EXCEPTION,
                                  requestNumber,
                                  JFapChannelConstants.PRIORITY_MEDIUM,
                                  true,
                                  ThrottlingPolicy.BLOCK_THREAD,
                                  null);
            } catch (SIException c) {
                FFDCFilter.processException(c, CLASS_NAME + ".sendExceptionToClient",
                                            CommsConstants.STATICCATHELPER_SEND_EXCEP_01);

                SibTr.error(tc, "COMMUNICATION_ERROR_SICO2023", c);
            }
        }
        else
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.entry(tc, "conversation send is not being called as jmsadminService is null");
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "sendExceptionToClient");
    }
633950
public static <T extends Throwable> T findException(Class<T> exceptionTypeToFind, Throwable t) {

    Throwable cause = t;

    while (cause != null)
    {
      if( exceptionTypeToFind.isAssignableFrom( cause.getClass() ) )
      {
        //noinspection unchecked
        return (T)cause;
      }
      if( cause == cause.getCause() )
      {
        return null;
      }
      cause = cause.getCause();
    }

    return null;
  }
416068
public static void exception(TraceComponent tc, Throwable t) {
    if(isTracing()) SibTr.exception(tc, t);

  }
1066458
private SIXAResource getXaResource() throws ResourceException
    {
        final String methodName = "getXaResource";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled())
        {
            SibTr.entry(this, TRACE, methodName);
        }

        if (_xaResource == null)
        {
            try
            {
              _xaResource = _connection.getSIXAResource();
            }
            catch (final SIException exception)
            {
                FFDCFilter.processException(exception, CLASS_NAME + "."
                        + methodName, FFDC_PROBE_1, this);
                if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled())
                {
                    SibTr.exception(this, TRACE, exception);
                }
                throw new ResourceException(NLS.getFormattedMessage(
                        ("XARESOURCE_EXCEPTION_CWSIV0650"), new Object[] {
                                exception, _connection }, null), exception);
            }
            catch (final SIErrorException exception)
            {
                FFDCFilter.processException(exception, CLASS_NAME + "."
                        + methodName, FFDC_PROBE_3, this);
                if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled()) {
                    SibTr.exception(this, TRACE, exception);
                }
                throw new ResourceException(NLS.getFormattedMessage(
                        ("XARESOURCE_EXCEPTION_CWSIV0650"), new Object[] {
                                exception, _connection }, null), exception);
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled())
        {
            SibTr.exit(this, TRACE, methodName, _xaResource);
        }
        return _xaResource;
    }
1351802
public static <T extends Throwable> T convertFromOrSuppressedThrowable(Throwable throwable, Class<T> exceptionClass) {
		return convertFromOrSuppressedThrowable(throwable, exceptionClass, true);
	}
132652
@Override
    public boolean process(String classSourceName, String className, InputStream inputStream, ScanPolicy scanPolicy) {
        return getTargets().scanClass(classSourceName, className, inputStream, scanPolicy);
    }
298244
public static Trace getTrace(Class sourceClass, String traceGroup) 
  {
    Class traceFactoryClass;
    Object ret = null;
    try 
    {
      traceFactoryClass = Class.forName("com.ibm.ws.sib.matchspace.utils.TraceFactory");

      Class[] params = new Class[]{Class.class, String.class};
      Method getTraceMethod = traceFactoryClass.getMethod("getTrace", params);
      Object[] objParams = new Object[]{sourceClass, traceGroup};
      ret = getTraceMethod.invoke(null, objParams);
    } 
    catch (Exception e) 
    {
      // No FFDC Code Needed.
      // Trace and FFDC not available so print to stdout.      
      e.printStackTrace();
    }    
       
    return (Trace)ret;
  }
1201451
@FFDCIgnore({ ConfigStartException.class })
    private void update() throws Exception {
        // OK to ignore calls to update() if already busy updating
        if (busy.compareAndSet(false, true)) {
            try {
                Map<String, String> updated = new HashMap<>();
                //a last minute check to see if the system is shutting down
                if (!com.ibm.wsspi.kernel.service.utils.FrameworkState.isStopping()) {
                    Map<String, String> props = source.getProperties();
                    if (props != null) {
                        updated.putAll(props);
                    }
                    if (!updated.equals(current)) {
                        current = updated;

                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "update: Contents of ConfigSource {0} has changed.", this);
                        }

                        notifyConfigUpdated();
                    } else {
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "update: Contents of ConfigSource {0} has NOT changed.", this);
                        }
                    }
                } else {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "update: Parent Config has been garbage collectded.", this);
                    }
                }
            } catch (ConfigStartException cse) {
                //Just Re-throw the ConfigStartException, don't FFDC
                //At the moment this exception means that we could not properly query the config source
                //It was introduced as a quick fix for issue #3997 but we might reconsider the design at some point
                throw cse;
            } catch (Exception e) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "update: Exception updating dynamic source: {0}. Exception: {1}", this, e);
                }

                throw e;
            } finally {
                busy.set(false);
            }
        }

    }
1351658
public void exception( ExceptionSource source, Throwable exception )
    {
        synchronized( m_monitors )
        {
            for( ExceptionMonitor monitor : m_monitors )
            {
                monitor.exception( source, exception );
            }
        }
    }