Force the loading of a class from disk

Is it possible to force the loading of a class from disk ? The assumption here is that the class we want to load will be continuously updated so we want the latest version of the class(on disk) rather than the one already in memory.
Thank you.

You have to implement a custom loader.
public class MyLoader extends URLClassLoader
  public (URL[] urls)
    super(urls);
  public synchronized loadClass(String className) throws ClassNotFoundException
    // first check built in JDK 1.2 class cache
    Class clazz = findLoadedClass(className);
    if (null == clazz)
      // Didn't find it in cache, so check our custom
      // URL[] classpath, added at the constructor.
      clazz = findClass(className);
      if (null == clazz)
        // Didn't find it in our classpath, so either
        // throw a ClassNotFoundException, or call to
        // the parent if we want to go that way.
        throw new ClassNotFoundException();
    return clazz;
}In the above, you can do all sort of things. We don't delegate to the parent at all, so if the class being looked for is NOT in any of the URL[] objects passed in when created, then a ClassNotFoundException is thrown. The normal delegation checks cache, then the parent loader, then the findClass(). We simply remove the check to the parent, and try the findClass() right away. Because URLClassLoader implements findClass() to look for a .class in ALL of the URL[] objects passed to it, we don't need to bother with that at all.
Does that help? Ask away if you have more questions.

