Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.GETSTATIC


        }
        InstructionList il = null;
        InstructionHandle handle = null;
        Instruction inst = null;

        GETSTATIC getStatic = null;

        Method m = null;

        try {
            il = mg.getInstructionList();
            handle = il.getStart();
            if (level_enters == SIMPLEENTER) {

                insertEnter(mg, il, handle, cp);
                insertFork(il, il.getStart(), handle.getPrev(), cp);
            }

            for (; handle != null; handle = handle.getNext()) {
                inst = handle.getInstruction();
                logger.info("next instruction: " + inst);
                if (level_exits == SIMPLEEXIT
                    && inst instanceof ReturnInstruction) {
                    InstructionHandle lastLogHandle = handle;
                    logger.info(
                        "Found a ReturnInstruction of type: "
                            + inst.toString());
                    int stackSize =
                        inst.consumeStack(cp) - inst.produceStack(cp);
                    while (stackSize != 0) {
                        handle = handle.getPrev();
                        inst = handle.getInstruction();
                        logger.info("prev instruction: " + inst);
                        stackSize += inst.consumeStack(cp)
                            - inst.produceStack(cp);
                    }

                    InstructionHandle insertHandle =
                        insertExit(mg, il, handle, cp);
                    if (insertHandle != null) {
                      // We need to redirect branches etc.... twice
                      // so that the if fork doesn't get erroneous modified.
                        il.redirectBranches(handle, insertHandle);
                        il.redirectExceptionHandlers(
                            mg.getExceptionHandlers(),
                            handle,
                            insertHandle);
                        il.redirectLocalVariables(
                            mg.getLocalVariables(),
                            handle,
                            insertHandle);
                        handle =
                            insertFork(il, insertHandle, handle.getPrev(), cp);
                        il.redirectBranches(insertHandle, handle );
                        il.redirectExceptionHandlers(
                            mg.getExceptionHandlers(),
              insertHandle,
                            handle);
                        il.redirectLocalVariables(
                            mg.getLocalVariables(),
                            insertHandle,
              handle);
                    }

                    handle = lastLogHandle;
                }
                if (inst instanceof GETSTATIC) {
                    getStatic = (GETSTATIC) inst;
                    Type type = getStatic.getFieldType(cp);
                    logger.info(
                        "Found a GETSTATIC instruction of type: "
                            + type.toString());

                    if (getStatic
                        .getFieldName(cp)
                        .equals(loggerAttribute.getName())) {
                        logger.info("This is a logger access");
                        transform(mg, il, handle, cp);
                    }
View Full Code Here


        staticConst.markChunkEnd();

  for (int i = 0; i < size; i++) {
      final String name = namesArray[i];
            staticConst.markChunkStart();
      il.append(new GETSTATIC(namesArrayRef));
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, name));
      il.append(AASTORE);
            staticConst.markChunkEnd();
  }

        staticConst.markChunkStart();
  il.append(new PUSH(cpg, size));
  il.append(new ANEWARRAY(cpg.addClass(STRING)));   
        int urisArrayRef = cpg.addFieldref(_className,
             STATIC_URIS_ARRAY_FIELD,
             URIS_INDEX_SIG);
  il.append(new PUTSTATIC(urisArrayRef));
        staticConst.markChunkEnd();

  for (int i = 0; i < size; i++) {
      final String uri = urisArray[i];
            staticConst.markChunkStart();
      il.append(new GETSTATIC(urisArrayRef));
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, uri));
      il.append(AASTORE);
            staticConst.markChunkEnd();
  }

        staticConst.markChunkStart();
  il.append(new PUSH(cpg, size));
  il.append(new NEWARRAY(BasicType.INT));   
        int typesArrayRef = cpg.addFieldref(_className,
              STATIC_TYPES_ARRAY_FIELD,
              TYPES_INDEX_SIG);
  il.append(new PUTSTATIC(typesArrayRef));
        staticConst.markChunkEnd();

  for (int i = 0; i < size; i++) {
      final int nodeType = typesArray[i];
            staticConst.markChunkStart();
      il.append(new GETSTATIC(typesArrayRef));
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, nodeType));
      il.append(IASTORE);
            staticConst.markChunkEnd();
  }

  // Put the namespace names array into the translet
  final Vector namespaces = getXSLTC().getNamespaceIndex();
        staticConst.markChunkStart();
  il.append(new PUSH(cpg, namespaces.size()));
  il.append(new ANEWARRAY(cpg.addClass(STRING)));   
        int namespaceArrayRef = cpg.addFieldref(_className,
                  STATIC_NAMESPACE_ARRAY_FIELD,
                  NAMESPACE_INDEX_SIG);
  il.append(new PUTSTATIC(namespaceArrayRef));
        staticConst.markChunkEnd();

  for (int i = 0; i < namespaces.size(); i++) {
      final String ns = (String)namespaces.elementAt(i);
            staticConst.markChunkStart();
      il.append(new GETSTATIC(namespaceArrayRef));
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, ns));
      il.append(AASTORE);
            staticConst.markChunkEnd();
  }

        // Put the tree of stylesheet namespace declarations into the translet
        final Vector namespaceAncestors = getXSLTC().getNSAncestorPointers();
        if (namespaceAncestors != null && namespaceAncestors.size() != 0) {
            addStaticField(classGen, NS_ANCESTORS_INDEX_SIG,
                           STATIC_NS_ANCESTORS_ARRAY_FIELD);
            staticConst.markChunkStart();
            il.append(new PUSH(cpg, namespaceAncestors.size()));
            il.append(new NEWARRAY(BasicType.INT));
            int namespaceAncestorsArrayRef =
                    cpg.addFieldref(_className, STATIC_NS_ANCESTORS_ARRAY_FIELD,
                                    NS_ANCESTORS_INDEX_SIG);
            il.append(new PUTSTATIC(namespaceAncestorsArrayRef));
            staticConst.markChunkEnd();
            for (int i = 0; i < namespaceAncestors.size(); i++) {
                int ancestor = ((Integer) namespaceAncestors.get(i)).intValue();
                staticConst.markChunkStart();
                il.append(new GETSTATIC(namespaceAncestorsArrayRef));
                il.append(new PUSH(cpg, i));
                il.append(new PUSH(cpg, ancestor));
                il.append(IASTORE);
                staticConst.markChunkEnd();
            }
        }
        // Put the array of indices into the namespace prefix/URI pairs array
        // into the translet
        final Vector prefixURIPairsIdx = getXSLTC().getPrefixURIPairsIdx();
        if (prefixURIPairsIdx != null && prefixURIPairsIdx.size() != 0) {
            addStaticField(classGen, PREFIX_URIS_IDX_SIG,
                           STATIC_PREFIX_URIS_IDX_ARRAY_FIELD);
            staticConst.markChunkStart();
            il.append(new PUSH(cpg, prefixURIPairsIdx.size()));
            il.append(new NEWARRAY(BasicType.INT));
            int prefixURIPairsIdxArrayRef =
                        cpg.addFieldref(_className,
                                        STATIC_PREFIX_URIS_IDX_ARRAY_FIELD,
                                        PREFIX_URIS_IDX_SIG);
            il.append(new PUTSTATIC(prefixURIPairsIdxArrayRef));
            staticConst.markChunkEnd();
            for (int i = 0; i < prefixURIPairsIdx.size(); i++) {
                int idx = ((Integer) prefixURIPairsIdx.get(i)).intValue();
                staticConst.markChunkStart();
                il.append(new GETSTATIC(prefixURIPairsIdxArrayRef));
                il.append(new PUSH(cpg, i));
                il.append(new PUSH(cpg, idx));
                il.append(IASTORE);
                staticConst.markChunkEnd();
            }
        }

        // Put the array of pairs of namespace prefixes and URIs into the
        // translet
        final Vector prefixURIPairs = getXSLTC().getPrefixURIPairs();
        if (prefixURIPairs != null && prefixURIPairs.size() != 0) {
            addStaticField(classGen, PREFIX_URIS_ARRAY_SIG,
                    STATIC_PREFIX_URIS_ARRAY_FIELD);

            staticConst.markChunkStart();
            il.append(new PUSH(cpg, prefixURIPairs.size()));
            il.append(new ANEWARRAY(cpg.addClass(STRING)));
            int prefixURIPairsRef =
                        cpg.addFieldref(_className,
                                        STATIC_PREFIX_URIS_ARRAY_FIELD,
                                        PREFIX_URIS_ARRAY_SIG);
            il.append(new PUTSTATIC(prefixURIPairsRef));
            staticConst.markChunkEnd();
            for (int i = 0; i < prefixURIPairs.size(); i++) {
                String prefixOrURI = (String) prefixURIPairs.get(i);
                staticConst.markChunkStart();
                il.append(new GETSTATIC(prefixURIPairsRef));
                il.append(new PUSH(cpg, i));
                il.append(new PUSH(cpg, prefixOrURI));
                il.append(AASTORE);
                staticConst.markChunkEnd();
            }
View Full Code Here

  il.append(new INVOKESPECIAL(cpg.addMethodref(TRANSLET_CLASS,
                 "<init>", "()V")));
 
        constructor.markChunkStart();
  il.append(classGen.loadTranslet());
  il.append(new GETSTATIC(cpg.addFieldref(_className,
                                          STATIC_NAMES_ARRAY_FIELD,
                                          NAMES_INDEX_SIG)));
  il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                         NAMES_INDEX,
                                         NAMES_INDEX_SIG)));
        constructor.markChunkEnd();
 
        constructor.markChunkStart();
  il.append(classGen.loadTranslet());
  il.append(new GETSTATIC(cpg.addFieldref(_className,
                                          STATIC_URIS_ARRAY_FIELD,
                                          URIS_INDEX_SIG)));
  il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                         URIS_INDEX,
                                         URIS_INDEX_SIG)));
        constructor.markChunkEnd();

        constructor.markChunkStart();
  il.append(classGen.loadTranslet());
  il.append(new GETSTATIC(cpg.addFieldref(_className,
                                          STATIC_TYPES_ARRAY_FIELD,
                                          TYPES_INDEX_SIG)));
  il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                         TYPES_INDEX,
                                         TYPES_INDEX_SIG)));
        constructor.markChunkEnd();

        constructor.markChunkStart();
  il.append(classGen.loadTranslet());
  il.append(new GETSTATIC(cpg.addFieldref(_className,
                                          STATIC_NAMESPACE_ARRAY_FIELD,
                                          NAMESPACE_INDEX_SIG)));
  il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                         NAMESPACE_INDEX,
                                         NAMESPACE_INDEX_SIG)));
