JUnit Test Debug: Static variable lost value!!!

Hi, I am writing JUnit code.
env: JDeveloper + JUnit Plugin + Selenium RC
While I am debugging, I found the static variable lost between 2 different test, I mean a test is a @Test, do somebody know why??
Thank you very much!!

1.) The File you initialize in the method is not the same as the instance file variable that you initially initialized to null. You declared a new File in that method.
2.) Read about layout managers. The behavior you are seeing is because of the default layout manager's behavior.

Similar Messages

  • Variable lost value

    else if (invalue >= STAMP3S && invalue <= STAMP3E)
    NSLog(@"Greater than 250,000 and leass than 500,000 StampDuty
    \t\t3%%"
    [lblIntrest setText:[NSString stringWithFormat:@"Stamp Duty:\t\t%@" , [currencyStyle stringFromNumber:stampN3]]];
    NSLog(@"Prints
    StampDuty value %@ ", [noStyleFormatter stringFromNumber:stampN3]);
    NSLog(@"Prints
    Purchase Price %.0f",
    invalue);
    NSLog(@"Prints stamp
    duty %@ ", stampDuty);
    NSNumber *stampDuty = [stampN3 retain];
    // at this point stampDuty seems to have a value but looses it on
    exit calculation
    float
    Beven = (invalue + SaleP + survey +
    stampDuty etc etc
    All
    the
    values
    have been calculated BUT "stampDuty" goes into the calculation total as
    zero
    Notice
    that stampDuty is a different color this must be
    significant???

    monalesa9876 wrote:
    else if (invalue >= STAMP3S && invalue <= STAMP3E) {
    NSLog(@"Greater than 250,000 and leass than 500,000 StampDuty           3%%");
    [lblIntrest setText:[NSString stringWithFormat:@"Stamp Duty:          %@", [currencyStyle stringFromNumber:stampN3]]];
    NSLog(@"Prints StampDuty value %@ ", [noStyleFormatter stringFromNumber: stampN3]);
    NSLog(@"Prints Purchase Price %.0f", invalue);
    NSLog(@"Prints stamp duty %@ ", stampDuty); // stampDuty #1
    NSNumber *stampDuty = [stampN3 retain]; // stampDuty #2
    // at this point stampDuty seems to have a value but looses it on exit
    // Which stampDuty? #1 or #2
    calculation
    float Beven = (invalue + SaleP + survey + stampDuty etc etc </div>
    Please, no "etc". You need to post more of this code is anyone is going to be able to figure anything out.
    Please, post it between two lines of:
    Don't use any other method.
    You have two variables with the name "stampDuty". Your compiler must be issuing a warning about this. Even if the compiler isn't issuing a warning for some reason, I am!
    <div class="jive-quote">Notice that stampDuty is a different color this must be significant???
    Color has no significance. You must post more code.

  • Static Variable Life Span

    Hi,
    I am trying to cache some data in to a static hashtable variable from database. But when I run my test program twice in dos window, I do not see that static variable's value. Do static variables are lost if the program exits?
    How can I keep a static variable keep its value? (may be using a infinite thread loop keep program alive)
    Any Ideas, suggestions. Thanks in advance

    if you run it twice in a dos window if you do that in the same window that means your first run has finished. And that your Object doesn't exist anymore in the memory.
    Static Variables are accessible as long as you stay within the same JVM and as long as the application where those static variables are created still exists...
    Then program X stops, all the static variables from program X won't be alive anymore in the JVM.
    Stronger is that is the only program running in the JVM then i believe the JVM is exited to.
    greetings

  • Modifying static variable in 1object dosent effect value in another object

    Hi,
    I have a simple class that declares a static variable x...
    class DeclareStatic
         static int x = 10;
    }I have another class that modifies this static variable (x)...
    class ModifyStatic
         public static void main(String[] Args)
              DeclareStatic.x = 20;
    }The problem I have is when I run the next class to simply print out the static variable x, I get 10 (the originally assigned value), not 20 (the modified value)...
    class StaticTest
         public static void main(String[] Args)
              System.out.println(DeclareStatic.x);
    }It is my understanding that by definition of being static, there is only 1 copy of this static variable(x), shared amongst all objects. Therefore, when I attempt to modify this value with a direct reference (DeclareStatic.x =20;), why isn't the change refelected in other classes which access the variable?
    This also leads to the question how DO I modify a (non final) static variable from an object and have the change reflected in all other objects?
    I have spent some time researching this on-line and in my java books to no avail, any help is greatly appreciated as I am studying to sit the SCJP and attention to detail is everything!
    Thanks,
    Alan Kilbride ;o)

    Hi,
    I have a simple class that declares a static variable
    x...
    class DeclareStatic
         static int x = 10;
    }I have another class that modifies this static
    variable (x)...
    class ModifyStatic
         public static void main(String[] Args)
              DeclareStatic.x = 20;
    }The problem I have is when I run the next class to
    simply print out the static variable x, I get 10 (the
    originally assigned value), not 20 (the modified
    value)...
    class StaticTest
         public static void main(String[] Args)
              System.out.println(DeclareStatic.x);
    }It is my understanding that by definition of being
    static, there is only 1 copy of this static
    variable(x), shared amongst all objects. Therefore,
    when I attempt to modify this value with a direct
    reference (DeclareStatic.x =20;), why isn't the
    change refelected in other classes which access the
    variable?Because your test code never makes a reference to the ModifyStatic class. You could delete ModifyStatic from your system and the code would run exactly the same.
    Jim S.

  • How to give different value to a static variable???

    Hi all:
    Is there any solution to set different values to a static variable???I had try two ways but all have errors!
    1.Way_1
    protected String tmp=null;
    protected void initSituation(int sayorpress)
    if (sayorpress==0)
    tmp = "string1";
    else if (sayorpress==1)
    tmp = "string2";
    protected static String RESOURCE_STRING = tmp; <---error
    Error:non-static variable tmp cannot be referenced from a static context
    2.Way_2
    protected void initSituation(int sayorpress)
    if (sayorpress==0)
    protected static String RESOURCE_STRING = "string1"; <---error
    else if (sayorpress==1)
    protected static String RESOURCE_STRING = "string2"; <---error
    Error:illegal start of expression at
    not an expression statement at
    Thank you very mich!!!

    Try this:
    protected static String RESOURCE_STRING = null;
    protected void initSituation(int sayorpress)
    if (sayorpress==0)
    yourClass.RESOURCE_STRING = "string1";
    else if (sayorpress==1)
    yourClass.RESOURCE_STRING = "string2";
    You cannot declare a static variable inside a method. But you can access a static variable thorugh your class.

  • Value of x , static variable..

    In the method callMe() i am returning x , which is 0, that gets assigned to x in main(the same static variable), then i am incrementing x. But the value of x is 0.
    Whats happening.
    public class TestClass {
         static int x=0;
         static int callMe(){
              return x++;
         public static void main(String[] args) {
              x = callMe();
              System.out.print("x= "+ x);
    }

    In the method callMe() i am returning x , which is 0,
    that gets assigned to x in main(the same static
    variable), then i am incrementing x. But the value of
    x is 0.
    Whats happening.
    public class TestClass {
         static int x=0;
         static int callMe(){
              return x++;
         public static void main(String[] args) {
              x = callMe();
              System.out.print("x= "+ x);
    syntax subtletly... i++ and ++i both do the same thing : increment 'i', but...
    i++ // value : i BEFORE incrementation
    ++i // value : i AFTER incrementationabundantly documented and answered on this forum, next time, use the search button ;-)
    hth

  • How to load value to a static variable on the run

    hi all
    i have a question about static variable. i need to have a variable to keep a value from DB shared by all instances. the variable is given value when the first instance is created. but from time to time, the value in DB may change, but i still need to maintain this shared value among instances. the static variable has life time as long as the program runs, does that mean if i need to change the value, i need to stop the program, and restart to load the new value? thanks.

    can the static variable be accessed within a
    non-static method, for instance, set the value by
    setXXX() method?Yes, and oddly enough, that usually how I access all my variables...
    Example...
    public class StaticTester {
           static String theString = " My Message ";
           public void setMessage(String mess){
                      theString = mess;
           public String getMessage(){
                      return theString;
           public static void main(String[] theArgs){
                      StaticTester myTest = new StaticTester();
                    System.out.println(myTest.getMessage());
                    myTest.setMessage(" a New Message ");
                 System.out.println(myTest.getMessage());
    }Hope this helps...
    - MaxxDmg...
    - ' He who never sleeps... '

  • Static variable for debugging mode?

    Hello I want to have a debugging mode for my application...
    Its jsp, servlets..
    If I have one static variable String called debug and set it to true then it should print all System.out. stuff in application... otherwise it shlould not...
    Do I have ot have this static variable defined in every jsp and servlet?

    try something like this
    public Class AppControl{
    public static boolean debugMode;
    public static void setDebugMode(boolean flag){
    this.debugMode = flag;
    public static boolean ifDebug(){
    return this.debugMode;
    In your JSP just do
    if (AppControl.isDebug()) {
    //print debug
    }

  • Cannot get to debugger when Debug As - Junit Test in OEPE

    In Oracle Enterprise Pack for Eclipse, I created a JUnit (3 or 4) test case. When I attempted to Debug As -> Junit Test, I would get NullPointerException and cannot get to the debugger at all. However, there is no such problem in Ganymede (not OEPE). Is this a known problem for OEPE?
    The stack trace is:
    junit.framework.AssertionFailedError: Exception in constructor: testMapCustomer (org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
         at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
         at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
         at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
         at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
         at org.springframework.test.ConditionalTestCase.<init>(ConditionalTestCase.java:50)
         at org.springframework.test.AbstractSpringContextTests.<init>(AbstractSpringContextTests.java:73)
         at org.springframework.test.AbstractSingleSpringContextTests.<init>(AbstractSingleSpringContextTests.java:80)
         at org.springframework.test.AbstractDependencyInjectionSpringContextTests.<init>(AbstractDependencyInjectionSpringContextTests.java:98)
         at com.cibc.wmfxr.pricing.processor.test.Junit38SybaseDaoTest.<init>(Junit38SybaseDaoTest.java:6)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
         at junit.framework.TestSuite.createTest(TestSuite.java:54)
         at junit.framework.TestSuite.addTestMethod(TestSuite.java:280)
         at junit.framework.TestSuite.<init>(TestSuite.java:140)
         at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.getTest(JUnit3TestLoader.java:102)
         at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.loadTests(JUnit3TestLoader.java:59)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
         at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
         at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
         ... 21 more
    Caused by: java.lang.NullPointerException
         at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
         at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
         at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
         at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
         at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
         at org.springframework.test.ConditionalTestCase.<init>(ConditionalTestCase.java:50)
         at org.springframework.test.AbstractSpringContextTests.<init>(AbstractSpringContextTests.java:74)
         at org.springframework.test.AbstractSingleSpringContextTests.<init>(AbstractSingleSpringContextTests.java:80)
         at org.springframework.test.AbstractDependencyInjectionSpringContextTests.<init>(AbstractDependencyInjectionSpringContextTests.java:98)
         at com.cibc.wmfxr.pricing.processor.test.Junit38SybaseDaoTest.<init>(Junit38SybaseDaoTest.java:6)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
         at junit.framework.TestSuite.createTest(TestSuite.java:54)
         at junit.framework.TestSuite.addTestMethod(TestSuite.java:280)
         at junit.framework.TestSuite.<init>(TestSuite.java:140)
         at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.getTest(JUnit3TestLoader.java:102)
         at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.loadTests(JUnit3TestLoader.java:59)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:674)
         ... 2 more
         at junit.framework.Assert.fail(Assert.java:47)
         at junit.framework.TestSuite$1.runTest(TestSuite.java:90)
         at junit.framework.TestCase.runBare(TestCase.java:130)
         at junit.framework.TestResult$1.protect(TestResult.java:106)
         at junit.framework.TestResult.runProtected(TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:120)
         at junit.framework.TestSuite.runTest(TestSuite.java:230)
         at junit.framework.TestSuite.run(TestSuite.java:225)
         at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
         at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

    Thanks. I tried it with the downloaded junit-4.6.jar and got the following stack trace. Now I wonder I should try it with the Junit bundle in the SpringSource Enterprise Bundle Repository since OEPE integrates the Spring OSGi Bundle. If this is the right idea, could you let me know how to install the Junit bundle in OEPE? Do I just add it to bundles.info? There are already a few lines for org.junit in bundles.info. What should I do with them? Thanks a lot.
    java.lang.ExceptionInInitializerError
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
         at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
         at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
         at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
         at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
         at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
         at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
         at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:28)
         at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:24)
         at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:40)
         at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:30)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
         at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
         at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
         at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
         at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
         at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<clinit>(SpringJUnit4ClassRunner.java:63)
         ... 18 more
    Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
         at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
         at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
         ... 22 more
    Caused by: java.lang.NullPointerException
         at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
         ... 23 more

  • Problems Debugging JUnit Tests

    Hi,
    I have been trying a TDD approach to my new development and until my latest test everythings been working well. Im using Eclipse by the way with JUnit incoporated into my project
    Now I have the following problem..
    I ran my latest test and my CPU usage shot up to 100%. In an attempt to work out why I selected Debug as JUnit Project, the following was displayed
    Class File Editor
    The Source attachment does not contain the source for the file Assert.class
    You can change the source attachment by clicking change attached source below.
    Unfortunately I don't know what this means, can anyone help me out here?
    Thanks

    I don't have access to any other IDE's apart from Eclipse, so I can't check if they run outside.You don't need an IDE to run outside Eclipse. Just run JUnit from a command shell, just like any other Java program that you'd run if you didn't have ANY IDE.
    Whats Ant? I presume i'm not using it.Ant is an XML and Java-based make tool that's a standard for Java these days:
    http://ant.apache.org
    It can run all your JUnit tests as part of your build process. It'll even work with Eclipse.
    Its my last test thats causing it not to work however
    it never even returns a failure it hangs the system
    before the failure is reported. If I remove this test
    and debug the other tests however the same error
    described in the first post occurs.Can you step through that JUnit test in the Eclipse debugger to see where it's hanging up? If you're going to use an IDE, might as well put it to work.

  • Junit test with debugging

    Hi All,
    I have my project souce with adding System.out.println statement and bundle it into jar file.
    When i running junit test . I cant see project source's println statement.
    Any properties file need to be modify to see println statement?
    Thanks,
    Nil

    How are you running JUnit? Logging to System.out will appear on the standard output stream, which is the console unless you explicitly redirect it.

  • Static Variable in webapplication

    Are the values of static variables preserved when two different users try and access them? i.e.
    If one web application user sitting in Chicago sets a static variable to 'true' from 'false'. Will the other user sitting in Omaha see it as 'true' or 'false' in his session?

    Alright, I did this test.
    1) On my local tomcat I created a mini webapp where I
    declared a static which populates from a form field.
    static String displayname = "";
    displayname = request.getParameter("username");
    and then displayed it on the html page.
    2) I opened IE sessions of my application and in one
    I gave the user name 'Tom' and other 'Janet' and hit
    continue. (Tom before Janet)
    3) The page that had 'Tom' displayed tom and other
    one Janet. Then I refreshed the display page for the
    tom instance and it still showed 'Tom'.
    Conclusion: It appears that the statics are indeed
    loyal to the class loader and not the JVM. Hence, for
    multiple users each instance should have its own
    static.
    Please let me know if you disagree or see my test to
    be wrong.
    Thanks
    Message was edited by:
    Birthdayhitting the refesh button on your IE page doesn't show you what the value of the static variable in your web app is. You're headding for trouble.
    EDIT: Ok well it depends on you implementation how the refresh will work, but if you have a static fields in a class on your web server I promise you it's not in any way associated with any session.

  • Error while executing customer Exit Variable (No value could be determined for variable.  BRAIN 632)

    Hello,
    I created a customer exit variable which has to show the range between the first and last day of the previous month. The query will be executed every first of the month.
    Variable is declared as: Customer exit, based on 0CALDAY, Interval, Mandatory and NOT input.
    When i debug the query, it is making the calculation but its not populating my variable; when I execute the query from RSRT, the output test shows a message:
    ENo value could be determined for variable ZRANGE_PREVMONTH.                            BRAIN               632ZRANGE_PREVMONTH
    Below the code i'm using (SAP 7.4)
    ***Customer Exit to calculate previous month.
    IF i_step = 2.
         CASE i_vnam.
              WHEN 'ZRANGE_PREVMONTH'.
    DATA:  LS_RA_SID  TYPE   RSR_S_RANGESID.
    DATA:  yyyy(4) TYPE n.
    DATA:  mm(2) TYPE n.
    DATA:  dd(2) TYPE n.
    DATA:  fst_date LIKE sy-datum.
    DATA:  fst_date2 LIKE sy-datum.
    LOOP AT i_t_var_range_c INTO loc_var_range
        WHERE vnam = '0DAT'.
          dd = sy-datum+6(2).
          mm = sy-datum+4(2).
          yyyy = sy-datum+0(4).
          fst_date2 = sy-datum.
          IF dd = '01' AND mm = '01'.
            mm = '12'.
            yyyy = yyyy - 1.
          ELSEIF dd = '01' AND mm <> '01'.
            mm = mm - 1.
          ELSEIF dd <> '01'.
            mm = mm - 1.
          ENDIF.
          CLEAR: fst_date.
          CONCATENATE yyyy mm '01' INTO fst_date.
          fst_date2 = fst_date2 - 1.
          CLEAR: ls_ra_sid.
          ls_ra_sid-sign = 'I'.
          ls_ra_sid-opt = 'BT'.
          ls_ra_sid-high = fst_date2.
          ls_ra_sid-low = fst_date.
          APPEND ls_ra_sid TO e_t_range.
    ENDLOOP.
    ENDCASE.
       ENDIF.

    Hi Fernanda,
    Try this:
    DATA:  LS_RA_SID  TYPE   RSR_S_RANGESID.
    DATA:  fst_date LIKE sy-datum.
       CASE i_vnam.
              WHEN 'ZRANGE_PREVMONTH'.
    fst_date = sy-datum - 1.
    concatenate fst_date(6) '01' into ls_ra_sid-low.
          ls_ra_sid-sign = 'I'.
          ls_ra_sid-opt = 'BT'.
          ls_ra_sid-high = fst_date.
          APPEND ls_ra_sid TO e_t_range.
    ENDLOOP.
    ENDCASE.
       ENDIF.
    Just post here for any queries..
    Regards,
    Loed

  • Is static variable serialized ???

    hi
    I have a static integer memeber of a serializable class. When I serialize and then deserialize this object into another object I am getting the lastest value of this variable. It looks like the variable is being serialized.
    but i have read that static variables are not serialized.
    can anyone clarify why i m getting the latest (updated) value??

    This is not a good test. Once a class is loaded it remains loaded and all its static fields remain set with any values assign to them.
    Try this instead:import java.io.*;
    public class Ser implements Serializable {
        static int var = 9;
        void set() {
            var = 100;
    public class DumpSer {
        public static void main(String[] args) throws Exception {
            Ser kk = new Ser();
            kk.set();
            File outFile = new File("out.dmp");
            ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(outFile));
            out.writeObject(kk);
            out.close();
    public class LoadSer {
        public static void main(String[] args) throws Exception {
            File inFile = new File("out.dmp");
            ObjectInputStream in = new ObjectInputStream(new FileInputStream(inFile));
            Ser jj = (Ser)in.readObject();
            in.close();
            System.out.println("Val -> "+jj.var);
    }After compilation, first execute:
    > java DumpSer
    Then execute:
    > java LoadSer
    What do you see?

  • Concurrent access to a static variable

    I think that I need a static lock to protect a static variable. However, the code below seems to be running fine on a 24-CPU machine.
    public class test {
    public static void main(String[] args)
      new Thread(new myclass()).start();
      new Thread(new myclass()).start();
    class myclass implements Runnable {
    private static int msgid;
    private Object lock = new Object();
    public void run()
       synchronized(lock) {
       int i=200000;
       while(i-- >0) {
       msgid = msgid+1;
       System.out.println("Thread " + Thread.currentThread().getName() + "value => "
    + msgid);
    }This testcode is roughly based on my actual program. I have a code (written by someone else) which protects the static msgid with an instance-level lock. IMHO , this shouldn't stop the multithreaded access to the msgId because two threads will have two different instances of the lock. However, I can't reproduce this on a 24-CPU machine. I know the MT-related bugs are hard to reproduce. So I just thought of confirming it with the experts. In my opinion, lock object should be :
    private static Object lock = new Object();
    Anyone against this thought?

    Yes I see the code and I can see the "msgid" can be updated by both threads randomly behaved as per CPU time slicing for each thread.
    like ThreadOne msgId-->10
    ThreadTwo msgId-->11
    ThreadTwo msgId--->12
    ThreadOne msgId -->13
    etc..
    What do you want to achieve if you use a common resource to lock in order to prevent the msgId to be incremented by two thread at the same time but rather by one thread at a time?
    Regards,
    Alan Mehio

Maybe you are looking for

  • Store a double into a variable of type int

    if I have a calculated value of type "double", and I would like to store it as an "int" in a variable of type "int". when i casted the double to int, seems it doesn't work. what should the command be? Thanks in advance!

  • Two desktop computers - one constantly looses wireless connection

    Hi, I have a Linksys Wireless-G Broadband Router with Speedbooster (model WRT54GS) for use with a cable modem.  I have two Dell Desktops, both with Linksys Wireless-G PCI with SpeedBooster Cards.  One desktop works perfect with the network, the other

  • Movie Will Not Upload Help

    I took one of my dvds and was able to convert it to the mp4 format to put it onto my ipod. Once I clicked on update it said that it could not be updated to my ipod because it could not play on it. What does this mean? Do I need to convert now through

  • The volume "Music" cannot be found! Help how do I fix this??

    Hello, I was a happy macbook user living in Hong Kong until the my Macbook hard drive suddenly made clanking noises and failed. I had my computer serviced by CASE and they replaced the hard drive, but took a month and two weeks do it. Now I finally h

  • How to create a ClobDomain object with a default's different charset.

    Hi, I'm developing a 10.1.3. ADF Faces application that need to upload a File to a CLOB column. The user will usually upload a text file CP1252 charset, but in samples like this: // read data into a character array char[] data = {'0','1','2','3','4',