C to Java Byte Code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Galga

    #76
    Re: C to Java Byte Code

    Gerry Quinn wrote:[color=blue]
    > In article <10nt68mmg3qtke 5@corp.supernew s.com>, nospam@nosite.z zz
    > says...[color=green]
    >> Gerry Quinn wrote:[color=darkred]
    >>>
    >>> typedef union abc
    >>> { int x;
    >>> float y;
    >>> } a_union;
    >>>
    >>>>>> 2. This is not a union, it it two instances of the same variable.
    >>>>>> Again, to reply to my post, you need to provide the Java
    >>>>>> bytecode that unites a Java float and a Java integer in the same
    >>>>>> address space, something that is not allowed in Java.
    >>>
    >>> Of course it's a union. It has two members x and y which are in
    >>> this instance of different types, although that is by no means part
    >>> of the specification.[/color]
    >>
    >> Yes, it is a union in C, but I am saying it is not a union in the
    >> Java bytecode.[/color]
    >
    > How could it be a union in the Java bytecode? Java bytecode doesn't
    > have unions, any more than machine code does. Unions are a feature of
    > C. The compiler compiles bytecode from C source. The C source may
    > contain unions. The bytecode doesn't, any more than a conventional
    > executable would.[/color]

    *JAVA* doesn't have unions, they could be compiled to *byte code*, in
    the same way Visual Studio (v6 I believe) compiles unions into object
    code. I get the feeling you just jumped on the band wagon here, rather
    then check the facts. It is *ENTIRELY* possible for the OP's compiler to
    support unions, in a similar way many normal C/C++ compilers, like VC
    do.

    ~Galga


    Comment

    • Galga

      #77
      Re: C to Java Byte Code

      CBFalconer wrote:[color=blue]
      > Mark McIntyre wrote:[color=green]
      >>[/color]
      > ... snip ...[color=green]
      >>
      >> Marvellous. Since this has nothing to do with C any more, why the
      >> heck are you stupidly crossposting this long and pointless thread
      >> in CLC and CLC++. Go away.[/color]
      >
      > Not only that but some mentally challenged posters insist on
      > restoring the mess when follow-ups have been set.[/color]

      Because the core topic can be relevant to any of those groups; who are
      you to speak for everyone in those groups? As a matter of fact, people
      from all those groups (that I've seen posting regularly in those
      respective groups) have been jumping into this thread.

      It's the whole long established *POINT* of cross posting, to make a
      thread available where it may serve common interests, which this thread
      has done.

      ~Galga


      Comment

      • Gerry Quinn

        #78
        Re: C to Java Byte Code

        In article <417E469B.95A63 564@yahoo.com>, cbfalconer@yaho o.com says...[color=blue]
        > Mohd Hanafiah Abdullah wrote:[/color]
        [color=blue][color=green]
        > > main()
        > > { a_union z;
        > >
        > > z.x = 1078531719;
        > > printf("int val = %d\n", z.x);
        > > printf("float val = %f\n", z.y);[/color]
        >
        > illegal statement here. You cannot access a field of a union as a
        > type other than what you last wrote into it.[/color]

        It's not illegal, any more than casting a float to an int (which it
        effectively is) is illegal.

        What Paul seems not to understand is that, while it is legal, the
        results are unspecified, and tend to be implementation-dependent.

        - Gerry Quinn

        Comment

        • Gerry Quinn

          #79
          Re: C to Java Byte Code

          In article <cloiqe$b90$1@n ews.astound.net >, none@none.spamblowz says...[color=blue]
          > Gerry Quinn wrote:[color=green]
          > > In article <10nt68mmg3qtke 5@corp.supernew s.com>, nospam@nosite.z zz
          > > says...[color=darkred]
          > >> Yes, it is a union in C, but I am saying it is not a union in the
          > >> Java bytecode.[/color]
          > >
          > > How could it be a union in the Java bytecode? Java bytecode doesn't
          > > have unions, any more than machine code does. Unions are a feature of
          > > C. The compiler compiles bytecode from C source. The C source may
          > > contain unions. The bytecode doesn't, any more than a conventional
          > > executable would.[/color]
          >
          > *JAVA* doesn't have unions, they could be compiled to *byte code*, in
          > the same way Visual Studio (v6 I believe) compiles unions into object
          > code. I get the feeling you just jumped on the band wagon here, rather
          > then check the facts. It is *ENTIRELY* possible for the OP's compiler to
          > support unions, in a similar way many normal C/C++ compilers, like VC
          > do.[/color]

          Which is exactly what I'm saying. C has unions. Bytecode and object
          code don't. Paul's objections are meaningless.

          - Gerry Quinn

          Comment

          • Gerry Quinn

            #80
            Re: C to Java Byte Code

            In article <MPG.1be9e02545 c89c61989a6d@ne ws.indigo.ie>,
            gerryq@DELETETH ISindigo.ie says...[color=blue]
            > In article <417E469B.95A63 564@yahoo.com>, cbfalconer@yaho o.com says...[color=green]
            > > Mohd Hanafiah Abdullah wrote:[/color]
            >[color=green][color=darkred]
            > > > main()
            > > > { a_union z;
            > > >
            > > > z.x = 1078531719;
            > > > printf("int val = %d\n", z.x);
            > > > printf("float val = %f\n", z.y);[/color]
            > >
            > > illegal statement here. You cannot access a field of a union as a
            > > type other than what you last wrote into it.[/color]
            >
            > It's not illegal, any more than casting a float to an int (which it
            > effectively is) is illegal.[/color]

            Sorry, I meant casting a float* to an int* and de-referencing. Casting
            a float to an int does give specified results, of course.

            - Gerry Quinn

            Comment

            • Galga

              #81
              Re: C to Java Byte Code

              Paul Lutus wrote:[color=blue]
              > Dave Vandervies wrote:
              >[color=green]
              >> In article <10nqq7cnnsv852 5@corp.supernew s.com>,
              >> Paul Lutus <nospam@nosite. zzz> wrote:[/color]
              >
              > / ...
              >[color=green][color=darkred]
              >>> When you are ready to address the topic of this thread, post again.[/color]
              >>
              >> I'm attempting to address the suitability of using an array of 32-bit
              >> values to store values of varying types and use a union to convert
              >> between the values stored there.[/color]
              >
              > That is not the topic, and you need to find out what "thread drift"
              > refers to. You are always free to start any thread, on any topic, in
              > any suitable newsgroup. For this thread, a thread originated and
              > cross-posted to four nearly unrelated newsgroups by an unscrupulous
              > commercial vendor eager for free publicity, you have limited options
              > other than addressing the topic.
              >[color=green]
              >> Since that's obviously not what you think the topic of this thread
              >> is,[/color]
              >
              > I did not start this thread, cross-post it, or choose its topic.[/color]

              But you *DID* participate and *YOU* are just as much to blame for the
              "thread drift" you speak of, yet it's everyone else's fault. How
              convenient.

              Actually, the part of the thread you are referring to discusses the
              validity of the OP's product, which has to do with the original topic.
              Since when is posting about weather the program can do what it's claimed
              to be able to do off-topical from the root topic? Granted it's
              stretched, but not so far as to warrant another thread, IMHO.


              Comment

              • Galga

                #82
                Re: C to Java Byte Code

                Gerry Quinn wrote:[color=blue]
                > In article <cloiqe$b90$1@n ews.astound.net >, none@none.spamblowz
                > says...[color=green]
                >> Gerry Quinn wrote:[color=darkred]
                >>> In article <10nt68mmg3qtke 5@corp.supernew s.com>, nospam@nosite.z zz
                >>> says...
                >>>> Yes, it is a union in C, but I am saying it is not a union in the
                >>>> Java bytecode.
                >>>
                >>> How could it be a union in the Java bytecode? Java bytecode doesn't
                >>> have unions, any more than machine code does. Unions are a feature
                >>> of C. The compiler compiles bytecode from C source. The C source
                >>> may contain unions. The bytecode doesn't, any more than a
                >>> conventional executable would.[/color]
                >>
                >> *JAVA* doesn't have unions, they could be compiled to *byte code*, in
                >> the same way Visual Studio (v6 I believe) compiles unions into object
                >> code. I get the feeling you just jumped on the band wagon here,
                >> rather then check the facts. It is *ENTIRELY* possible for the OP's
                >> compiler to support unions, in a similar way many normal C/C++
                >> compilers, like VC do.[/color]
                >
                > Which is exactly what I'm saying. C has unions. Bytecode and object
                > code don't. Paul's objections are meaningless.[/color]

                Quite right. I think most of this thread could have been avoided if Paul
                had admitted his blunder, or had not made it in the first place. But,
                sigh, you can't expect much of PL anymore, as he is *never* wrong....


                Comment

                • Galga

                  #83
                  Re: C to Java Byte Code

                  Gerry Quinn wrote:[color=blue]
                  > In article <MPG.1be9e02545 c89c61989a6d@ne ws.indigo.ie>,
                  > gerryq@DELETETH ISindigo.ie says...[color=green]
                  >> In article <417E469B.95A63 564@yahoo.com>, cbfalconer@yaho o.com
                  >> says...[color=darkred]
                  >>> Mohd Hanafiah Abdullah wrote:[/color]
                  >>[color=darkred]
                  >>>> main()
                  >>>> { a_union z;
                  >>>>
                  >>>> z.x = 1078531719;
                  >>>> printf("int val = %d\n", z.x);
                  >>>> printf("float val = %f\n", z.y);
                  >>>
                  >>> illegal statement here. You cannot access a field of a union as a
                  >>> type other than what you last wrote into it.[/color]
                  >>
                  >> It's not illegal, any more than casting a float to an int (which it
                  >> effectively is) is illegal.[/color]
                  >
                  > Sorry, I meant casting a float* to an int* and de-referencing.
                  > Casting a float to an int does give specified results, of course.
                  >
                  > - Gerry Quinn[/color]

                  Good catch, I was about to reply about that, saved me the trouble :-)

                  ~Galga


                  Comment

                  • Richard Herring

                    #84
                    Re: C to Java Byte Code

                    In message <cloijm$b7b$1@n ews.astound.net >, Galga <none@none.spam blowz>
                    writes[color=blue]
                    >Richard Herring wrote:[color=green]
                    >> In message <10ntsg1o8vbi16 f@corp.supernew s.com>, Paul Lutus
                    >> <nospam@nosite. zzz> writes[color=darkred]
                    >>> Mark McIntyre wrote:
                    >>>
                    >>>> On Tue, 26 Oct 2004 11:36:02 -0700, in comp.lang.c , Paul Lutus
                    >>>> <nospam@nosite. zzz> wrote:
                    >>>>
                    >>>>> Yes, it is a union in C, but I am saying it is not a union in the
                    >>>>> Java bytecode.
                    >>>>
                    >>>> Marvellous. Since this has nothing to do with C any more,
                    >>>
                    >>> Do you see a reference to C in the sentence above? No? Is there an
                    >>> optometrist available in your neighborhood?
                    >>>
                    >>> The discussion is about a C to Java cross-compiler. Both languages
                    >>> are therefore topical.[/color]
                    >>
                    >> Not in comp.lang.c++, they are not. Please take this elsewhere.
                    >>[/color]
                    >Richard, is it going to warp the the fecking space time continuum to get
                    >off your high horse about a topic that is just maybe mere ounces off
                    >topic?[/color]

                    Why is it so important to you to continue crossposting this thread?
                    What's your agenda? I[color=blue]
                    >
                    >In case you haven't noticed, C and even Java are related languages; many
                    >who use one use or have experience with the others,[/color]

                    In case _you_ haven't noticed, C and C++ are even more closely related
                    languages, yet comp.lang.c and comp.lang.c++ are separate groups and
                    there are good reasons for that.
                    [color=blue]
                    >and who are you to
                    >speak for everyone in c.l.c++,[/color]

                    Where did I claim to do that?
                    [color=blue]
                    >when it might be of interest of people
                    >there?[/color]

                    "Might be"? Have you actually read this group before today?
                    [color=blue]
                    >Actually many people I've seen post there have taken interest in
                    >this thread,[/color]

                    Yeah, right. Name five. Then show that they aren't reading it in one of
                    the other groups where it might be on topic.
                    [color=blue]
                    >so I think you are proven wrong just by that.[/color]

                    Logic failure. Even *I* take an interest in some off-topic threads. That
                    doesn't bring them back on topic.[color=blue]
                    >
                    >If you don't like a thread, then kill it on your end, please don't try
                    >to push your tastes on other people; even though this thread may not be
                    >100% topical, but it still can have a place in any of the groups listed.[/color]

                    So why don't we just add misc.misc to the Newsgroup: line?[color=blue]
                    >
                    >In fact, this was the entire point of cross posted, as par a gigantic
                    >thread a couple years ago about cross posting; ultimately it's to bring
                    >people of similar interests together,[/color]

                    And what exactly is the "similar interest" in this case? Feel free to
                    point out which features of the standard C++ language
                    [color=blue]
                    > and this topic is just that and
                    >has DONE just that.[/color]

                    In your opinion, perhaps.[color=blue]
                    >
                    >So again, kindly kill file this thread if you don't want to see it.[/color]


                    --
                    Richard Herring

                    Comment

                    • Galga

                      #85
                      Re: C to Java Byte Code

                      Richard Herring wrote:[color=blue]
                      > In message <cloijm$b7b$1@n ews.astound.net >, Galga
                      > <none@none.spam blowz> writes[color=green]
                      >> Richard Herring wrote:[color=darkred]
                      >>> In message <10ntsg1o8vbi16 f@corp.supernew s.com>, Paul Lutus
                      >>> <nospam@nosite. zzz> writes
                      >>>> Mark McIntyre wrote:
                      >>>>
                      >>>>> On Tue, 26 Oct 2004 11:36:02 -0700, in comp.lang.c , Paul Lutus
                      >>>>> <nospam@nosite. zzz> wrote:
                      >>>>>
                      >>>>>> Yes, it is a union in C, but I am saying it is not a union in the
                      >>>>>> Java bytecode.
                      >>>>>
                      >>>>> Marvellous. Since this has nothing to do with C any more,
                      >>>>
                      >>>> Do you see a reference to C in the sentence above? No? Is there an
                      >>>> optometrist available in your neighborhood?
                      >>>>
                      >>>> The discussion is about a C to Java cross-compiler. Both languages
                      >>>> are therefore topical.
                      >>>
                      >>> Not in comp.lang.c++, they are not. Please take this elsewhere.
                      >>>[/color]
                      >> Richard, is it going to warp the the fecking space time continuum to
                      >> get off your high horse about a topic that is just maybe mere ounces
                      >> off topic?[/color]
                      >
                      > Why is it so important to you to continue crossposting this thread?
                      > What's your agenda? I[/color]

                      Because you wanted to speak on behalf of that group, it made no sense
                      *NOT* to reply to that group. Unless you have something to hide.
                      [color=blue][color=green]
                      >> In case you haven't noticed, C and even Java are related languages;
                      >> many who use one use or have experience with the others,[/color]
                      >
                      > In case _you_ haven't noticed, C and C++ are even more closely related
                      > languages, yet comp.lang.c and comp.lang.c++ are separate groups and
                      > there are good reasons for that.[/color]

                      True, but that alomne doesn't mean you cannot have cross topic
                      disccusion. Again, please do not act like you are some sort of owner of
                      the news groups. Your opinion is only that, it's not an administrative
                      or royal decry.
                      [color=blue][color=green]
                      >> and who are you to
                      >> speak for everyone in c.l.c++,[/color]
                      >
                      > Where did I claim to do that?[/color]

                      By trying to decide for everyone what groups this belogns to (ie,
                      setting follow up.) Not that this part of the thread matters all that
                      much, your attempt goes meaningless.
                      [color=blue][color=green]
                      >> when it might be of interest of people
                      >> there?[/color]
                      >
                      > "Might be"? Have you actually read this group before today?[/color]

                      Yes, plenty, what is your point? People from all these groups may read
                      one of these groups a lot more then the others. Even if not, why do
                      *YOU* care? If you don't want to see this thread in that group, then
                      kill file it.

                      Who the hell is holding a gun to your head making you read this thread?


                      [color=blue]
                      >
                      > And what exactly is the "similar interest" in this case? Feel free to
                      > point out which features of the standard C++ language[/color]

                      Nice try, but that was never the point. The point was, as you actually
                      said, that the c and c++ groups are rather seperated, but people in
                      either might be *interested* in this topic, as it bares some relation.
                      The original post was not a direct C post, nor was it a direct Java
                      post, but a post about a utility, that if it works, could be a useful
                      program.

                      In that sense, there really seems to be no real reason to shout "off
                      topic" for only in the name of 100% conformity and ultimately complete
                      utter inflexibility. Only if you really feel the need to make noise by
                      making a unnecessary fuss.
                      [color=blue][color=green]
                      >>
                      >> So again, kindly kill file this thread if you don't want to see it.[/color][/color]

                      And again, ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^



                      ~Galga


                      Comment

                      • John Gordon

                        #86
                        Re: C to Java Byte Code

                        In <clombd$d04$1@n ews.astound.net > "Galga" <none@none.spam blowz> writes:
                        [color=blue]
                        > If you don't want to see this thread in that group, then kill file it.
                        > Who the hell is holding a gun to your head making you read this thread?[/color]

                        This sounds like the classic spam defense. "If you don't want to read
                        it, just delete it!" And we all know how well that works...

                        --
                        John Gordon "Between BST melee, their spells, their warders' melee,
                        gordon@panix.co m and their warders' procs, they put out enough damage
                        to make monks cry." -- Dark Tyger

                        Comment

                        • Alfred Z. Newmane

                          #87
                          Re: C to Java Byte Code

                          John Gordon wrote:[color=blue]
                          > In <clombd$d04$1@n ews.astound.net > "Galga" <none@none.spam blowz>
                          > writes:
                          >[color=green]
                          >> If you don't want to see this thread in that group, then kill file
                          >> it. Who the hell is holding a gun to your head making you read this
                          >> thread?[/color]
                          >
                          > This sounds like the classic spam defense. "If you don't want to read
                          > it, just delete it!"[/color]

                          That maybe a classic defense, but I don't see how this thread (except
                          maybe in some views, the original post) could be spam.

                          In this case, I think the "kill the thread if you dont like it" hold
                          water, as no one is forcing anyone to read it.
                          [color=blue]
                          > And we all know how well that works...[/color]

                          Works rather well if you know how to delete a thread that you /really/
                          don't want to read. Is it /that/ hard?


                          Comment

                          • Old Wolf

                            #88
                            Re: C to Java Byte Code

                            Paul Lutus <nospam@nosite. zzz> wrote:[color=blue]
                            > Old Wolf wrote:
                            >[color=green]
                            > > Sorry, you are wrong. There is no requirement in the C standard for
                            > > the members of the union to occupy the same piece of memory.
                            > > If you disagree then please quote a standard reference.[/color]
                            >
                            > http://explanation-guide.info/meanin...age-union.html
                            >
                            > "Because they occupy the same space, changing u.a also changes the value of
                            > u.b."
                            >
                            > "The primary usefulness of a union is to conserve space, since it provides a
                            > way of letting many different types be stored in the same space."
                            >
                            > There are plenty of similar references[/color]

                            And what makes you think those pages are accurate?
                            None of these contain references to the C standard.
                            They are comments made by people who are used to programming on
                            implementations that do the what those quotes say. However it is
                            possible to have a conforming C implementation without
                            these quotes applying.

                            As an analogy, I could find screensful of quotes saying that
                            bytes have 8 bits. But as we all know, there are C implementations
                            in which a byte has 9, or 32, or some other amount of bits.
                            [color=blue][color=green][color=darkred]
                            > >> Show us the Java bytecode that allows one to manipulate
                            > >> individual bits of a Java float datatype, as a C union allows.[/color]
                            > >
                            > > A C union does not allow that.
                            > > Any C program that relies on it is non-portable.[/color]
                            >
                            > Non sequitur. It is a question of syntactic correctness, not portability.[/color]

                            In C it is possible to have a syntactically correct
                            program that is not portable (by which I mean, it may
                            work reliably on one platform, but give different results,
                            or crash entirely, on different platforms). For example:

                            int i = 3;
                            i = i++;
                            printf("%d\n", i);

                            Here is another example of non-portability that doesn't
                            include undefined behaviour:

                            int x = 12;
                            assert( *(unsigned char *)&x == 0 );

                            Comment

                            • E. Robert Tisdale

                              #89
                              Re: C to Java Byte Code

                              John Gordon wrote:
                              [color=blue]
                              > Something that calls itself Galga writes:
                              >[color=green]
                              >>If you don't want to see this thread in that group, then kill file it.
                              >>Who the hell is holding a gun to your head making you read this thread?[/color]
                              >
                              > This sounds like the classic spam defense.
                              > "If you don't want to read it, just delete it!"
                              > And we all know how well that works...[/color]

                              Please don't feed the trolls.

                              Comment

                              • Flash Gordon

                                #90
                                Re: C to Java Byte Code

                                On Wed, 27 Oct 2004 16:17:29 +0200
                                "dandelion" <dandelion@mead ow.net> wrote:

                                <snip using union to pan array of unsigned char to structs containing
                                unsigned chars>
                                [color=blue][color=green]
                                > > I recommend, however, that you do not rely so heavily on undefined
                                > > behaviour.[/color]
                                >
                                > Which undefined behavior?[/color]

                                Reading using a different type to the type used for writing. IIRC some
                                of the elements of your struct we actually declared as uint16
                                [color=blue]
                                > If you knew the compiler i'm using, you'd
                                > (probably) laugh your arse off thinking of "undefined behavior". It is
                                > (putting it mildly) not very conforming. In fact, it isn't even C,
                                > just(vaguely) C-like. However, the structure as presented in my
                                > previous post is what's running (more or less) on the host aswell.
                                > Although padding *is* an issue (a tackled one) there.[/color]

                                From the sounds of it you will be using implementation specific trickery
                                and/or work arounds for implementation deficiencies, so I would not
                                worry about using implementation specific knowledge about unions.
                                [color=blue][color=green]
                                > > If you intend to read a series of chars, it would be a good
                                > > idea to define your opcodes or whatever in terms of chars.[/color]
                                >
                                > I intend to read a structured message coming in from a UDP connection
                                > and/or a RS485 serial line (allthough the latter uses a slightly
                                > different definition on the lowest level). So, no... There's no naked
                                > 'char' in sight, only a number of 8-bit values (in order to avoid
                                > endianness issues). That's why I defined everything using uint8 (which
                                > is typedeffed as an unsigned char). The chances of any of the uint8's
                                > mentioned containing anything printable is not very big.[/color]

                                I thought I saw a uint16 or something like that? Maybe a typo or faulty
                                memory on my part.
                                [color=blue][color=green]
                                > > Then you
                                > > need have no fears that your code will give unpredictable results on
                                > > different implementations .[/color]
                                >
                                > Does the 'Byte-code compiler' of the OP move memory or not? As
                                > previously mentioned, the intended platform is a micro-controller in
                                > an embedded environment.[/color]

                                Using the union to map the different types all on to one piece of memory
                                *does* achieve what you want, i.e. it does *not* move the data around to
                                copy with the accesses by different types. So in *your* case I would
                                say hang the portability issues (but comment them) and go for it.

                                You would be probably be best discussing this on groups/mailing lists
                                dedicated to your platforms of interest since on comp.lang.c we won't
                                know the limitations of your C-like implementation and the would be off
                                topic in any case.

                                It is probably off topic for most of the other groups as well, so I've
                                set follow ups to comp.programmin g as the most likely group of the ones
                                this is cross-posted to.
                                --
                                Flash Gordon
                                Sometimes I think shooting would be far too good for some people.
                                Although my email address says spam, it is real and I read it.

                                Comment

                                Working...