Subclassing nested (private ns) classes at runtime

A question for the AVM2 engineers here.
I am the author of
asmock, a dynamic object
mocking framework, and am looking at a few features to add before
1.0. One of the biggest features I'd like to support is the ability
to mock a "nested" (private namespace) class.
I know that subclassing a nested class outside the "code
file" is illegal, but I have assumed that the AVM will let me do it
as long as I setup the DoABC tag correctly.
Based on dumps of valid SWFs that do this, there does not
seem to be anything special about the classes. Both the child and
the parent are declared with a private ns multiname (0x05) and the
members are declared as public traits of the class. The ns used is
copied directly from the parent (for nested classes), and is always
"Filename.as$number". However, during loadBytes, I get a
ValidateError: "Class
MockRepositoryNestedClassIntegrationFixture.as$452::NestedClass
could not be found".
Is there anything I might have missed? Or, alternatively, is
there an explicit AVM restriction that nested classes can only be
subclassed within the SWF they were loaded from?
Many thanks,
Richard

"richard.szalay" <[email protected]> wrote
in message
news:gm3rfo$f0h$[email protected]..
>A question for the AVM2 engineers here.
>
> I am the author of
http://asmock.sourceforge.net/,
a dynamic object
> mocking
> framework, and am looking at a few features to add
before 1.0. One of the
> biggest features I'd like to support is the ability to
mock a "nested"
> (private
> namespace) class.
>
> I know that subclassing a nested class outside the "code
file" is illegal,
> but
> I have assumed that the AVM will let me do it as long as
I setup the DoABC
> tag
> correctly.
>
> Based on dumps of valid SWFs that do this, there does
not seem to be
> anything
> special about the classes. Both the child and the parent
are declared with
> a
> private ns multiname (0x05) and the members are declared
as public traits
> of
> the class. The ns used is copied directly from the
parent (for nested
> classes),
> and is always "Filename.as$number". However, during
loadBytes, I get a
> ValidateError: "Class
>
MockRepositoryNestedClassIntegrationFixture.as$452::NestedClass
could not
> be
> found".
>
> Is there anything I might have missed? Or,
alternatively, is there an
> explicit
> AVM restriction that nested classes can only be
subclassed within the SWF
> they
> were loaded from?
I think you're more likely to find someone who knows the
framework and the
player in this kind of detail on the flexcoders yahoo group.