View Full Code Here

                //                prefixURIsIndexArray, prefixURIPairsArray,
                //                !ignoreDefaultNamespace)
                String transletClassName = getXSLTC().getClassName();
                il.append(DUP);
                il.append(new PUSH(cpg, getNodeIDForStylesheetNSLookup()));
                il.append(new GETSTATIC(cpg.addFieldref(
                                             transletClassName,
                                             STATIC_NS_ANCESTORS_ARRAY_FIELD,
                                             NS_ANCESTORS_INDEX_SIG)));
                il.append(new GETSTATIC(cpg.addFieldref(
                                             transletClassName,
                                             STATIC_PREFIX_URIS_IDX_ARRAY_FIELD,
                                             PREFIX_URIS_IDX_SIG)));
                il.append(new GETSTATIC(cpg.addFieldref(
                                             transletClassName,
                                             STATIC_PREFIX_URIS_ARRAY_FIELD,
                                             PREFIX_URIS_ARRAY_SIG)));
                // Default namespace is significant
                il.append(ICONST_0);
View Full Code Here

        staticConst.markChunkEnd();

  for (int i = 0; i < size; i++) {
      final String name = namesArray[i];
            staticConst.markChunkStart();
      il.append(new GETSTATIC(namesArrayRef));
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, name));
      il.append(AASTORE);
            staticConst.markChunkEnd();
  }

        staticConst.markChunkStart();
  il.append(new PUSH(cpg, size));
  il.append(new ANEWARRAY(cpg.addClass(STRING)));   
        int urisArrayRef = cpg.addFieldref(_className,
             STATIC_URIS_ARRAY_FIELD,
             URIS_INDEX_SIG);
  il.append(new PUTSTATIC(urisArrayRef));
        staticConst.markChunkEnd();

  for (int i = 0; i < size; i++) {
      final String uri = urisArray[i];
            staticConst.markChunkStart();
      il.append(new GETSTATIC(urisArrayRef));
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, uri));
      il.append(AASTORE);
            staticConst.markChunkEnd();
  }

        staticConst.markChunkStart();
  il.append(new PUSH(cpg, size));
  il.append(new NEWARRAY(BasicType.INT));   
        int typesArrayRef = cpg.addFieldref(_className,
              STATIC_TYPES_ARRAY_FIELD,
              TYPES_INDEX_SIG);
  il.append(new PUTSTATIC(typesArrayRef));
        staticConst.markChunkEnd();

  for (int i = 0; i < size; i++) {
      final int nodeType = typesArray[i];
            staticConst.markChunkStart();
      il.append(new GETSTATIC(typesArrayRef));
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, nodeType));
      il.append(IASTORE);
            staticConst.markChunkEnd();
  }

  // Put the namespace names array into the translet
  final Vector namespaces = getXSLTC().getNamespaceIndex();
        staticConst.markChunkStart();
  il.append(new PUSH(cpg, namespaces.size()));
  il.append(new ANEWARRAY(cpg.addClass(STRING)));   
        int namespaceArrayRef = cpg.addFieldref(_className,
                  STATIC_NAMESPACE_ARRAY_FIELD,
                  NAMESPACE_INDEX_SIG);
  il.append(new PUTSTATIC(namespaceArrayRef));
        staticConst.markChunkEnd();

  for (int i = 0; i < namespaces.size(); i++) {
      final String ns = (String)namespaces.elementAt(i);
            staticConst.markChunkStart();
      il.append(new GETSTATIC(namespaceArrayRef));
      il.append(new PUSH(cpg, i));
      il.append(new PUSH(cpg, ns));
      il.append(AASTORE);
            staticConst.markChunkEnd();
  }

        // Put the tree of stylesheet namespace declarations into the translet
        final Vector namespaceAncestors = getXSLTC().getNSAncestorPointers();
        if (namespaceAncestors != null && namespaceAncestors.size() != 0) {
            addStaticField(classGen, NS_ANCESTORS_INDEX_SIG,
                           STATIC_NS_ANCESTORS_ARRAY_FIELD);
            staticConst.markChunkStart();
            il.append(new PUSH(cpg, namespaceAncestors.size()));
            il.append(new NEWARRAY(BasicType.INT));
            int namespaceAncestorsArrayRef =
                    cpg.addFieldref(_className, STATIC_NS_ANCESTORS_ARRAY_FIELD,
                                    NS_ANCESTORS_INDEX_SIG);
            il.append(new PUTSTATIC(namespaceAncestorsArrayRef));
            staticConst.markChunkEnd();
            for (int i = 0; i < namespaceAncestors.size(); i++) {
                int ancestor = ((Integer) namespaceAncestors.get(i)).intValue();
                staticConst.markChunkStart();
                il.append(new GETSTATIC(namespaceAncestorsArrayRef));
                il.append(new PUSH(cpg, i));
                il.append(new PUSH(cpg, ancestor));
                il.append(IASTORE);
                staticConst.markChunkEnd();
            }
        }
        // Put the array of indices into the namespace prefix/URI pairs array
        // into the translet
        final Vector prefixURIPairsIdx = getXSLTC().getPrefixURIPairsIdx();
        if (prefixURIPairsIdx != null && prefixURIPairsIdx.size() != 0) {
            addStaticField(classGen, PREFIX_URIS_IDX_SIG,
                           STATIC_PREFIX_URIS_IDX_ARRAY_FIELD);
            staticConst.markChunkStart();
            il.append(new PUSH(cpg, prefixURIPairsIdx.size()));
            il.append(new NEWARRAY(BasicType.INT));
            int prefixURIPairsIdxArrayRef =
                        cpg.addFieldref(_className,
                                        STATIC_PREFIX_URIS_IDX_ARRAY_FIELD,
                                        PREFIX_URIS_IDX_SIG);
            il.append(new PUTSTATIC(prefixURIPairsIdxArrayRef));
            staticConst.markChunkEnd();
            for (int i = 0; i < prefixURIPairsIdx.size(); i++) {
                int idx = ((Integer) prefixURIPairsIdx.get(i)).intValue();
                staticConst.markChunkStart();
                il.append(new GETSTATIC(prefixURIPairsIdxArrayRef));
                il.append(new PUSH(cpg, i));
                il.append(new PUSH(cpg, idx));
                il.append(IASTORE);
                staticConst.markChunkEnd();
            }
        }

        // Put the array of pairs of namespace prefixes and URIs into the
        // translet
        final Vector prefixURIPairs = getXSLTC().getPrefixURIPairs();
        if (prefixURIPairs != null && prefixURIPairs.size() != 0) {
            addStaticField(classGen, PREFIX_URIS_ARRAY_SIG,
                    STATIC_PREFIX_URIS_ARRAY_FIELD);

            staticConst.markChunkStart();
            il.append(new PUSH(cpg, prefixURIPairs.size()));
            il.append(new ANEWARRAY(cpg.addClass(STRING)));
            int prefixURIPairsRef =
                        cpg.addFieldref(_className,
                                        STATIC_PREFIX_URIS_ARRAY_FIELD,
                                        PREFIX_URIS_ARRAY_SIG);
            il.append(new PUTSTATIC(prefixURIPairsRef));
            staticConst.markChunkEnd();
            for (int i = 0; i < prefixURIPairs.size(); i++) {
                String prefixOrURI = (String) prefixURIPairs.get(i);
                staticConst.markChunkStart();
                il.append(new GETSTATIC(prefixURIPairsRef));
                il.append(new PUSH(cpg, i));
                il.append(new PUSH(cpg, prefixOrURI));
                il.append(AASTORE);
                staticConst.markChunkEnd();
            }
View Full Code Here

  il.append(new INVOKESPECIAL(cpg.addMethodref(TRANSLET_CLASS,
                 "<init>", "()V")));
 
        constructor.markChunkStart();
  il.append(classGen.loadTranslet());
  il.append(new GETSTATIC(cpg.addFieldref(_className,
                                          STATIC_NAMES_ARRAY_FIELD,
                                          NAMES_INDEX_SIG)));
  il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                         NAMES_INDEX,
                                         NAMES_INDEX_SIG)));
        constructor.markChunkEnd();
 
        constructor.markChunkStart();
  il.append(classGen.loadTranslet());
  il.append(new GETSTATIC(cpg.addFieldref(_className,
                                          STATIC_URIS_ARRAY_FIELD,
                                          URIS_INDEX_SIG)));
  il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                         URIS_INDEX,
                                         URIS_INDEX_SIG)));
        constructor.markChunkEnd();

        constructor.markChunkStart();
  il.append(classGen.loadTranslet());
  il.append(new GETSTATIC(cpg.addFieldref(_className,
                                          STATIC_TYPES_ARRAY_FIELD,
                                          TYPES_INDEX_SIG)));
  il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                         TYPES_INDEX,
                                         TYPES_INDEX_SIG)));
        constructor.markChunkEnd();

        constructor.markChunkStart();
  il.append(classGen.loadTranslet());
  il.append(new GETSTATIC(cpg.addFieldref(_className,
                                          STATIC_NAMESPACE_ARRAY_FIELD,
                                          NAMESPACE_INDEX_SIG)));
  il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
                                         NAMESPACE_INDEX,
                                         NAMESPACE_INDEX_SIG)));
