Late binding of integer constants?

<[email protected]> Thu, 16 Nov 2017 14:34:51 +0100 (CET)
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
Hi,

The following source code:

if (response.getStatus() == SpHttpStatus.SC_OK)

Leads to the following byte code:

         1: invokevirtual #3                  // Method /redacted/
Response.getStatus:()I
         4: sipush        200
         7: if_icmpne     18

In other words, the SpHttpStatus.SC_OK constant has been inlined and replaced
with its value. However, that constant is defined in a different module than
the calling code, meaning that if at runtime, a version with a different value
is used, things will break. I didn't expect that (I was expecting late
binding) - does anyone on this list know something about the rationale for
this?

Another question, probably more suitable for this mailing list: The problem I
am trying to solve is to automatically trim/correct inter-project dependencies
by looking into the bytecode of the classes to see which external classes are
actually referenced. This particular thing makes it hard for me to extract the
fact that this code references the SpHttpStatus class. That fact is noted in
the constant pool, but I don't see an easy way of accessing that information -
is there a good way to do that?

Thanks,
Petter


-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws