Private / final / compiler optimization

i have read that:
defining methods / properties to be final helps that compiler to optimize performance.
however:
it does not make logical sense to declare private or protected methods as final .
and so the compiler ignores it, right?

kappa9h wrote:
i have read that:
defining methods / properties to be final helps that compiler to optimize performance.by properties, if you're talking about getter / setter methods that's one thing. If you're just talking about member/class data structures, then definitely not. Even in the first case, I do see why that would result in any performance gain.
Long and the short of this is that you should use final when you don't want the method / class to be overridden. Performance gains from making a method final are going to be minimal or zero
>
however:
it does not make logical sense to declare private or protected methods as final .
and so the compiler ignores it, right?

Similar Messages

  • What does this  assignment op. do? private final List X x = ...;

    I saw an example of this in Joshua Bloch's Effective Java 2nd edition:
    Item 43 P201/202
    private final List<Cheese> cheesesInStock = ...;
    What do the three dots signify here. I've only seen it in the vararg scenario before.

    JGF wrote:
    I think there is more to it than that. :)There isn't. In cases where it is not immediately obvious that the '...' symbol refers to varargs, interpret that symbol to mean "some more code that isn't relevant to the example". For example, read further in the example you cited from page #201, and you will see the following:
    public Cheese[] getCheeses() {
        if (cheesesInStock.size() == 0)
            return null;
    }Note the '...' symbol in the line after the if statement. That won't compile, and isn't intended to. Nor is it a mistake on the author's part. It's simply to let you know that there is some code that returns some array of the Cheese type, but it's not important to the example. Most importantly, note this passage from the introduction (page 3):
    The examples are reasonably complete, but they favor readability over completeness... [Boilerplate] is similarly omitted
    ~

  • Private final method

    When can we use private final method. Could you please give some detail explanation
    Thanks

    Did you look at the output? No, I did never execute the code, and I didn't even
    look at the code that much (as you can see from my
    previous post)Sorry. I was posting while you were continuing to reply.
    I found that if I put this in B I get a compile error.
    public static void main(String[] args){
        A b = new B();
        System.out.println(b);
        System.out.println(b.isFoo());//this surprises me
    A.java:27: isFoo() has private access in A
        System.out.println(b.isFoo());//this surprises meWhich is still puzzling to me somehow. What happened to B isFoo in this case? I didn't think that referencing by the supertype would have worked like this.

  • In-Place Element Structures, References and Pointers, Compiler Optimization, and General Stupidity

    [The title of this forum is "Labview Ideas". Although this is NOT a direct suggestion for a change or addition to Labview, it seems appropriate to me to post it in this forum.]
    In-Place Element Structures, References and Pointers, Compiler Optimization, and General Stupidity
    I'd like to see NI actually start a round-table discussion about VI references, Data Value references, local variables, compiler optimizations, etc. I'm a C programmer; I'm used to pointers. They are simple, functional, and well defined. If you know the data type of an object and have a pointer to it, you have the object. I am used to compilers that optimize without the user having to go to weird lengths to arrange it. 
    The 'reference' you get when you right click and "Create Reference" on a control or indicator seems to be merely a shorthand read/write version of the Value property that can't be wired into a flow-of-control (like the error wire) and so causes synchronization issues and race conditions. I try not to use local variables.
    I use references a lot like C pointers; I pass items to SubVIs using references. But the use of references (as compared to C pointers) is really limited, and the implementation is insconsistent, not factorial in capabilites, and buggy. For instance, why can you pass an array by reference and NOT be able to determine the size of the array EXCEPT by dereferencing it and using the "Size Array" VI? I can even get references for all array elements; but I don't know how many there are...! Since arrays are represented internally in Labview as handles, and consist of basically a C-style pointer to the data, and array sizing information, why is the array handle opaque? Why doesn't the reference include operators to look at the referenced handle without instantiating a copy of the array? Why isn't there a "Size Array From Reference" VI in the library that doesn't instantiate a copy of the array locally, but just looks at the array handle?
    Data Value references seem to have been invented solely for the "In-Place Element Structure". Having to write the code to obtain the Data Value Reference before using the In-Place Element Structure simply points out how different a Labview reference is from a C pointer. The Labview help page for Data Value References simply says "Creates a reference to data that you can use to transfer and access the data in a serialized way.".  I've had programmers ask me if this means that the data must be accessed sequentially (serially)...!!!  What exactly does that mean? For those of use who can read between the lines, it means that Labview obtains a semaphore protecting the data references so that only one thread can modify it at a time. Is that the only reason for Data Value References? To provide something that implements the semaphore???
    The In-Place Element Structure talks about minimizing copying of data and compiler optimization. Those kind of optimizations are built in to the compiler in virtually every other language... with no special 'construct' needing to be placed around the code to identify that it can be performed without a local copy. Are you telling me that the Labview compiler is so stupid that it can't identify certain code threads as needing to be single-threaded when optimizing? That the USER has to wrap the code in semaphores before the compiler can figure out it should optimize??? That the compiler cannot implement single threading of parts of the user's code to improve execution efficiency?
    Instead of depending on the user base to send in suggestions one-at-a-time it would be nice if NI would actually host discussions aimed at coming up with a coherent and comprehensive way to handle pointers/references/optimization etc. One of the reasons Labview is so scattered is because individual ideas are evaluated and included without any group discussion about the total environment. How about a MODERATED group, available by invitation only (based on NI interactions with users in person, via support, and on the web) to try and get discussions about Labview evolution going?
    Based solely on the number of Labview bugs I've encountered and reported, I'd guess this has never been done, with the user community, or within NI itself.....

    Here are some articles that can help provide some insights into LabVIEW programming and the LabVIEW compiler. They are both interesting and recommended reading for all intermediate-to-advanced LabVIEW programmers.
    NI LabVIEW Compiler: Under the Hood
    VI Memory Usage
    The second article is a little out-of-date, as it doesn't discuss some of the newer technologies available such as the In-Place Element Structure you were referring to. However, many of the general concepts still apply. Some general notes from your post:
    1. I think part of your confusion is that you are trying to use control references and local variables like you would use variables in a C program. This is not a good analogy. Control references are references to user interface controls, and should almost always be used to control the behavior and appearance of those controls, not to store or transmit data like a pointer. LabVIEW is a dataflow language. Data is intended to be stored or transmitted through wires in most cases, not in references. It is admittedly difficult to make this transition for some text-based programmers. Programming efficiently in LabVIEW sometimes requires a different mindset.
    2. The LabVIEW compiler, while by no means perfect, is a complicated, feature-rich set of machinery that includes a large and growing set of optimizations. Many of these are described in the first link I posted. This includes optimizations you'd find in many programming environments, such as dead code elimination, inlining, and constant folding. One optimization in particular is called inplaceness, which is where LabVIEW determines when buffers can be reused. Contrary to your statement, the In-Place Element Structure is not always required for this optimization to take place. There are many circumstances (dating back years before the IPE structure) where LabVIEW can determine inplaceness and reuse buffers. The IPE structure simply helps users enforce inplaceness in some situations where it's not clear enough on the diagram for the LabVIEW compiler to make that determination.
    The more you learn about programming in LabVIEW, the more you realize that inplaceness itself is the closest analogy to pointers in C, not control references or data references or other such things. Those features have their place, but core, fundamental LabVIEW programming does not require them.
    Jarrod S.
    National Instruments

  • Discussion: private final static vs public final static

    take following class variable:public final static int constant = 1;Is there any harm in making this variable public if it's not used (and never will be) in any other class?
    Under the same assumption Is there any point in making this variable static?
    tx for your input

    Is there any harm in making this variablepublic
    if it's not used (and never will
    be) in any other class?Harm? No. Use? Neither.I suppose it makes no difference at all concerning
    runtime performance?
    Under the same assumption Is there any point inmaking this variable
    static?If the creation of the constant is costly, for
    instance. A logger is private final static most of
    the time.Same here, does making a variable final or static
    have any influence on runtime performance?No. And for 'expensive' operations (say, parsing a XML configuration file, which only needs to occur once), making a variable static will improve performance.
    - Saish

  • Declaring a datamember  as  private final

    Hi,
    private final String text;
    In the above line whats the use of declaring the variable as private and final?
    If its private cannot subclassed and if its final cannot be changed.
    If I give with out assigning value,what will happen. Please refer following code snap.
    What is the use of using private and final with out assign valued as data member?
    If its final .how will it get changed ?
    13 private final String text;
    14.               private final String name;
    15.     
    16.               //Also make default parameters
    17.               private int cols = 20;
    18.               private int rows = 5;
    19.               private String align = "left";
    20.     
    21.               public Builder(String name, String text) {
    22.                    this.text = text;
    23.                    this.name = name;
    24.               }

    Could you say what will be the value for the final fields in the below example,where I am setting values to the
    final field text in its constructor,I checked the value of this, are null.First value of the blank final is null then it
    getting value assigned from the Constructor,My question is "Is Final is get Assigned second time or null value
    is not considered as assignment".
    public class Builder {
              //Required field
              private final String text;
              private final String name;
              public Builder(){
                   System.out.println("Text :: "+this.text);
                   System.out.println("Name :: "+this.name);
                   text = new Date().toString().substring(2,4);
                   this.name = "";
                   System.out.println("Text :: "+this.text);
                   System.out.println("Name :: "+this.name);
              public Builder(String name, String text) {
                   this.text = text;
                   this.name = name;
    Class Test
    public static void main(String[] arg)
    Builder b= new Builder();
    O/p
    Text :: null
    Name :: null
    Text :: u
    Name ::

  • Intel Core Duo 1.83GHz compiler optimization / makefile help

    Hi,
    I have a C listing which was originally written with unix or Windows in mind, I wonder if anyone could help me to compile it on my Intel iMac 17inch. It's a small benchmarking program so compiler optimization is important - is this possible on an Intel Core Duo (I don't expect to include threading) using XCode or gcc?
    I'm not a programmer, the original programmer does not know anything about Macs or OS X, however I would like to use this program to effectively benchmark my machine. Currently the program will not compile using the makefile I have, I can run code compiled on a G4 but it runs slow and gives a false result.
    Here's my makefile:
    obj = c-ray-f.o
    bin = c-ray-f
    CC = gcc
    CFLAGS = -O3 -ffast-math
    $(bin): $(obj)
    $(CC) -o $@ $(obj) -lm
    .PHONY: clean
    clean:
    rm -f $(obj) $(bin)
    I do not really understand what any of that lot does, nor can I get my head around compiler options (I tried looking, but found nothing that made any sense to me!)
    Any help would really really be appreciated!

    Change all the -
    #include <GL/glut.h>
    to
    #include <GLUT/glut.h>
    and
    if ( (!((*x)>=min)) || _isnan(*x) ) { // Other compilers may use "isnan" instead of "_isnan"
    to
    if ( (!((*x)>=min)) || isnan(*x) ) { // Other compilers may use "isnan" instead of "_isnan"
    Then run this script in directory RayTraceKd to build RayTraceKd -
    [dranta:~/RayTrace/RayTrace_3.2/RayTraceKd] dir% cat build
    cd ../VrMath
    g++ -O2 -fpermissive -c *.cpp
    cd ../DataStructs
    g++ -O2 -fpermissive -c *.cpp
    cd ../Graphics
    g++ -O2 -fpermissive -c *.cpp
    cd ../OpenglRender
    g++ -O2 -fpermissive -c *.cpp
    cd ../RaytraceMgr
    g++ -O2 -fpermissive -c *.cpp
    cd ../RayTraceKd
    g++ -O2 -fpermissive -c *.cpp
    g++ -o RayTraceKd -bindatload -framework GLUT -fpermissive *.o ../VrMath/*.o ../DataStructs/*.o ../Graphics/*.o ../OpenglRender/*.o ../RaytraceMgr/*.o -L/usr/X11R6/lib -lgl -lglu

  • "private final" vs. private

    hi,
    I'm sure that this question has been dealt with before in here, but I was unable to find anything via the search.
    Basically, is there a point to making a method both private and final instead of just private?
    What about with a member of a class?
    final is supposed to in-line the code.
    Does private on its own do this too?
    I'd be interested in people's knowledge on this matter.
    thanks,
    Alan

    final variables means that you can only assign them once ...
    If you add static, then the variable is shared between the objects...Unfortunatly I think this is not completely right. I do not know why, but when you define a static final constant it's value is somehow obtained at compile time, not sharing it. If later you modify the constant value, the old classes using it should be recompiled, or they will still get the old value, while new classes will get the new value.
    This, to my understanding, means that the constant is not being shared among classes.
    Although a constant should remain invariable in time, have you never had the need to change a constant defined in an interface?

  • Compiler Optimization

    Author: semorri_ Sep 27, 2004 1:18 PM
    One "feature" of the Java compiler is the lack of optimization. For example, this code:
    int x = 10;
    int y = 20;
    int z = x + y;
    compiles into bytecodes that execute literally, meaning 10 is pushed on the stack, stored in local var 0, etc. A good C compiler would optimize this code (assuming x and y are not used elsewhere in the method) to simply store 30 in local var z.
    I have been told that the compiler does not optimize such code because then the JIT compiler can most efficiently optimize depending on the hardware platform.
    My question is: is there a way to get the standard compiler to do a more efficient job of optimizing the bytecodes? Are there compilers out there that will?

    Don't you just hate it when people assume that a
    simplified example to illustrate a point is taken
    directly from actual code?Please point to where anyone says the example appears to be taken from actual code...
    Anyway, that is beside the point and does not change the fact that your post seems to imply that the compiler ought to compensate for poor design / coding skills
    (because you failed to tell us why you wanted "full" optimization).
    I have been told that the compiler does not optimize
    such code because then the JIT compiler can most
    efficiently optimize depending on the hardware
    platform.The JIT compiler might very well become bloatware if it had to cater for every imaginable bytecode sequence.
    It is quite possible that "hand optimized" bytecode would leave the JIT compiler clueless.
    Unless you planned to run with the JIT compiler disabled (for whatever reason) this is not going to help performance.
    If you plan to make a hardware implementation, similar considerations to those that apply to the JIT compiler will most likely apply to your pipeline prediction logic.
    My question is: is there a way to get the standard
    compiler to do a more efficient job of optimizing the
    bytecodes? Are there compilers out there that will?There are other Java compilers. There are also Java bytecode assemblers. Google is your friend.
    It is possible that you could get ideas from C optimizer logic and implement post-processing of class files (or pre-processing of bytecode).

  • Compiler optimization in C++ much worse than in C on x86

    Hello everybody!
    I noticed something really ugly.
    If you have a small code fragment like this:
    #define MATRIX_SIZE 1000
    int Mat_x_Mat_transposed_C( double **c, double **a, double **b ) {
      int i, j, k;
      memset( *c, 0, MATRIX_SIZE*MATRIX_SIZE*sizeof(double) );
      for( i=0; i<MATRIX_SIZE; i++ )
        for( j=0; j<MATRIX_SIZE; j++ )
          for( k=0; k<MATRIX_SIZE; k++ )
            c[i][j]   += a[i][k] * b[j][k];
      return 0;
    }and compile it under CC and cc, you get completely different execution times!!!
    Using for both tests:
    CC -fast
    cc -fast
    you get for the innermost loop from the C compiler:
            movsd      (%ebx),%xmm1                         ;/ line : 138
            mulsd      (%edx),%xmm1                         ;/ line : 138
            addsd      %xmm1,%xmm0                          ;/ line : 138
            movsd      %xmm0,(%esi)                         ;/ line : 138
            movsd      8(%ebx),%xmm1                                ;/ line : 138
            mulsd      8(%edx),%xmm1                                ;/ line : 138
            addsd      %xmm1,%xmm0                          ;/ line : 138
            movsd      %xmm0,(%esi)                         ;/ line : 138
            movsd      16(%ebx),%xmm1                               ;/ line : 138
            mulsd      16(%edx),%xmm1                               ;/ line : 138
            addsd      %xmm1,%xmm0                          ;/ line : 138
            movsd      %xmm0,(%esi)                         ;/ line : 138
            movsd      24(%ebx),%xmm1                               ;/ line : 138
            mulsd      24(%edx),%xmm1                               ;/ line : 138
            addsd      %xmm1,%xmm0                          ;/ line : 138
            movsd      %xmm0,(%esi)                         ;/ line : 138
            movsd      32(%ebx),%xmm1                               ;/ line : 138
            mulsd      32(%edx),%xmm1                               ;/ line : 138
            addsd      %xmm1,%xmm0                          ;/ line : 138
            movsd      %xmm0,(%esi)                         ;/ line : 138
            movsd      40(%ebx),%xmm1                               ;/ line : 138
            mulsd      40(%edx),%xmm1                               ;/ line : 138
            addsd      %xmm1,%xmm0                          ;/ line : 138
            movsd      %xmm0,(%esi)                         ;/ line : 138
            addl       $48,%ebx                             ;/ line : 137
            addl       $48,%edx                             ;/ line : 137
            addl       $6,%eax                              ;/ line : 137
    .LU24.444:
            cmpl       $994,%eax                            ;/ line : 137
            jle        .CG28.52                             ;/ line : 137which is quite nice in loop unrolling and eliminating all references to local variables, no references to
    %ebp etc.
    (safing %xmm0 every time is another thing, but g++ is doing this also ;)
    If you use C++ you get something like this:
            movl       -28(%ebp),%eax                               ;/ line : 110
            movl       (%eax),%eax                          ;/ line : 110
            addl       %ebx,%eax                            ;/ line : 110
            movl       (%edx),%edi                          ;/ line : 110
            movsd      (%edi,%esi),%xmm0                            ;/ line : 110
            movl       (%ecx),%edi                          ;/ line : 110
            mulsd      (%edi,%esi),%xmm0                            ;/ line : 110
            addsd      (%eax),%xmm0                         ;/ line : 110
            movsd      %xmm0,(%eax)                         ;/ line : 110
            movl       -28(%ebp),%eax                               ;/ line : 110
            movl       (%eax),%eax                          ;/ line : 110
            addl       %ebx,%eax                            ;/ line : 110
            movl       (%edx),%edi                          ;/ line : 110
            movsd      8(%edi,%esi),%xmm0                           ;/ line : 110
            movl       (%ecx),%edi                          ;/ line : 110
            mulsd      8(%edi,%esi),%xmm0                           ;/ line : 110
            addsd      (%eax),%xmm0                         ;/ line : 110
            movsd      %xmm0,(%eax)                         ;/ line : 110
            movl       -28(%ebp),%eax                               ;/ line : 110
            movl       (%eax),%eax                          ;/ line : 110
            addl       %ebx,%eax                            ;/ line : 110
            movl       (%edx),%edi                          ;/ line : 110
            movsd      16(%edi,%esi),%xmm0                          ;/ line : 110
            movl       (%ecx),%edi                          ;/ line : 110
            mulsd      16(%edi,%esi),%xmm0                          ;/ line : 110
            addsd      (%eax),%xmm0                         ;/ line : 110
            movsd      %xmm0,(%eax)                         ;/ line : 110
            movl       -28(%ebp),%eax                               ;/ line : 110
            movl       (%eax),%eax                          ;/ line : 110
            addl       %ebx,%eax                            ;/ line : 110
            movl       (%edx),%edi                          ;/ line : 110
            movsd      24(%edi,%esi),%xmm0                          ;/ line : 110
            movl       (%ecx),%edi                          ;/ line : 110
            mulsd      24(%edi,%esi),%xmm0                          ;/ line : 110
            addsd      (%eax),%xmm0                         ;/ line : 110
            movsd      %xmm0,(%eax)                         ;/ line : 110
            movl       -28(%ebp),%eax                               ;/ line : 110
            movl       (%eax),%eax                          ;/ line : 110
            addl       %ebx,%eax                            ;/ line : 110
            movl       (%edx),%edi                          ;/ line : 110
            movsd      32(%edi,%esi),%xmm0                          ;/ line : 110
            movl       (%ecx),%edi                          ;/ line : 110
            mulsd      32(%edi,%esi),%xmm0                          ;/ line : 110
            addsd      (%eax),%xmm0                         ;/ line : 110
            movsd      %xmm0,(%eax)                         ;/ line : 110
            movl       -28(%ebp),%eax                               ;/ line : 110
            movl       (%eax),%eax                          ;/ line : 110
            addl       %ebx,%eax                            ;/ line : 110
            movl       (%edx),%edi                          ;/ line : 110
            movsd      40(%edi,%esi),%xmm0                          ;/ line : 110
            movl       (%ecx),%edi                          ;/ line : 110
            mulsd      40(%edi,%esi),%xmm0                          ;/ line : 110
            addsd      (%eax),%xmm0                         ;/ line : 110
            movsd      %xmm0,(%eax)                         ;/ line : 110
            addl       $48,%esi                             ;/ line : 110
            movl       -32(%ebp),%eax                               ;/ line : 110
            addl       $6,%eax                              ;/ line : 110
            movl       %eax,-32(%ebp)
    .LU4.715:
            cmpl       $994,%eax                            ;/ line : 110
            jle        .CG44.86                             ;/ line : 110Here all references are still using %ebp and there are lots of memory accesses
    to local variables in the innermost loop!
    The examples were generated using the DevPreview 01/08:
    CC: Sun C++ 5.9 SunOS_i386 2007/11/15
    cc: Sun C 5.9 SunOS_i386 2007/11/15
    Is there a way to raise the optimization level in C++ to get something comparable to the C output?
    Cheers,
    bugchucker

    Ah, yes, I think I can see your problem....
    It does not depend on either the compiler flags or the platform (as long as it can use sse2).
    I tried it on P4 and opteron.
    For the compiler flags: My favourite there is
    -fast -xtarget=opteron -m64 -xdepend -xprefetch=auto -xprefetch_level=3 -xprefetch_auto_type=indirect_array_access -xvector=lib,simd -xalias_level=simple -xrestrict=%all -g0 -xpagesize=2M
    but it does not matter in this case. You get the same with -fast.
    But first, here is the example code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include <string.h>
    #include <time.h>
    #define MATRIX_SIZE 1000
    double** NewMatrix(int r, int c)
    { int i;
      double **p;
      long int mem;
      mem = (long int) r * (long int) c;
      p    = (double**)malloc(r*sizeof(double*));
      p[0] = (double*)calloc(mem, sizeof(double));
      for (i=1;i<r;i++)
        p= p[i-1] + c;
    return p;
    int DelMatrix(double** p)
    if (p!=0){
    free(p[0]);
    free(p);
    return 0;
    int InitMatrix(double **a)
    memset( a, 0, MATRIX_SIZEMATRIX_SIZE*sizeof(double) );
    return 0;
    int CopyMatrix(double **d, double **s)
    memcpy( d, s, MATRIX_SIZE*MATRIX_SIZE*sizeof(double) );
    return 0;
    int RandomizeMatrix(double **a) {
    int i, j;
    for( i=0; i<MATRIX_SIZE; i++ )
    for( j=0; j<MATRIX_SIZE; j++ )
    a[i][j] = 100.0 * random()/RAND_MAX;
    return 0;
    int Mat_x_Mat_transposed( double **c, double **a, double **b ) {
    int i, j, k;
    InitMatrix( c );
    for( i=0; i<MATRIX_SIZE; i++ )
    for( j=0; j<MATRIX_SIZE; j++ )
    for( k=0; k<MATRIX_SIZE; k++ )
    c[i][j] += a[i][k] * b[j][k];
    return 0;
    int main() {
    clock_t t0, t1;
    double t;
    double **a, **b, **c;
    printf("Initializing Matrices...\n");
    t0 = clock();
    a = NewMatrix( MATRIX_SIZE, MATRIX_SIZE);
    b = NewMatrix( MATRIX_SIZE, MATRIX_SIZE);
    c = NewMatrix( MATRIX_SIZE, MATRIX_SIZE);
    t1 = clock();
    t = (double)( t1 - t0 ) / CLOCKS_PER_SEC;
    printf("Time for setup/s: %lf\n", t/3.0);
    RandomizeMatrix( a );
    RandomizeMatrix( b );
    printf("Starting Multiplication transposed... ( %i x %i )\n", MATRIX_SIZE, MATRIX_SIZE );
    t0 = clock();
    Mat_x_Mat_transposed( c, a, b );
    t1 = clock();
    t = (double)( t1 - t0 ) / CLOCKS_PER_SEC;
    printf("Time difference: %lf\n", t );
    And now comes the strange stuff:
    When I try this one with cc and CC the timings are ok!
    BUT: If you generate the output via CC -fast -S
    you will see, that the CC compiler generates the code for the function as I have shown
    above, BUT *inlines* the fast version as in C !!!
    It looks like this:__1cUMat_x_Mat_transposed6Fppd11_i_:
         push %ebp                    ;/ line : 70
         movl %esp,%ebp                    ;/ line : 70
         push %ebx                    ;/ line : 70
         push %esi                    ;/ line : 70
         push %edi                    ;/ line : 70
         subl $44,%esp                    ;/ line : 70
    .CG15.33:
         movl 8(%ebp),%eax                    ;/ line : 41
         movl (%eax),%eax                    ;/ line : 41
         push $8000000                    ;/ line : 41
         push $0                    ;/ line : 41
         push %eax                    ;/ line : 41
         call _memset                    ;/ line : 41
         addl $12,%esp                    ;/ line : 41
         movl 8(%ebp),%eax                    ;/ line : 77
         movl %eax,-28(%ebp)                    ;/ line : 77
         movl 12(%ebp),%edx                    ;/ line : 77
         xorl %eax,%eax                    ;/ line : 78
         movl 16(%ebp),%ecx                    ;/ line : 78
         movl %ecx,-44(%ebp)
         movl %eax,-40(%ebp)
    .CG16.34:
         xorl %eax,%eax                    ;/ line : 80
         movl -44(%ebp),%ecx                    ;/ line : 80
         xorl %ebx,%ebx                    ;/ line : 80
         movl %eax,-36(%ebp)
    .CG17.35:
    .CG2.266:
         xorl %esi,%esi                    ;/ line : 80
         xorl %eax,%eax                    ;/ line : 80
         movl %esi,-32(%ebp)
         movl %eax,%esi
    .CG1A.38:
         movl -28(%ebp),%eax                    ;/ line : 80
         movl (%eax),%eax                    ;/ line : 80
         addl %ebx,%eax                    ;/ line : 80
         movl (%edx),%edi                    ;/ line : 80
         movsd (%edi,%esi),%xmm0                    ;/ line : 80
         movl (%ecx),%edi                    ;/ line : 80
         mulsd (%edi,%esi),%xmm0                    ;/ line : 80
         addsd (%eax),%xmm0                    ;/ line : 80
         movsd %xmm0,(%eax)                    ;/ line : 80
         movl -28(%ebp),%eax                    ;/ line : 80
         movl (%eax),%eax                    ;/ line : 80
         addl %ebx,%eax                    ;/ line : 80
         movl (%edx),%edi                    ;/ line : 80
         movsd 8(%edi,%esi),%xmm0                    ;/ line : 80
         movl (%ecx),%edi                    ;/ line : 80
         mulsd 8(%edi,%esi),%xmm0                    ;/ line : 80
         addsd (%eax),%xmm0                    ;/ line : 80
         movsd %xmm0,(%eax)                    ;/ line : 80
         movl -28(%ebp),%eax                    ;/ line : 80
         movl (%eax),%eax                    ;/ line : 80
         addl %ebx,%eax                    ;/ line : 80
         movl (%edx),%edi                    ;/ line : 80
         movsd 16(%edi,%esi),%xmm0                    ;/ line : 80
         movl (%ecx),%edi                    ;/ line : 80
         mulsd 16(%edi,%esi),%xmm0                    ;/ line : 80
         addsd (%eax),%xmm0                    ;/ line : 80
         movsd %xmm0,(%eax)                    ;/ line : 80
         movl -28(%ebp),%eax                    ;/ line : 80
         movl (%eax),%eax                    ;/ line : 80
         addl %ebx,%eax                    ;/ line : 80
         movl (%edx),%edi                    ;/ line : 80
         movsd 24(%edi,%esi),%xmm0                    ;/ line : 80
         movl (%ecx),%edi                    ;/ line : 80
         mulsd 24(%edi,%esi),%xmm0                    ;/ line : 80
         addsd (%eax),%xmm0                    ;/ line : 80
         movsd %xmm0,(%eax)                    ;/ line : 80
         movl -28(%ebp),%eax                    ;/ line : 80
         movl (%eax),%eax                    ;/ line : 80
         addl %ebx,%eax                    ;/ line : 80
         movl (%edx),%edi                    ;/ line : 80
         movsd 32(%edi,%esi),%xmm0                    ;/ line : 80
         movl (%ecx),%edi                    ;/ line : 80
         mulsd 32(%edi,%esi),%xmm0                    ;/ line : 80
         addsd (%eax),%xmm0                    ;/ line : 80
         movsd %xmm0,(%eax)                    ;/ line : 80
         movl -28(%ebp),%eax                    ;/ line : 80
         movl (%eax),%eax                    ;/ line : 80
         addl %ebx,%eax                    ;/ line : 80
         movl (%edx),%edi                    ;/ line : 80
         movsd 40(%edi,%esi),%xmm0                    ;/ line : 80
         movl (%ecx),%edi                    ;/ line : 80
         mulsd 40(%edi,%esi),%xmm0                    ;/ line : 80
         addsd (%eax),%xmm0                    ;/ line : 80
         movsd %xmm0,(%eax)                    ;/ line : 80
         addl $48,%esi                    ;/ line : 80
         movl -32(%ebp),%eax                    ;/ line : 80
         addl $6,%eax                    ;/ line : 80
         movl %eax,-32(%ebp)
    .LU19.271:
         cmpl $994,%eax                    ;/ line : 80
         jle .CG1A.38                    ;/ line : 80
    but the code acually executed in main() is:.CG2B.55:
         movsd (%edi),%xmm1                    ;/ line : 80
         mulsd (%ebx),%xmm1                    ;/ line : 80
         addsd %xmm1,%xmm0                    ;/ line : 80
         movsd 8(%edi),%xmm1                    ;/ line : 80
         mulsd 8(%ebx),%xmm1                    ;/ line : 80
         addsd %xmm1,%xmm0                    ;/ line : 80
         movsd 16(%edi),%xmm1                    ;/ line : 80
         mulsd 16(%ebx),%xmm1                    ;/ line : 80
         addsd %xmm1,%xmm0                    ;/ line : 80
         movsd 24(%edi),%xmm1                    ;/ line : 80
         mulsd 24(%ebx),%xmm1                    ;/ line : 80
         addsd %xmm1,%xmm0                    ;/ line : 80
         movsd 32(%edi),%xmm1                    ;/ line : 80
         mulsd 32(%ebx),%xmm1                    ;/ line : 80
         addsd %xmm1,%xmm0                    ;/ line : 80
         movsd 40(%edi),%xmm1                    ;/ line : 80
         mulsd 40(%ebx),%xmm1                    ;/ line : 80
         addsd %xmm1,%xmm0                    ;/ line : 80
         movsd %xmm0,(%ecx)                    ;/ line : 80
         addl $48,%edi                    ;/ line : 80
         addl $48,%ebx                    ;/ line : 80
         addl $6,%esi                    ;/ line : 80
    .LU65.419:
         cmpl $994,%esi                    ;/ line : 80
         jle .CG2B.55                    ;/ line : 80
    in the body of main().
    But believe me, if your program gets larger, the function code is as shown
    in the function body, not the fast version implemented here in main()
    That is why I got interested in this in the first place, because the timings
    were so bad!
    In contrast to this, the cc compiler generates also for the function code the fast version.
    Uh, by the way, why are only two sse registers used?
    bugchucker                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Compiler optimization for CPU familes

    Fortunately or unfortunately, we have various CPU families used in the build, test, and production families. They include UltraSparc II's, UltraSparc III's, and UltraSparc IV+'s.
    In this scenario, can I use -fast option for optimization of my sources? If not, which would be the best options that I can go for it?
    I appreciate your efforts in advance...
    -Saravanan Kannan

    The -fast option generates code tor the exact processor that runs the compilation. The resulting code might not run on an earlier processor, and in might not run as well on other processors compared to just using the generat -xO4 flag.
    The combination
    -xO4 -xarch=v8plusa -xtarget=ultra3
    will generate well-optimized code that runs best on Ultra III, but will also run on Ultra II and IV.
    It would be a good idea to build with and without the -xtarget option, and compare performance on all systems. You cannot predict in advance whether overall performance across systems will be better with or without the option.
    You should also experiment with -xO5. It often gives better performance, but leads to larger code size. Sometimes the larger code size results in more paging at run time, destroying the benefits of micro-optimization.
    See also this forum article:
    http://forum.sun.com/jive/thread.jspa?threadID=108492

  • Preview is different than final compile? HELP PLEASE

    This is a simple test animation, but 2 things go wrong when I compile it
    1: the clouds in the compiled version move at different speeds than when I hit "play" in the workstation
    2: one of the clouds dissapears (the bottom one), and then reappears randomly, something that it doesn't do in the workstation
    Ive tried it in different layers, with different types of objects, and even capturing it frame-by-frame, but it always messes up when i export it!
    Heres the .fla and the .swf files, if someone could look and see if i'm overlooking something and give me feedbac
    http://speedy.sh/fxWTk/RECOVER-RECOVER-1.fla

    Hi,
    It looks like you have accidently added the same motion tween twice at different levels of nesting within the same symbol. Also within nesting, you're using Movieclip instance somewhere and Graphic instance at other places.
    This answers both of your queries:
    1. Speed is different because the resultant speed is the addition of two motions along the same path. (When previewing within application, animations within a movieclip are not shown but within Graphics are shown.)
    2. The disappearance happens due to the same eason. The start and end point of a grapic animation is dependent on the parent timeline and remains the same during looping. Movieclip animations on the other hand, always play completely and may spill over multiple loops. So basically the start point of the animation is getting shifted with every loop.
    You can remove one of the tweens from the nested symbol to fix this.
    -Nipun

  • Compiles in Java 5.0 but not 6.0

    I did my homework on my school computer (in eclipse) and compiled in in 6.0 and everything worked. Then I saved it to a usb drive
    and brought it home. I tried to run it on my computer (in eclipse) in 6.0 and it gave me this error:
    Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)when I tried to run it. The weird thing is, if I change eclipse's preferences to compile in 5.0 everything works fine. I just don't understand
    why it compiled in 6.0 at school but won't work on my home computer in 6.0? I'm worried that my teacher might grade the assignment in
    6.0 because if he does I'll get a 0 even though everything works 100% in 5.0.
    I was just wondering if anyone could shed some light on this for me. Thanks in advance!
    Here is my assignment (just giving this so you know what the program is suppose to do):
    http://www2.ics.hawaii.edu/~esb/2008spring.ics211/hw9.html
    It basically reads from a file and adds items in the file to a PriorityQueue using a heap as the data structure. It keeps track of levels
    traversed to re-establish the heap property. How long add/poll take in realTime. And when add/poll occurs in simulatedTime.
    Here's my program:
    import java.io.*;
    import java.util.*;
    public class KinseyAnthony9<T> {
         private static String name = "";
         private static long deadline;
         private static long duration;
         private static int time;
         private static int simulatedTime = 0;
         private static boolean add;
         public static void ProcessLine(Scanner line){
              if(line.next().equalsIgnoreCase("schedule")){
                   add = true;
                   if(line.hasNext()){
                        name = line.next();
                   if(line.hasNext()){
                        deadline = Long.parseLong(line.next());
                   if(line.hasNext()){
                        duration = Long.parseLong(line.next());
                   else {
                        System.out.print("There is a format error in the supplied file");
                        System.exit(1);
                   return;
              else {
                   add = false;
                   if(line.hasNext()){
                        time = Integer.parseInt(line.next());
                   else {
                        System.out.print("There is a format error in the supplied file");
                        System.exit(1);
         public static void main(String[] param) {
              Comparator<MyProc> procCompare = new ProcComparator();
              MyPQueue<MyProc> myQueue = new MyPQueue<MyProc>(procCompare);
    //          PriorityQueue<MyProc> myQueue = new PriorityQueue<MyProc>(1000, procCompare);
              if(param.length == 1) {
                   try {
                        File readMe = new File(param[0]);
                        Scanner readFile = new Scanner(readMe);
                        String line = "";
                        while(readFile.hasNextLine()) {
                             line = readFile.nextLine();
                             Scanner readLine = new Scanner(line);
                             ProcessLine(readLine);
                             if(add) {
                                  System.out.println(simulatedTime + ": adding " + name + " with deadline " + deadline + " and duration " + duration + ".");
                                  myQueue.add(new MyProc(name, deadline, duration));
                             else if(!add) {
                                  String procName = "";
                                  long procDeadline = 0;
                                  long procDuration = 0;
                                  while(simulatedTime != time) {
                                       Scanner procScan = null;
                                       int queueSize = myQueue.size();
                                       if(queueSize <= 0) {
                                            simulatedTime = time;
                                            break;
                                       if(queueSize > 0) {
                                            procScan = new Scanner(myQueue.peek().toString());
                                            procName = procScan.next();
                                            procDeadline = Long.parseLong(procScan.next());
                                            procDuration = Long.parseLong(procScan.next());
                                            System.out.println(simulatedTime + ": performing " + procName + " with deadline " + procDeadline + " and duration " + procDuration + ".");
                                            myQueue.poll();
                                            simulatedTime += procDuration;
                                            if(simulatedTime > time) {
                                                 System.out.println((simulatedTime-procDuration) + ": adding " + procName + " with deadline " + procDeadline + " and duration " + (simulatedTime-time) + ".");
                                                 myQueue.add(new MyProc(name, deadline, (simulatedTime-time)));
                                                 simulatedTime = time;
                                                 break;
                                            else if(simulatedTime <= time) {
                                                 if(procDeadline < simulatedTime) {
                                                      System.out.println(simulatedTime + ": done performing " + procName + " (late).");
                                                 else {
                                                      System.out.println(simulatedTime + ": done performing " + procName + ".");
                   //catch any exception that might occur
                   catch(Exception e){
                        System.out.println(e); //print out the error
                        System.exit(1); //exit
              //Check if more than one or less than one parameter is entered
              else {
                   //if so give an error
                   System.out.println("Error with parameter.");
                   System.exit(1); //exit
    class ProcComparator implements Comparator<MyProc>{
         public int compare(MyProc x, MyProc y){
              long result = x.getDeadline() - y.getDeadline();
              if(result < 0)
                   return -1;
              else if(result > 0)
                   return 1;
              else
                   return 0;
    class MyPQueue<T>{
         public MyHeap<T> theHeap;
         public MyPQueue(Comparator<T> comp) {
              theHeap = new MyHeap<T>(comp);
         public boolean add(T item){
              if(theHeap.add(item)) return true;
              else return false;
         public T peek(){
              return theHeap.peek();
         public int size(){
              return theHeap.numItems();
         public T poll(){
              T result = null;
              if(theHeap.numItems() == 0) return result;
              try{
                   result = theHeap.remove();
              catch(Exception e){
                   System.out.println(e);
                   System.exit(1);
              return result;
         public String toString(){
              return theHeap.toString();
    @SuppressWarnings("unchecked")
    class MyHeap<T>{
         private Comparator<T> heapComparator = null;
         private final int MAX_SIZE = 1000;
         private T heap[];
         private int rTraverseCount = 0;
         private int aTraverseCount = 0;
         public MyHeap(Comparator<T> comp){
              heapComparator = comp;
              heap = (T[])new Object[MAX_SIZE];
         public int numItems() {
              int numItems = 0;
              for(int i = 0; heap[i] != null; i++) {
                   numItems++;
              return numItems;
         public T peek() {
              if(numItems() == 0) return null;
              return heap[0];
         public boolean add(T item) {
              long start = System.nanoTime();
              long time;
              int numItems = numItems();
              if(numItems == 0) {
                   heap[numItems] = item;
                   System.out.println("--> " + aTraverseCount +" levels were traversed to re-heapify the tree.");
                  time = System.nanoTime() - start;
                   System.out.println("--> It took " + time + "ns to complete the add operation.");
                   return true;
              else if(numItems > 0) {
                   heap[numItems] = item;
                   siftUp(0, numItems);
                   if(aTraverseCount == 1)
                        System.out.println("--> " + aTraverseCount +" level was traversed to re-heapify the tree.");
                   else
                        System.out.println("--> " + aTraverseCount +" levels were traversed to re-heapify the tree.");
                   aTraverseCount = 0;
                   time = System.nanoTime() - start;
                   System.out.println("--> It took " + time + "ns to complete the add operation.");
                   return true;
              return false;
         public T remove() throws Exception{
              long start = System.nanoTime();
              long time;
              int numItems = numItems();
              T result = heap[0];
              if(numItems == 0){
                   throw new Exception("NoSuchElementException");
              if(numItems == 1){
                   heap[0] = null;
                   time = System.nanoTime() - start;
                   System.out.println("--> It took " + time + "ns to complete the remove operation.");
                   System.out.println("--> " + rTraverseCount +" levels were traversed to re-heapify the tree.");
                   return result;
              else {
                   heap[0] = heap[numItems - 1];
                   heap[numItems - 1] = null;
                   removalswap(0);
                   if(rTraverseCount-1 == 1)
                        System.out.println("--> " + (rTraverseCount-1) +" level was traversed to re-heapify the tree.");
                   else
                        System.out.println("--> " + (rTraverseCount-1) +" levels were traversed to re-heapify the tree.");
                   rTraverseCount = 0;
              time = System.nanoTime() - start;
              System.out.println("--> It took " + time + "ns to complete the remove operation.");
              return result;
         public void removalswap(int root) {
              rTraverseCount++;
              T valueHolder = heap[root];
              int left = (2*root) + 1;
              int right = (2*root) + 2;
              if(heap[right] != null && heap[left] != null){ //make sure left and right children aren't null
                   if(heapComparator.compare(heap[root],heap[left]) <= 0 &&  //if root is less than or equal
                      heapComparator.compare(heap[root],heap[right]) <= 0) return; //to its children return
                   if(heapComparator.compare(heap[root],heap[left]) > 0){ //if root is greater than left
                        if(heapComparator.compare(heap[left], heap[right]) > 0){ //compare left and right
                             heap[root] = heap[right]; //and swap with the smaller of the two
                             heap[right] = valueHolder;//in this case right is smaller so swap with right
                             removalswap(right);
                        else { //in this case left is smaller so swap with left
                             heap[root] = heap[left];
                             heap[left] = valueHolder;
                             removalswap(left);
                   else if(heapComparator.compare(heap[root],heap[right]) > 0){ //root can be greater than left
                             heap[root] = heap[right]; //but smaller than right. In this case just swap with the
                             heap[right] = valueHolder; //right child.
                             removalswap(right);               
              else if(heap[right] == null && heap[left] != null){ //the right child can be null while the left child
                   if(heapComparator.compare(heap[root],heap[left]) <= 0) return;//is not, but the left child will never
                   else { //be null if the right child isn't. If this is the case see if the root is greater than the
                        heap[root] = heap[left]; //left child and swap if so.
                        heap[left] = valueHolder;
                        removalswap(left);
         public void siftUp(int root, int end) {
              int child = end;
              int parent = (child-1)/2;
              while(child > root){
                   parent = (child-1)/2;
                   if(heapComparator.compare(heap[parent], heap[child]) > 0) {
                        swap(parent,child);
                        child = parent;
                   else{
                        return;
         public void swap(int parent, int child){
              aTraverseCount++;
              T holdValue = heap[parent];
              heap[parent] = heap[child];
              heap[child] = holdValue;
         public String toString(){
              int i = 0;
              String heapPrint = "";
              while(heap[i] != null){
                   heapPrint += heap;
                   i++;
              return heapPrint;
    class MyProc {
         private String name;
         private long deadline;
         private long duration;
         public MyProc(String n, long dl, long dur) {
              name = n;
              deadline = dl;
              duration = dur;
         //Acessors
         public String getName() {
              return name;
         public long getDeadline() {
              return deadline;
         public long getDuration() {
              return duration;
         //Mutators
         public void setName(String n) {
              name = n;
         public void setDeadline(long dl) {
              deadline = dl;
         public void setDuration(long dur) {
              duration = dur;
         public String toString(){
              return name + " " + deadline + " " + duration;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    But if I run that in terminal I get this:
    anthony-computer:~ anthonyjk$ java -version
    java version "1.5.0_13"Yes - commandline/Terminal, that's what I meant.
    So long as the program doesn't use any 1.6-only features, then will it will compile OK both at school (using1.6) and at home (using 1.5). Eclipse can be told to produce .class files that are compatible with a particular runtime. In your case the school compiler was producing 1.6 class files that are no good when you take them home. Hence the need to recompile, telling Eclipse you want 1.5 compatible .class files.
    Or - as I mentioned - download and install the most recent JDK for use at home. There'll be less confusion that way

  • JDev 1013 Error: Internal compilation error, terminated with a fatal except

    I've a class I compiled used in JDev 10.1.2.1.
    Now I try to compile it with JDev 10.1.3 but I get an error :
    Error: Internal compilation error, terminated with a fatal exception
    What does it means ?
    How can I solve it ?
    I tried to use both 5.0 and 1.4.2 compilers but the result is the same.
    Tks
    Tullio
    Here the class
    /* The following code was generated by JFlex 1.2.2 on 05/10/04 17.46 */
    * Copyright (C) 1998,99 Gerwin Klein <[email protected]>. *
    * All rights reserved. *
    * This program is free software; you can redistribute it and/or modify *
    * it under the terms of the GNU General Public License. See the file *
    * COPYRIGHT for more information. *
    * This program is distributed in the hope that it will be useful, *
    * but WITHOUT ANY WARRANTY; without even the implied warranty of *
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
    * GNU General Public License for more details. *
    * You should have received a copy of the GNU General Public License along *
    * with this program; if not, write to the Free Software Foundation, Inc., *
    * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
    package axioma.a4j.parser;
    import java_cup.runtime.*;
    * This class is a scanner generated by
    * JFlex 1.2.2
    * on 05/10/04 17.46 from the specification file
    * <tt>file:/C:/A4j/A4j/Common/Parser/grammatiche/Scanner.flex</tt>
    public class AxScanner implements java_cup.runtime.Scanner {
    /** this character denotes the end of file */
    final public static int YYEOF = -1;
    /** lexical states */
    final public static int STRING = 1;
    final public static int YYINITIAL = 0;
    final public static int CHARLITERAL = 2;
    * Translates characters to character classes
    final private static String yycmap_packed =
    "\11\10\1\3\1\2\1\0\1\3\1\1\16\10\4\0\1\3\1\50"+
    "\1\16\1\0\1\7\1\0\1\44\1\15\1\31\1\32\1\5\1\41"+
    "\1\40\1\42\1\14\1\4\1\12\11\13\1\0\1\37\1\47\1\46"+
    "\1\45\2\0\32\11\1\35\1\17\1\36\1\0\1\11\1\0\1\25"+
    "\1\51\2\11\1\23\1\24\5\11\1\26\1\6\1\30\3\11\1\21"+
    "\1\27\1\20\1\22\5\11\1\33\1\43\1\34\1\0\41\10\2\0"+
    "\4\11\4\0\1\11\12\0\1\11\4\0\1\11\5\0\27\11\1\0"+
    "\37\11\1\0\u0128\11\2\0\22\11\34\0\136\11\2\0\11\11\2\0"+
    "\7\11\16\0\2\11\16\0\5\11\11\0\1\11\21\0\117\10\21\0"+
    "\3\10\27\0\1\11\13\0\1\11\1\0\3\11\1\0\1\11\1\0"+
    "\24\11\1\0\54\11\1\0\10\11\2\0\32\11\14\0\202\11\1\0"+
    "\4\10\5\0\71\11\2\0\2\11\2\0\2\11\3\0\46\11\2\0"+
    "\2\11\67\0\46\11\2\0\1\11\7\0\47\11\11\0\21\10\1\0"+
    "\27\10\1\0\3\10\1\0\1\10\1\0\2\10\1\0\1\10\13\0"+
    "\33\11\5\0\3\11\56\0\32\11\5\0\13\11\13\10\12\0\12\10"+
    "\6\0\1\10\143\11\1\0\1\11\7\10\2\0\6\10\2\11\2\10"+
    "\1\0\4\10\2\0\12\10\3\11\22\0\1\10\1\11\1\10\33\11"+
    "\3\0\33\10\65\0\46\11\13\10\u0150\0\3\10\1\0\65\11\2\0"+
    "\1\10\1\11\20\10\2\0\1\11\4\10\3\0\12\11\2\10\2\0"+
    "\12\10\21\0\3\10\1\0\10\11\2\0\2\11\2\0\26\11\1\0"+
    "\7\11\1\0\1\11\3\0\4\11\2\0\1\10\1\0\7\10\2\0"+
    "\2\10\2\0\3\10\11\0\1\10\4\0\2\11\1\0\3\11\2\10"+
    "\2\0\12\10\4\11\16\0\1\10\2\0\6\11\4\0\2\11\2\0"+
    "\26\11\1\0\7\11\1\0\2\11\1\0\2\11\1\0\2\11\2\0"+
    "\1\10\1\0\5\10\4\0\2\10\2\0\3\10\13\0\4\11\1\0"+
    "\1\11\7\0\14\10\3\11\14\0\3\10\1\0\7\11\1\0\1\11"+
    "\1\0\3\11\1\0\26\11\1\0\7\11\1\0\2\11\1\0\5\11"+
    "\2\0\1\10\1\11\10\10\1\0\3\10\1\0\3\10\2\0\1\11"+
    "\17\0\1\11\5\0\12\10\21\0\3\10\1\0\10\11\2\0\2\11"+
    "\2\0\26\11\1\0\7\11\1\0\2\11\2\0\4\11\2\0\1\10"+
    "\1\11\6\10\3\0\2\10\2\0\3\10\10\0\2\10\4\0\2\11"+
    "\1\0\3\11\4\0\12\10\22\0\2\10\1\0\6\11\3\0\3\11"+
    "\1\0\4\11\3\0\2\11\1\0\1\11\1\0\2\11\3\0\2\11"+
    "\3\0\3\11\3\0\10\11\1\0\3\11\4\0\5\10\3\0\3\10"+
    "\1\0\4\10\11\0\1\10\17\0\11\10\21\0\3\10\1\0\10\11"+
    "\1\0\3\11\1\0\27\11\1\0\12\11\1\0\5\11\4\0\7\10"+
    "\1\0\3\10\1\0\4\10\7\0\2\10\11\0\2\11\4\0\12\10"+
    "\22\0\2\10\1\0\10\11\1\0\3\11\1\0\27\11\1\0\12\11"+
    "\1\0\5\11\4\0\7\10\1\0\3\10\1\0\4\10\7\0\2\10"+
    "\7\0\1\11\1\0\2\11\4\0\12\10\22\0\2\10\1\0\10\11"+
    "\1\0\3\11\1\0\27\11\1\0\20\11\4\0\6\10\2\0\3\10"+
    "\1\0\4\10\11\0\1\10\10\0\2\11\4\0\12\10\22\0\2\10"+
    "\1\0\22\11\3\0\30\11\1\0\11\11\1\0\1\11\2\0\7\11"+
    "\3\0\1\10\4\0\6\10\1\0\1\10\1\0\10\10\22\0\2\10"+
    "\15\0\60\11\1\10\2\11\7\10\4\0\10\11\10\10\1\0\12\10"+
    "\47\0\2\11\1\0\1\11\2\0\2\11\1\0\1\11\2\0\1\11"+
    "\6\0\4\11\1\0\7\11\1\0\3\11\1\0\1\11\1\0\1\11"+
    "\2\0\2\11\1\0\4\11\1\10\2\11\6\10\1\0\2\10\1\11"+
    "\2\0\5\11\1\0\1\11\1\0\6\10\2\0\12\10\2\0\2\11"+
    "\42\0\1\11\27\0\2\10\6\0\12\10\13\0\1\10\1\0\1\10"+
    "\1\0\1\10\4\0\2\10\10\11\1\0\42\11\6\0\24\10\1\0"+
    "\2\10\4\11\4\0\10\10\1\0\44\10\11\0\1\10\71\0\42\11"+
    "\1\0\5\11\1\0\2\11\1\0\7\10\3\0\4\10\6\0\12\10"+
    "\6\0\6\11\4\10\106\0\46\11\12\0\47\11\11\0\132\11\5\0"+
    "\104\11\5\0\122\11\6\0\7\11\1\0\77\11\1\0\1\11\1\0"+
    "\4\11\2\0\7\11\1\0\1\11\1\0\4\11\2\0\47\11\1\0"+
    "\1\11\1\0\4\11\2\0\37\11\1\0\1\11\1\0\4\11\2\0"+
    "\7\11\1\0\1\11\1\0\4\11\2\0\7\11\1\0\7\11\1\0"+
    "\27\11\1\0\37\11\1\0\1\11\1\0\4\11\2\0\7\11\1\0"+
    "\47\11\1\0\23\11\16\0\11\10\56\0\125\11\14\0\u026c\11\2\0"+
    "\10\11\12\0\32\11\5\0\113\11\225\0\64\11\40\10\7\0\1\11"+
    "\4\0\12\10\41\0\4\10\1\0\12\10\6\0\130\11\10\0\51\11"+
    "\1\10\u0556\0\234\11\4\0\132\11\6\0\26\11\2\0\6\11\2\0"+
    "\46\11\2\0\6\11\2\0\10\11\1\0\1\11\1\0\1\11\1\0"+
    "\1\11\1\0\37\11\2\0\65\11\1\0\7\11\1\0\1\11\3\0"+
    "\3\11\1\0\7\11\3\0\4\11\2\0\6\11\4\0\15\11\5\0"+
    "\3\11\1\0\7\11\17\0\4\10\32\0\5\10\20\0\2\11\51\0"+
    "\6\10\17\0\1\11\40\0\20\11\40\0\15\10\4\0\1\10\40\0"+
    "\1\11\4\0\1\11\2\0\12\11\1\0\1\11\3\0\5\11\6\0"+
    "\1\11\1\0\1\11\1\0\1\11\1\0\4\11\1\0\3\11\1\0"+
    "\7\11\46\0\44\11\u0e81\0\3\11\31\0\11\11\6\10\1\0\5\11"+
    "\2\0\3\11\6\0\124\11\4\0\2\10\2\0\2\11\2\0\136\11"+
    "\6\0\50\11\4\0\136\11\21\0\30\11\u0248\0\u19b6\11\112\0\u51a6\11"+
    "\132\0\u048d\11\u0773\0\u2ba4\11\u215c\0\u012e\11\322\0\7\11\14\0\5\11"+
    "\5\0\1\11\1\10\12\11\1\0\15\11\1\0\5\11\1\0\1\11"+
    "\1\0\2\11\1\0\2\11\1\0\154\11\41\0\u016b\11\22\0\100\11"+
    "\2\0\66\11\50\0\14\11\44\0\4\10\17\0\2\11\30\0\3\11"+
    "\31\0\1\11\6\0\3\11\1\0\1\11\1\0\207\11\2\0\1\10"+
    "\4\0\1\11\13\0\12\10\7\0\32\11\4\0\1\11\1\0\32\11"+
    "\12\0\132\11\3\0\6\11\2\0\6\11\2\0\6\11\2\0\3\11"+
    "\3\0\2\11\3\0\2\11\22\0\3\10\4\0";
    * Translates characters to character classes
    final private static char [] yycmap = yy_unpack_cmap(yycmap_packed);
    * Translates a state to a row index in the transition table
    final private static int yy_rowMap [] = {
    0, 42, 84, 126, 168, 126, 210, 126, 252, 294,
    336, 378, 126, 126, 420, 462, 504, 126, 126, 126,
    126, 126, 126, 126, 126, 126, 126, 546, 126, 588,
    126, 630, 672, 714, 756, 126, 126, 798, 840, 882,
    126, 924, 966, 1008, 1050, 336, 1092, 1134, 1176, 1218,
    126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
    126, 126, 126, 126, 1260, 1302, 1344, 1386, 1428, 1470,
    1512, 1554, 126, 1596, 1638, 1680, 1722, 126, 126, 126,
    126, 126, 126, 126, 1764, 294, 1806, 294, 294
    * The packed transition table of the DFA
    final private static String yy_packed =
    "\1\4\1\5\2\6\1\7\1\10\1\11\1\12\1\4"+
    "\1\12\1\13\1\14\1\4\1\15\1\16\1\4\1\17"+
    "\3\12\1\20\3\12\1\21\1\22\1\23\1\24\1\25"+
    "\1\26\1\27\1\30\1\31\1\32\1\33\1\34\1\35"+
    "\1\36\1\37\1\40\1\41\1\12\1\42\1\43\1\44"+
    "\12\42\1\45\1\42\1\46\32\42\1\47\1\50\1\51"+
    "\13\47\1\4\1\52\32\47\54\0\1\6\53\0\1\53"+
    "\1\54\52\0\1\12\1\55\4\12\4\0\11\12\20\0"+
    "\1\12\6\0\6\12\4\0\11\12\20\0\1\12\12\0"+
    "\2\56\1\57\47\0\2\14\1\57\43\0\6\12\4\0"+
    "\1\12\1\60\7\12\20\0\1\12\6\0\6\12\4\0"+
    "\5\12\1\61\3\12\20\0\1\12\6\0\6\12\4\0"+
    "\2\12\1\62\6\12\20\0\1\12\43\0\1\63\54\0"+
    "\1\64\51\0\1\65\51\0\1\66\3\0\1\42\2\0"+
    "\12\42\1\0\1\42\1\0\32\42\2\0\1\44\47\0"+
    "\2\67\1\0\12\67\1\70\1\71\1\72\1\73\1\74"+
    "\2\67\1\75\3\67\1\76\20\67\1\77\15\0\1\100"+
    "\36\0\1\51\47\0\2\67\1\0\12\67\1\101\1\102"+
    "\1\103\1\104\1\105\2\67\1\106\3\67\1\104\20\67"+
    "\1\107\1\53\1\110\1\111\47\53\52\112\6\0\6\55"+
    "\4\0\11\55\20\0\1\55\12\0\2\57\44\0\6\12"+
    "\4\0\2\12\1\113\6\12\20\0\1\12\6\0\6\12"+
    "\4\0\6\12\1\114\2\12\20\0\1\12\6\0\6\12"+
    "\4\0\6\12\1\115\2\12\20\0\1\12\15\0\1\116"+
    "\51\0\1\117\51\0\1\120\51\0\1\121\51\0\1\122"+
    "\51\0\1\123\51\0\1\124\36\0\1\111\47\0\5\112"+
    "\1\125\44\112\6\0\6\12\4\0\3\12\1\126\5\12"+
    "\20\0\1\12\6\0\6\12\4\0\7\12\1\127\1\12"+
    "\20\0\1\12\6\0\6\12\4\0\6\12\1\130\2\12"+
    "\20\0\1\12\4\112\1\111\1\125\44\112\6\0\6\12"+
    "\4\0\3\12\1\131\5\12\20\0\1\12";
    * The transition table of the DFA
    final private static int yytrans [] = yy_unpack(yy_packed);
    /* error codes */
    final private static int YY_UNKNOWN_ERROR = 0;
    final private static int YY_ILLEGAL_STATE = 1;
    final private static int YY_NO_MATCH = 2;
    final private static int YY_PUSHBACK_2BIG = 3;
    /* error messages for the codes above */
    final private static String YY_ERROR_MSG[] = {
    "Unkown internal scanner error",
    "Internal error: unknown state",
    "Error: could not match input",
    "Error: pushback value was too large"
    * YY_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
    private final static byte YY_ATTRIBUTE[] = {
    0, 0, 0, 9, 1, 9, 1, 9, 1, 1, 1, 1, 9, 9, 1, 1,
    1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 9, 1, 9, 1,
    1, 1, 1, 9, 9, 1, 1, 1, 9, 1, 0, 0, 1, 0, 1, 1,
    1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
    1, 1, 1, 1, 1, 1, 1, 1, 9, 0, 1, 1, 1, 9, 9, 9,
    9, 9, 9, 9, 0, 1, 1, 1, 1
    /** the input device */
    private java.io.Reader yy_reader;
    /** the current state of the DFA */
    private int yy_state;
    /** the current lexical state */
    private int yy_lexical_state = YYINITIAL;
    /** this buffer contains the current text to be matched and is
    the source of the yytext() string */
    private char yy_buffer[] = new char[16384];
    /** the textposition at the last accepting state */
    private int yy_markedPos;
    /** the textposition at the last state to be included in yytext */
    private int yy_pushbackPos;
    /** the current text position in the buffer */
    private int yy_currentPos;
    /** startRead marks the beginning of the yytext() string in the buffer */
    private int yy_startRead;
    /** endRead marks the last character in the buffer, that has been read
    from input */
    private int yy_endRead;
    /** number of newlines encountered up to the start of the matched text */
    private int yyline;
    /** the number of characters up to the start of the matched text */
    private int yychar;
    * the number of characters from the last newline up to the start of the
    * matched text
    private int yycolumn;
    * yy_atBOL == true <=> the scanner is currently at the beginning of a line
    private boolean yy_atBOL;
    /** yy_atEOF == true <=> the scanner has returned a value for EOF */
    private boolean yy_atEOF;
    /** denotes if the user-EOF-code has already been executed */
    private boolean yy_eof_done;
    /* user code: */
    StringBuffer string = new StringBuffer();
    private InContestoParser mContesto = null;
    private Symbol symbol(int type) {
    return new JavaSymbol(type, yyline+1, yycolumn+1);
    private Symbol symbol(int type, Object value) {
    return new JavaSymbol(type, yyline+1, yycolumn+1, value);
    private Symbol axSymbol(Object value) {
    int tipo = 0;
    CercaValore cercaVal = new CercaValoreComm(value.toString(),mContesto);
    Ritorno rito = cercaVal.cercaValore();
    int tipoSym = rito.getTipo();
    if (tipoSym == Domini.tipoDatoNumerico) {
         tipo = AxSym.VAR_N;
    else if (tipoSym == Domini.tipoDatoAlfanumerico) {
    tipo = AxSym.VAR_A;
    else if (tipoSym == Domini.tipoDatoBooleano) {
         tipo = AxSym.VAR_B;
    JavaSymbol myJ = new JavaSymbol(tipo, yyline+1, yycolumn+1, value);
    return myJ;
    private Symbol axMetodo(Object value) {
    int tipo = 0;
    CercaValore cercaVal = new CercaValoreComm(value.toString(),mContesto);
    Ritorno rito = cercaVal.cercaValore();
    int tipoSym = rito.getTipo();
    if (tipoSym == Domini.tipoDatoNumerico) {
         tipo = AxSym.MET_N;
    else if (tipoSym == Domini.tipoDatoAlfanumerico) {
    tipo = AxSym.MET_A;
    else if (tipoSym == Domini.tipoDatoBooleano) {
         tipo = AxSym.MET_B;
    JavaSymbol myJ = new JavaSymbol(tipo, yyline+1, yycolumn+1, value);
    return myJ;
    * Set the reader and reset variables
    public void setReader(java.io.Reader in) {
    this.yy_lexical_state = YYINITIAL;
    this.yy_atEOF = false;
    this.yy_atBOL = false;
    this.yy_eof_done = false;
    this.yy_state = 0;
    this.yy_pushbackPos = 0;
    this.yy_markedPos = 0;
    this.yy_currentPos = 0;
    this.yy_startRead = 0;
    this.yy_endRead = 0;
    this.yyline = 0;
    this.yychar = 0;
    this.yycolumn = 0;
    this.yy_reader = in;
    public void setContesto(InContestoParser xpContesto) {
    mContesto = xpContesto;
    public InContestoParser getContesto() {
    return mContesto;
    * Creates a new scanner.
    * There is also java.io.Reader version of this constructor.
    * @param in the java.io.Inputstream to read input from.
    public AxScanner() throws java.io.IOException { this(System.in); }
    * Creates a new scanner
    * There is also a java.io.InputStream version of this constructor.
    * @param in the java.io.Reader to read input from.
    AxScanner(java.io.Reader in) {
    this.yy_reader = in;
    * Creates a new scanner.
    * There is also java.io.Reader version of this constructor.
    * @param in the java.io.Inputstream to read input from.
    AxScanner(java.io.InputStream in) {
    this(new java.io.InputStreamReader(in));
    * Unpacks the compressed DFA transition table.
    * @param packed the packed transition table
    * @return the unpacked transition table
    private static int [] yy_unpack(String packed) {
    int [] trans = new int[1848];
    int i = 0; /* index in packed string */
    int j = 0; /* index in unpacked array */
    while (i < 492) {
    int count = packed.charAt(i++);
    int value = packed.charAt(i++);
    value--;
    do trans[j++] = value; while (--count > 0);
    return trans;
    * Unpacks the compressed character translation table.
    * @param packed the packed character translation table
    * @return the unpacked character translation table
    private static char [] yy_unpack_cmap(String packed) {
    char [] map = new char[0x10000];
    int i = 0; /* index in packed string */
    int j = 0; /* index in unpacked array */
    while (i < 1614) {
    int count = packed.charAt(i++);
    char value = packed.charAt(i++);
    do map[j++] = value; while (--count > 0);
    return map;
    * Gets the next input character.
    * @return the next character of the input stream, EOF if the
    * end of the stream is reached.
    * @exception IOException if any I/O-Error occurs
    private int yy_advance() throws java.io.IOException {
    /* standard case */
    if (yy_currentPos < yy_endRead) return yy_buffer[yy_currentPos++];
    /* if the eof is reached, we don't need to work hard */
    if (yy_atEOF) return YYEOF;
    /* otherwise: need to refill the buffer */
    /* first: make room (if you can) */
    if (yy_startRead > 0) {
    System.arraycopy(yy_buffer, yy_startRead,
    yy_buffer, 0,
    yy_endRead-yy_startRead);
    /* translate stored positions */
    yy_endRead-= yy_startRead;
    yy_currentPos-= yy_startRead;
    yy_markedPos-= yy_startRead;
    yy_pushbackPos-= yy_startRead;
    yy_startRead = 0;
    /* is the buffer big enough? */
    if (yy_currentPos >= yy_buffer.length) {
    /* if not: blow it up */
    char newBuffer[] = new char[yy_currentPos*2];
    System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length);
    yy_buffer = newBuffer;
    /* finally: fill the buffer with new input */
    int numRead = yy_reader.read(yy_buffer, yy_endRead,
    yy_buffer.length-yy_endRead);
    if ( numRead == -1 ) return YYEOF;
    yy_endRead+= numRead;
    return yy_buffer[yy_currentPos++];
    * Closes the input stream.
    final public void yyclose() throws java.io.IOException {
    yy_atEOF = true; /* indicate end of file */
    yy_endRead = yy_startRead; /* invalidate buffer */
    yy_reader.close();
    * Returns the current lexical state.
    final public int yystate() {
    return yy_lexical_state;
    * Enters a new lexical state
    * @param newState the new lexical state
    final public void yybegin(int newState) {
    yy_lexical_state = newState;
    * Returns the text matched by the current regular expression.
    final public String yytext() {
    return new String( yy_buffer, yy_startRead, yy_markedPos-yy_startRead );
    * Returns the length of the matched text region.
    final public int yylength() {
    return yy_markedPos-yy_startRead;
    * Reports an error that occured while scanning.
    * @param errorCode the code of the errormessage to display
    private void yy_ScanError(int errorCode) {
    try {
    System.out.println(YY_ERROR_MSG[errorCode]);
    catch (ArrayIndexOutOfBoundsException e) {
    System.out.println(YY_ERROR_MSG[YY_UNKNOWN_ERROR]);
    System.exit(1);
    * Pushes the specified amount of characters back into the input stream.
    * They will be read again by then next call of the scanning method
    * @param number the number of characters to be read again.
    * This number must not be greater than yylength()!
    private void yypushback(int number) {
    if ( number > yylength() )
    yy_ScanError(YY_PUSHBACK_2BIG);
    yy_markedPos -= number;
    * Contains user EOF-code, which will be executed exactly once,
    * when the end of file is reached
    private void yy_do_eof() throws java.io.IOException {
    if (!yy_eof_done) {
    yy_eof_done = true;
    yyclose();
    * Resumes scanning until the next regular expression is matched,
    * the end of input is encountered or an I/O-Error occurs.
    * @return the next token
    * @exception IOException if any I/O-Error occurs
    public java_cup.runtime.Symbol next_token() throws java.io.IOException {
    int yy_input;
    int yy_action;
    while (true) {
    boolean yy_counted = false;
    for (yy_currentPos = yy_startRead; yy_currentPos < yy_markedPos;
    yy_currentPos++) {
    switch (yy_buffer[yy_currentPos]) {
    case '\r':
    yyline++;
    yycolumn = 0;
    yy_counted = true;
    break;
    case '\n':
    if (yy_counted)
    yy_counted = false;
    else {
    yyline++;
    yycolumn = 0;
    break;
    default:
    yy_counted = false;
    yycolumn++;
    if (yy_counted) {
    if ( yy_advance() == '\n' ) yyline--;
    if ( !yy_atEOF ) yy_currentPos--;
    yy_action = -1;
    yy_currentPos = yy_startRead = yy_markedPos;
    yy_state = yy_lexical_state;
    yy_forAction: {
    while (true) {
    yy_input = yy_advance();
    if ( yy_input == YYEOF ) break yy_forAction;
    int yy_next = yytrans[ yy_rowMap[yy_state] + yycmap[yy_input] ];
    if (yy_next == -1) break yy_forAction;
    yy_state = yy_next;
    int yy_attributes = YY_ATTRIBUTE[yy_state];
    if ( (yy_attributes & 1) > 0 ) {
    yy_action = yy_state;
    yy_markedPos = yy_currentPos;
    if ( (yy_attributes & 8) > 0 ) break yy_forAction;
    switch (yy_action) {   
    case 83:
    {  yybegin(YYINITIAL); return symbol(AxSym.CHARACTER_LITERAL, new Character('\b')); }
    case 90: break;
    case 82:
    {  yybegin(YYINITIAL); return symbol(AxSym.CHARACTER_LITERAL, new Character('\f')); }
    case 91: break;
    case 81:
    {  yybegin(YYINITIAL); return symbol(AxSym.CHARACTER_LITERAL, new Character('\r')); }
    case 92: break;
    case 80:
    {  yybegin(YYINITIAL); return symbol(AxSym.CHARACTER_LITERAL, new Character('\t')); }
    case 93: break;
    case 78:
    {  yybegin(YYINITIAL); return symbol(AxSym.CHARACTER_LITERAL, new Character('\"')); }
    case 94: break;
    case 77:
    {  yybegin(YYINITIAL); return symbol(AxSym.CHARACTER_LITERAL, new Character('\'')); }
    case 95: break;
    case 88:
    {  return symbol(AxSym.BOOLEAN_LITERAL, new Boolean(false));  }
    case 96: break;
    case 87:
    {  return symbol(AxSym.NULL_LITERAL);  }
    case 97: break;
    case 85:
    {  return symbol(AxSym.BOOLEAN_LITERAL, new Boolean(true));  }
    case 98: break;
    case 79:
    {  yybegin(YYINITIAL); return symbol(AxSym.CHARACTER_LITERAL, new Character('\\'));  }
    case 99: break;
    case 71:
    case 72:
    {  /* ignore */  }
    case 100: break;
    case 63:
    {  yybegin(YYINITIAL); return symbol(AxSym.CHARACTER_LITERAL, new Character(yytext().charAt(0)));  }
    case 101: break;
    case 62:
    {  string.append( '\b' );  }
    case 102: break;
    case 61:
    {  string.append( '\n' );  }
    case 103: break;
    case 60:
    {  string.append( '\f' );  }
    case 104: break;
    case 59:
    {  string.append( '\r' );  }
    case 105: break;
    case 58:
    {  string.append( '\t' );  }
    case 106: break;
    case 57:
    {  string.append( '\\' );  }
    case 107: break;
    case 56:
    {  string.append( '\"' );  }
    case 108: break;
    case 55:
    {  string.append( '\'' );  }
    case 109: break;
    case 25:
    {  return symbol(AxSym.PLUS);  }
    case 110: break;
    case 24:
    {  return symbol(AxSym.COMMA);  }
    case 111: break;
    case 23:
    {  return symbol(AxSym.SEMI);  }
    case 112: break;
    case 22:
    {  return symbol(AxSym.RQUADRA);  }
    case 113: break;
    case 21:
    {  return symbol(AxSym.LQUADRA);  }
    case 114: break;
    case 20:
    {  return symbol(AxSym.RGRAFFA);  }
    case 115: break;
    case 19:
    {  return symbol(AxSym.LGRAFFA);  }
    case 116: break;
    case 18:
    {  return symbol(AxSym.RPAREN);  }
    case 117: break;
    case 17:
    {  return symbol(AxSym.LPAREN);  }
    case 118: break;
    case 3:
    case 37:
    case 38:
    case 41:
    {  throw new RuntimeException("Illegal character \""+yytext()+"\" at line "+yyline+", column "+yycolumn);  }
    case 119: break;
    case 4:
    case 5:
    {  /*return symbol(AxSym.INVIO);*/ /* ignore */  }
    case 120: break;
    case 6:
    {  return symbol(AxSym.DIVIDE);  }
    case 121: break;
    case 7:
    {  return symbol(AxSym.TIMES);  }
    case 122: break;
    case 8:
    case 9:
    case 14:
    case 15:
    case 16:
    case 47:
    case 48:
    case 49:
    case 74:
    case 75:
    case 76:
    case 86:
    {  return axSymbol(yytext());  }
    case 123: break;
    case 10:
    case 11:
    {  return symbol(AxSym.INTEGER_LITERAL, new Integer(yytext()));  }
    case 124: break;
    case 12:
    {  yybegin(STRING); string.setLength(0);  }
    case 125: break;
    case 13:
    {  yybegin(CHARLITERAL);  }
    case 126: break;
    case 26:
    {  return symbol(AxSym.MINUS);  }
    case 127: break;
    case 27:
    {  return symbol(AxSym.ORB);  }
    case 128: break;
    case 28:
    {  return symbol(AxSym.ANDB);  }
    case 129: break;
    case 29:
    {  return symbol(AxSym.GT);  }
    case 130: break;
    case 30:
    {  return symbol(AxSym.EQ);  }
    case 131: break;
    case 31:
    {  return symbol(AxSym.LT);  }
    case 132: break;
    case 32:
    {  return symbol(AxSym.NEG);  }
    case 133: break;
    case 33:
    {  string.append( yytext() );  }
    case 134: break;
    case 34:
    case 35:
    {  throw new RuntimeException("Unterminated string at end of line");  }
    case 135: break;
    case 36:
    {  yybegin(YYINITIAL); return symbol(AxSym.STRING_LITERAL, string.toString());  }
    case 136: break;
    case 39:
    case 40:
    {  throw new RuntimeException("Unterminated character literal at end of line");  }
    case 137: break;
    case 44:
    {  return axMetodo(yytext());  }
    case 138: break;
    case 46:
    {  return symbol(AxSym.FLOATING_POINT_LITERAL, new Float(yytext()));  }
    case 139: break;
    case 50:
    {  return symbol(AxSym.DUEP);  }
    case 140: break;
    case 51:
    {  return symbol(AxSym.GE);  }
    case 141: break;
    case 52:
    {  return symbol(AxSym.LE);  }
    case 142: break;
    case 53:
    {  return symbol(AxSym.NE);  }
    case 143: break;
    case 54:
    case 64:
    case 65:
    case 66:
    case 67:
    case 68:
    case 69:
    case 70:
    {  throw new RuntimeException("Illegal escape sequence \""+yytext()+"\"");  }
    case 144: break;
    default:
    if (yy_input == YYEOF && yy_startRead == yy_currentPos) {
    yy_atEOF = true;
    yy_do_eof();
    {     return new java_cup.runtime.Symbol(AxSym.EOF);
    else {
    yy_ScanError(YY_NO_MATCH);
    }

    I setted use Javac checkbox and it worked ???
    Could someone explain me what happened ?
    The problem seems to be in the very long privated final string I defined, making it shorther the problem is solved again .
    Tks
    Tullio

  • Include an in-memory jar file for JSR-199 compilation

    I want to compile a source file in memory, which requires a jar file that is also represented in memory. I used the JavaSourceFromString class recommended in the documentation for the class JavaCompiler and in a demo I found online that shows how to compile sources represented as String in memory. To represent the jar file, I used a similar trick to JavaSourceFromString:
    public class JarJavaFileObjectFromByteArray extends SimpleJavaFileObject {
       * The contents of this jar file.
      private final byte[] contents;
       * Constructs a new JarJavaFileObjectFromByteArray given the name and binary
       * contents of a jar file.
       * @param name the name of this jar file
       * @param contents the contents of this jar file
      public JarJavaFileObjectFromByteArray(String name, byte[] contents) {
        super(newURI(name), Kind.OTHER);
        this.contents = contents;
      ... // code not shown ensures that the URI returned from newURI is of the form,
          // for instance, bytes:///MathConstants.jar, if the name of the jar file is MathConstants.jar
      @Override
      public InputStream openInputStream() throws IOException {
        return new ByteArrayInputStream(contents);
    }However, I do not know how to alert the compiler that this jar file should be on the classpath. I tried this:
    List<String> options = Arrays.asList(" -classpath bytes:///MathConstants.jar ");
    CompilationTask task = compiler.getTask(null, fileManager, null, options, null, compilationUnits);but I get the following error when calling getTask:
    java.lang.IllegalArgumentException: invalid flag: -classpath bytes:///MathConstants.jarI assume there is some way to tell the compiler, "look at the MathConstants.jar file that I am storing in memory when searching the classpath", but I do not know how to do this. I assumed that the options parameter for getTask represents command-line flags that would be passed to the compiler if this were happening on the command line (such as "-cp .", which also does not work), but perhaps this assumption is wrong.

    Hi Bruce,
    I have a question regarding loading a jar file by the compiler to dynamically compile with a source file. I hope you can probably offer me an idea on what has been missing or wrong with the source codes I have written for my application.
    I am using Eclipse compiler to dynamically compile a class. In the class, I want it to make a reference to a jar file for compilation dynamically.
    Here is the source of a test class I wrote:
    import javax.servlet.http.HttpServlet;
    class MyServlet extends HttpServlet {
    }The import statement refers to the class javax.servlet.http.HttpServlet from the jar file C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\lib\\servlet-api.jar placed in the file system.
    In the method called compileClass (shown below), I used the path of the jar file to add to the option -classpath as you suggested.
         private static CompileClassResult compileClass(Writer out, String className, String classSource) {
              try {
                   JavaCompiler javac = new EclipseCompiler();
                   StandardJavaFileManager sjfm = javac.getStandardFileManager(null, null, null);
                   SpecialClassLoader scl = new SpecialClassLoader();
                   SpecialJavaFileManager fileManager = new SpecialJavaFileManager(sjfm, scl);
                   List<String> options = new ArrayList<String>();
                   options.addAll(Arrays.asList("-classpath", "C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\lib\\servlet-api.jar"));
                   List<MemorySource> compilationUnits = Arrays.asList(new MemorySource(className, classSource));
                   DiagnosticListener<JavaFileObject> diagnosticListener = null;
                   Iterable<String> classes = null;
                   if (out == null) {
                        out = new PrintWriter(System.err);
                   JavaCompiler.CompilationTask compile = javac.getTask(out, fileManager, diagnosticListener, options, classes, compilationUnits);
                   boolean res = compile.call();
                   if (res) {
                        //Need to modify the api to return an array of two elements - one classes and other bytecodes for all classes in the same class file.
                        return CompileClassResult.newInstance(scl.findClasses(), scl.findByteCodes());
              } catch (Exception e) {
                   e.printStackTrace();               
              return null;
         }I also extended the class ForwardingJavaFileManager as you suggested and have it delegated to the StandardJavaFileManager sent to the compiler mentioned in the method compileClass above. The extended class (called SpecialJavaFileManager) is as follows:
    public class SpecialJavaFileManager extends ForwardingJavaFileManager<StandardJavaFileManager> {
         private SpecialClassLoader xcl;
         public SpecialJavaFileManager(StandardJavaFileManager sjfm, SpecialClassLoader xcl) {
              super(sjfm);
              System.out.println("SpecialJavaFileManager");
              this.xcl = xcl;
         public JavaFileObject getJavaFileForOutput(Location location, String name, JavaFileObject.Kind kind, FileObject sibling) throws IOException {
              System.out.println("getJavaFileForOutput");
              MemoryByteCode mbc = new MemoryByteCode(name);
              xcl.addClass(name, mbc);
              return mbc;
         public Iterable<JavaFileObject> list(JavaFileManager.Location loc, String pkg, Set kinds, boolean recurse) throws IOException {
              System.out.println("list ");
            List<JavaFileObject> result = new ArrayList<JavaFileObject>();
            for (JavaFileObject f : super.list(loc, pkg, kinds, recurse)) {
                 System.out.println(f);
                result.add(f);
              return result;
    }I run the application and the result shows that it didn't load the jar file into the memory as expected. From the output (below) I got, it doesn't seem to invoke the method list(...) in the class SpecialJavaFileManager.
    SpecialJavaFileManager
    1. ERROR in \MyServlet.java (at line 1)
         import javax.servlet.http.*;
                ^^^^^^^^^^^^^
    The import javax.servlet cannot be resolved
    2. ERROR in \MyServlet.java (at line 3)
         class MyServlet extends HttpServlet {
                                 ^^^^^^^^^^^
    HttpServlet cannot be resolved to a typeWould you please let me know what has possibly be missing or wrong?
    Thanks.
    Jonathan
    Edited by: jonathanlam on Aug 10, 2009 6:47 PM

Maybe you are looking for

  • How to write select statement before the loop and how to use read statemnt

    Hi, Recently our system has changed from 4.6 to ECC6. As its migrated its showing lots of errors like in between loop and endloop there should be no select statemnt........ Can any one please tell how to write that coding in ECC6 , how can i change t

  • Clear the entry for killed/sniped session in v$session

    Dear all, In our production database(11.2.0.1.0) running on windows 2008 server many client session showing inactive from last 4-5 hour and I want to kill those session because all sessions are dedicated so for this I created a resource plan set its

  • Music dvd in Toast and iTunes 9.2.1

    I am trying to create a music dvd in Toast 10, but it always crashes right at the very end when it is supposed to write the dvd or the image file. Looking at the recovery file in Toast, the last completed file is the dvd folder, though that is probab

  • Bouncing To MP3 Format: Stereo Mode = Normal or Joint Stereo?

    After much research on these forums and listening test, I finally realized that having the "Normalize" box checked (in the Bounce window) resulted in a different sound from what I had mixed. It did "protect" my songs from being distorted in iTunes bu

  • Air for Android - Sqlite - Slow inserts

    Hello there, What is the best way to follow in order to make a lot of insert on a sqlite db? I ask because I noticed a great and unpredicatable slowdown on my Galaxy S when I make a lot of insert. I use an openAsync connection because I need to monit