View Full Code Here

        final int offset = xsltc.addCharacterData(_text);
        final int length = _text.length();
        String charDataFieldName =
            STATIC_CHAR_DATA_FIELD + (xsltc.getCharacterDataCount()-1);

        il.append(new GETSTATIC(cpg.addFieldref(xsltc.getClassName(),
                                       charDataFieldName,
                                       STATIC_CHAR_DATA_FIELD_SIG)));
        il.append(new PUSH(cpg, offset));
        il.append(new PUSH(cpg, _text.length()));
    }
View Full Code Here

  // for call to addDecimalFormat()
        // Use the US Locale as the default, as most of its settings
        // are equivalent to the default settings required of
  il.append(new NEW(cpg.addClass(DFS_CLASS)));
  il.append(DUP);
        il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLASS, "US",
                                                LOCALE_SIG)));
  il.append(new INVOKESPECIAL(init));

  String tmp = getAttribute("NaN");
  if ((tmp == null) || (tmp.equals(EMPTYSTRING))) {
View Full Code Here

        // default, as most of its settings are equivalent to
        // the default settings required of xsl:decimal-format -
        // except for the NaN and infinity attributes.
  il.append(new NEW(cpg.addClass(DFS_CLASS)));
  il.append(DUP);
        il.append(new GETSTATIC(cpg.addFieldref(LOCALE_CLASS, "US",
                                                LOCALE_SIG)));
  il.append(new INVOKESPECIAL(init));

  int nan = cpg.addMethodref(DFS_CLASS,
           "setNaN", "(Ljava/lang/String;)V");
View Full Code Here

                //                prefixURIsIndexArray, prefixURIPairsArray,
                //                !ignoreDefaultNamespace)
                String transletClassName = getXSLTC().getClassName();
                il.append(DUP);
                il.append(new PUSH(cpg, getNodeIDForStylesheetNSLookup()));
                il.append(new GETSTATIC(cpg.addFieldref(
                                             transletClassName,
                                             STATIC_NS_ANCESTORS_ARRAY_FIELD,
                                             NS_ANCESTORS_INDEX_SIG)));
                il.append(new GETSTATIC(cpg.addFieldref(
                                             transletClassName,
                                             STATIC_PREFIX_URIS_IDX_ARRAY_FIELD,
                                             PREFIX_URIS_IDX_SIG)));
                il.append(new GETSTATIC(cpg.addFieldref(
                                             transletClassName,
                                             STATIC_PREFIX_URIS_ARRAY_FIELD,
                                             PREFIX_URIS_ARRAY_SIG)));
                // Default namespace is significant
                il.append(ICONST_0);
View Full Code Here

TOP

Related Classes of org.apache.bcel.generic.GETSTATIC

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.