ClassFileTransformer and how to transform the base class first

Hello,
I've written a ClassFileTransformer that uses ASM to enhance classes at load time.
But some of the enhancements depends on possible enhancements to the super class.
Example: under some coditions a method doWork() is inserted. This method did not exist in any class (doWork is just an example, I use a name that is not accepted by the compiler but allowed by the JLS).
  public class A {}
  public class B extends A {}If the method doWork() was inserted into class A, then the doWork() of B has to call doWork() of class A:
   super.doWork().Currently I try to load the base class by using
   loader.loadClass(superName.replace('/', '.'));this loads the super class but without passing my transformer !
How can I solve this ?

Looking at the comments in ClassFileTransformer.java and the code in ClassLoader, it seems the transformers are called only for class files that get a ClassFormatError. Transformers are intended to fix old broken/incompatible class files on the fly.
I guess the intended way to do what you are doing is to define a custom class loader. Read class into byte[], transform, call defineClass() on the transformed byte[]. Google for java custom class loader for examples.

Similar Messages

  • Class override, how to create the child class and then the base class

    I started to write a program for a smart DMM, the problem is every version of the DMM the company change the communication commend.
    My idea is to write a child class for every DMM version and every SubVI of the child will override the base class SubVI.
    My problem is, i want first to create one child class and after i will see every thing is work,  start to create the base class. that way i will see if am thinking the right way.
    My question is
    How can i create a child class and then create the base class and configure the SubVi of the child class to be Override of the base class?
    I tried to search in the property of the class but i didn't see nothing.
    Thanks
    Solved!
    Go to Solution.

    This can be done and I've done it on occasion.
    You simply create the base class with the dynamic dispatch methods you require (connector panes need to be identical to thos of the child class).
    Then set the inheritance of the class to inherit from this base class.  If your method is defined as a dynamic dispatch method in the parent, you'll most likely now have some errors (unless your child method was already DD in which case you might just be OK already).
    To change the inheritance of a class, right-click the properties of the class in your project and select properties.  I believe the ineritance tree is at the lower end of the properties.  Click on the "change inheritance" (or something similar) to choose the class from which you now wish to inherit.
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

  • How to specify a base class for Remote Interface in Workshop 9.2? -- URGENT

    Hi,
    I am trying to create a UUP EJB in WebLogic 9.2 workshop. I am using @FileGeneration to create my home & remote interfaces. And the generated remote interface is extending javax.ejb.EJBObject;I want my remote interface to extend com.bea.p13n.property.EntityPropertyManager which in turn implements javax.ejb.EJBObject. Can someone tell how i can do it in Workshop?.
    I came across Predefined Variable: remote.baseClass and as per docume
    ntation..."If specified, the value of this variable will be used as the base class for all generated remote classes. Where i should specify it?. @FileGeneration does nt have any option for it. Any help is grtly appreciated.
    Following are my code snippets:
    IMPL Class
    @FileGeneration(remoteClass = Constants.Bool.TRUE,remoteHome = Constants.Bool.TRUE, localClass = Constants.Bool.FALSE, localHome = Constants.Bool.FALSE,remoteClassName = "MyEntityPropertyManager",remoteHomeName = "MyEntityPropertyManagerHome")
    public class MyEntityPropertyManagerImpl extends GenericSessionBean implements
              SessionBean {
    //code
    }

    This question was posted to both the bea.workshop.developer.general and weblogic.developer.interest.workshop (I had replied to the later on 10/19); after seeing an identical question today on this list want to include a reference to that reply here:
    http://forums.bea.com/bea/message.jspa?messageID=600044925&tstart=0
    -Rob

  • Introspector calling the Base Class multiple times

    Hi
    I am having a Java Bean C (which extends B which in turn extends A) ...and each of these Classes have the BeanInfo classes .. ABeanInfo , BBeanInfo , CBeanInfo....
    And i had written my beaninfos such a way that they are optimised by extending the basebeaninfo and calling super.getPropertyDescriptors and adding them to the Descriptoirs of extra methods like
    Class A
    private String name;
    public void getName()
    Class B extends A
    private String city ;
    public void getCity
    class ABeanInfo extends SimpleBeanInfo
    public PropertyDescriptors[] getPropertyDescriptors()
    // Got the property descriptor for name
    // return by forming array
    My Class B bean info will look like this
    class BBeanInfo extends ABeanInfo
    public PropertyDescriptors[] getPropertyDescriptors()
    PropertyDescriptors[] baseDesc = super.getPropertyDescriptors();
    // Get the property descriptor for City
    // Club the base class desc and the new ones added
    // return by forming array
    But when i use Introspector.getBeanInfo(B.class) , the A.getPropertyDescriptors method is getting called twice (One internally by the introspector and the other when my super.get...)
    How can this be avoided ?? Ofcourse after the first time , the introspector is caching the instances of BeanInfos...
    If this is the implicit behaviour , can i change my BeanInfo classses in such a way that it won't get called

    Why is this a problem?

  • [svn] 3873: Modify asdoc tool to show DefaultProperty and SkinStates, if defined on base classes.

    Revision: 3873
    Author: [email protected]
    Date: 2008-10-24 09:42:17 -0700 (Fri, 24 Oct 2008)
    Log Message:
    Modify asdoc tool to show DefaultProperty and SkinStates, if defined on base classes.
    QE Notes: None
    Doc Notes: None
    Reviewer: Paul
    Bugs: SDK-17719 - FxList is missing a description of 'Skinning the Component' and its default MXML property in ASDoc.
    tests: checkintests
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17719
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/ASDocExtension.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/ClassTable.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/lang/StandardDefs.java

    ls -l /var/run/lighttpd/
    And how are you spawning the php instances? I don't see that in the daemons array anywhere.
    EDIT: It looks like the info in that page is no longer using pre-spawned instances, but lighttpd adaptive-spawn. The documentation has been made inconsistent it looks like.
    You will note that with pre-spawned information, the config looks different[1].
    You need to do one or the other, not both (eg. choose adaptive-spawn, or pre-spawn..not both).
    [1]: http://wiki.archlinux.org/index.php?tit … oldid=8051 "change"

  • Warning :: Derived class hides the base class virtual function

    We are porting from CC5.3 to CC5.8 compiler with Sun Studio one compiler. After plenty of hurdles we are in the final stage of removing the warning messages... Amoung the plenty the following one is very common and in different files. Why am I getting this error in 5.8 and not in 5.3 compiler....
    Warning: derived_Object::markRead Hides the virtual function base_Object::markRead(ut_SourceCodeLocation&) const in a virtual base
    From this it is easily understandable that the base class mark read was hidden by derived class markRead... when we drive and override the derived class function.... It is all over the place....
    Thank you,
    Saravanan Kannan
    //public: using xx_Object :: markRead;
    virtual void markRead() const;

    The Sun C++ FAQ discusses the warning message:
    http://developers.sun.com/prodtech/cc/documentation/ss11/mr/READMEs/c++_faq.html#Coding1
    Notice that warnings are not necessarily errors. But I applaud your desire to fix the code so that it generates no warnings. I wish more of our customers could be persuaded to do the same. :-)
    C++ 5.3 issues this warning, by the way. Example:
    struct B { virtual int foo(int); };
    struct D : B { virtual int foo(double); }; // line 2
    D d;
    line 2: Warning: D::foo hides the virtual function B::foo(int).
    If for your particular code you do not see a warning with C++ 5.3, it would be due to a bug in C++ 5.3 that was later fixed.

  • How to use the different class for each screen as well as function.

    Hi Experts,
    How to use the different class for each screen as well as function.
    With BestRegards,
    M.Thippa Reddy.

    Hi ThippaReddy,
    see this sample code
    Public Class ClsMenInBlack
    #Region "Declarations"
        'Class objects
        'UI and Di objects
        Dim objForm As SAPbouiCOM.Form
        'Variables
        Dim strQuery As String
    #End Region
    #Region "Methods"
        Private Function GeRate() As Double
                Return Double
        End Function
    #End Region
    Public Sub SBO_Appln_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean)
            If pVal.BeforeAction = True Then
                If pVal.MenuUID = "ENV_Menu_MIB" Then
                End If
            Else ' Before Action False
                End If
        End Sub
    #End Region
    End Class
    End Class
    Rgds
    Micheal
    Vasu Anna Regional Feeling a???? Just Kidding
    Edited by: micheal willis on Jul 27, 2009 5:49 PM
    Edited by: micheal willis on Jul 27, 2009 5:50 PM

  • Reflection: attributes from the base class

    Is there a way to get the attributes from the base class of a derived class via reflection? I only found methods to get the attributes from the derived class.
    Example:
    class A
    int a = 4;
    class B extends A
    int b = 5;
    Object unknown = new B();
    Code/Idea to get all attributes from baseclass A using unknown (here: a=4)?

    Thank you all for your hints. The mistake I make, was to use the baseclass, and not the derived class for getting the attributes. By using an extra parameter of type class I got all attributes in their context.
       private StringBuffer getDump(Object obj, Class cl)
             dmp.append(cl.getName() + " {\n");
             Field[] attribute = cl.getDeclaredFields();             <--- only the fields of the current class
             for (int j = 0; j < attribute.length; j++)
                attribute[j].setAccessible(true);
                try
                   if (attribute[j].getType().isPrimitive() || attribute[j].getType() == String.class)
                      dmp.append(attribute[j].getName() + "=" + attribute[j].get(obj) + "\n");
                   else
                      if (((attribute[j].getModifiers() & Modifier.STATIC) != Modifier.STATIC) &&
                          (attribute[j].getType().getName().startsWith("java.lang") == false) &&
                          ((attribute[j].getModifiers() & Modifier.FINAL) != Modifier.FINAL))
                         dmp.append(getDump(attribute[j].get(obj), attribute[j].get(obj).getClass())); <- recursive call
                catch (IllegalAccessException ex)
                   ex.printStackTrace();
             dmp.append("}");
          return dmp;
       }

  • [svn:osmf:] 13027: Fix bug in SerialElement where the durationReached event was dispatched on a child-to-child transition due to the base class thinking that the duration had been reached  (since the second child didn't have a duration yet).

    Revision: 13027
    Revision: 13027
    Author:   [email protected]
    Date:     2009-12-16 18:09:46 -0800 (Wed, 16 Dec 2009)
    Log Message:
    Fix bug in SerialElement where the durationReached event was dispatched on a child-to-child transition due to the base class thinking that the duration had been reached (since the second child didn't have a duration yet).  Injection from trait refactoring.
    Modified Paths:
        osmf/trunk/framework/MediaFramework/org/osmf/composition/CompositeTimeTrait.as

    http://ww2.cs.fsu.edu/~rosentha/linux/2.6.26.5/docs/DocBook/libata/ch07.html#excatATAbusErr wrote:
    ATA bus error means that data corruption occurred during transmission over ATA bus (SATA or PATA). This type of errors can be indicated by
    ICRC or ABRT error as described in the section called “ATA/ATAPI device error (non-NCQ / non-CHECK CONDITION)”.
    Controller-specific error completion with error information indicating transmission error.
    On some controllers, command timeout. In this case, there may be a mechanism to determine that the timeout is due to transmission error.
    Unknown/random errors, timeouts and all sorts of weirdities.
    As described above, transmission errors can cause wide variety of symptoms ranging from device ICRC error to random device lockup, and, for many cases, there is no way to tell if an error condition is due to transmission error or not; therefore, it's necessary to employ some kind of heuristic when dealing with errors and timeouts. For example, encountering repetitive ABRT errors for known supported command is likely to indicate ATA bus error.
    Once it's determined that ATA bus errors have possibly occurred, lowering ATA bus transmission speed is one of actions which may alleviate the problem.
    I'd also add; make sure you have good backups when ATA errors are frequent

  • How to find the Feeder class behind Incident creation in SAP EHS?

    I have a requirement where i need to change the message text after clicking "Send" button while creating Incident.
    How to find the feeder class and method which is called behind "Send" button ?
    Thanks,
    Vimal

    I dont have such.. but you can set  external debug point in function module POWL_QUERY_REFRESH
    * get the result object type from the feeder
       lr_feeder->get_object_definition(
          EXPORTING
           i_selcrit_values = lt_crit_para  " selcrit dependent object def.
           i_langu = l_langu                                     "nt_1673495
           i_type  = i_query_data-type
          IMPORTING
           e_object_def = lr_object_def
    In I_QUERY_DATA-TYPE you can see name of POWL ID.
    Find it in transaction POWL_TYPE and you get name of feader class!

  • What is meant by Local Class and how we can create local classes in abap?

    Hi Friends
    what is meant by Local Class and how we can create local classes in abap?
    Regards,
    Sree

    Hi
    Local classes are the classes which we declare and use using the SE38 ABAP editor
    Global classes are the classes which we find in SE24 and call the methods of them into our program.
    see the sample code
    REPORT zs_class.
    SELECTION SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
    PARAMETERS:p_var TYPE i,
    p_var1 TYPE i.
    SELECTION-SCREEN END OF BLOCK b1.
    CLASS d_class DEFINITION
    CLASS d_class DEFINITION.
    PUBLIC SECTION.
    METHODS:
    add,
    sub.
    PROTECTED SECTION.
    DATA : var2 TYPE i.
    ENDCLASS. "d_class DEFINITION
    CLASS d_class IMPLEMENTATION
    CLASS d_class IMPLEMENTATION.
    METHOD add.
    var2 = p_var + p_var1.
    WRITE:/ var2.
    ENDMETHOD. "add
    METHOD sub.
    var2 = p_var - p_var1.
    WRITE:/ var2.
    ENDMETHOD. "sub
    ENDCLASS. "d_class IMPLEMENTATION
    START-OF-SELECTION
    START-OF-SELECTION.
    DATA: obj TYPE REF TO d_class.
    CREATE OBJECT: obj .
    CALL METHOD: obj->add,
    Regards
    Anji

  • Please help how to save a movieclip in flash to svg...and how to retrive the saved svg to movieclip in flash?

    hi all
    please help how to save a movieclip in flash to svg...and how
    to retrive the saved svg to movieclip in flash?
    thanks

    Do you mean from flash in a web page or do you mean
    converting the swf file format (maybe with a decompiler or
    whatever).
    If you're meaning to do it from flash in a web page:
    You can't save a movieclip from flash to svg. You could
    perhaps record drawingAPI commands and create the appropriate svg
    output in an internal xml object which you then send to the server.
    But I don't know of any pre-built classes to do that (disclaimer:
    because I don't know of any doesn't mean they don't exist).
    Going from svg to flash is doing it the other way around.
    Converting the svg paths back to actionscript drawing commands. I
    think I've seen some examples of this online somewhere.

  • How to Change the Development Class from $TMP to YABAP in Layout

    Hi all,
    How to Change the Development Class from $TMP to YABAP in Layout( SE71).
    Thanks & Regards,
    N.L.Narayana

    Hi,
    it is possible with SE03. you just click on Change <b>Object Directory Entries</b> under the tree menu <b>Object directory</b>, and then enter in the last column of table control
    Check the check box and enter FORM and formname,
      R3TR FORM SAPscript form 
    then execute it.
    then you will be able to change it to PACKAGE from $TMP
    regards
    vijay

  • Why the constructor of the base class calls first when u run the java app.

    why the constructor of the base class calls first when u run the java application

    For the record the other very exciting questions are:
    pls give the differences between application server and web server with examples
    will u pls narrate the differences between servlet context and servlet config.....
    where can we find servlet config...
    is there any methods to access servlet config

  • How to use the implementation class in propetty pallete

    Hi,
    I am using forms 10g....I have to insert horizontal scroll bar in text item..
    I have only class files instead of jar files ...how cani place the class file instead of jar file...
    How to use the implementation class in property palette to display the PJC
    Thanks,
    Ansaf.

    The Implementation Class must reflect the full name of the class. For instance, if the full class name is : xx.yyy.zz.class_name, then put this in the Implementation Class property of the corresponding item.
    Also, the class must be stored in the equivalent directory structure, so that, in my example: <DEV_HOME>/forms/java/xx/yyy/zz
    Francois

Maybe you are looking for

  • Can't restore latest Time Machine backup after drive replacement- only the very first.

    My 13" Macbook Pro running 10.8.5 had a bad hard drive which had to be replaced. After the new drive was put in I tried to restore everything to the new drive with Time Machine but could only restore the first backup I ever did after getting the comp

  • Adobe Reader won't open

    just posted a long question (1st time on this forum) & been sent here after creating a username - do I really need to re-type everything all over again or can someone there see it? just in case..... Adobe Reader won't open - I eventually get a messag

  • Disk Utility stops repairing Time Capsule backup with no info

    After having problems backing up to a long-term stable backup on TC, I have tried using Disk Utility to repair the sparsebundle. The repair begins, but never finishes. And no details are left in DU to decode what happened. Does this mean sparsebundle

  • Iphoto sharpness parameter

    IPhoto sharpenss parameter - Jean Paul Ker Rault ( Today 10:41 am) I am using iPhoto 5.0.4 (263) but when I use the modofication tool, the sharpness parameter (Neetness, Clearness???) is not save when I am changing of photo. All other modified parame

  • Preview rendering question

    Hey all, Mike the newbie has more questions I imported about 6k images into lightroom and I'm working on organizing them within the collections but my question previews. As I scroll through the library there is a delay in seeing the images as they se