Using static .values() method of Enum in Generic Class

Hi *,
I tried to do the following:
public class AClass<E extends Enum<E> >  {
     public AClass() {
          E[] values = E.values(); // this DOESN'T work
          for (E e : values) { /* do something */ }
}This is not possible. But how can I access all Enum constants if I use
an Enum type parameter in a Generic class?
Thanks for your help ;-) Stephan

Here's a possible workaround. The generic class isn't adding much in this case; I originally wrote it as a static method that you simply passed the class to:
public class Test21
  public static enum TestEnum { A, B, C };
  public static class AClass<E extends Enum<E>>
    private Class<E> clazz;
    public AClass(Class<E> _clazz)
    {  clazz = _clazz;  }
    public Class<E> getClazz()
    {  return clazz;  }
    public void printConstants()
      for (E e : clazz.getEnumConstants())
        System.out.println(e.toString());
  public static void main(String[] argv)
    AClass<TestEnum> a = new AClass<TestEnum>(TestEnum.class);
    a.printConstants();
}

Similar Messages

  • UnusedPrivateMethod - bug when using static private method?

    Hi,
    I get the following violation:UnusedPrivateMethod. This private method (createDefaultSolidColors) does not seem to be used.
    For the foloowing code snippet:
    private  static const defaultSolidColors:Array = createDefaultSolidColors(); 
    private static function createDefaultSolidColors():Array { 
         var _a:Array = new Array(); 
         for each (var color:uint in defaultColors) {          _a.push(
    new SolidColor(color, 0.8));     }
         return _a;}
    Why is it a violation? the function is used by the defaultSolidColors property.
    Is it a bug or am I missing something?
    Thanks,
    -ilan

    This is a known issue, which has been fixed on trunk.
    The fix will be in the next release:
    https://bugs.adobe.com/jira/browse/FLEXPMD-173

  • Enums and generic classes

    Hi all,
    consider the following class:
    public class Box<T> {
      // omitted
    }Suppose I create an Enum like so:
    public enum BoxEnum {
        FIRST_BOX("Box1", String.class), SECOND_BOX("Box2", Integer.class);
        private final String name;
        private final Class<?> classType;
        // The starting point of the problem
        private static Map<String, Box<?>> map;
        static {
            map = new Hashtable<String, Box<?>>();
            for (BoxEnum i : BoxEnum.values()) {
                map.put(i.getName(), new Box<Same Type as classType>());
                // note the error in the upper line
        BoxEnum(String name, Class<?> classType) {
            this.name = name;
            this.classType = classType;
        public String getName() {
            return name;
        @SuppressWarnings("unchecked")
        public <T> T getClassType() {
            return (T) classType;
    }Note where the problem occurs; what I am trying to achieve is to populate a Map. Moreover, I should be able to create a new Box holding the exact same data that is specified in the Enum constant. To be more precise, consider the following example:
    FIRST_BOX("Box1", String.class)the program should populate a Map so that the key would be "Box1" and the value would be "new Box<String>()".
    Is there a way to achieve this?
    Thank you.

    Hi, thank you for a quick response.
    I'm not really sure if I understand your reply correctly, or maybe I was not clear enough describing my question. I did try a few different approaches with your suggestion but none of them worked, so I'll try to show one more example, to make this clearer (or so I hope)
    // This is where it goes down:
    private static Map<String, Box<?>> map;
        static {
            map = new Hashtable<String, Box<?>>();
            for (BoxEnum i : BoxEnum.values()) {
                // This is the fundamental part; this is where the new Box
                // should be created, having the same data type as its
                // enum constant, thus if i == 0, then:
                String name = i.getName();  // "Box1"
                Class<?> cls = i.getClassType() // this method was corrected, please note below
                map.put(name, new Box<cls>());  // please note the cls variable; here's the error
      // the corrected method
    public <T> T getClassType() {
            return (T) classType.newInstance();
    }

  • Static factory methods, instead of constructor

    Hi All,
    why we use static factory methods, instead of constructor.
    Apart from Singleton class , what is use of static factory methods ?
    Thanks in Advance,
    Rishi

    One reason for using factories is that they simplify creating instances of immutable classes that might otherwise have messy constructors with lots of arguments.

  • Static abstract method equivalent?

    From the forum thread:
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=5202376
    baftos wrote:
    On the othe hand OP had a legitimate desire.
    How can a superclass force its subclasses to
    provide a certain class (as opposed to instance) behaviour?
    Do other languages provide something like this?I like to have a static abstract method in a super abstract class:
    public static abstract Behavior getClassMarker();And each sub concrete class should have:
    public static Behavior getClassMarker(){
      return new Behavior(-- parameters --);
    }Could we have an equivalent that current Java allows? Or, do we see some good news on the horizon?

    Normally you create an instance with the metadata for the type, which annotations let you do:package dog;
    abstract class Dog {
      abstract String getBark() ;
      Dog () {
        assert (getBreed() != null);
      DogBreed getBreed () { return getClass().getAnnotation(DogBreed.class); }
    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.TYPE)
    public @interface DogBreed {
      String genericBark () ;
      String name () ;
    @DogBreed(name="Bulldog", genericBark="GrrrGrrrGrrr")
    class Bulldog extends Dog {
      String getBark() {
        return "Grrr";
    @DogBreed(name="Pomeranian", genericBark="Pirrr")
    class Pomeranian extends Dog {
      String getBark() {
        return "Sausages";
    public class DogAnnotationTest {
      public static void main (String...args) {
        Pomeranian pomme = new Pomeranian();
        System.out.println("The generic bark of the " + pomme.getBreed().name() + " breed is "
              + Pomeranian.class.getAnnotation(DogBreed.class).genericBark() + " but our  pomme cries "
              + pomme.getBark() + " for a jerky, his favorite food");
    }The limitation is that you can only annotate with simple types, so you're stuck with the abstract factory pattern if you want the creation. Not that that's a bad thing, as it lets you create instances of classes which haven't been loaded yet.

  • Static Values in IN operator

    Hi All,
    Can we use static values with IN operator for multiple columns.
    Ex :- I have a table tab_1 with col_1 and col_2.
    If i try to execute the query
    select * from tab_1 where
    (col_1,col_2) in (val_1,val_2)
    Iam getting invalid relational operator error message.
    But
    select * from tab_1 where
    (col_1,col_2) in (select col_1,col_2 from tab_1)
    Works Fine.
    Pls help me to understand this problem.
    Thanks & Regs
    Dhananjaya.H

    These are two different queries. The static list:
    select * from tab_1 where
    (col_1) in (1,2,3) means return all rows where COL_1 = 1 or COL_1 = 2 or COL_1 = 3. The syntax only allows one column as the argument in this sort of IN.
    The variable list:
    select * from tab_1 where
    (col_1,col_2) in (select col_1,col_2 from tab_2)means return all rows where TAB_1.COL_1 = TAB_2.COL_1 and TAB_1.COL_2 = TAB_2.COL_2. In this case the number on arguments on the left hand side of the IN must match the number of arguments on the righthand side of the argument.
    In other words this is not valid syntax either: select * from tab_1 where
    (col_1,col_2) in (select col_1 from tab_2)If you want to test two columns against a static list you need separate clauses for each of them.
    You may find the documentation helpful.
    expression lists: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/expressions14a.htm#1029285
    membership conditions: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/conditions5a.htm#1013449
    Cheers, APC

  • How to update and use the values of variables of another class

    I can we update or use the values of the variables of another class. For example, if we have class A
    public class A //(situated in package view)
    public s0,s1;
    public void runFunction()
    ...some coding and proceedings
    s0="Hi";s1"Hello";
    ......some coding
    RequestDispatcher dispatcher = request.getRequestDispatcher("/MainUser.jsp?alert=F");
    dispatcher.forward(request, response);
    ARunner.jsp
    <jsp:useBean id="a" class="view.A" scope="session"/>
    <%
    a.runFunction();
    %>
    MainUser.jsp
    <jsp:useBean id="a" class="view.A" scope="session"/>
    <%
    System.out.println("S0:"+a.s0+" S1:"+a.s1); //should print S0:Hi S1:Hello, but printing S0:null S1:null
    %>
    A.class has some procedures and String variables which can be updated and later can be used in JSP pages. The project starts with ARunner.jsp which uses the A.class and updates the values of string variables s0 and s1of A to hi and hello respectively.And then redirects the page to MainUser.jsp.
    Now what I want is ,when I call those string variables(s0 & s1 of A.class) in any another jsp likeMainUser.jsp it should give me the value of hi and hello respectively not null as it is giving right now. Could you refine the coding for this one?

    public class A //(situated in package view)
    public String s0,s1;
    public void runFunction()
    ...some coding and proceedings
    s0="Hi";s1"Hello";
    ......some coding
    RequestDispatcher dispatcher = request.getRequestDispatcher("/MainUser.jsp");
    dispatcher.forward(request, response);
    ARunner.jsp
    <jsp:useBean id="a" class="view.A" scope="session"/>
    <%
    a.runFunction();
    %>
    MainUser.jsp
    <jsp:useBean id="a" class="view.A" scope="session"/>
    <%
    System.out.println("S0:"+a.s0+" S1:"+a.s1); //should print S0:Hi S1:Hello, but printing S0:null S1:null
    %>
    giving code again to remove the typing errors. Please guide.

  • How to use my findTheHighest method to find the highest value in my two dim

    I am going to create a 13row by 10 colume two dimensional array.
    how to use my findTheHighest method to find the highest value in my two dimensional array.
    .When i compile this program , i got those as following;
    "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsExce
    at TaxEvolution.findTheHighest(TaxEvolution.java:31)
    at TaxEvolutionClient.main(TaxEvolutionClient.java:25)"
    public class TaxEvolution{
    public double[][] salesTaxRates;
    public TaxEvolution()
      salesTaxRates = new double[13][10];
      fillProvinTaxRates();
    private void fillProvinTaxRates()
      for ( int row = 0; row < salesTaxRates.length; row++ )
        for ( int column = 0; column < salesTaxRates[row].length; column++ )
          salesTaxRates[row][column]= (int)(Math.random()*5000) + 1;
    public double findTheHighest()
        double highest = salesTaxRates[0][0];
        for ( int row = 0; row <= salesTaxRates.length; row++ )
          for ( int column = 0; column <= salesTaxRates[row].length; column++ )
             if ( salesTaxRates[row][column] >= highest )
                   highest = salesTaxRates[row][column];
        return highest;   
    public double[][] arrayTaxEvolution()
      double[][] returnTaxRates = new double[13][10];
      for ( int row = 0; row < salesTaxRates.length; row++ )
        for ( int column = 0; column < salesTaxRates[row].length; column++ )
          returnTaxRates = salesTaxRates;
      return returnTaxRates;
    public class TaxEvolutionClient{
    public static void main( String[] args ){
      TaxEvolution protaxRateList = new TaxEvolution();
      double[][] taxRateList = protaxRateList.arrayTaxEvolution();
        for ( int i = 0; i < taxRateList.length; i++ )
          for ( int j = 0; j < taxRateList[0].length; j++ )
            System.out.print( taxRateList[i][j] + "\t" );               
            System.out.print( protaxRateList.findTheHighest + "\t" );
    }

    Multiposted
    http://forum.java.sun.com/thread.jspa?threadID=699057&tstart=0

  • Adding new constant value to an 'enum' used in a field causes an exception

    We are using the DPL. I added a new constant to an enum that is used as a field on an entity called Booking (this field is not a key). This seems to cause an exception during onForeignKeyDelete when we delete an object from a related entity. The constraint is a "NULLIFY" on a "MANY_TO_ONE" relationship, so the effect should be just to nullify the Booking foreign key, but for some reason the fields are being checked and causing this exception. Shouldn't it be possible to add a new constant value to an enum without having to do some sort of migration? The stack is below. Note that the two types mentioned in the exception message are in fact the same (this is the enum). For the moment we can truncate our database, because we are still in development, but this would present a problem in production.
    IllegalArgumentException: Not a subtype of the field's declared class com.chello.booking.model.BookingStatus: com.chello.booking.model.BookingStatus
    at com.sleepycat.persist.impl.RawAbstractInput.checkRawType(RawAbstractInput.java:142)
    at com.sleepycat.persist.impl.RecordOutput.writeObject(RecordOutput.java:75)
    at com.sleepycat.persist.impl.RawAccessor.writeField(RawAccessor.java:232)
    at com.sleepycat.persist.impl.RawAccessor.writeNonKeyFields(RawAccessor.java:148)
    at com.sleepycat.persist.impl.ComplexFormat.writeObject(ComplexFormat.java:528)
    at com.sleepycat.persist.impl.PersistEntityBinding.writeEntity(PersistEntityBinding.java:143)
    at com.sleepycat.persist.impl.PersistKeyCreator.nullifyForeignKeyInternal(PersistKeyCreator.java:170)
    at com.sleepycat.persist.impl.PersistKeyCreator.nullifyForeignKey(PersistKeyCreator.java:137)
    at com.sleepycat.je.SecondaryDatabase.onForeignKeyDelete(SecondaryDatabase.java:1082)
    at com.sleepycat.je.ForeignKeyTrigger.databaseUpdated(ForeignKeyTrigger.java:37)
    at com.sleepycat.je.Database.notifyTriggers(Database.java:2016)
    at com.sleepycat.je.Database.deleteInternal(Database.java:800)
    at com.sleepycat.je.Database.delete(Database.java:714)
    at com.sleepycat.persist.BasicIndex.delete(BasicIndex.java:133)
    at com.sleepycat.persist.PrimaryIndex.delete(PrimaryIndex.java:206)
    at com.sleepycat.persist.BasicIndex.delete(BasicIndex.java:124)
    at com.sleepycat.persist.PrimaryIndex.delete(PrimaryIndex.java:206)
    Kind regards
    James Brook

    James,
    I've started investigating this and at first look it does appear to be a DPL bug. Over the next few days I'll look more deeply and report back here with what I find. If it is indeed a bug, we'll fix this for the next JE 4.0.x release and I'll make the fix available to you.
    You are correct that adding enum values is allowed without a conversion of any kind. The only change you should have to make, other than adding the enum value, is to bump the version of the containing entity in the @Entity annotation. I'm suspect you've already done that, but if you hadn't, it wouldn't cause the problem you're seeing.
    We have tested the addition of enum values, but not in combination with foreign key deletion and the NULLIFY constraint, I'm afraid.
    If I'm correct about it, the bug is specific to adding enum values and deleting a secondary key with the NULLIFY constraint, prior to re-writing the entity in some other way. So if the entity is updated (written) before the secondary key is deleted, then the problem should not occur. Therefore, one workaround is to call EntityStore.evolve after adding the enum value, and before using the store in other ways.
    Thanks for reporting this, and I hope this is not blocking your development.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Passing select-options values using call transaction method

    Hi Experts,
    I have a scenario in which i have three fields BUKRS,WERKS and MATKL in an internal table i_tab and I have MATNR as a selection-option.
    After this I have to use call transaction <tcode> for all the line items in the internal table and the MATNR select-option values I have to pass directly for each line of i_tab using call transaction method.
    TYPES:  BEGIN OF t_tab,
              bukrs TYPE bukrs,
              werks TYPE werks_d,
              matkl TYPE matkl,
            END OF t_tab.
    DATA:  w_tab TYPE t_tab,
                i_tab      TYPE STANDARD TABLE OF t_tab.
    SELECT-OPTIONS: s_matnr FOR marc-matnr.
    Now I am putting a loop at i_tab and have to use CALL TRANSACTION <TCODE> for each line with the SELECT-OPTIONS for MATNR.
    Please tell me whether we can pass multiple ranges for MATNR using call transcation method.
    for example there can be multiple single values/multiple ranges/excluded ranges for MATNR. so please suggest me how tho achieve this sceanrio using CALL transaction method of BDC.
    Thanks a lot.
    Regards,
    Krishan

    Hi Krishan,
    For the Call transaction TCODE there is extension ....OPTIONS from OPT. Just Check it out. I think it is possible like this.
    ... OPTIONS FROM opt
    *Effect*
    This addition gives you control using the values of the components of the structure opt, which must be of the Dictionary type CTU_PARAMS. The components have the following meaning:
    DISMODE
    Processing mode (comparable with the MODE addition)
    UPDMODE
    Update mode (comparable with the UPDATE addition)
    CATTMODE
    CATT mode (controlling a CATT procedure)
    The CATT mode can have the following values:
    ' ' No CATT procedure active
    'N' CATT procedure without single screen control
    'A' CATT procedure with single screen control
    DEFSIZE
    Use standard window size
    RACOMMIT
    COMMIT WORK does not end CATT procedure
    NOBINPT
    No batch input mode, that s SY-BINPT = SPACE.
    NOBIEND
    No batch input mode after BDC data has been read
    The components DEFSIZE , RACOMMIT, NOBINPT, NOBIEND always take the following values:
    'X' Yes
    ' ' No
    If the OPTIONS addition is omitted, the following settings are valid for the control parameters:
    DISMODE from the MODE addition
    UPDMODE
    from the UPDATE addition
    CATTMODE
    No CATT procedure active
    DEFSIZE
    Do not use standard window size
    RACOMMIT
    COMMIT WORK ends procedure successfully
    NOBINPT
    Batch input mode, that is SY-BINPT =X.
    NOBIEND
    Batch input mode also active after BDC data has been read
    Regards,
    Swapna.

  • How to use any cell as an static value

    Hello,
    I don't know if it is possible to use any cell as an static value, same as $ in excel, E$2$.
    I need to divide all the values of a table with a unique value of a cell. In excel is when you put $E$2, this make a cell an static value.
    This is possible en Web Intelligence?
    Best Regards
    SU

    Hello Srivatsa,
    Thanks for your response. An example could be the sum and divide by the sum (to calculate participation) of a table.
    2
    2
    3
    S=7
    Then I want to divide 2 by 7, 2 by 7 and 3 by 7. The Sum (in this case 7) is the static value, how can I use it for operate all the registries?
    To have,
    0.29
    0.29
    0.43
    Thanks & Regards
    SU

  • Which Function Should i use for static values for a an array[] in BPM 11g.

    Hi Experts,
    Please throw some light on this..
    I've a requirement which is bugging me..
    How do i assign a static value to a array in BPM11g in script activity. What exactly function do i need to use to assign a Static value for an Array []
    I been doing like taking the business object as a Array thats fine. But how can i set a static value in BPM 11g.
    Iam using BPM 11.1.1.6 version..
    Regards,
    Pavan

    Hi Pavan,
    Here's one approach, but it assumes you're comfortable with XSDs and XML.
    Know this is light on detail, but without knowing what your array looks like it's the best I can do. Here's what you'd do from a high level:
    1. Create an XSD that defines the structure of your array.
    2. Create the XML that represents the static item you want to add to the array.
    3. Create a process variable based on the XSD that defined the array.
    4. Add a Script activity.
    5. Open the "Implementation" tab -> click "Data Associations".
    6. On the right, expand the folder under your process -> drag the XML icon in the upper right corner on the array variable -> paste your XML into the XML literal panel.
    Hope this gets you going,
    Dan

  • Why not to use static methods - with example

    Hi Everyone,
    I'd like to continue the below thread about "why not to use static methods"
    Why not to use static methods
    with a concrete example.
    In my small application I need to be able to send keystrokes. (java.awt.Robot class is used for this)
    I created the following class for these "operations" with static methods:
    public class KeyboardInput {
         private static Robot r;
         static {
              try {
                   r = new Robot();
              } catch (AWTException e) {
                   throw new RuntimeException(e + "Robot couldn't be initialized.");
         public static void wait(int millis){
              r.delay(millis);
         public static void copy() {
              r.keyPress(KeyEvent.VK_CONTROL);
              r.keyPress(KeyEvent.VK_C);
              r.keyRelease(KeyEvent.VK_C);
              r.keyRelease(KeyEvent.VK_CONTROL);
         public static void altTab() {
              r.keyPress(KeyEvent.VK_ALT);
              r.keyPress(KeyEvent.VK_TAB);
              r.keyRelease(KeyEvent.VK_TAB);
              r.keyRelease(KeyEvent.VK_ALT);
                   // more methods like  paste(), tab(), shiftTab(), rightArrow()
    }Do you thinks it is a good solution? How could it be improved? I've seen something about Singleton vs. static methods somewhere. Would it be better to use Singleton?
    Thanks for any comments in advance,
    lemonboston

    maheshguruswamy wrote:
    lemonboston wrote:
    maheshguruswamy wrote:
    I think a singleton might be a better approach for you. Just kill the public constructor and provide a getInstance method to provide lazy initialization.Thanks maheshguruswamy for advising on the steps to create a singleton from this class.
    Could you maybe advise also about why do you say that it would be better to use singleton? What's behind it? Thanks!In short, it seems to me that a single instance of your class will be able to coordinate actions across your entire application. So a singleton should be enough.But that doesn't answer why he should prefer a singleton instead over a bunch of static methods. Functionally the two are almost identical. In both cases there's only one "thing" on which to call methods--either a single instance of the class, or the class itself.
    To answer the question, the main reason to use a Singleton over a classful of static methods is the same reason the drives a lot of non-static vs. static decisions: Polymorphism.
    If you use a Singleton (and and interface), you can do something like this:
    KeyboardInput kbi = get_some_instance_of_some_class_that_implements_KeyboardInput_somehow_maybe_from_a_factory();And then whatever is calling KBI's public methods only has to know that it has an implementor of that interface, without caring which concrete class it is, and you can substitute whatever implementation is appropriate in a given context. If you don't need to do that, then the static method approach is probably sufficient.
    There are other reasons that may suggest a Singleton--serialization, persistence, use as a JavaBean pop to mind--but they're less common and less compelling in my experience.
    And finally, if this thing maintains any state between method calls, although you can handle that with static member variables, it's more in keeping with the OO paradigm to make them non-static fields of an instance of that class.

  • Load Akamai plugin example using Static plugin loading method

    Hi,
    I want to load Akamai plugin example using Static plugin loading method. For that, I passed "com.akamai.osmf.AkamaiBasicStreamingPluginInfo" as a class defination, but I got error stating, ReferenceError: Error #1065: Variable AkamaiBasicStreamingPluginInfo is not defined.
    Makjosh once sent a post that the title was "Getting an error while loading the plugin using static plugin load method". I then follow the solution. But how can I add the dependent project(Flex/AS Build Path -> Library Path -> Add Project). As a result, I do not find the AkamaiBasicStreamingPlugin project only having the NetMocker project and the StrobeUnit project in it.
    So I try to link the AkamaiBasicStreamingPlugin project use the following method(project properties->Project References->select "AkamaiBasicStreamingPlugin"), it still causes the same error.
    Please help me.
    Thanks.

    Hi,
    A couple of things to look at:
    1) Make sure you have the import statement in your project:
                import com.akamai.osmf.AkamaiBasicStreamingPluginInfo;
    2) Make sure you add the AkamaiBasicStreamingPlugin folder to your Flex Build Path (right click project, select "properties", then "Flex Build Path", in "Source Path" you need to add the plugin folder).
    3) If you are still getting Error #1065, you can try a trick where you force the swf compiler to pull in the class:
                private static const loadTestRef:AkamaiBasicStreamingPluginInfo = null;
    Now you should be able to use getDefinitionByName to load the plugin:
                    var pluginResource:IMediaResource;
                    var pluginInfoRef:Class = flash.utils.getDefinitionByName(className) as Class;
                    pluginResource = new PluginClassResource(pluginInfoRef);
                    pluginManager.addEventListener(PluginLoadEvent.PLUGIN_LOADED, onPluginLoaded);
                    pluginManager.addEventListener(PluginLoadEvent.PLUGIN_LOAD_FAILED, onPluginLoadFailed);
                    pluginManager.loadPlugin(pluginResource);
    Hope that helps,
    - charles

  • Best practice for using static methods

    When i want to call a static method, should i call:
    1) classInstance.staticMethod()
    or should i call
    2) ClassName.staticMethod()??
    is the first style bad programming practice?

    dubwai: which compiler?I had assumed that this was what the JLS specifies, but intsead, it goes into length how to make the runtime environment treat calls to static methods on instances as if they were static calls on the variable's type.
    However, I imagine anyone creating a compiler would go ahead and compile calls to static methods on instances to static calls on the variable's type instead of going through the effort of making the runtime environment treat calls to static methods on instances as if they were static calls on the variable's type.
    But of course, it is concievable that somone didn't in their compiler. I doubt it but it is possible. Sun does compile calls to static methods on instances to static calls on the variable's type:
    public class Garbage
        public static void main(String[] args)
            Garbage g = null;
            method();
            g.method();
        public static void method()
            System.out.println("method");
    public class playground.Garbage extends java.lang.Object {
        public playground.Garbage();
        public static void main(java.lang.String[]);
        public static void method();
    Method playground.Garbage()
       0 aload_0
       1 invokespecial #1 <Method java.lang.Object()>
       4 return
    Method void main(java.lang.String[])
       0 aconst_null
       1 astore_1
       2 invokestatic #3 <Method void method()>
       5 invokestatic #3 <Method void method()>
       8 return
    Method void method()
       0 getstatic #4 <Field java.io.PrintStream out>
       3 ldc #5 <String "method">
       5 invokevirtual #6 <Method void println(java.lang.String)>
       8 return

Maybe you are looking for

  • How to copy a dir structure with files and subdir's in to another dir

    Hi there. How can i copy a dir structure with files and subdirs to another dir structure ie., all files and dirs in side the dir c:\aDir to c:\copyDir so i should get like c:\copyDir\aDir(all the files and subdirs of adir here) Thanks in advance Muth

  • Passing variable from php into flash, help please

    Here are what I'm having: <?PHP $testVal = "This is a test"; $test = urlencode($testVal); $out = "test=". $testVal; echo $out; ?> // and this is my flash file function getData() { // Prepare request var urlReq:URLRequest=new URLRequest("http://localh

  • Dividing Genrated PDF no  of  pages into two parts

    Dear Friends, I have requirement in which i need to divide total number output pdf pages into two parts. E.g. If there are 10 pages Then   10 / 2 = 5 Before generation of pdf file from smartform it automatically divide by 2 and then show these files.

  • [Help] - Wrong storage location in production order!

    Hello SAP Gurus and friends, I have a finish product with a BOM with only one Raw material. This Raw material is created for storage location 1001 and 1010, but in MRP2 view, I have defined "Prod. stor. location" and "Storage loc. for EP" 1010. When

  • I forget secret answer i want to reset

    i forget secret answer i want to reset but the reset email not correct i want to send it to my main email please