Similar Messages

  • TS1463 What is the easiest way to restore my ipod back to factory specs. It has a red circle with a red x in the middle,please help me to fix my ipod, until now i can't use my ipod..i tried all the procedures in Restore ipod from disk mode but still not w

    What is the easiest way to restore my ipod back to factory specs. It has a red circle with a red x in the middle,please help me to fix my ipod, until now i can't use my ipod..i tried all the procedures in Restore ipod from disk mode but still not working, please help me...

    If you are unable to get the iPod into Disk Mode to try and restore it, it's a very good indication, as mentioned in the article, that the iPod's hard drive is damaged and in need of replacement either by Apple or a third party repair company.
    B-rock

  • MX 925 - how to force the printer to use paper from lower tray

    Hi' there,
    Several people seems to have the problem, that the printer "wants" to print from the upper tray, - I assume it's because it want's photo paper. Is it possible to FORCE the printer to use paper from the lower tray, when e.g. you have no photo paper, receive the error message, and just want to see the print?
    :-) Sogge

    I found a methoid that while clumsy, works. I have defined another printer on my windows machine that points to the same
    printer as my original printer defination. I have named this printer "Legal" and has defined legal paper as it's default. When
    I print to this printer( DECTYPE, DECNAME) it now defaults to legal.

  • Netscape 's inconsistency in the loading of applets/classes

    Please I will appreciate any help.
    I am using Netscape version 4.75 on a Windows NT platform to launch my application.
    My application is a collection of java classes and applet classes and a gif file all zipped
    into an archive ( zip -o ). These classes are written in the old java version 1.0.2
    (unfortunately).The problem is that when it is launched from a netscape browser,
    sometimes all the classes get loaded but other times the loading fails. The zip file is not compressed since we realized that it was failing more often with a compressed zip file.
    SO we removed the zip file... This is how we are launching the application now but this,
    too, creates a problem because there are incidents of partial or incomplete loading of
    the classes. This application has been in use for over 3 years now, what can I do?
    Please help!
    Ike Eke

    Thanks for you quick response.
    I have not tried a jar. Can I jar these classes that were written in java 1.0.2?
    I have recommended that the application be upgraded to 1.1.x but they say there is
    no money to do that, The customer would not fund it.
    This problem does not occur on IE but we do not support IE any way. We run on HP,SUN,
    and Windows NT platforms but this problem occurs only on NT. This is a production problem
    so it occurs very where there is an NT machine ( over 200 NT users out there).
    This is the version of Netscape that was chosen by the customer and yes it occurs on other netscape versions as well. I thought that jar files came with the emergence of java 1.1.x.
    If it is possible to jar this outdated version of java classes, then I am willing to try it but
    what is required to do this?
    Thanks again
    Ike

  • The NYT website won't stop loading whenever it does an auto-update. While this loading continues, other websites are unresponsive until I force the loading to terminate. This started happening with FF 4.0.1.

    When I do a manual refresh on certain sites like NY Times or CNN, or when sites like NYT periodically push an update through, the updates won't stop loading. It's as though the update never completes. The rotating circle icon on the affected tab just continues indefinitely. While this is happening, other websites that I try to open or update are either very slow or unresponsive.
    My fix has been to force the update to terminate by using the red X button next to the website name. Then other websites respond normally but often the one that I have manually stopped becomes unresponsive.

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    If it does work in Safe-mode then disable all extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    * Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    * Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")
    In Firefox 4 you can use one of these to start in <u>[[Safe mode]]</u>:
    * Help > Restart with Add-ons Disabled
    * Hold down the Shift key while double clicking the Firefox desktop shortcut (Windows)
    * https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • Loading fails, when classes from other packages are referenced

    My applet follows a simple package structure.
    There's package P1 and there's another package in it P2 (P1.P2)
    P1 contains Applet class A.
    P2 contains another class C and interface I. C implements I.
    A contains a reference of C, which is initialized in the constructor. The use in the constructor of the A (the applet) is something like this
    public A () {
              reg = ToolkitRegistry.getEntry (); //where reg is a reference of type ToolkitRegistry.
              // some more code
              i = (I) C.getC (); //where i is a reference of type I.
    }Trying to load this applet throws error saying "Package Loading failed". Important is to note that the loading occurs successfully by commenting out this line           i = (I) C.getC (); //where i is a reference of type I. , without any other change.
    I understood this to be some problem with the AIDs assigned to both the packages while converting. Unsure of what's the correct way to assign the PIX values, I've been trying some permutation/combinations, it doesn't seem to work.
    Has neone already faced this problem & knows the solution? (The specs aren't much help)

    One more point ..... I mentioned commenting the statements, I DO NOT commment the other statements referencing the other package. This means that the loading IS succesfull, even when these two lines reside in there.
    1. import P1.P2.*; 2. private I i = null;Above two lines pass the loader. The object creation gets stuck.
    Wonder if the package references are actually alright, because JVM wud've treated both situations in a similar way. JCVM is ofcourse different but JCVM spec does not say nething abt this situation (rem: everything is public, so the access control restrictions also do not apply)
    are there ne instantiation restrictions? [In my case, it's in the constructor thread)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Is there any way to force jvm load a new class?

    I write a standalone command line program. This program calls a function which I added to an existing class. the existing class has run run for a while by other processes.
    When I run my command line program, it can not find the function I added to the existing class. But I am 100% sure I have overwrote the existing class file with my new copy. It looks like the old class file is still in effect.
    How can I instruct the JVM to load my new class file, not using the old one(maybe it is cached in memory, and didn't get refreshed)
    Welcome any suggestions. I have run out of idea. (BTW: It is infeasible for me to restart the computer)

    Classes are loaded by an object called a ClassLoader which stores all the classes it loads in some kind of internal Map object. If you ask the same ClassLoader for a class it's already loaded it will given you the old one.
    The only way to drop a class is to drop the ClassLoader which loaded it and create a new one to load a new version.
    What you need to do is to put the class file in question is a directory or jar which isn't on the class path. And make sure that no class file of the same name exists on the classpath (because that will be loaded in preference).
    Then you create a java.net.URLClassLoader pointing to the directory or jar (use FIle.toURL() to turn a file into a URL).
    Then call loadClass on that to load your class file. Then you'll probably have to call newInstance() on the class object to create an instance.
    Of course, if new method signatures are added you'll have to access them using Method objects, since they won't be know about at compile time.

  • How to edit PSA and continue the load with corrected data from PSA.

    Hi,
    Can you guide me on how to edit data in PSA and then continue a load?
    i.e. if you can provide me with the steps on how to fix a load problem if a load fails. The load fails and Monitor shows red, so how do I fix them in the PSA and then allow the load continue with the corrected data into the data target.
    I will appreciate the details steps involved.
    Thanks

    Hi
    First select that request then turn to Red and delete the Request , delete the qeruest then system allow to edit the psa data ,selete psa then selet packet then selet record double click modify the data, dont forget after completing save the data. after competing modification then select psa right click select- start update immediatly......
    thanks
    ram

  • Can a signed applet run classes from disk?

    Hi all,
    I have a signed applet jar and a signed jar file somewhere on disk (I can ensure the jar file is available on client's machine before i run the applet). My applet doesn't let me have file io access from the classes in the jar file on disk. It gives the following exception:
    java.security.AccessControlException: access denied (java.io.FilePermission C:\test.jar read)
    However I do have file io access from classes in the applet jar itself. Both the jar files are signed.
    Is there any way to get around the plug-in security in this case?
    Using installed extension (jar/lib/ext) is not an option, unfortunately.
    Any help will be appreciated.
    -Jas

    Is it not the same problem of JavaScript which calls Java ?
    Harmemejer posted : http://forum.java.sun.com/thread.jsp?forum=63&thread=524815 (second post) ???
    Hope it helps
    Rafax.

  • Help! how to refresh the JTable of a class from another thread class

    there is an application, in server side ,there are two classes, one is a class called face class that screen a JTable, another is a class the a thread ,which accept socket from client, when it accept the client socket, it deal the data and insert into db,then notify the face class to refresh the JTable,but in the thread class I used JTable's revalidate() and updateUI() method, the JTable does not refresh ,how should i do, pls give me help ,thank you very much

    thank you very much !
    i tried it ,but the TableModel i used like this ,and how to change the TableModel?
    here the files of mine ,pls give me some help,thank you very much
    1,first file is a class that create a JInternalFrame,and on it there is a table
    public class OutFace{
    public JInternalFrame createOutFace(){
    JInternalFrame jf = new JInternalFram();
    TableModel tm = new MyTableModel();
    JTable jt = new JTable(tm);
    JScrollPane jsp = new JScrollPane();
    jsp.add(jt);
    jf.getContentPane().add(jsp);
    return jf;
    2,the second file is the main face ,there is a button,when press the button,screen the JInternalFrame. there is also a thread is beggining started .
    public class MainFace extends JFrame implements ActionListener,Runnable{
    JButton jb = new JButton("create JInternalFrame");
    jb.addActionListener(this);
    JFrame fram = new JFrame();
    public void performance(ActionEvent e){
    JInternalFrame jif = new OutFace().createOutFace(); frame.getContentPane().add(JInternalFrame,BorderLayout.CENTER);
    public static void main(String[] args){
    frame.getContentPane().add(jb,BorderLayout.NORTH);
    frame.pack();
    frame.setVisible(true);
    ServerSokct ss = new ServerSocket(10000);
    Socket skt = ss.accept()'
    new ServerThread(skt).start();
    3.the third file is a thread class, there is a serversoket ,and accept the client side data,and want to refresh the JTable of the JInternalFrame
    public class ServerThread extends Thread{
    private skt;
    public ServerThread(Sokcet skt){
    this.skt = skt;
    public void run(){
    OutputObjectStream oos = null;
    InputObjectStream ios = null;
    try{
    Boolean flag = flag;
    //here i want to refresh the JTable,how to write?? }
    catch(){}
    4.second is the TableModel
    public class MyTableModel{
    public TableModel createTableModel(){
    String[][] data = getData();
    TableModel tm = AbstractTableModel(
    return tm;
    public String[][] getData(){
    }

  • Removing some of the wagetypes in evaluation class from display in HR forms

    Hi,
    I need to remove few wagetypes from evaluation class, which is used in group of a window from displaying.
    Window x1 which has a group G1,
    Structure of G1:
    Table  ID
    RT  **01 
    Now **01 contains 100 wagetypes out of which I have to do not want to display 4 WT.
    Please suggest how to get the required result.

    I do not want to touch the evaluation class, my requirement is that I have to print rate for these 4 WT and only for a group of people, also if rate is 0.00 then do not print text for rate.
    I have defined three rules one is for ee-subgroup, one for rate not equal to 0 and the third for the 4WT.
    For 4WT rule is  RT LGART eq xxxx    TEXT,  where text resembles nothing.
    Now in the line layout for the rate text field rule written is XRT BETPE ne 0, thus rate text field will not appear.
    And for the group in window rule specified is WPBP PERSK eq xx.
    Please let me know if more information is needed.

  • Forcing the ReadAllQuery to return results from DB instead of cache

    How can I programmatically setup a ReadAllQuery to always return results from DB instead of cache. I dont want to use session.refreshObject - as this will result in 2 lookups - first for the actual search from cache or db and then a second search on each object on the DB. I am using Toplink 11.1.1

    You can use,
    query.refreshIdentityMapResult()
    or,
    query.setShouldRefreshIdentityMapResult(true)
    James : http://www.eclipselink.org

  • How can you retieve a list of classes from the Library

    Is it possible to retrieve a list of the Linkage or Export
    Classes from a swf library dynamically?
    I am building an application where I allow the user to load
    an asset swf at runtime, then they can choose to load any Exported
    class from the library of the swf. Currently it works if you know
    the name of the asset, that you want to load, but I would like to
    be able to bring up a chooser list of the assets, rather than
    having to type the Class names.
    So far I have only seen examples where "if you know the class
    name you can load it", but nothing concerning pulling the list.
    There must be a list somewhere in flash, I just want to tap into
    that.

    I saw this before and did not have a chance to go through it
    completely.
    As I was reading it, though it did not seem to be giving me
    the answer, as they seem to extend the Export clips in the library
    by extending the class.
    I'll run through that and see.
    It does give me another idea though.
    (crazy) Idea:
    What if I extend the loader class and add a method, kind of
    like what they are doing on the document class of the loaded swf,
    to pull the class names. They hard code in the class names into the
    array though.... so that is the crux of the issue.
    Somehow I think this concept is doomed to fail but, I will
    also see if that is possible.
    I suppose for the application, I could require that any user
    would use a swf with a document class that has the getAssets()
    method.... also has some problems .... namely dealing with the
    issue of "what if they do not extend" and having it fail
    gracefully.
    oh well, food for thought... I will leave this open for now
    and perhaps I will post some answer.

  • Load class from XML (Dynamic Dispatch)

    I'm continuing my voyage into the realms of LVOOP.....
    I have encountered a new problem which I am sure there's a solution to.....
    I have a certain hierarchy and I want to implement a single save and load routine for all objects int he hierarchy (located int he parent class of course).
    Using the "flatten to XML" I'm able to create some nice XML files with all parent and sibling information saved (as long as the values are non-default of course).
    Where I am running into problems is the loading of the data within this XML file.  I want to be able to take an object and basically re-initialise it to the values within the file.  All fine and good I thought, but it doesn't work.
    The problem is that when using the VI with Dynamic dispatch inputs, the output of the "Unflatten from XML" is giving me a conflict with the Dynamic dispatch output saying the obejct types do not  necessarily match.  Is it not possible to match the object type on the input and output of the "Unflatten from XML" primitive?
    If I try removing the "Dynamic Dispatch" input to a static input, then it only loads the data for the parent class regardless of the actual input class.
    Am I doing something silly here or is there no other way to properly load a sibling class from a file using only a method residing within the parent class?  I was hoping I could have a single "Save-Restore" function residing within my parent class to make life easier for me.
    Shane.
    Message Edited by Intaris on 06-17-2009 05:24 AM
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

    Hi Tst,
    Problem is that in order for the cast to yield any useful results, I have to make the inputs and outputs non-Dynamic which results in ONLY the data for the parent class being loaded.
    If the inputs and outputs are Dynamic, then a cast will not solve the problem (It could be a grandchild class being cast as a child, thus breaking the dynamic dispatch tables).
    The only solution I see is for the "UnFlatten from XML" to RETAIN the true object type.
    Either that or use my beautiful solution 
    Shane.
    Ps I just did a bit of a test of the race condition probabilities.  I ran 100000 tests (100k) with a program stressing both cores AND ram of my machine in parallel and all 100k of 100k iterations worked out OK.  I suppose that lets me think I should be in the range of at least 99.99%....... 
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

  • Compilation error: "The definition of base class Application was not found."

    Hi,
    I imported my Flash Builder 4.6 project to the 4.7 pre-release version. My application use a CustomSystemManager (in order to force the loading of a "TextContainerManager", I'm using latest TextLayoutFramework 3.0.0.29).
    I had no error with previous versions (Flex SDK 4.5 and Flex SDK 4.6).
    My application is main.mxml :
    <myapp:MyApp>
    </myapp:MyApp>
    myapp/MyApp.as :
    package myapp {
              import spark.components.Application;
              [Frame(factoryClass="skyrockchat.CustomSystemManager")]
              public class MyApp extends Application {
            public function MyApp() {
              super();
    myapp/CustomSystemManager.as :
    package myapp {
              import flashx.textLayout.container.TextContainerManager;
              import mx.managers.SystemManager;
              public class CustomSystemManager extends SystemManager
                        public function CustomSystemManager()
                                  var c:Class = TextContainerManager; // force the inclusion of this class
                                  super();
    If I right click on the "Application" word and then "Open declaration", the correct class from spark.components is opened...
    I don't know if this is a bug or a side effect... ^^

    The packages of the CustomSystemManager don't seem to match:
    [Frame(factoryClass="skyrockchat.CustomSystemManager")] has "skyrockchat" as the package and another place says to put CustomSystemManager in package "myapp".
    myapp/CustomSystemManager.as :
    package myapp {
    When I changed "skyrockchat" to "myapp" the project compiled.
    -Darrell

Maybe you are looking for

  • Runtime error!  when doing XML output

    Hi, I am really stuck with this error... When running a script to genarate a XML file I keep getting an error. The error looks like it is coming from IE: Microsoft Visual C++ Runtime Library Runtime Error! Program: C:\Program Files\Internet Explorer\

  • Internal orders - Plan Line items are not uploading into SAP!!

    Hi Experts, Am uploading the budget values as plan line items of Internal orders(AUFK table) from my Z prog. by using BAPI_COSTACTPLN_POSTPRIMCOST.......in Return table(bapiret2), am not getting any error messages........so, am taking it for granted

  • Keynote

    Hi! When I import a keynote file into the iBooks author, the keynote file play without build in and out effects and moving objects does not work. thanks

  • Where can CWMS 1.5 mr2 be Downloaded from?

    I saw that CWMS 1.5 mr2 'was release last weekend' (https://supportforums.cisco.com/message/4113446#4113446). I can get to the releae notes but the download is not in the location specified in the release notes.  Has there been a delay in making mr2

  • Can I get my iphone 5 screen fixed even though it's not underwarranty?

    My iPhone screen is cracked and has lost a corner of the screen. Can I get it fixed through apple or should j just get a new phone?