Classloading a class that depends on non-existent classes..

hi,
an application i am working on needs to be run in an environment where it will dynamically load existing classes (which i have no control over) that might depend on API that we no longer ship. I don't want to reimplement the API so instead would like to detect and ignore the class completely.
it would be possible to just ignore all classes, but this throws the baby out with the bathwater - its better to be able to do as much as possible and just ignore those classes we can't load at all
is there a way of detecting whether a class you are loading depends on classes that aren't currently loaded using the standard library API? (using jreversepro you can get access to the entire constant pool but i'd prefer to avoid this if possible)
the language. spec. says that a ClassNotFoundException can be thrown lazily (i think this is also how the sun vms work?) - ie not until the reference is actually used
ClassLoader.loadClass(String fqn, boolean resolveBindings) looks the most promising but the lang. spec. implies it won't actually moan about this?
any help appreciated,
thanks,
asjf

Try loading the class with the java.lang.Class object. This way you can catch the noClassDefFound error.
I've used this to determine that they aren't using Microsofts VM. I'm not certain that it will work in your case, but here is my VM example....
try
               Class SystemVersionManager;
               Object VMVersion;
               Method getVMVersion;
               Method getProperty;
               Object[] inc = {"BuildIncrement"};
               String a = "";
               Class[] arg = {a.getClass()};
               System.out.println("Running IE?");
               SystemVersionManager = Class.forName("com.ms.util.SystemVersionManager");
               getVMVersion = SystemVersionManager.getMethod("getVMVersion",null);
               VMVersion = getVMVersion.invoke(SystemVersionManager,null);
               getProperty = VMVersion.getClass().getMethod("getProperty",arg);
               System.out.println("You are running VM level " +  getProperty.invoke(VMVersion,inc));
          catch (Exception e)
               System.out.println("You're not using Microsofts VM.");
          }It invokes the com.ms.util.SystemVersionManager and uses its getProperty() method on it.

