Package javassist.expr

Examples of javassist.expr.ExprEditor


  public void threadLocalBoolean(CtClass ctClass, Map<String, String> attributes) throws CannotCompileException {
    final String field = attributes.get("field");
    final String threadLocalField = attributes.get("threadLocalField");
    final IntHolder done = new IntHolder();
    for (CtConstructor ctConstructor : ctClass.getDeclaredConstructors()) {
      ctConstructor.instrument(new ExprEditor() {
        @Override
        public void edit(FieldAccess e) throws CannotCompileException {
          if (e.getFieldName().equals(field)) {
            if (e.isWriter()) {
              e.replace("{ }");
              done.value++;
            }
          }
        }
      });
    }
    ctClass.instrument(new ExprEditor() {
      @Override
      public void edit(FieldAccess e) throws CannotCompileException {
        if (e.getFieldName().equals(field)) {
          if (e.isReader()) {
            e.replace("{ $_ = ((Boolean) " + threadLocalField + ".get()).booleanValue(); }");
View Full Code Here


    final String className = className_;
    final String field = attributes.get("field");
    final int index = Integer.valueOf(index_);
    final IntHolder replaced = new IntHolder();

    ctBehavior.instrument(new ExprEditor() {
      private int currentIndex = 0;

      @Override
      public void edit(MethodCall methodCall) throws CannotCompileException {
        if ((className == null || methodCall.getClassName().equals(className)) && (method.isEmpty() || methodCall.getMethodName().equals(method)) && (index == -1 || currentIndex++ == index)) {
View Full Code Here

    if (!contains) {
      ctMethod.setName(newName);
      return;
    }
    final String methodName = ctMethod.getName();
    ctMethod.instrument(new ExprEditor() {
      @Override
      public void edit(MethodCall methodCall) throws CannotCompileException {
        if (methodName.equals(methodCall.getMethodName()) && superClassNames.contains(methodCall.getClassName())) {
          methodCall.replace("$_ = super." + newName + "($$);");
        }
View Full Code Here

    final String className = className_;
    final String field = attributes.get("field");
    final int index = Integer.valueOf(index_);
    final IntHolder replaced = new IntHolder();

    ctBehavior.instrument(new ExprEditor() {
      private int currentIndex = 0;

      @Override
      public void edit(MethodCall methodCall) throws CannotCompileException {
        if ((className == null || methodCall.getClassName().equals(className)) && (method.isEmpty() || methodCall.getMethodName().equals(method)) && (index == -1 || currentIndex++ == index)) {
View Full Code Here

  public static void findUnusedFields(CtClass ctClass) {
    final Set<String> readFields = new HashSet<String>();
    final Set<String> writtenFields = new HashSet<String>();
    try {
      ctClass.instrument(new ExprEditor() {
        @Override
        public void edit(FieldAccess fieldAccess) {
          if (fieldAccess.isReader()) {
            readFields.add(fieldAccess.getFieldName());
          } else if (fieldAccess.isWriter()) {
View Full Code Here

  {
    // index method calls
    final BehaviorEntry behaviorEntry = BehaviorEntryFactory.create( behavior );
    try
    {
      behavior.instrument( new ExprEditor( )
      {
        @Override
        public void edit( MethodCall call )
        {
          String className = Descriptor.toJvmName( call.getClassName() );
View Full Code Here

         
    // get all the called methods
    final List<MethodCall> methodCalls = Lists.newArrayList();
    try
    {
      method.instrument( new ExprEditor( )
      {
        @Override
        public void edit( MethodCall call )
        {
          methodCalls.add( call );
View Full Code Here

    // collect all the field accesses, constructor calls, and method calls
    final List<FieldAccess> illegalFieldWrites = Lists.newArrayList();
    final List<ConstructorCall> constructorCalls = Lists.newArrayList();
    try
    {
      constructor.instrument( new ExprEditor( )
      {
        @Override
        public void edit( FieldAccess fieldAccess )
        {
          if( fieldAccess.isWriter() && constructorCalls.isEmpty() )
View Full Code Here

          break;
        }
      }
     
      // update hash with method and field accesses
      behavior.instrument( new ExprEditor( )
      {
        @Override
        public void edit( MethodCall call )
        {
          updateHashWithString( digest, scrubClassName( call.getClassName() ) );
View Full Code Here

TOP

Related Classes of javassist.expr.ExprEditor

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.