Constant reference to a class - ClassLoader needed?

Withing my class I have the following statics defined
public static final Class GENERALIZATION = MGeneralization.class;
public static final Class ASSOCIATION = MAssociation.class;
public static final Class ASSOCIATION_ROLE = MAssociationRole.class;If within the body of my code I refer to ASSOCIATION it seems to give me a null reference.
If I refer to MAssociation.class my code works fine.
Can anyone explain this. Is there some trick I need to do with ClassLoader first?

Should be fine; can you show us the code where you access this static attribute ?
D.

Similar Messages

  • Need reference to calling class

    Is it possible to get a reference to the class that called a particular method? I have a class with an "Object owner" attribute. I am passing this between several different classes, because they all have to perform some operations on the class, but I want certain methods to execute one way if they are called by the object referenced by this.owner, and a different way if they are not. Is there a way to get calling class without passing it in?

    This design is an attempt to control SQL database connections in a threaded environment....No idea what you are talking about. If you are attempting to span threads with a single transaction then you need to control access to the transaction because multiple threads cannot access one jdbc resource at the same time. That it true regardless of anything else.
    If you just want a easy way to control transactions in a persistence layer across multiple DAOs then the following demonstrates a conceptual way to control this. There are endless variations. And error handling must be dealt with.
      class MyConnection
           private bool isTransaction;
           private Connection conn;
           MyConnection(bool isTransaction)
                 this.isTransaction = isTransaction;
                 if (isTransaction)
                      conn = ....with transaction
                 else
                      conn = ....without transaction
           void commit()
                 if (isTransaction)
                       conn.commit()
                 conn.close();
           void rollback()
                 if (isTransaction)
                       conn.rollback()
                 conn.close();
      class MyCustomerDao
              private MyConnection conn;
              private bool isConnOwned;
              MyCustomerDao(MyConnection conn)
                   if (conn == null)
                       this.conn = new MyConnection(false)
                       isConnOwned = true
                   else
                       this.conn = conn
                       isConnOwned = false
              void commit()
                     if (isConnOwned)
                          conn.commit()
      class MyOrderDao
              MyOrderDao(MyConnection conn)
                   if (conn == null)
                       this.conn = new MyConnection(false)
                       isConnOwned = true
                   else
                       this.conn = conn
                       isConnOwned = false
      // Usage for non-transaction
      MyCustomerDao dao1 = new MyCustomerDao(null);
      dao1.commit()
      // Usage for transaction
      MyConnection conn = new MyConnection(true);
      MyCustomerDao dao1 = new MyCustomerDao(conn);
      MyOrderDao dao2 = new MyCustomerDao(conn);
      // following on dao1 is optional since it has no impact.
      // But the idiom is useful because it allows
      // for calls in nested routines without concern
      // for whether parent is needs to control it.
      dao1.commit();
      conn.commit();

  • Regular Expression back-reference in character class

    I am trying to capture quoted text (excluding the quotes) with the following pattern:
    "(['\"])([^\\1]+)\\1"
    The input string might look like:
    "That's strange"
    or:
    'valid "regex" pattern'
    I get an exception when trying to compile the pattern, because of the back-reference within character-class brackets: [^\1]
    This pattern worked with the org.apache.oro package. Is this a bug in the 1.4 Pattern class? Can you offer an alternative solution?
    Thanks,
    Tony

    Thanks for the reply. Apparently, my pattern wasn't working as I thought with ORO. The pattern you suggested, however, wouldn't do what I need either, because it would match anything between the first and last quote character. I don't want to match the string you included in your reply, because it includes the same quote character that encloses the entire string. If you think about my pattern again, you'll notice that the first capture group should match either a single or double quote character. Then the back-reference should be the exact character (single character) that was matched and captured. So the second capture group should be any number of characters, as long as they don't match the first capture group character, followed by the exact string matched in the first capture group (the single character). You probably are aware that when one or more characters are included in square brackets [], that it specifies a match of a single character that is found anywhere within that character class. So if the first capture group happened to match more than one character (impossible due to the pattern in that grouping), the following character class [^\1] should match any character EXCEPT any of the ones matched in the first capture group...right? There must be a bug in ORO that doesn't match correctly per my description, but it seems there is a bug in JDK 1.4 Pattern that will not even compile it. Just to re-iterate...if \1 matched "abc", [^\1] should match any single character EXCEPT a or b or c. I can get what I want, though, if I do it in 2 matches:
    Pattern pat = Pattern.compile("(['\"])(.*)");
    Matcher mat = pat.matcher(sText);
    mat.matches();
    String sQuote = mat.group(1);
    String sRem = mat.group(2);
    pat = Pattern.compile("([^" + sQuote + "]*)" + sQuote);
    mat = pat.matcher(sRem);
    mat.matches();
    String sWhatIWanted = mat.group(1);
    Thanks,
    Tony

  • How can a function return a constant reference to an object

    how can a function return a constant reference to an object so that the calling party dont have rights to change it.
    like this example
    class obj = somefunc();
    obj.changeit(); // this line lust give error saying that its read only..
    somefunc()
    return criticalobj;
    in c++ we can achieve this by using the const pointer to the object.. how can we do this in java???

    arun160411 wrote:
    in c++ we can achieve this by using the const pointer to the object.. how can we do this in java???Of course the first thing anyone learns about const pointers is how to cast away constness, so this is completely useless, up there with the chastity movement's thong underwear with the stop sign on it. If you can read this, you're too close!

  • How do I reorder songs in a playlist in the new itunes??? I can no longer just click and drag. When I click, it doesn't move!!!! Need help ASAP- trying to prepare for an aerobics class and need songs in a specific order!

    How do I reorder songs in a playlist in the new itunes??? I can no longer just click and drag. When I click, it doesn't move!!!! Need help ASAP- trying to prepare for an aerobics class and need songs in a specific order!

    Vera,
    Use View > View Options, and set 'Sort By" to "Manual Order."
    Then you will be able to drag-n-drop songs up and down the list.

  • I teach Continuing education classes to Real Estate agents and I need to issue them certificates at the class, whihc need to be signed by me and it needs to contain their info on the certificate. The certificate is currently saved in a word format.What i'

    I teach Continuing education classes to Real Estate agents and I need to issue them certificates at the class, whihc need to be signed by me and it needs to contain their info on the certificate. The certificate is currently saved in a word format.What i'm trying to accomplish is to do a "mail merge " ( as some classes i have as many as 150 attendees) for the document, digitally sign each one with my signature on the certificate and then e-mail it out to the respective attendees. can this be done? if so How?

    This is the step that I took after inputting my signature.
    On the right, after saving my document, I click "Get Others to Sign."  I was confused because it says that it's powered by EchoSign.  Like I stated before, my clients are able to sign this document when I send it to them, but it is returned to me with their signature (not in the signature field, but at the end of the document), and my signature is missing.  I tested this on myself - my signature is missing when they receive it. 

  • Managing constants in base / derived classes

    Hi there,
    The problem:
    I'm facing what is certainly a simple problem but fail to come up with an acceptable solution. What I'd like to do is managing constants in a base class and derived class... which for some reasons are not parts of the same package. Also, these constants may have different values in the derived base.
    Down to earth description:
    Class base uses a set of constants A=1, B=2, C=3.
    Class derived should be provided with similarly named constants but they may have different values A=10, B=20, C=30. I could declared these constants in the classes themselves but somehow I think this is ugly.
    A "solution" that does not work:
    Assume for a moment that I'm just a very naive programmer (which actually I am... but anyway...). I would them come up with something like:
    package base;
    import base.Constants;
    public class Base {
        public Base() {
        public void myfunction() {
           System.out.println("My constant: " + Constants.A);
    }and
    package derived;
    import derived.Constants;
    public class Derived extends Base {
        public Derived() {
    }Now of course this is stupid since Derived.myfunction() prints the value of the constants given by Base.myfunction()The question is: is there a static construction that would allow me to have the desired behaviour? What I mean is that I don't want to provide a "Constants" object nor an hashtable dynamically loaded or whatever.
    Bonus question:
    I'm not a pro in OOP (seriously guys... C rocks! Oops, wrong forum :-) but it seems to be a case of "code inheritance" vs "behaviour inheritance" (I just made those expressions up!). What I mean is: if what is inherited is the actual "code" of the methods (as if a huge copy paste took place) then the naive solution would work. But in the real world, a "behaviour inheritance" is at work in the sense that what is inherited is the "behaviour" (or, more bluntly, simply the code as compiled in the base class). Hmm... Am I making any sense here? Is that distinction theorized in some way? I tried to search a bit by myself but did not know where to start.
    Thanks,

    I mucked around with this exact problem a while back.
    The (simplified) scenario is AbstractCourse is extended by CookingCourse, WritingCourse, and BusinessCourse. Every course has a basePrice and a materialsCost... both of which vary from course to course... The same price calculation applies to all types of course, just the amounts will vary.
    totalPrice = basePrice + materialsCost The traditional non-oo solution is simple enough... you would just create a "table" of all six contstants, and a function with a switch statement...
    but How to do this "The OO Way"?
    What I came up with is:
    class BaseCourse {
      abstract double getBasePrice();
      abstract double getMaterialsCost();
      public double getPrice() {
        return getBasePrice() + getMaterialsCost();
    public class CookingCourse {
      private static final double BASE_PRICE = 300.00;
      private static final double MATERIALS_COST = 112.60;
      public double getBasePrice() { return CookingCourse.BASE_PRICE }
      public double getMaterialsCost() { return CookingCourse.MATERIALS_COST }
    public class WritingCourse {
      private static final double BASE_PRICE = 200.00;
      private static final double MATERIALS_COST = 50.00;
      public double getBasePrice() { return WritingCourse.BASE_PRICE }
      public double getMaterialsCost() { return WritingCourse.MATERIALS_COST }
    public class BusinessCourse {
      private static final double BASE_PRICE = 600.00;
      private static final double MATERIALS_COST = 18.12;
      public double getBasePrice() { return BusinessCourse.BASE_PRICE }
      public double getMaterialsCost() { return BusinessCourse.MATERIALS_COST }
    }The base class specifies that each subclass must be able to tell it's base price, and it's materials cost... then we implement the calculation on those values just once, in the base class.
    For all I know there are much more succinct, flexible, efficient, and basically much more smarter ways of doing this... this is just a way that worked for me... and it's simple enough so even I can follow it.
    Java can be a very very very very verbose language :-( ... But hey it still shits on C ;-)
    Cheers. Keith.
    Edited by: corlettk on 23/05/2008 11:17 - typos

  • Are there any advantages to using a Data Value Reference for LabVIEW Classes?

    Hi
    I recently came across an example where the developer had used a data value reference for the class cluster in LabVIEW.
    What are the advantages of doing this?
    Doesn't the use of LV objects already avoid the creation of multiple copies of data thereby reducting memory usage?
    Thanks
    AD

    LabVIEW's OOP is implemented as a By Value.  This means, as Tst stated, branches in wires could mean copies in the object.  The DVR is a way to make it By Reference.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Correct references to other classes

    I'm working on a student project and I'm in some troubles.
    I have a schema "2010_12209" on faculty 11g Oracle DB.
    I have successfully loaded Class A (that has no references to other class) in Oracle DB using SQL Developer.
    Then I try to load Class B (that has references to class A) and I get error: java.sql.SQLException: ORA-24344: success with compilation error ORA-06512: at line 1
    which I'm pretty sure that's from the incorrect classes references.
    So what's the correct syntax to properly reference to class A
    ex: 2010_12209.A or ???

    References to other classes will be links only if the class is in the one of the packages you generate the javadoc in, or if you use the -link option to link your javadoc to other javadocs.

  • Passing const vecter in a class function

    I am trying to initialize a const vecter in a class but I cannot finger out what is wrong. I have not program for a few years I finally got back into it.
    class bag {
    Public:
        bag();
        bag(const vector<char> &v);
    Private:
    const vector<char>v;
    bag::bag(const vector<char> &v)
       v.push_back('a');
    here is the error
    std::vector<_Ty>::push_back' : 2 overloads have no legal conversion for 'this' pointer
    bag 

    class bag {
    Public:
        bag();
        bag(const vector<char> &v);
    Private:
    const vector<char>v;
    Which compiler and version are you using? Always state that at the outset, as different
    compilers and different versions of a given compiler have different features, bugs,
    requirements, Standards-compliance, etc.
    Also, which language are you using? C++ doesn't have "Public" and "Private" keywords, It
    has "public" and "private". If those are simply typing errors when composing the forum
    post, then it's a good example of why you should never try to retype code into a post here
    as it often leads to unintentional changes from what's in the *actual* code being compiled.
    Always use Windows copy & paste to post the *real* code that is being used in the compiler.
    - Wayne

  • [svn] 1101: compiler: fixing a few more sneaky references to renamed classes

    Revision: 1101
    Author: [email protected]
    Date: 2008-04-03 18:17:30 -0700 (Thu, 03 Apr 2008)
    Log Message:
    compiler: fixing a few more sneaky references to renamed classes
    Bugs: n/a
    QA: Yes, Gaurav please retest and send me any remaining failures.
    Doc: No
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/Logger.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/SymbolTable.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler_en.properties
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler_ja.properties

    Revision: 1101
    Author: [email protected]
    Date: 2008-04-03 18:17:30 -0700 (Thu, 03 Apr 2008)
    Log Message:
    compiler: fixing a few more sneaky references to renamed classes
    Bugs: n/a
    QA: Yes, Gaurav please retest and send me any remaining failures.
    Doc: No
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/Logger.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/SymbolTable.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler_en.properties
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler_ja.properties

  • Need syntax to get reference to enclosing class.

    Given the following program, how do I change testIsMember() so that the program prints out the desired output as indicated in the program text:
    public class Nested
        public class Inner
        private boolean testIsMember(Inner i)
            // Help what goes here?
            return true;
        public void someMethod(Inner i)
            if(testIsMember(i)) {
                System.out.println("I am i's this$0");
            else {
                System.out.println("I am not i's this$0");
        public static void main(String a[])
            Nested n1 = new Nested();
            Nested n2 = new Nested();
            Inner i1 = n1.new Inner();
            Inner i2 = n2.new Inner();
            n1.someMethod(i1);
            n1.someMethod(i2);
            n2.someMethod(i1);
            n2.someMethod(i2);
            // Desired output:
            // I am i's this$0
            // I am not i's this$0
            // I am not i's this$0
            // I am i's this$0
    }

    Here's the only way I can think of doing it:
    public class Nested
        public class Inner
        private boolean testIsMember(Inner i)
            try {
               java.lang.reflect.Field f = Inner.class.getDeclaredField ("this$0");
               f.setAccessible (true);
               return f.get (i) == this;
            } catch (Exception e) {}
            return true;
        public void someMethod(Inner i)
            if(testIsMember(i)) {
                System.out.println("I am i's this$0");
            else {
                System.out.println("I am not i's this$0");
        public static void main(String a[])
            Nested n1 = new Nested();
            Nested n2 = new Nested();
            Inner i1 = n1.new Inner();
            Inner i2 = n2.new Inner();
            n1.someMethod(i1);
            n1.someMethod(i2);
            n2.someMethod(i1);
            n2.someMethod(i2);
            // Desired output:
            // I am i's this$0
            // I am not i's this$0
            // I am not i's this$0
            // I am i's this$0
    }I've tried the code and it produces the desired output.

  • IOException: Resource not found - custom class loader needs findResource

    I've been attempting to develop test classes using the PowerMock and Mockito mock frameworks
    I've developed the tests in Eclipse in windows XP (64 bit) and the tests run to completion with passes
    One of the classes being tested references the joda-time-1.4.jar and this jar contains the resource org/joda/time/tz/data/ZoneInfoMap
    I then attempted to migrate the development to running the unit tests in a Windows XP command prompt launched by Maven 2 (mvn)
    With JAVA_HOME set to to a standard Sun JDK (C:\Program Files (x86)\Java\jdk1.5.0_21), I get the resource not found error for one test only - here is an extract from the exception:
    Running com.visaeu.rcs.application.cas.parser.RCSInternalTCR8HelperTest
    Exception in thread "main" java.io.IOException: Resource not found: "org/joda/time/tz/data/ZoneInfoMap" ClassLoader: org.powermock.core.classloader.MockClassLoader@3ab28980
    at org.joda.time.tz.ZoneInfoProvider.openResource(ZoneInfoProvider.java:206)
    at org.joda.time.tz.ZoneInfoProvider.<init>(ZoneInfoProvider.java:123)
    at org.joda.time.tz.ZoneInfoProvider.<init>(ZoneInfoProvider.java:82)
    at org.joda.time.DateTimeZone.getDefaultProvider(DateTimeZone.java:435)
    at org.joda.time.DateTimeZone.setProvider0(DateTimeZone.java:389)
    at org.joda.time.DateTimeZone.<clinit>(DateTimeZone.java:113)
    at org.joda.time.chrono.GregorianChronology.<clinit>(GregorianChronology.java:71)
    at org.joda.time.chrono.ISOChronology.<clinit>(ISOChronology.java:66)
    at org.joda.time.base.BaseDateTime.<init>(BaseDateTime.java:97)
    at org.joda.time.DateTime.<init>(DateTime.java:114)
    at com.visaeu.rcs.cts.datetime.RCSDateTime.<init>(RCSDateTime.java:178)
    at com.visaeu.rcs.cts.datetime.RCSDateTime.<clinit>(RCSDateTime.java:53)
    at com.visaeu.rcs.application.cas.parser.RCSInternalTCR8Helper.setTcr8ValuesInTransaction(RCSInternalTCR8Helper.java:230)
    at com.visaeu.rcs.application.cas.parser.RCSInternalTCR8Helper.bindTcr8(RCSInternalTCR8Helper.java:164)
    at com.visaeu.rcs.application.cas.parser.RCSInternalTCR8HelperTest.testBindSampleData(RCSInternalTCR8HelperTest.java:423)
    Running the tests on a unix host under the AIX OS launched with Maven 2 (mvn), I also get the
    Resource not found: "org/joda/time/tz/data/ZoneInfoMap" error
    Just to emphaises, I don't get any error when running the test in Eclipse
    Looking at the discussions page for PowerMock, it seems likely that this may be due to MockClassLoader (which effectively extends ClassLoader) not implementing findResource - see:
    http://groups.google.com/group/powermock/browse_thread/thread/0bba0faa3027026f
    I have contacted the PowerMock developers, but they are very busy and do not have time to look at the problem yet
    However, they have indicated that it would be helpful if I could create a patch for the problem and submit it
    - see the above reference and:
    http://groups.google.com/group/powermock/browse_thread/thread/3002fddca62f7ef5
    I don't have any background of classloaders, and although I've done lots of 'Googling', I've not found anything that I can use
    So my question here is:
    Can anyone
    a) provide a reference that will help me understand what I need in findResource
    OR
    b) provide a sample findResource that I could try in the code
    Thanks for reading and any help

    The JDK comes with most of the Java API source code in a file called src.zip (or something like that.) There should be examples in there.
    You can also download the entire VM source, there might be a couple more in there.
    FYI - do NOT copy the code you find in there. You can reference it but you must create your code from scratch.

  • MovieClip references from a class

    I have a files that has movie clips and nested movie clips on the stage. I am now writing a class and want to give the MCs event handlers and other properties.
    When I do something like the following:
    myMC_mc.MyOtherMC_mc.mouseEnabled = false;
    I get the error:
    1120: Access of undefined property myMC_mc.
    I added this to the top of my class and it seems to take away the error, but I thought this was not needed in AS3 anymore.
    private var myMC_mc:MovieClip;
    private var myMC_mc.MyOtherMC_mc:MovieClip;
    What do I have to do to not get the error? How is this done right?
    Thanks a lot for any help!

    you can't access/reference objects until they exist.
    if your class is the document class and myMC_mc doesn't exist on frame 1 of the main timeline, you'll have a problem.

  • BOR reference in ABAP Class

    Hello,
    I am writing method in ABAP class which I will link to the Workflow Step. I want  to access values of one of the Workflow Element which is Multiline and refering to BOR Object Type. My queries are as below:
    1. How should I define Importing Parameter of Method which will import values from the Workflow Element which is Multiline and refering to BOR object type.
    2. If I change value of that Workflow Element (Multipline refering to BOR object type)  in ABAP class method, will it be automatically reflected in Workflow Container due to binding?
    Edited by: Ashwin Sonkusare on Apr 1, 2011 3:35 PM

    Hi,
    1. How should I define Importing Parameter of Method which will import values from the Workflow Element which is Multiline and refering to BOR object type.
    Please create a table type same as workflow multiline element type. ( You can also use standard table if present ).
    Then use this table type as the type of the import parameter of the class.
    Then u can pass the multiline element of workflow to  abab calss
    2. If I change value of that Workflow Element (Multipline refering to BOR object type) in ABAP class method, will it be automatically reflected in Workflow Container due to binding?
    If u change the Workflow Element (Multipline refering to BOR object type) in ABAP class method, then  u need to update the values of the workflow multiline element through reverse binging ( binding abap class to WF ).
    Thanks and regards,
    SNJY

Maybe you are looking for

  • Can you use an itunes card for purchase of an ipad

    I am trying to determine if I can use itunes gift cards to purchase an ipad?

  • Linear image but not Raw

    Hi Guys, I think this is quite a simple question, but I'd like to check with you, since you are the experts. I have an image that was generated by a bit of software, a simple program. The program knows nothing about colour profiles sRGB or otherwise.

  • Missing TV season after downloading all 6 seasons

    Hi all, I recently downloaded a TV series that has 6 seasons. All seasons are in my Itunes except season 3. when I go to the Itunes page where I purchased it, and it says I already purchased it. Where do I locarte the missing season and where can I r

  • Please Help!!!  Encrypt/Decrypt Password

    i'm a newbie to Cryptography...and i know that this question have been asked MILLIONS of time...but i'm going to ask it again. i searched through the forum, and i didn't find anything useful...but: i want to write a program to encrypt the password i

  • Image Fade Out/Load new Image/Fade In

    I think I am having an event timing issue. My desire is to change the "header" image on each selection of a tabNavigator. I can swap the image without issue through a img.load process. I placed the image on a canvas and set the "showEffect" and "hide