Jvm runtime constant pool

Hi there,
this is my query:
As we know java builds a constant pool for all the symbols if a class in a class file. This class file when loaded by VM, the constant pool is translated into the runtime constant pool in the method area of the Heap.
Does any one know if there is only 1 runtime constant pool per class or is it 1 per class instance(Object). The JVM spec did not clarify on this. Also if its 1 per class then how does the JVM know where all the instances of a class are while resolving references and also when garbage collecting???
thank a lot.
Rishabh.

rishabhchandra wrote:
As we know java builds a constant pool for all the symbols if a class in a class file. This class file when loaded by VM, the constant pool is translated into the runtime constant pool in the method area of the Heap.
Symbols?
It builds it for literals.
Does any one know if there is only 1 runtime constant pool per class or is it 1 per class instance(Object). Certainly not by instance.
And more likely it is per class loader. A class can't be unloaded unless its class loader is unloader so there would be no point in managing a pool per class when it could be managed via the class loader.
The JVM spec did not clarify on this. Nor should it. That is an implementation detail of how the VM is implemented.
Also if its 1 per class then how does the JVM know where all the instances of a class are while resolving references and also when garbage collecting???Not sure that question is sensical. The only reason it would need to know is because it is using the class. And the class might not own the pool, but it certainly references it.
As for garbage collection that only occurs in the context of this question if the class loader is collected.

