Static __thread member : class vs. template

Hello,
I am observing a kind of mismatch between simple class declaration and
class template instantiation.
----- working.cpp ---------
class A {
static __thread int a;
__thread int A::a;
----- failing.cpp ---------
template<typename TT> class TA {
typedef TT TA_type;
static __thread TT a;
typedef TA<int> A;
template<> __thread A::TA_type A::a;
Why does sunCC 5.10 tells me that in the 2nd case __thread
is not allowed here? (gcc for example insists of __thread being
specified here).
Thanks!
--L
Edited by: Landmann on Nov 27, 2008 7:12 AM
Edited by: Landmann on Nov 27, 2008 7:18 AM

The bug number is 6779114, and you can track its status at [http://bugs.sun.com]
If you have a service contract with Sun, you can have the bug escalated to get a fix sooner, and also get a pre-release version of a patch with the bug fix.

Similar Messages

  • Why a non static member class can be defined in an interface

    Non-static member classes are defined as instance members of other classes, just like fields and instance methods are defined in a class. An instance of a non-static member class always has an enclosing instance associated with it.
    An interface can't be instantiated then how a non static member class will have an enclosing instance associated with it.
    interface outer
            public  class inner{
            public void p()
                System.out.println("inside interface's non static member class");
        public  static class inner1{
                public void p(){System.out.println("inside interface's  static member class");
    public class Client {                                           // (11)
        public static void main(String[] args) {                    // (12)
        outer.inner nonStatic = new outer.inner();
            nonStatic.p();
        outer.inner1 stat = new outer.inner1();
          stat.p();
    }inner is a non static member class even then " outer.inner nonStatic = new outer.inner();" working fine ?????????????

    class outer
            public  class inner{
            public void p()
                System.out.println("inside interface's non static member class");
    public class Client {                                           // (11)
        public static void main(String[] args) {                    // (12)
        outer.inner nonStatic = new outer.inner();
        nonStatic.p();
    }on compiling the above code the error message i got is
    "not an enclosing class: outer"
    the reason of this compilation error is "outer.inner nonStatic = new outer.inner();
    it should be "outer.inner nonStatic = new outer(). new inner();"
    now my question is
    interface outer
            public  class inner{
            public void p()
                System.out.println("inside interface's non static member class");
    public class Client {                                           // (11)
        public static void main(String[] args) {                    // (12)
        outer.inner nonStatic = new outer.inner();
        nonStatic.p();
    }on compiling the above code why compilation error is not coming??????????
    i think now it is more clear what i am asking

  • About static member class?

    I can unstand the technical detail about static member class. But i still have a question about it.The questionis when shall we use it when we design a poject. In another word, in which situation, static member class will show its advantage? Thanks a lot.

    http://search.java.sun.com/search/java/index.jsp?qp=&nh=10&qt=static+nested+class&col=javaforums

  • Static const int attributes and template functions

    The following does not link with CC on Solaris9. From what I can glean from the standards committee's notes it looks like it should and it compiles and links fine with g++. If I use a cast in the function call: ("foo((int)B::X)") then it links. If I move the static initialization out of the class definition then it works as well. Should we expect this to work or not?
    #include <iostream>
    class B
    public:
    static const int X = 42;
    template< typename T > void foo( const T& t ) { std::cout << t << std::endl;}
    int main()
    foo(B::X);
    }

    The C++ rule (C++ Standard, section 9.4.2 paragraph 4) is that a static const data member of integral type can have an in-class initializer, and the value can be used in integral constant expressions. But if the data member is used, it must be defined outside the class without an initializer. If gcc allows the code, it is by accident. Some other compilers (apart from Sun C++) do not.
    Add the line
    const int B::X;
    somewhere at global scope (or at namespace scope if B is in a namespace) after the declaration of class B. But you can't put this definition in a header file. The entire program must have exactly one definition of the static member.

  • Does a member class have to be within the same source file?

    Hi there,
    I have this application that extensively uses two classes. The main class setsup the GUI, and the second main class is responsible for handling all of the actions that arise from the GUI.
    I could have done this by making all of my handler methods be of the first main class, but this class really is just for the GUI setup, the logic doesn't fit into this class' behaviour.
    The class that handles the GUI actions is required to use the fields of the main class e.g. to get values of a text field. The problem is that since the class that handles the actions is getting very big, I would kind of like to move this class into a different source file - because currently it is a member class of the first one, so that it can access all of its fields.
    Is there some way that I can move this handler class into another source file, and still have it access all of the fields of the main GUI class - without making the fields public, or using millions of get/set methods? Also, I can't use inheritance because the both the GUI class creates an instance of the handler class in its constructor, and so leads to an infinite loop when trying to instantiate the GUI class.
    Can I ask.. would a static class or something be of use here? Do they exist? I'm confused as to how to do this without getting the mother of all source files (in size that is - nothing to do with cooking or baking).
    - Anyway, thanks in advance for any help that you could give me -
    BYEE, Edd.

    You can't have an inner class that is not in the same source file. However, you could use package-protected (default) access to give another class in the same package access to things without making them public. Actually, that's how inner classes are actually compiled. Package-protected access is underused IMHO. It's a great tool that most people (including myself) are suspicious of at first.

  • Creating a new instance of a member class?

    I'm writting a serialization library for a college project and I have a problem with deserializing an object which class contains a member class. A rough example:
    class Outer{
         class Member{
              double d =0;
         public Member member =new Member();     
    }Most basically I tried to get a new instance of the Member class in order to get the double field, change it's value, then use that new instance as a field of an object of the Outer class.
    Field f = Outer.class.getDeclaredField("member");
    f.setAccessible(true);
    f.getClass().newInstance(); Both this and the Constructor method throw an exception:
    Exception in thread "main" java.lang.InstantiationException: java.lang.reflect.Fieldpointing at the line with newInstance().
    Is there anything I can do to create an object of a member class? And if not then taking into account that I have to deserialize the Outer object from an XML file what could be the alternative?

    The error message already gives you a hint that it's not class Outer.Member you're instantiating there (review the API docs)...
    import java.lang.reflect.*;
    public class Outer{
      public static void main(final String[] args) {
        final Field f = Outer.class.getDeclaredField("member");
        f.setAccessible(true);
        final Constructor ctor =
                f.getType().getDeclaredConstructor(new Class[] { Outer.class });
        final Object outer = new Outer();
        final Object member = ctor.newInstance(new Object[] { outer });
        // set member.d
        f.set(outer, member);
      class Member{
        double d =0;
      public Member member =new Member();     
    }

  • Instantiating member classes using reflection

    I have checked through this forum but if the answer to this question is here I missed it.
    I am trying to find out how to invoke the appropriate instantiation / constructor call to create an instance of a member class.
    The following works finepublic class Succeeds {
      public abstract static class AbstractMember {
      Succeeds(final AbstractMember am) {
      public static void main(final String[] args) {
        Succeeds a = new Succeeds (new Succeeds.AbstractMember () {
    }However I want to make the AbstractMember a real member class not a nested inner class and I want to instantiate the concrete subclass of AbstractMember in the constructor of Succeeds rather than outside the class. I tried the following:public class Fails {
      public abstract class AbstractMember {
        public class ConcreteMember extends AbstractMember {
      Fails(final Class<? extends AbstractMember> c)
        throws InstantiationException, IllegalAccessException {
        AbstractMember am = c.newInstance() ;
      public static void main(final String[] args)
        throws InstantiationException, IllegalAccessException {
        Fails a = new Fails (Fails.AbstractMember.ConcreteMember.class) ;
    }(Please forgive the appling treatment of exceptions, I wanted to make a small example). This compiles fine but fails at runtime with an InstantiationException I assume because the nullary constructor doesn't exist for a member class because of the need to make the connection to the containing object.
    So the question is is there a bit of reflection that allows me to achieve what I want?
    I cannot be the first person to try doing this. I am hoping it is doable otherwise I am going to have to make the design a bit yukky.
    Thanks.

    import java.lang.reflect.*;
    public class Fixed
        public abstract class AbstractMember
        public class ConcreteMember extends AbstractMember
        <T extends AbstractMember> Fixed(final Class<T> c) throws Exception
            Constructor<T> ctor = c.getConstructor(new Class[]{getClass()});
            AbstractMember am = ctor.newInstance(new Object[]{this});
        public static void main(final String[] args) throws Exception
            new Fixed(ConcreteMember.class);
    }My exception handling is even more lax than yours. Why isn't there a class ReflectionException? I moved ConcreteMember out of AbstractMember to keep things simple. It's not entirely necessary, but I didn't want to construct an AbstractMember first.

  • Enclosing class calling private constructor of private member class

    Hi all,
    I have this question concerning member classes and privtae constructors.
    public class MyTest {
        private class Inner {
            private Inner() {
                System.out.println("Why Am I here!??");
        public MyTest() {
            Inner a = new Inner();
        public static void main(String[] s) {
            MyTest z = new MyTest();
    }It doesn't work for my JDK SE 1.3.3, build 1.3.1-b24.
    It works for many other versions.
    Can somebody kindly enlighten me, should this code work?
    I really didn't think that it should, but it did!

    I am sorry. It was actually my jikes 1.15 that was causing the problem.
    After some research, I found out that my problem arose out of my understanding of OO concepts, or rather, the meaning of access modifiers in Java.
    I had thought that nobody can access a private variable/method of class except the class itself. Apparently, this is not so. The access modifiers apply to the class themselves and not the object. Thus explaining why an object can access the private variables/methods of another object of the same class.
    Actually, it's not really the case here. The Java language specs states that the inner class has total access to the enclosing class, but I could not find any word on enclosing class access to inner classes in the specs.
    As for Jikes, I really hope they will fix it soon. I like it a lot as it is significantly faster than javac for everything I have done so far.
    cheers!

  • Problem - Class containing template functions

    Hi everyone,
    I've written a simple class (not template), containing one template functions, like te following one:
    class MyClass
    public:
    template <typename T>
    typename T::_ptr_type DoSomeThing(int a, int b);
    When I am within a function and I need to call DoSomeThing, I have no problems if I declare a local variable of class MyClass, but I get the following compilation error:
    Error: Unexpected type name "ThirdClass" encountered
    when I use a pointer or a reference to MyClass that is declared elsewhere in the code.
    The following is a sample code that returns me an error:
    int OtherClass::MyFunc()
    m_pMyClass->DoSomeThing<ThirdClass>(10, 20);
    In the above function m_pMyClass is a member variable of OtherClass pointing to an instance of MyClass and ThirdClass is a valid class name (visible to the function).
    Does anyone know why I got the error ?
    Thank you,
    Massimo

    You need to use the syntax:
    m_pMyClass->template DoSomeThing<ThirdClass>(10, 20);
    Really, exactly like I wrote it ;)
    Josh

  • How to refer to enclosing instance from within the member class?

    Hi
    How to refer to the enclosing instance from within the member class?
    I have the following code :
    import java.awt.*;
    import java.awt.event.*;
    public class MyDialog extends Dialog
         public MyDialog(Frame fr,boolean modal)
              super(fr,modal);
              addWindowListener(new MyWindowAdapter());
         public void paint(Graphics g)
              g.drawString("Modal Dialogs are sometimes needed...",10,10);
         class MyWindowAdapter extends WindowAdapter
              public void windowClosing(WindowEvent evt)
                   //MyDialog.close(); // is this right?
    In the above code, how can I call the "close()" method of the "Dialog" class (which is the enclosing class) from the inner class?
    Thanks in advance.
    Senthil.

    Hi Senthil,
    You can directly call the outer class method. Otherwise use the following way MyDialog.this.close(); (But there is no close() method in Dialog!!)
    If this is not you expected, give me more details about problem.
    (Siva E.)

  • Where is the member class?

    Hi,
    I am Ryan.
    Here is a small piece of code.
    <pre>
    if( error.getClass().equals( SoftErrorException.<b>class</b> ) )
         throw new JspException();
    </pre>
    Can somebody tell me where is the member "class" referred in the object SoftErrorException. I checked in the class "Object" and "Class". I also checked in the Java documentation index. I still could not find it.
    Thanks in advance
    Ryan

    Can somebody tell me where is the member "class"
    referred in the object SoftErrorException. I checked
    in the class "Object" and "Class". I also checked in
    the Java documentation index. I still could not find
    it.
    Thanks in advance
    Ryanclass is not a member. This is part of the language. Also, SoftErrorException is not an Object it is a class. I'm also having a problem finding the documentation for this. I assume it is part of the JLS. ClassName.class is the same as InstanceOfClass.getClass().

  • Static member-class varaiable instanciation

    Hello,
    I have an inner class which I'm trying instanciate as a static variable. here is the code:
    public class A {
    protected static B b;
    private A (){} //private constructor because B is singleton
    class B {
    //some code
    =========================================================
    I cannot say
    protected static B b = new B();
    because new operator returns this.new_instance_of_B, and "this" cannot be referenced from the static constant...
    How can I instanciate this variable (b)?? Thank you,
    Elana

    You could make the class static but depending on how the class is written you might be better off just instatiating b in your constuctor. I question declaring b protected. You can not subclass a singleton (no public constructor), therefore there is no reason to declare b protected. If you want other classes to access b from inside the package just use package level (default) access. Having a static member of a singleton that isn't private seems to violoate the purpose of the Singleton pattern though. I don't know what you are trying ot do but I would declare your class like this.
    public class A {
        private static B b;
        private A (){
            b = new B();
        private class B {
            //some code
    }

  • Why do we need private static method or member class

    Dear java gurus,
    I have a question about the use of private and static key words together in a method or inner class.
    If we want to hide the method, private is enough. a private static method is sure not intended to be called outside the class. So the only usage I could see is that this private static method is to be called by another static method. For inner class, I see the definition of Entry inner class in java.util.Hashtable, it is static private. I don't know why not just define it as private. Could the static key word do anything better.
    Could anybody help me to clear this.
    Thanks,

    What don't you get? Private does one thing, andstatic does >something completely different.
    If you want to listen to music, installing an airconditioner doesn't help>
    Hi, if the private keyword is the airconditioner, do
    you think you could get music from the static keyword
    (it acts as the CD player) in the following codes:You're making no sense and you're trying to stretch the analogy too far.
    Private does one thing. If you want that thing, use private.
    Static does something completely different and unrelated. If you want that thing, use static.
    If you want both things, use private static.
    What do you not understand? How can you claim that you understand that they are different, and then ask, "Why do we need static if we have private"? That question makes no sense if you actually do understand that they're different.

  • How to integrate a class with template.java - Java Concurrent Program. 11i

    Hello, I have a java class I got from a vendor. This java class needs to run through as concurrent program. As per metalink note *How To Create a Java Concurrent Program? [ID 827563.1]* it says that, we must require template.java to wrap around the custom class. I have done that in the following java code. However, being a new java guy, I really dont know how to connect these two classes and constructor.
    Any suggestions about how do I make these classes work in order to run from a concurrent program?
    package oracle.apps.fnd.cp.request;
    import oracle.apps.fnd.util.*;
    import oracle.apps.fnd.cp.request.*;
    import java.io.BufferedReader;
    import java.io.IOException;
    import javax.net.ssl.SSLSocketFactory;
    public class cyberBatch implements JavaConcurrentProgram {
        // Optionally provide class constructor without any arguments.
        // If you provide any arguments to the class constructor then while running the program will fail.
        public void runProgram(CpContext pCpContext) {
            ReqCompletion lRC = pCpContext.getReqCompletion();
            String CompletionText = "";
        // This class is to upload files but can be expanded to download files also.
        public class SSLFileTransfer {
            Properties props =
                new Properties(); // stores properties from property file
       * SSLFileTransfer(): constructor
            public SSLFileTransfer() {
       * init(): initialization (load property file)
          * @param propsFile          properties needed for file transfer
            public void init(String propsFile) {
                try {
                    props.load(new BufferedInputStream(new FileInputStream(new File(propsFile))));
                } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(-1);
       * usage()
            public static void usage() {
                System.out.println("USAGE: java SSLFileTransfer <full path property file name>");
                System.exit(-1);
       * getFactory(): get factory for authentication
          * @throws IOException     if exception occurs
            private SSLSocketFactory getFactory() throws IOException {
                try {
                    SSLContext ctx;
                    KeyManagerFactory kmf;
                    KeyStore ks, ks1;
                    char[] passphrase =
                        props.getProperty("passPhrase").toCharArray();
                    ctx = SSLContext.getInstance("TLS");
                    kmf = KeyManagerFactory.getInstance("SunX509");
                    ks = KeyStore.getInstance("PKCS12", "BC");
                    ks1 = KeyStore.getInstance("JKS");
                    ks.load(new FileInputStream(props.getProperty("key")),
                            passphrase);
                    ks1.load(new FileInputStream(props.getProperty("keyStore")),
                             passphrase);
                    kmf.init(ks, passphrase);
                    TrustManagerFactory tmf =
                        TrustManagerFactory.getInstance("SunX509");
                    tmf.init(ks1);
                    ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
                    return ctx.getSocketFactory();
                } catch (Exception e) {
                    e.printStackTrace();
                    throw new IOException(e.getMessage());
       * getHost(): Get host from property file
            private String getHost() {
                return props.getProperty("host", "localhost");
       * getPort(): Get port from property file
            private int getPort() {
                return Integer.parseInt(props.getProperty("port"));
       * sendRequest(): Send request (file) to the server
          * @param out          stream to send the data to the server
          * @throws Exception     if an error occurs.
            private void sendRequest(PrintWriter out) throws Exception {
                String path = props.getProperty("path");
                out.println("POST " + path + " HTTP/1.0");
                final String BOUNDARY = "7d03135102b8";
                out.println("Content-Type: multipart/form-data; boundary=" +
                            BOUNDARY);
                String uploadFile = props.getProperty("uploadFile");
                String authString =
                    props.getProperty("bcUserName") + ":" + props.getProperty("bcPassword");
                String encodedAuthString =
                    "Basic " + new sun.misc.BASE64Encoder().encode(authString.getBytes());
                out.println("Authorization: " + encodedAuthString);
                final String CRLF = "\r\n";
                StringBuffer sbuf = new StringBuffer();
                sbuf.append("--" + BOUNDARY + CRLF);
                sbuf.append("Content-Disposition: form-data; name=\"upfile\"; filename=\"" +
                            uploadFile + "\"" + CRLF);
                sbuf.append("Content-Type: text/plain" + CRLF + CRLF);
                FileReader fi = new FileReader(uploadFile);
                char[] buf = new char[1024000];
                int cnt = fi.read(buf);
                sbuf.append(buf, 0, cnt);
                sbuf.append(CRLF);
                sbuf.append("--" + BOUNDARY + "--" + CRLF);
                int sz = sbuf.length();
                out.println("Content-Length: " + sz);
                out.println();
                out.println(sbuf);
                out.flush();
                // Make sure there were no surprises
                if (out.checkError())
                    System.out.println("SSLFileTransfer: java.io.PrintWriter error");
       * readResponse(): reads response from the server
          * @param in          stream to get the data from the server
          * @throws Exception     if an error occurs.
            private void readResponse(BufferedReader in) throws Exception {
                boolean successful = false;
                String inputLine;
                while ((inputLine = in.readLine()) != null) {
                    if (inputLine.startsWith("HTTP") &&
                        inputLine.indexOf("200") >= 0)
                        successful = true;
                    System.out.println(inputLine);
                System.out.println("UPLOAD FILE " +
                                   (successful ? "SUCCESSFUL" : "FAILED") +
                                   "!!!\n");
       * upload(): upload file to server
          * @throws Exception     if an error occurs.
            public void upload() throws Exception {
                try {
                    SSLSocketFactory factory = getFactory();
                    SSLSocket socket =
                        (SSLSocket)factory.createSocket(getHost(), getPort());
                    PrintWriter out =
                        new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())));
                    BufferedReader in =
                        new BufferedReader(new InputStreamReader(socket.getInputStream()));
                    socket.startHandshake();
                    sendRequest(out);
                    readResponse(in);
                    out.close();
                    in.close();
                    socket.close();
                } catch (Exception e) {
                    e.printStackTrace();
                    throw e;
       * main(): main method to start file transfer
          * @param args          command line arguments (property file, see usage())
          * @throws Exception     if an error occurs.
            public static void main(String[] args) throws Exception {
                if (args == null || args.length != 1)
                    usage();
                SSLFileTransfer fileXfer = new SSLFileTransfer();
                fileXfer.init(args[0]);
                fileXfer.upload();
        lRC.setCompletion(ReqCompletion.NORMAL,CompletionText) ;
    }Thanks,
    R

    I believe the OP is aware of this :) -- Re: Oracle 11i - 11.5.10.2 - and Java
    Thanks,
    Hussein

  • Static Inheritance, Constructors --- Classes as objects

    First I asked myself why constructors are not inherited.
    Then I asked myself why Static Methods are not inherited.
    And it all seems to come down to, why Classes are not objects in Java as they are in Smalltalk?
    Is there any reason I'm missing?
    I would love at least inheritable static methods.

    That's OK, but that method would not be inherited, and would execute in the context of the superclass.
    Picture this (a simple "template method"):
    class SuperClass {
         public static void staticMethod() {          
              System.out.println("Static in SuperClass");
              other();          
         public static void other() {          
              System.out.println("other in SuperClass");
    class SubClass extends SuperClass{
         public static void other () {
              System.out.println("other in SubClass");
    Here, I just want to redefine other() in SubClass, but it calls the SuperClass version.
    Let's test:
    public class Test {
         public static void main(String[] args) throws DatabaseErrorException, TableUpdateException {
              SuperClass.staticMethod();
              SubClass.staticMethod();
    Output:
    Static in SuperClass
    other in SuperClass
    Static in SuperClass
    other in SuperClass
    First line calls static in SuperClass, which calls other (found in SuperClass and executed), the output from other is second line.
    Then, the third line shows calling staticMehod in SubClass, which doesn't redefine it, and executes the SuperClass version, that's ok, but when staticMethod calls other, it doesn't look for it in SubClass, but it directly executes the one in SuperClass (which is shown in line 4).

Maybe you are looking for

  • Help urgent

    HI ALL, I WANT TO KNOW THE INPUT FILE STRUCTURE FOR THE BELOW PROGRAM. ITS TRUELY URGENT. *--Constant CONSTANTS : c_maint(1)  value 'M'. *data from the Excel is picked up into this internal table DATA : BEGIN OF ITAB OCCURS 0,      FIELD1(200),     

  • How to see the Complete Line In SO10??

    Hi All, In the satndard text So10, when we enter any text and if it exceeds more than the length of the line. It is not shown to us in the display. In order to see the text what are the control keys we use? Can anyone give me the idea?? Cheers, Simha

  • Incentive Management

    Hiii, I want to map the incentive policy of my client (my client is in a manufacturing industry). Here the customers/dealers are entitled for an annual incentive on achieving their sales targets. The sales traget can be of certain quantity, value, mi

  • Webservice messages

    Hi Guys, I couldn't see the messages sent from a webservice in SXMB_MONI. I have tested my interface successfully at Runtim Work Bench -->Component Monitoring --> Adapter Engine -->Test Message. Any ideas how to trouble shoot? Is there any batch job

  • Photoshop installation problems - Windows 8.1

    So I got adobe elements 13 & adobe premiere elements 13 in which i recieved via a gift card. I have followed the instructions on how to install e.g 1. visit the website 2.enter the redemption code from the card 3.download the software using the provi