Similar Messages

  • Private subclass access in another class

    I have a private subclass in one public classY file. I return a vector with numerous elements of this subclass to a public classX but when I try to print out an element of the vector in public classX it does not know how to do so since I have non primitive data types in the vector and the subclass in declared in public classY. I cannot cast it to the subclass and print each variable b/c the subclass is private and in the public classY file. How can I get around this?
    TIA
    Doopterus
    structure looks like this...
    private class AddressInfo {
        String pcode;
        String av;
        String country;
        String state;
        String county;
        String city;
        String zipBegin;
        String zipEnd;
        AddressInfo() {}
        AddressInfo(String pcode, String av, String country, String state,
                    String county,
                    String city, String zipBegin, String zipEnd) {
          this.pcode = pcode;
          this.av = av;
          this.country = country;
          this.state = state;
          this.county = county;
          this.city = city;
          this.zipBegin = zipBegin;
          this.zipEnd = zipEnd;
        public Vector getVector() {
          Vector vect = new Vector(8);
          vect.add(pcode);
          vect.add(av);
          vect.add(country);
          vect.add(state);
          vect.add(country);
          vect.add(city);
          vect.add(zipBegin);
          vect.add(zipEnd);
          return vect;
        public void setData(String pcode, String av, String country, String state,
                            String county,
                            String city, String zipBegin, String zipEnd) {
          this.pcode = pcode;
          this.av = av;
          this.country = country;
          this.state = state;
          this.county = county;
          this.city = city;
          this.zipBegin = zipBegin;
          this.zipEnd = zipEnd;
      }

    What do you mean by "subclass"? AddressInfo doesn't extend anything but Object. Do you mean nested or inner class? If so, you either need to redesign your app so that other classes don't need access to AddressInfo (perhaps they could ask AddressInfo's enclosing class to talk to it) or you need to make it visible outside the enclosing class.

  • How to set property classes at runtime.

    Well, as the subject line says my question is plain and simple. I don't see any property for this in SET_ITEM_PROPERTY built-in.
    Currently a form has 10 subclassed blocks and views. These blocks have almost similar/definite number of items. At a time only one block with its canvas will be shown to the user. Instead of using so many sub-classed objects, I would like to use only one block and canvas. Now I am looking get getting just property classes from the 10 child forms, which I am looking forward to apply to the common block and items. Any other ideas for the same also appreciated.
    Thanks,
    -- Raam.

    alsalamu alykom
    I think there is no way to set property classes at runtime.
    u must loop through the objects

  • Attributes of private static class - private or package private?

    Consider the following code:
    public class Outer {
        // Remainder omitted
        private static class Nested {
            int someInt           = 10;
            String someString = "abc";
    }The nested class Nested is declared private, as it is only used by the Outer class... now I wonder... should I declare Nested's attributes private oder package private... either way, they can't be accessed from the outside... any ideas?

    stevops wrote:
    either way, they can't be accessed from the outsideThat is true. However, when in addition the members of class Nested are declared as private, you will not be able to access them also from within the class Outer as well, i.e. int i = Nested.someInt; will give you compliation errorsAs a matter of fact, at most it'll generate some warnings, for it (the compiler) will generate synthetic accessor methods for Nested's fields.
    All in all, if you plan to access private class members from an enclosing (or inner) class, you really only have two options: make them explicitly package-private, or make them implicitly so.

  • Dynamic loading of a class at runtime with known inheritance

    Hi,
    I am trying to dynamically load a class during runtime where I know that the class implements a particular interface 'AInterface'. Also, this class may be linked to other classes in the same package as that class, with their implementations/extensions given in their particular definitions.
    The class is found by using a JFileChooser to select the class that implements 'AInterface', and loaded up.
    Because the name of the class can be practically anything, my current approach only works for certain classes under the package 'Foo' with classname 'Bar'. Some names have been changed to keep it abstract.
    private AInterface loadAInterface(URL url) throws Exception {
         URL[] urls = { url };
         // Create a new class loader with the directory
         URLClassLoader cl = new URLClassLoader(urls);
         // Load in the class
         Class<?> cls = cl.loadClass("Foo.Bar");
         return (AInterface) cls.newInstance();
    }As you can see, all that is being returned is the interface of the class so that the interface methods can be accessed. My problem is that I don't know what the class or package is called, I just know that the class implements AInterface. Also note that with this approach, the class itself isn't selected in the JFileChooser, rather the folder containing Foo/Bar.class is.

    ejp wrote:
    The class is found by using a JFileChooser to select the class that implements 'AInterface', and loaded up.
    Also note that with this approach, the class itself isn't selected in the JFileChooser, rather the folder containing Foo/Bar.class is.These two statements are mutually contradictory...My apologies, I worded that wrong. My current approach (the one given in the code) selects the root package folder. However, what I want to be able to do, is to simply select a single class file. The current code just makes some assumptions so that I can at least see results in the program.
    As you said, if the root of the package hierarchy is known, then this could be achieved. The problem is that the user either selects the package root or the AInterface class, but not both.
    Is there a way to get package details from a .class file to be used in the actual loading of the class?

  • Creating Private Inner Classes in Separate Files

    I sometimes find myself wanting to use private inner classes to do things, but then moving the classes to separate files and giving them package access just because I don't like having single large files.
    Is there a way to create private inner classes on a class but just save them in another file?
    Thanks,
    John

    For me, short file sizes usually make design structure
    more clear. This can make maintenance easier. It can
    also make browsing the code easier, even if you have a
    good editor or IDE. It is also less intimadating
    psychologically (for me, anyway) to work with a number
    of small files, each one with a distinct purpose, than
    it is to open up a monster, even if the monster does
    represent a coherent design unit in some sense. I
    think this psychological impact may be more important
    than most people give it credit for.The psychological impact is lessened if you use an IDE like VisualAge (where only one method at a time is generally displayed) or use the "Show Source Of Selected Element Only" option in Eclipse.
    It's one thing to say a method should be short and a class should have as few methods as possible. Those forces reduce complexity and ease maintenance. It's another to say a source file should be short. A source file is just a storage artifact; source code could be stored in a database without changing how the programmer interacts with it. The fact that the standard java compiler requires the implementation of nested classes to be stored inside the source file of their containing class is a minor inconvenience. Don't let it discourage you from using inner classes when they make sense. The design should not be driven by source file size considerations.
    >
    But you have added code only with the sole intent of
    making a source file smaller. If Java had amechanism
    for storing nested classes in other files youwouldn't
    do this. My point below was that you shouldn't let
    source file size override the decision to use anested
    class.Why shouldn't I let it? There are plenty of
    non-trivial benefits (the ones I gave above, for
    starters) to working with smaller files.Because all of those benefits can be gained from using a decent IDE. Eclipse is free. It can show only the current method and it can collapse nested classes.
    You say "If
    Java had a mechanism...." Well, I could answer: It
    does have such a mechanism, and that mechanism is
    packages.Packages are not a mechanism for creating private inner classes in separate files. Eclipse has a mechanism for making the fact that they reside in the same source file a non-issue.
    >>
    I am not being cavalier. I have no argument, onlyan
    opinion.Again, you are perfectly entitled to your opinion.
    But if it is truly an opinion, and nothing more, why
    bother telling me about it. You might as well post
    your favorite color. It is the reasons for your
    opinion that interest me, and you still have not
    really given any.I have had lengthy arguments about the issue of method and class size. Like I said before, I prefer very small classes and methods. I also think the number of nested classes should be as small as possible. But I have no problem with large files. Files are just one way to organize source code. The size of the things in the files matters, not the files themselves.

  • How to get the subclass from a super class( or interface)

    hi,
    I want to get subclass from a super class (or a interface), how to do that? the subclass of a interface means the class implementing the interface.
    for example;
    List ls;
    I want to get the subclass of ls, i.e., LinkedList, Stack, Vector......
    AbstractList al;
    the subclass of al, i.e., ArrayList, Vector.......
    thanks
    Aiwu

    List ls = new ArrayList();Since ls has been declared as a List we can only use List methods
    with it. This is a good thing because we might later want to change
    it to some other sort of List.
    I want to get subclass from a super class (or a interface), how to do
    that?The instance of the subclass declared above did not really come
    from the super class. A class "knows nothing" about its
    subclasses: many sub classes would not even exist at the time
    the class was written.

  • Nested while defining class: com.sun.xml.ws.api.WSBinding ???

    Why is this happening, I am trying to access servlet, 2.4 on the Webshere 6.1, installation as succesfull and the servlet is running without exceptions.
      nested while defining class: com.sun.xml.ws.api.WSBinding
    This error indicates that the class: javax.xml.ws.Binding
    could not be located while defining the class: com.sun.xml.ws.api.WSBinding
    This is often caused by having the class at a higher point in the classloader hierarchy
    Dumping the current context classloader hierarchy:
        ==> indicates defining classloader
        *** indicates classloader where the missing class could have been found
    ==>[0]
    com.ibm.ws.classloader.CompoundClassLoader@51905190
       Local ClassPath: C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\classes;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\aopalliance-1.0.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\commons-logging-1.1.1.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\jaxb-impl-2.1.7.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\jaxb-xjc-2.1.7.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\jaxws-rt-2.1.4.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\jaxws-rt-2.1.7.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\jaxws-spring-1.8.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\jboss-j2ee.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\jremote.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\log4j-1.2.9.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\org.springframework.aop-3.0.1.RELEASE.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\org.springframework.asm-3.0.1.RELEASE.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\org.springframework.beans-3.0.1.RELEASE.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\org.springframework.context-3.0.1.RELEASE.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\org.springframework.core-3.0.1.RELEASE.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\org.springframework.expression-3.0.1.RELEASE.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\org.springframework.jms-3.0.1.RELEASE.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\org.springframework.transaction-3.0.1.RELEASE.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\org.springframework.web-3.0.1.RELEASE.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\spring-batch-infrastructure-2.1.0.RELEASE.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\stax-ex-1.2.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\streambuffer-0.7.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\TWSCore.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war\WEB-INF\lib\xbean-spring-3.4.3.jar;C:\Program Files\IBM\WebSphere\AppServer2\profiles\AppSrv01\installedApps\UKDSK-DBURFORD1Node02Cell\myappservelett2_4_again_war.ear\myappservelett2.4_again.war
       Delegation Mode: PARENT_FIRST
       [1] com.ibm.ws.classloader.JarClassLoader@777399894 Local Classpath:  Delegation mode: PARENT_FIRSTEdited by: romanshtekelman on Sep 9, 2010 7:34 AM

    For future reference...
    We followed the following instructions and created a shared lib.
    http://download.oracle.com/docs/cd/E12524_01/web.1013/e12290/opensrc.htm#BABDDAIF
    We resolved most of our class loading issues.
    BR//Bahman

  • Private inner class and static private inner

    Hi,
    I understand the concept and usage of inner classes in general.
    When should we go for a private inner class and when for a static private inner class? I tried searching but it wasn't of much help.
    Basically I need to design a caching solution in which I need to timestamp the data object. After timestamping, data will be stored in a HashMap or some other collection. I'm planning to use a wrapper class (which is inner and private) which holds the data object and timestamp. I can make the program work by using either normal inner class or static inner class, however would like to know which is better in such case. Also If I can get some general guidelines as to when to use a staic inner class and when to use a normal inner class, it would help me.
    Thanks in advance.

    user1995721 wrote:
    When should we go for a private inner class and when for a static private inner class?
    I can make the program work by using either normal inner class or static inner class, however would like to know which is better
    If I can get some general guidelines as to when to use a static inner class and when to use a normal inner class, it would help me.Making the inner class static is helpful in that it limits visibility.
    If the inner class needs to access non-static fields or methods from the containing class instance
    the inner class has to be non-static.

  • Release memory for nested top-level classes

    Hello experts.
    I have a top-level class which consists of several static methods. Inside such a method I create several new instances of a nested top-level class inside my original class. Later I want to release one of these instances i.e. destroy instance and free memory. How can I do that?
    Thanks.

    sure, but I do not see any references to this nested top-level class. With "Releasing" I mean something like directly assigning a NULL value to the nested top-level clas in order to enable GC.
    But as I said there are no references and while monitoring the memory I see that the GC does not collect some memory. (I know that GC is not reliable, but after ten attempts of this scenario the memory allocation is equal the whole time).
    I guess the GC does not work with classes, but the classloader. But how can I control releasing memory in this scenario?
    Any further hints?

  • Extending classes at runtime

    Hi,
    Is there a way to extend a class at runtime? What I'd like to do is the following:
    I want to have a tabbed pane component that does not stretch its tabs when there are several lines of tabs. The stretching of the tabs is implemented in the UI component of JTabbedPane - and this depends on the look & feel - it can be MetalTabbedPaneUI, WindowsTabbedPaneUI, etc.
    I want to extend the currently-used UI class (which is only known at runtime) with my own class that overrides a single method.
    I can extend all those that I currently know and use some mapping from the currently used class to the one extending it - but tomorrow someone may install a new look & feel which uses a different UI component, for which I will not have an extending class.
    Therefore, I'd like to find the currently used UI component class and extend it at runtime.
    Thanks,
    Shlomy

    Shlomy-Reinstein wrote:
    Thanks. It's a good solution, but it requires me to write wrappers for all the public methods of BasicTabbedPaneUI, doesn't it? All I'm interested in is to override a single method. If there is no easier way, that's okay, but since there are scripting languages that interface with Java (e.g. BeanShell), in which I can extend classes, I thought there should be an easy way to extend a class at runtime.You don't write code that is "easy". You write code that is correct.
    If there are several different ways to write code which are all correct then you use other criteria to determine the best one. The first criteria is how much maintenance each would require. And how complex each solution would be. Complexity also impacts maintenance.
    And nothing I have seen in this thread would suggest that anything but a wrapper is a correct solution. Certainly unless you can demonstrate that it would not work then I doubt anything would be better.
    And using beanshell just so you don't have to type is definitely not the correct solution.

  • Compiler bug with generics and private inner classes

    There appears to be a bug in the sun java compiler. This problem was reported against eclipse and the developers their concluded that it must be a problem with javac.
    Idea also seems to compile the example below. I couldn't find a bug report in the sun bug database. Can somebody tell me if this is a bug in javac and if there is a bug report for it.
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=185422
    public class Foo <T>{
    private T myT;
    public T getT() {
    return myT;
    public void setT(T aT) {
    myT = aT;
    public class Bar extends Foo<Bar.Baz> {
    public static void main(String[] args) {
    Bar myBar = new Bar();
    myBar.setT(new Baz());
    System.out.println(myBar.getT().toString());
    private static class Baz {
    @Override
    public String toString() {
    return "Baz";
    Eclipse compiles and runs the code even though the Baz inner class is private.
    javac reports:
    Bar.java:1: Bar.Baz has private access in Bar
    public class Bar extends Foo<Bar.Baz>
    ^
    1 error

    As I said in my original post its not just eclipse that thinks the code snippet is compilable. IntelliJ Idea also parses it without complaining. I haven't looked at the java language spec but intuitively I see no reason why the code should not compile. I don't think eclipse submitting bug reports to sun has anything to do with courage. I would guess they just couldn't be bothered.

  • Creating an instance of a class at runtime?

    Does anyone know how to create an instance of a class at RunTime? For example, I want to load classes from a JAR file at RunTime, and then create instances of certain classes of each JAR. I ask this because I do not see how to create an instance of one of those classes the traditional way, SomeClass var = new SomeClass(). I am pretty sure that someone out there has done this and succeeded in doing it. All of the post on this stuff only talk about loading the class from a JAR file, but I have already loaded them using URLClassLoader�s findClass() method. I have also created an instance of the class that findClass() returns using newInstance(), but newInstance() returns an object of type Object. How can I convert this object to an object of type SomeClass? You cannot cast it because the compiler will complain due to the import statement issue. So if you cannot include the import statement because that classpath does not exist, then how the heck would you cast the newInstance() object into a SomeClass object?

    You can cast the returned object to the type you need...that is what I do in my applet. The trick is that you must get the instance of the applets class loader (or you get a classCastException). Pay attention to this line below - that's the real key here.
    "// Get a reference to the applets own classloader"
    protected CBaseQuestionnaireFile m_BaseObject = null;// declared up front
    m_BaseObject = loadAndRunClass("com.cpm.dataentry.questionnaire.CQuestionnaireFile");// fully qualified base object
    Here is the load and run method:
       CBaseQuestionnaireFile loadAndRunClass(String classname)
          com.cpm.common.base.CBaseQuestionnaireFile questBase = null;
          Class cClass = null;
          try
             // first we open the jar file with the classes we need
             String[] aJarList = new String[10];
             // Questionnaire format file
             File fURL1 = new File(GetMainFrame().m_strQuestionnaireFileName);
             URL url1   = new URL(fURL1.toURL(),"");
             URL urlNew = new URL("jar:" + url1.toExternalForm() + "!/" );
             // Server base class directory
             String strServerDirectory = "http://" + GetMainFrame().m_strHost + "/APPLETS/";
             File fURL2 = new File(strServerDirectory);
             URL url2 = new URL(fURL2.toURL(),"");
             URL urlNew2 = new URL("jar:" + url2.toExternalForm() + "!/" );
             // Local base class directory
             String strLocalDirectory = CSystem.GetBasePath() + "/Research/bin/";
             File fURL3 = new File(strLocalDirectory);
             URL url3 = new URL(fURL3.toURL(),"");
             URL urlNew3 = new URL("jar:" + url3.toExternalForm() + "!/" );
             File fURLBase = new File(CSystem.GetBasePath() + "/Research/bin/base.jar");
             URL urlBase = new URL(fURLBase.toURL(),"");
             URL urlNewBase = new URL("jar:" + urlBase.toExternalForm() + "!/" );
             File fURLControl = new File(CSystem.GetBasePath() + "/Research/bin/controls.jar");
             URL urlControl = new URL(fURLControl.toURL(),"");
             URL urlNewControl = new URL("jar:" + urlControl.toExternalForm() + "!/" );
             File fURLUtil = new File(CSystem.GetBasePath() + "/Research/bin/utlities.jar");
             URL urlUtil= new URL(fURLUtil.toURL(),"");
             URL urlNewUtil = new URL("jar:" + urlUtil.toExternalForm() + "!/" );
             // Determine where to look
             URL[] urlList = null;
             if(GetMainFrame().m_isStandalone == false) {
                // From a browser
                CSystem.PrintDebugMessage("Running as an applet");
                if(GetMainFrame().m_bOnLineMode == true) {
                   // On line
                   CSystem.PrintDebugMessage("*** On Line Mode ***");
                   urlList = new URL[2];
                   urlList[0] = urlNew;
                   urlList[1] = urlNew2;
                else {
                   // Off line
                   CSystem.PrintDebugMessage("*** Off Line Mode ***");
                   urlList = new URL[4];
                   urlList[0] = urlNew;
                   urlList[1] = urlNewBase;
                   urlList[2] = urlNewControl;
                   urlList[3] = urlNewUtil;
              else {
                 CSystem.PrintDebugMessage("*** Stand Alone Mode ***");
                 urlList = new URL[1];
                 urlList[0] = urlNew;
    CSystem.PrintDebugMessage("Question file/path: " + GetMainFrame().m_strQuestionnaireFileName);
            // Set the wait cursor
            GetMainFrame().SetWaitCursor();
            // Get a reference to the applets own classloader
            Class myClass = getClass();
            ClassLoader appletClassLoader = myClass.getClassLoader();
            // Call our multi-jar class loader
            JarClassLoader jarLoader = new JarClassLoader(urlList,appletClassLoader);
    CSystem.PrintDebugMessage("CPM Test - passed Jar Loader" + jarLoader.toString());
             // Load the classname from the jarfile
             try
                  cClass = jarLoader.loadClass(classname);
             catch(ClassNotFoundException cnfe)
                Object[] optionsConfirm = { "Ok" };
                JOptionPane.showOptionDialog(GetMainFrame(),"Questionnaire file is either damaged or has been tampered with.", "Questionnaire File Error",
                JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsConfirm, optionsConfirm[0]);
                GetMainFrame().m_strQuestionnaireFileName = "";
                // Clear the wait cursor
                GetMainFrame().ClearWaitCursor();
                return null;
             Class cSuperclass = cClass.getSuperclass();
    CSystem.PrintDebugMessage("Test Superclass type is: " + cSuperclass.toString());
             Object o = cClass.newInstance();
    CSystem.PrintDebugMessage("Test plain class type is: " + o.toString());
             // Never remove this line of code
             // without it, a crafty user could use our load routine
             // to load/and run some nasty code
             // This test makes SURE that *ONLY* questionnaires get opened
             // and their methods get called
             if(o instanceof com.cpm.common.base.CBaseQuestionnaireFile)
                // Create the object
    CSystem.PrintDebugMessage("Test Is instance of CBaseQuestionnaireFile");
    CSystem.PrintDebugMessage("CPM Test - Casting to Base Class");
                questBase = (com.cpm.common.base.CBaseQuestionnaireFile)o;
    CSystem.PrintDebugMessage("CPM Test - Getting languages from questionnaire");
                GetMainFrame().GetLanguagesFromQuestionnaire(questBase);
    CSystem.PrintDebugMessage("CPM Test - Setting locale from Questionnaire selection");
                questBase.SetQuestionnaireLocale(GetMainFrame().m_locale);
    CSystem.PrintDebugMessage("CPM Test - Initializing Questionnaire");
                questBase.Initialize();
                questBase.InitializeCards();
              else
                Object[] optionsConfirm = { "Ok" };
                JOptionPane.showOptionDialog(GetMainFrame(),"Questionnaire file is either damaged or has been tampered with.", "Questionnaire File Error",
                JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsConfirm, optionsConfirm[0]);
                GetMainFrame().m_strQuestionnaireFileName = "";
                // Clear the wait cursor
                GetMainFrame().ClearWaitCursor();
                return null;
          catch (Exception e)
              exDialog.showForThrowable(e.toString(),e);
         // Clear the wait cursor
         GetMainFrame().ClearWaitCursor();
         // Set MouseListener Pointer
    //     questBase.SetMouseListenerPointer(GetMainFrame().m_mouseListener);
         return questBase;
       }

  • Is it possible to instantiate arbitrary classes at runtime??

    Hi,
    I was wondering if it is possible to instantiate an arbitrary class at runtime using its class name.
    My plan is to have a collection of java classes in a folder, which could be instantiated and have their member methods called. This collection of classes however, could change at any time. I'd like to be able to specify which class to work with at runtime, using a string containing the class name to identify it.
    Is this possible using java?? If so, how?
    Thanks in advance.

    It's called reflection.
    Class someClass = Class.forName("some.package.SomeClass");
    ...

  • Could not initialize class coldfusion.runtime.report.Report

    I have inherited an application that contains a number of
    reports. This application was developed on our CF7 server, and when
    we upgraded, the application was copied to 8, but not fully tested.
    Now, when we request the reports, we get the following errors (this
    is a Flex application):
    (mx.rpc::Fault)#0
    errorID = 0
    faultCode = "Server.Processing"
    faultDetail = (null)
    faultString = "Could not initialize class
    coldfusion.runtime.report.Report"
    message = "faultCode:Server.Processing faultString:'Could
    not initialize class coldfusion.runtime.report.Report'
    faultDetail:'null'"
    name = "Error"
    rootCause = (null)
    My searching for a solution has not been successful on
    Google. Has anyone experienced this error and been able to fix it?
    I'm at a loss on what to do next, and as the app is in production,
    I have some upset clients over this.
    Thanks!!
    Jenn

    I can't find anything further on this error after much
    research. I'm getting the problem when I try to run any report on a
    live web server (hosted site), even though it runs fine in the
    development environment. My hosting company could only suggest that
    the problem could lie with the fact they have RDS disabled;
    however, although the Report Builder requires RDS, running uploaded
    .cfr reports from the cfreport tag shouldn't. If anyone solves this
    I'd be most grateful for the information to be posted.

Maybe you are looking for

  • Lr_selections- get_selected_rows returns zero entries Follow-Up Question...

    Hello SDN Community, I was able to get a list of row numbers returned from GET_SELECTED_ROWS when I added a call to GET_METADATA. However, GET_SELECTED_ROWS only works the first time.  When I return to the screen, the lines are still highlighted and

  • How do I get adobe pdf to connect and appear back on Microsoft Oulook next to the help button?

    Adobe Acrobat 9 is on most of our computers and is connected to Micrsoft Oulook email because the adobe pdf button is next to the help button in Oulook.  For some reason it has disappeared on one of the computers and don't know why and now how do we

  • Automatic creation of Generic Transactions

    Hi colleagues I am thinking about using generic transaction in our TRM implemetation. But I havn't found a way for creating them except manual enter via RCA00. I am sure there must be a kind of user-exit for their automatic creation (a sort of BADi o

  • Anyone noticed their 24" screen brightness lowered recently?!

    I used to have my brightness (on my 24") set down a few bars because it was so bright on full... Since the apparent release of a new graphics driver, I have had to set my brightness to full. Surely Apple could have made the maximum higher and the low

  • Get method

    Hi I'm wondering if there is a way in Java to get a Method object directly from using the method name. As in the manner of MyClass.class. Something like MyClass.methodName.method? Thanks, Mike