Similar Messages

  • [svn:fx-trunk] 16929: Add a [Mixin] class that will register the required class aliases in the event the mxml compiler generation   [RemoteClass(alias="")] code is not called because an application does not use the Flex UI framework .

    Revision: 16929
    Revision: 16929
    Author:   [email protected]
    Date:     2010-07-15 07:38:44 -0700 (Thu, 15 Jul 2010)
    Log Message:
    Add a class that will register the required class aliases in the event the mxml compiler generation  [RemoteClass(alias="")] code is not called because an application does not use the Flex UI framework.
    Add a reference to this class in the RPCClasses file so it always gets loaded.
    QE notes: Need a remoting and messaging regression test that doesn't use Flex UI.
    Bugs: Watson bug 2638788
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/rpc/src/RPCClasses.as
    Added Paths:
        flex/sdk/trunk/frameworks/projects/rpc/src/mx/utils/RpcClassAliasInitializer.as

    Great exercise to document the problem like this.  It got me thinking about how an app with modules would be different from an app that does not use modules.  Solution: I moved the dummy reference of PersonPhotoView out to the main application file (as opposed to being inside the module) and it worked.  I've probably been lucky not to have experienced this problem earlier, because for most other entities I have an instance attached to my model which is linked / compiled with the main application.

  • Can I invoke a class that extends JAppl from another class extends JAppl

    Can I invoke a class that extends JApplet from another class that extends JApplet. I need to invoke an applet then select an action which opens another applet. Thanks in advance.

    Nobody is able to solve this problem, i cant even
    think this things. i have hope so plz try and get
    result and help.Did you understand what Sharad has said???
    Yep, you can forward to specific error page from servlet when even error occured in JSP. In order to achieve you have to open jsp file from servlet say example by using reqdisp.forward.
    handle exception in the part where you are forwarding. And forward to the specific error page inside catch block.

  • Why can't I create new object from a class that is in my big class?

    I mean:
    class A
    B x = new B;
    class B
    and how can I solve it if I still want to create an object from B class.
    Thank you very much :)

    public class ItWorksNow  {
      public ItWorksNow() {
      public static void main ( String[] argv )  throws Exception {
        ItWorksNow.DaInnaClass id = new ItWorksNow().new DaInnaClass();
      public class DaInnaClass {
    }

  • Forgot answers to 2 security questions but it sends the reset variation email to an email that is no longer existent. I have added in a new secondary email and the rescue email does not even show up anywhere. I have no idea what to do please help

    ok so I went to buy a an album on iTunes that I havnt used on the device before. It said I needed to do clarification questions but I cannot remember the answers to them. When I go to reset the questions it sends to an email that is now non existant. It wont let me change it what so ever, I cannot find it anywhere to delete or change. Please help

    You will need to call Apple and ask for Account Security, and will need to provide documentation in order to prove your identity. Use the Contact Us links at the bottom of every page of this forum for phone numbers. Best of luck.

  • Calling a function in another class that is not the App delegate nor a sngl

    Hi all-
    OK- I have searched and read and searched, however I cannot figure out an easy way to call a function in another class if that class is not the app delegate (I have that down) nor a singleton (done that also- but too much code)
    If you use the method Rick posted:
    MainView *myMainView = [[MainView alloc] init];
    [MyMainView goTell];
    That works, however myMainView is a second instance of the class MainView- I want to talk to the instance/Class already instantiated.
    Is there a way to do that without making the class a singleton?
    Thanks!

    I had some trouble wrapping my head around this stuff at first too.
    I've gotten pretty good at letting my objects communicate with one another, however I don't think my method is the most efficient or organized way but I'll try to explain the basic idea.
    When you want a class to be able to talk to another class that's initialized elsewhere, the class your making should just have a pointer in it to the class you want to communicate with. Then at some point (during your init function for example) you should set the pointer to the class you're trying to message.
    for example in the app-delegate assume you have an instance of a MainView class
    and the app-delegate also makes an instance of a class called WorkClass
    If you want WorkClass to know about MainView just give it a pointer of MainView and set it when it's instantiated.
    So WorkClass might be defined something like this
    //WorkClass.h
    @import "MainView.h"
    @interface WorkClass : NSObject
    MainView *myPointerToTheMainView;
    @property (retain) myPointerToTheMainView;
    -(void)tellMainViewHello;
    @end
    //WorkClass.m
    @import "WorkClass.h"
    @implementation WorkClass
    @synthesize myPointerToTheMainView;//this makes getter and setter functions for
    //the pointer and allows us to use the dot
    //syntax to refrence it.
    -(void)tellMainViewHello
    [myPointerToTheMainView hello]; //sends a message to the main view
    //assume the class MainView has defined a
    //method -(void)hello
    @end
    now somewhere in the app delegate you would make the WorkClass instance and pass it a reference to the MainView class so that WorkClass would be able to call it's say hello method, and have the method go where you want (to the single instance of MainView owned by the app-delegate)
    ex:
    //somewhere in app-delegate's initialization
    //assume MainView *theMainView exists and is instantiated.
    WorkClass *myWorkClass = [[WorkClass alloc] init];
    myWorkClass.myPointerToTheMainView = theMainView; //now myWorkClass can speak with
    // the main view through it's
    // reference to it
    I hope that gets the basic idea across.
    I'm pretty new to Obj-c myself so if I made any mistakes or if anyone has a better way to go about this please feel free to add
    Message was edited by: kodafox

  • Ok my iphone 3g touch screen is not responding, i can recieve calls and it can charge and connect to itunes, but i cannot go any further than using the home button or the power button, but the slide feature and touch feature is non existent

    ok my iphone 3g touch screen is not responding, i can recieve calls and it can charge and connect to itunes, but i cannot go any further than using the home button or the power button, it is only the slide feature and touch feature that has become non existent.  Also, i have a f'ew cracks in my screen for a while now and it was running smoothly up until saturday when i sat on it applying large amounts of pressure to the phone screen.  Is there a way i can fix this myself without having to recover my phone to factory settings or wasting 50 bucks to get it fixed??

    Hi Dire Dawa,
    If the screen on your iPhone isn't responding, you may find the following article helpful:
    iOS: Not responding or does not turn on
    http://support.apple.com/kb/ts3281
    Regards,
    - Brenden

  • Class that manage directory

    hello,
    I'm looking for a class that manage a directory.
    the class should "know" the names of the files it owns,
    and has to be able to create a new files in it.
    i looked for suck, but didn't find,
    and i believe it is exist.
    (as a student, i should write a small compiler.
    the compiler should get a directory name,
    and it need to translate the source files to dest. files written in the intermediate language.
    (the next stage is to translate from the intermediate language to machine language).)
    thank a lot!!

    naama749 wrote:
    i looked for suck, but didn't find,That is very unfortunate.
    ~

  • Cannot compile two classes that are on same package

    When I compile two classes that are on same package one class that is independent of other class gets compiled but the other class which uses
    the first one shows cannot find symbol error with the first class name

    try...
    javac *.java
    that should compile all the java files in that folder at the same time. I dont know if that will fix your problem but it is worth a shot.

  • Referencing a class that created another class

    Is there a certain way reference the class that created "you" - examples:
    public class SomeClass
      public SomeClass()
        // blah blah
        SomeOtherClass foo = new SomeOtherClass();
    public class SomeOtherClass
      public SomeOtherClass()
        // blah
      public void SomeMethod()
        // access SomeClass here
        TheClassThatCreatedMe.method();
    }Any ideas?

    one way is u can modify ur code this way
    public class SomeClass{  public SomeClass()  {    // blah blah    SomeOtherClass foo = new SomeOtherClass(String creator);  }}
    //where string creator u pass the same clasas name i.e someclass
    public class SomeOtherClass{  public SomeOtherClass()  {
    System.out.println("created class name is "+creator );
    // blah
    } public void SomeMethod() {    // access SomeClass here    TheClassThatCreatedMe.method();  }}

  • Using the UI editor  for a class that extends an abstract class

    Hi,
    At the moment it's unfortunately impossible to use the UI editor to edit a class that extends a certain abstract class. There is a way to circumvent this problem, by using a proxy class. Does anyone know how to create a proxy class for this purpose and how to register it?
    Hopefully a future JDeveloper release will solve this problem. Is this a planned feature?
    Regards,
    Peter

    I hope it works for you now (why using , but not indentation?).                                                                                                                                                                                           

  • AddChild in non-document class

    Hello, I'm trying to migrate the hundreds of lines of code in
    my main actions frame into classes.
    Could someone be so kind as to tell me how to use the
    addChild in a class that isn't the document class. I have got my
    file structure setup with the package folder and the main document
    class in the .fla root.
    I can trace from secondary classes but not use addChild and I
    am about to lose my mind!
    I have included one of my the classes so you can see how I
    have worked it.

    I am trying to catch up to AS3 from older versions of Flash,
    so I may be wrong about this.
    from what I understand, the only way to reference the stage
    is to use the stage property from an item already on the stage,
    such as your main document class (or another sprite or movie clip
    on the stage). as it stands you are adding 'aCloud' as a child of
    the new CloudClass object, not as a child of the stage. so..
    MyClouds.stage.addchild(aCloud);
    also, the other poster was right about the typo--
    aCloud:captionCloud = new captionCloud();
    one other thing I don't understand, maybe I'm missing
    something-- where is the "captionCloud" class? is it public, or at
    least accessable by CloudClass? also wouldn't it be a better idea
    to define all the properties for a captionCloud object in a method
    of the captionCloud class, and then use CloudClass to control the
    relationship between all the different captionCloud objects (but
    not their internal properties such as alpha, x, y, etc). this seems
    more OOP appropriate to me.
    anyway, i'd like to know what finally works for you, please
    post your solution when you figure it out. i'm just starting on my
    1st AS3 project.

  • 6.1 Doesnt read classes that arent part of packages

    Migrating webapps from 6.0, it appears the 6.1 server doesnt find classes that are in WEB-INF/classes directory. When I place them in packages it finds them. Do I have to convert all classes to be part of a package now?

    Migrating webapps from 6.0, it appears the 6.1 server doesnt find classes that are in WEB-INF/classes directory. When I place them in packages it finds them. Do I have to convert all classes to be part of a package now?

  • How to load a class dynamically in the current/system class loader

    I need to dynamically load a new jdbc driver jar to the current/system class loader... Please note that creating a new classloader will not help since the DriverManager refers to the systemclassloader itself.
    Restarting the application by appending the jar to its classpath will solve the problem but I want to avoid doing this.

    Did you then create a ClassLoader to load the JDBC
    driver and then install it into the system as
    directed by the JDBC specification (ie
    Class.forName(someClassName))?
    And then try to use it from a class loaded fromsome
    other ClassLoader (i.e. the system class loader)?
    If you did not try this please explain why not.O.K. I just looked at the source to
    java.sql.DriverManager. I did not know what I was
    talking about, as what I suggested above will not
    work.
    This is my new Idea:
    Create a URLClassLoader to load the JDBC driver also
    in this ClassLoader you need to place a helper class
    that does the following:
    public class Helper {
    public Driver getJDBCDriver(String driverClassName,
    String url) {
    try {
    Class.forName(driverClassName);
    Driver d = DriverManager.getDriver(url);
    return d;
    catch(Exception ex) {
    ex.printStackTrace();
    return null;
    }Now create an instance of the Helper class in the new
    ClassLoader, and call its getJDBCDriver method to get
    an instance of the driver (you will probably have to
    create an interface in the root class loader that the
    Helper implements so that you can easily call it).
    Now from the root classloader you can make calls
    directly to the returned Driver and bypass the
    DriverManager and its restrictions on cross
    ClassLoader access.
    The only catch here is that you would have to call to
    the returned Driver directly and not use the Driver
    Manager.This sounds like will work but I did not want to load DriverManager in a new classloader.. I did a hack
    I unzip the jar dynamically in a previously known location (which I included in my classpath when launching the app). The classLoader finds the class now though it did not exist when the app was launched !
    A hack of-course but works eh ..

  • Jnlp main class: static void main() or applet class????

    When create jnlp file for applet, I have to specify main class. This "main class", is it the class that contain static void main(), or the applet class. The way I design is the that the applet class will SwingUtilities.InvokeAndWait the "main class".
    Should I specify main class when jar the files or in jnlp file?
    Lastly, when I upload my jnlp file to my web server, and try to access it through a web browser, it keeps saying that the web address is invalid. Do I need any special permission from the web server to run jnlp file?
    Thank you and have a wonderful day

    Subject: jnlp main class: static void main() or applet class????
    Note that one '?' denotes a question, wile two or more often denotes a dweeb.
    yunaeyes wrote:
    When create jnlp file for applet, I have to specify main class. This "main class", is it the class that contain static void main(), or the applet class.That depends on whether the JNLP you did not think to add, declares an [<application-desc>|http://java.sun.com/j2se/1.4.2/docs/guide/jws/developersguide/syntax.html#application_desc] or [<applet-desc>|http://java.sun.com/j2se/1.4.2/docs/guide/jws/developersguide/syntax.html#applet_desc].
    .. The way I design is the that the applet class will SwingUtilities.InvokeAndWait the "main class".
    Should I specify main class when jar the files or in jnlp file?Either way should work, but I prefer in the JNLP file, to avoid the webstart client having to download any Jar(s) eagerly just to look for it.
    Lastly, when I upload my jnlp file to my web server, and try to access it through a web browser, it keeps saying that the web address is invalid. What address, what URL?
    ..Do I need any special permission from the web server to run jnlp file?No. All that is required is that it is accessible, and returns the correct content-type for .jnlp files.
    Thank you and have a wonderful dayIt's bright sunshine, clear skies and a lovely(1) 28 deg. C here, so not going too bad so far. ;)
    (1) Lovely if you are not working in the sun.
    Note that I also offer JaNeLA for comprehensive(2) checking of JNLP launches. Someone at your level of experience with JWS should definitely check it out.
    (2) JaNeLA's checks include validity of JNLP, content-type, resource availability..

Maybe you are looking for

  • Best way to free disk space/memory?

    Need to free up disk space/memory in order to back-up my iPhone 4 before switching to the iPhone 6. More PC than Mac, where do I look, and what is safe to delete from my computer? I don't know what is using all the space.

  • .ttx file in UNIX/PLSQL

    Hi All, Is it possible to generate .ttx file through shellscript/plsql procedure? Please help me in this. Thanks, Bopty Edited by: Bopty on Aug 29, 2012 3:36 PM

  • How to use iPhone to sync Outlook with Google calendar?

    This is a bit of a convoluted question, but I think there may be an answer using the iPhone as a go between. Here is the issue, I cannot get my google calendar and my Outlook calendar to sync with each other.  I'm using Outlook 2011 on a macbook pro

  • LR 3.2 Facebook Export Error

    Hello everyone, I keep getting a "Failed to Retrieve item info" when I try to publish my photos using Lightroom's facebook export publish feature.  I was able to use it a month ago but every time that I try to publish new albums to facebook it gives

  • Is it okay to ask opinions about other software programs?

    I was just wondering if it is appropriate and not a violation of the terms of use to ask other users about particular software programs for macs. I see people suggesting things in relation to solving problems, but I do want to make sure that its also