Similar Messages

  • When String instances in Constant Pool will be GC'ed?

    Hi all,
    I'm involved in an application development; where we are storing numerous string objects into multiple HashMaps. Since the string objects created/placed in HashMap may have duplicate values; we're calling String::intern() method to make use of String Constant Pool feature in Java. But, my concern is - When the Constant String instance will be removed from Pool? Is it follow the same behaviour that if no references are presentm it is eligible for GC; i.e., removal of an instance from all HashMaps?
    Please help.
    Thanks & regards,
    R Kaja Mohideen

    EJP wrote:
    How do you figure?Doesn't say so in the Javadoc. It talks about another pool ...You're taking "A pool of strings, initially empty, is maintained privately by the class String." as meaning it's not "the constant pool"? I wouldn't interpret it that way. And based on the JVM spec, I don't see anything saying the intern()ed Strings go to a different pool than "the constant pool". And if it is a separate pool, then what does go into "the constant pool"?
    http://java.sun.com/docs/books/jvms/second_edition/html/Overview.doc.html#22972
    "A runtime constant pool is a per-class or per-interface runtime representation of the constant_pool table in a class file (§4.4). It contains several kinds of constants, ranging from numeric literals known at compile time to method and field references that must be resolved at run time. "
    "Each runtime constant pool is allocated from the Java virtual machine's method area (§3.5.4)."
    http://java.sun.com/docs/books/jvms/second_edition/html/Overview.doc.html#6656
    "The Java virtual machine has a method area that is shared among all Java virtual machine threads. [...] It stores per-class structures such as the runtime constant pool, field and method data, and the code for methods and constructors [...]"
    http://java.sun.com/docs/books/jvms/second_edition/html/ConstantPool.doc.html#73272
    "The Java virtual machine maintains a per-type constant pool (§3.5.5),"
    "A string literal (§2.3) is derived from a CONSTANT_String_info structure (§4.4.3) in the binary representation of a class or interface. The CONSTANT_String_info structure gives the sequence of Unicode characters constituting the string literal.
    The Java programming language requires that identical string literals (that is, literals that contain the same sequence of characters) must refer to the same instance of class String. In addition, if the method String.intern is called on any string, the result is a reference to the same class instance that would be returned if that string appeared as a literal. Thus,
    ("a" + "b" + "c").intern() == "abc"
    must have the value true.
    To derive a string literal, the Java virtual machine examines the sequence of characters given by the CONSTANT_String_info structure.
    If the method String.intern has previously been called on an instance of class String containing a sequence of Unicode characters identical to that given by the CONSTANT_String_info structure, then the result of string literal derivation is a reference to that same instance of class String.
    Otherwise, a new instance of class String is created containing the sequence of Unicode characters given by the CONSTANT_String_info structure; that class instance is the result of string literal derivation. Finally, the intern method of the new String instance is invoked."
    Edited by: jverd on Jan 23, 2012 8:09 AM

  • Reflection error (Illegal constant pool index)

    Heya,
    I use reflection to invoke Java classes and I get Error:
    java.lang.ClassFormatError: AppendToElement (Illegal constant pool index)
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:431)
         at XCOClassLoader.loadClass(XCOClassLoader.java:74)
    // AppendToElement is name of class I want to invoke
    I have bunch of classes from someone else, which I need to invoke and I get this error for all of them. When I invoke classes written (and compiled) by me, everything is OK.
    It seems that the problem is that, these external classes were compiled with different version of Java. As they were written by someone else and I don't have source code, I can't recompile them.
    Is cause of that problem, different JVM versions ? Is there a way how to correct it on runtime ?
    Thanks,
    Michal

    The problem isn't one of versions. The files have become corrupted somehow. I suggest you ask for another copy.

  • Lifetime and behavior of the String Constant Pool

    If you 'inline' a String constant in Java, I'm aware in the VM spec that it says this String is put in the constant pool.
    What is the lifetime of the constant pool and what is it tied to? Is there one constant pool per Class, per Class instance, or per VM?
    If an instance is GC'd, do it's constants previously moved to the constant pool get destroyed, or do they live on until I create another instance of that Class?
    Thanks, Kevin

    Is the constant pool created at compile time and written into the Class file?Yes.
    Each class has it's own constant pool which contains constant values and references to other classes and fields.
    It is created a compile time.
    A class (definition) is loaded by a classloader at runtime.
    In theory you could have the same class loaded twice by different classloaders and each would have a copy of the class definition.
    As far as I know, a class definition can only be removed from memory by nulling/garbage collecting the classloader that loaded it.
    regards,
    Owen

  • Why jvm maintains string pool only for string objects why not for other objects?

    why jvm maintains string pool only for string objects why not for other objects? why there is no pool for other objects? what is the specialty of string?

    rp0428 wrote:
    You might be aware of the fact that String is an immutable object, which means string object once created cannot be manipulated or modified. If we are going for such operation then we will be creating a new string out of that operation.
    It's a JVM design-time decision or rather better memory management. In programming it's quite a common case that we will define string with same values multiple times and having a pool to hold these data will be much efficient. Multiple references from program point/ refer to same object/ value.
    Please refer these links
    What is Java String Pool? | JournalDev
    Why String is Immutable in Java ? | Javalobby
    Sorry but you are spreading FALSE information. Also, that first article is WRONG - just as OP was wrong.
    This is NO SUCH THING as a 'string pool' in Java. There is a CONSTANT pool and that pool can include STRING CONSTANTS.
    It has NOTHING to do with immutability - it has to do with CONSTANTS.
    Just because a string is immutable does NOT mean it is a CONSTANT. And just because two strings have the exact same sequence of characters does NOT mean they use values from the constant pool.
    On the other hand class String offers the .intern() method to ensure that there is only one instance of class String for a certain sequence of characters, and the JVM calls it implicitly for literal strings and compile time string concatination results.
    Chapter 3. Lexical Structure
    In that sense the OPs question is valid, although the OP uses wrong wording.
    And the question is: what makes class Strings special so that it offers interning while other basic types don't.
    I don't know the answer.
    But in my opinion this is because of the hybrid nature of strings.
    In Java we have primitive types (int, float, double...) and Object types (Integer, Float, Double).
    The primitive types are consessons to C developers. Without primitive types you could not write simple equiations or comparisons (a = 2+3; if (a==5) ...). [autoboxing has not been there from the beginning...]
    The String class is different, almost something of both. You create String literals as you do with primitives (String a = "aString") and you can concatinate strings with the '+' operator. Nevertheless each string is an object.
    It should be common knowledge that strings should not be compared with '==' but because of the interning functionality this works surprisingly often.
    Since strings are so easy to create and each string is an object the lack ot the interning functionality would cause heavy memory consumption. Just look at your code how often you use the same string literal within your program.
    The memory problem is less important for other object types. Either because you create less equal objects of them or the benefit of pointing to the same object is less (eg. because the memory foot print of the individual objects is almost the same as the memory footpint of the references to it needed anyway).
    These are my personal thoughts.
    Hope this helps.
    bye
    TPD

  • Error in groovy expression: Illegal type in constant pool

    Hi,
    I intermittently get this error on my page:
    EMGC_OMS1 ERROR] [ http://oracle.adfinternal.view.faces.config.rich.RegistrationConfigurator [tid:
    userId: SYSMAN ecid: 004emUHK7jA9XbWLHyl3if0002JD0011gG,0:1 APP: emgc URI: ... ... ... :Server Exception during PPR, #15[[ javax.servlet.ServletException: java.lang.VerifyError: (class: org/codehaus/groovy/runtime/ArrayUtil, method: createArray signature: ()[Ljava/lang/Object;) Illegal type in constant pool
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    Caused by: java.lang.VerifyError: (class:
    org/codehaus/groovy/runtime/ArrayUtil, method: createArray signature:
    ()[Ljava/lang/Object;) Illegal type in constant pool
             at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
             at bc4j.oracle_sysman_core_event_console_uimodel_view_IssueListVO_PriorityLocalizedLabel_null.gs.run(bc4j.oracle_sysman_core_event_console_uimodel_view_IssueListVO_PriorityLocalizedLabel_null.gs.groovy:1)
             at oracle.jbo.ExprEval.internalEvaluateGroovyScript(ExprEval.java:1208)
    The IssueListVO getPriorityLocalizedLabel uses a groovy expression:
    oracle.sysman.core.event.common.uimodel.util.MetadataUtil.getPriorityLabel(Priority.intValue()).
    The Priority field is defined to be numeric, and the repository data shows all records having a value of 0, so this groovy expression should behave correctly.
    We are using Build JDEVADF_11.1.1.5.0_GENERIC_110409.0025.6013.
    Any ideas on how to resolve this?
    Thanks!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    cn u chk this
    LinkageError

  • XSLT mapping, how can I include a Runtime Constants in target message

    Hi, I would like in my XSLT mapping, to have an attribute include the MessageID.
    From my understanding of the online help [http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm|http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm], I have the following code in my XSL:
                   <xsl:param name="MessageId" />
                   <xsl:attribute name="filename">Output_<xsl:value-of select="$MessageId"/>.xml</xsl:attribute>
    But for now the result is to have a filename attribute that only contains: "Output_.xml" as if the $MessageId is empty.
    Anyone experienced successfully using one of those runtime constants with XSLT mapping ?
    Cheers,
    greg

    Hi, found the answer of why it was not running: I'm in a transform step of a BPM:
    For more info check this thread:
    [/message/435521#435521 [original link is broken]|/message/435521#435521 [original link is broken]]

  • Reg problem in Runtime Constants $SenderService

    Hi
          Have a problem , I am using ABAP XSLT Processor  mapping (I have used message split for this particular scenario i.e. input is single file and output is multiple file)
    Instead of hard coding the sender service i tried to use Runtime Constants $SenderService but this was not working .
    For one to one scenrio it is working fine ,also in JAVA XSLT Processor  it is working fine ....
    can any one help on this
    Ramamurthy

    are you testing your XSL program in XI or outside ?
    These runtime consants can be accessed only inside XI.
    also,
    <i>
    If you want to access one of the constants in the XSLT program, you first have to declare the constant as a parameter, for example:
    <xsl:param name="MessageId" /></i>
    ref: more @
    http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm

  • Selection dynamic Mapping Runtime Constant with a qualifier

    Hello all,
    i want to access a Mapping Runtime Constant out of a message mapping specified with a qualifier.
    In the Integration Directory i specified in the identifier tab the following Value Pairs:
    Agency               Scheme          Name
    http://Sap.com/xi/XI    XIParty         ABC
    R3D_310                 Partner         111
    R3T_310                 Partner         222
    R3P_310                 Partner         333
    In the message mapping i want to have the Name for the agency "R3T_310".
    I know i can access the Name with:
    constant = (String) map.get(StreamTransformationConstants.SENDER_PARTY);
    But i getting everytime the name "ABC", which i don't want.
    At this point i need your help, to find out how i can dynamically get the correct one??
    many thanks for your help
    ilka

    Ilka,
    You can also access other Mapping Runtime constants. For example, SENDER_PARTY_AGENCY.
    If needed, you can also access SENDER_PARTY_SCHEME and SENDER_SERVICE.
    The SAP Help link for all the Mapping Runtime constants accessible with StreamTransformationConstants is:
    http://help.sap.com/saphelp_nw04/helpdata/en/78/b4ea10263c404599ec6edabf59aa6c/frameset.htm
    Hope this helps,
    Bhanu

  • Runtime constant: mapping-programm

    Hello,
    we got a exception branch for mapping errors in BPM.
    Now we want to inform the user, which mapping programm caused the error.
    Is there a runtime constant?
    I already analyzed:
    http://help.sap.com/saphelp_nw04/helpdata/en/b3/9a2aeb24dc4ab6b1855c99157529e4/content.htm
    Regards Mario

    Hi Mario,
    You can raise alerts if mapping, receiver determination etc.. fails in the integartion engine. You need to configure alert rules for this. You can go to RWB->Alert Configuration->Where did the error occur? choose integration engine and you can see different error categories and error codes which can be configured using alert rules. Refer this michal's weblog for configuring the same..
    /people/michal.krawczyk2/blog/2005/09/09/xi-alerts--step-by-step
    You can also raise an alerts from BPM for any mapping failures, send step system errors/application errors using fault messages (through exception branch).
    Refer this weblog for configuring an alert in the BPM
    /people/michal.krawczyk2/blog/2005/03/13/alerts-with-variables-from-the-messages-payload-xi--updated
    In you BPM, You can add Container Variables to Messages by using Container Opertaions(Append/Assign)
    http://help.sap.com/saphelp_nw2004s/helpdata/en/59/e1283f2bbad036e10000000a114084/frameset.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/33/4a773f12f14a18e10000000a114084/frameset.htm
    And also you can throw this exceptions via Alerts.
    Also go through these links....
    http://help.sap.com/saphelp_nw2004s/helpdata/en/33/4a773f12f14a18e10000000a114084/frameset.htm
    /people/alessandro.guarneri/blog/2006/01/26/throwing-smart-exceptions-in-xi-graphical-mapping
    /people/sap.user72/blog/2005/02/23/raising-exceptions-in-sap-xi-mapping
    http://help.sap.com/saphelp_nw2004s/helpdata/en/80/942f3ffed33d67e10000000a114084/frameset.htm
    /people/michal.krawczyk2/blog/2005/09/09/xi-alerts--step-by-step
    /people/aravindh.prasanna/blog/2005/12/23/configuring-scenario-specific-e-mail-alerts-in-xi-ccms-part--1
    Regards,
    Abhy
    Message was edited by: Abhy Thomas
    Message was edited by: Abhy Thomas

  • ** Not able to access Runtime Constants in ABAP XSL

    Hi friends,
    We have written one ABAP XSLT program. (XSLT program runs in ABAP Engine). This program is for the interface Mapping in XI. Source Interface occurrence is 1 and target interface occurrence is 0..unbounded. ie. We use Message Split to send source messages to multiple target messages. For this we have written one ABAP XSLT program. To find Value mappings we use 'SenderService' Runtime Constant to determine Sender Service (for Source Agency) at runtime. But the problem is,  inside template the constant $SenderService did not have the value.  I have given below the coding
    <xsl:param name = 'SenderService'/>
    <xsl:template match="/">
         <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
                 <ns0:Message1>          
                  <ns1:employeeDemographicsRequest xmlns:ns1="http://aprilbiztec.com">
    <!-- here we are $SenderService did not receive the value -->
    Friends, Could you kindly help me to solve this problem ? (ie how to access Runtime Constants in ABAP XSLT when use message Split)
    Thanks in advance.
    Kind Regards
    Jeagthees P.
    Note :
    1) In normal ABAP XSLT, we are able to access Runtime Constant.
    2) For the same scenario, if we use normal XSLT ie. JAVA XSLT, we are able to access Runtime Constant.

    Hi,
    As far as I know you cannot access Runtime constants if there is a message split.
    Regards,
    Kumar

  • Runtime Constant in XSLT :-(

    Hi together,
    I have one problem with constant at the runtime.
    The tag <RCVPRN> is empty, but I need this for my IDoc communication.
    In the SAP help stands this:
    Runtime Constants
    $ReceiverService
    Service on the receiver side that receives the message. For example, the name of a business system.
    As of SAP XI 3.0, use this constant instead of the constant RECEIVER_SYSTEM used previously.
    Yes
    See also: Service
    If you want to access one of the constants in the XSLT program, you first have to declare the constant as a parameter, for example:
    <xsl:param name="MessageId" />
    In my XSLT mapping I have this:
    <RCVPOR>empty</RCVPOR>
    <RCVPRT>LS</RCVPRT>
    <xsl:param name="ReceiverService"/>
    <RCVPRN>
    <xsl:value-of select="$ReceiverService"/>
    </RCVPRN>
    </EDI_DC40>
    But during the runtime the constant is empty
      <RCVPOR>empty</RCVPOR>
      <RCVPRT>LS</RCVPRT>
      <RCVPRN />
       </EDI_DC40>
    Have you an idea for my problem?
    Bye
    Stefan

    Hi Udo/all,
    Thank you for your answer.
    Please see in my last post:
    Idoc with XSLT Mapping ALE service error
    I mark in my channel:
    Take Sender from Payload and Take Receiver from Payload
    I must set control field by xslt maping, because the receiver is flexible.
    With your setting I became a converting error to an ALE logical system.
    I need the runtime constant in the xslt mapping.
    Idea?
    bye
    stefan

  • How to read runtime constants in ejb Module?

    Hi all,
    Anyone knows how to have special access to Runtime Constants at ejb Modules? I've searched and all I found is for Java and ABAP Mapping ...I hope it is possible! I want to read the interface name in order to choose which code my module should apply, as a case statement I mean.
    Thanks in advance,
    Ricardo.

    Hi Ricardo !
    Check these links:
    http://help.sap.com/saphelp_nw70/helpdata/en/b3/9a2aeb24dc4ab6b1855c99157529e4/content.htm
    Parameter MessageId
    Regards,
    Matias.

  • Mapping runtime constant to get system details of the XI box

    Hi
       We have a need to get the XI system details ( sysid and the client) at runtime - when executing a mapping that we designed using Message mapping . Is there any runtime constant/udf that we  can use to retrieve this information ?
    We are on XI 3.0 SP23.

    Hi,
    refer this blog by Michal..
    /people/michal.krawczyk2/blog/2005/06/11/xi-how-to-retrieve-messageid-from-a-bpm
    just ignore the BPM part...you will need only the mapping logic and your target message will have the necessary value...also refer this link for the list of parameters that you can access:
    http://help.sap.com/saphelp_nwpi71/helpdata/en/b3/9a2aeb24dc4ab6b1855c99157529e4/content.htm
    http://help.sap.com/saphelp_nwpi71/helpdata/en/78/b4ea10263c404599ec6edabf59aa6c/frameset.htm
    Regards,
    Abhishek.

  • How to construct the constant pool?

    Greetings,
    I seems to have a little bit of a problem.
    I have a text file, generated by the javap -c <class_name> command,
    i.e.:
    javap -c myClass > myClass.txt
    This myClass.txt is the input I've got. I do not have the myClass.class, from which it was generated.
    What I wish to do, is to generate, from this text file, a leagal, runnable, class file (i.e., myClass.class).
    But, I have problems understanding how to construct the constant pool array.
    I have read the VM spec (java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html).
    The thing is, that it does not explain how to extract the needed information from the text file.
    Can someone assist?
    Would appreciate,
    Ohad.

    Compiled from Hello.java
    public class Hello extends java.lang.Object {
        public Hello();
        public static void main(java.lang.String[]);
    Method Hello()
       0 aload_0
       1 invokespecial #6 <Method java.lang.Object()>
       4 return
    Method void main(java.lang.String[])
       0 new #4 <Class java.util.Timer>
       3 dup
       4 invokespecial #7 <Method java.util.Timer()>
       7 new #2 <Class Hello$1>
      10 dup
      11 invokespecial #5 <Method Hello$1()>
      14 lconst_0
      15 lconst_1
      16 invokevirtual #8 <Method void schedule(java.util.TimerTask, long, long)>
      19 returnWell in this example, you have opcodes with arguments which are expressed as (for example) "#7 <Method java.util.Timer()>". This describes a constant pool element. I assume #7 refers to the location within the constant pool, and the text description tells you that it's an item of type method, and gives you the method name. So for all arguments expressed in this form, you'll need to reconstruct a constant pool item.

Maybe you are looking for

  • Can't target main stage from dynamically loaded swf...

    A part of the Flash app. I'm working on right now does the following - Main stage loads an external swf using the following function: function loadAsset(evt:String):void{ var assetName:String = evt; if (assetName != null){   var assetLdr:Loader = new

  • Locale shown in the wrong language in the production server.

    I have an application with a few projects which all have two locales - faroese and english. When I run the application on the default application server on my local machine it works fine with faroese locale but when I deploy to our production server

  • What is the newest version of Microsoft odbc for oracle

    We are trying to integrate UPS Worldship with Oracle 10g. Everything worked fine when the system was on 9i. The writeback after every shipment takes about 30 seconds. I want to make sure we are on the latest version. Our current version is 2.575.1117

  • JSP hanging when 9i database invoked through JSP

    Hi I have just installed Oracle 9i DB on Win 2000 server. When I try to invoke a SQL from a jsp on the application server on the same machine, it hangs. The jsp is able to connect to the Oracle 8i database on a different machine. We are having classe

  • Adobe Reader vs Preview

    I downloaded Adobe Reader and now my Preview does not work, especially for converting files to PDF in the print function.  But if I delete Adobe Reader I cannot read some pdf files from the internet.  What do I do to have both operational?