Multiple Inheritence/Const Compiler bug

I'm encountering what appears to be a bug when mixing multiple inheritence & const/non-const methods. The compiler (WorkShop 6 Update 2) is accepting the following ill-formed code :
class Base1 {
int a; //If Base1 is empty, the problem doesn't appear.
//A virtual function elicits the bug as well.
class Base2 {
public:
void mutator() { //non-const method   
class Derived : public Base1, public Base2 {
class Foo {
private:
Derived my_derived;
public:
void f() const {
my_derived.mutator();
int main (int argc, char* argv[])
Foo my_foo;
my_foo.f();
Note how f() in class Foo is const, yet attempts to call mutator(), a non-const method that my_derived gets via inheritence to Base2. This is ill formed and should, I believe, yield a compiler error. If the code is just subtly changed, the correct error will appear. For instance, if Base1 is empty, the appropriate error appears. Alternatively, if Base2 appears before Base1 in Derived's inheritence list, then the appropriate error appears.
Is this a known problem? Is there a patch available? I'm very concerned that this bug is allowing const-incorrect code to be developed unknowingly, as it has in the project I'm involved in.
Thanks in advance for giving this your attention!
David Michael

The bug report hasn't been filed yet. If you have contract with Sun, please follow the service channel to file the report. Otherwise, I can do it for you. Please provide:
- O/S version
- Architecture
Please notice that if you don't have contract with sun, the bug might be in a low priority.
- Rose

Similar Messages

  • I acheived Multiple Inheritence in JAVA !!!!!!!!

    Hi,
    Im in ob_imit2_a2 group. I can use member variables and methods of two(or more) classes in another class without importing them just like Multiple Inheritence in C++.
    TECHNICAL COMMENTS REQUIRED
    See Below
    ///////// Outer.java
    public class Outer implements myInterface, myInterface2{
    public Outer() {
    System.out.println("outer class");
    public void check()
         inter2.test();
         inter.test();
    ////////// myInterface.java
    interface myInterface{
    class interclass{
         interclass()
              System.out.println("SS");
         public void test()
              System.out.println("TEST");
    public interclass inter=new interclass();
    //////////myInterface2.java
    interface myInterface2{
    class interclass2{
         interclass2()
              System.out.println("SS 2");
         public void test()
              System.out.println("TEST 2");
    public interclass2 inter2=new interclass2();
    //////////// Main.java
    public class Main {
    public static void main(String abc[]) {
    Outer o = new Outer();
         o.check();
    }

    Any and all variables declared in an interface are always implicitly public, static, and final; meaning that they are constants and NOT member variables. You can call these methods directly from the main method (a static scope) as well; meaning that they are not associated with any instance of the class Outer; i.e. they are NOT inherited.
    The difference between inheritance (extending) and realization (implementing) is that when extending you inherit everything from your parent class, and while implementing you are taking up a role and agree to fulfill all the responsibilities (methods) of that role.

  • Another Compiler Bug (message: An internal build error has occurred... Unknown Flex Problem)

    I was fighting with this problem for a few days. Finally I've got it resolved. I want to describe it and fill in BUG in the bug report, but I am not sure about Adobe support options. So, I am putting bug report here.
    1. ASSUMPTION: All problems which compiler reports as unknown problem are the real compiler BUGs/Problems. Eventually MXML compiler/ActionScript compiler should be able to take C++ or FORTRAN code or an aribitrary text and nicely tell "Error: It is not ActionScript (Flex) code" or "the code is corrupted from Line so and so...". When compiler crashed, it is most probably due to one of the states not handled (or not handled correct). Keeping this in mind I assume, that my code has nothing to do with the compiler crash.
    2. PROBLEM Description.
         - I tried to port our internal project from Flex3.5/Flex Builder 3 to Flex4.1/Flash Builder 4.
         - After checking out and trying to build code I start getting weird problems like Error 1037: Packages cannot be nested.
         - After cleaning and compiling project by project, walking up dependency tree, I was able to get rid of this problem.
         - On last Project I've got another problem (An internal build error has occurred... Unknown Flex Problem). Which I stuck with for a while.
         - When I checked log file I found following messages:
    ============================================================
    !ENTRY com.adobe.flexbuilder.project 4 43 2010-12-21 15:45:24.353
    !MESSAGE Uncaught exception in compiler
    !STACK 0
    java.lang.ClassCastException: macromedia.asc.parser.InputBuffer cannot be cast to flex2.compiler.as3.CodeFragmentsInputBuffer
    at flex2.compiler.as3.AbstractSyntaxTreeUtil.lineNumberToPosition(AbstractSyntaxTreeUtil.jav a:1266)
    at flex2.compiler.mxml.ImplementationGenerator.generateBinding(ImplementationGenerator.java: 569)
    at flex2.compiler.mxml.ImplementationGenerator.generateBindingsSetupFunction(ImplementationG enerator.java:863)
    at flex2.compiler.mxml.ImplementationGenerator.generateBindingsSetup(ImplementationGenerator .java:812)
    at flex2.compiler.mxml.ImplementationGenerator.generateInitializerSupportDefs(Implementation Generator.java:1878)
    at flex2.compiler.mxml.ImplementationGenerator.generateClassDefinition(ImplementationGenerat or.java:1044)
    at flex2.compiler.mxml.ImplementationGenerator.<init>(ImplementationGenerator.java:206)
    at flex2.compiler.mxml.ImplementationCompiler.generateImplementationAST(ImplementationCompil er.java:499)
    at flex2.compiler.mxml.ImplementationCompiler.parse1(ImplementationCompiler.java:197)
    at flex2.compiler.mxml.MxmlCompiler.parse1(MxmlCompiler.java:168)
    at flex2.compiler.CompilerAPI.parse1(CompilerAPI.java:2871)
    at flex2.compiler.CompilerAPI.parse1(CompilerAPI.java:2824)
    at flex2.compiler.CompilerAPI.batch2(CompilerAPI.java:446)
    at flex2.compiler.CompilerAPI.batch(CompilerAPI.java:1274)
    at flex2.compiler.CompilerAPI.compile(CompilerAPI.java:1496)
    at flex2.tools.oem.Application.compile(Application.java:1188)
    at flex2.tools.oem.Application.recompile(Application.java:1133)
    at flex2.tools.oem.Application.compile(Application.java:819)
    at flex2.tools.flexbuilder.BuilderApplication.compile(BuilderApplication.java:344)
    at com.adobe.flexbuilder.multisdk.compiler.internal.ASApplicationBuilder$MyBuilder.mybuild(A SApplicationBuilder.java:276)
    at com.adobe.flexbuilder.multisdk.compiler.internal.ASApplicationBuilder.build(ASApplication Builder.java:127)
    at com.adobe.flexbuilder.multisdk.compiler.internal.ASBuilder.build(ASBuilder.java:190)
    at com.adobe.flexbuilder.multisdk.compiler.internal.ASItemBuilder.build(ASItemBuilder.java:7 4)
    at com.adobe.flexbuilder.project.compiler.internal.FlexProjectBuilder.buildItem(FlexProjectB uilder.java:480)
    at com.adobe.flexbuilder.project.compiler.internal.FlexProjectBuilder.build(FlexProjectBuild er.java:306)
    at com.adobe.flexbuilder.project.compiler.internal.FlexIncrementalBuilder.build(FlexIncremen talBuilder.java:157)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:633)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:170)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:253)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:218)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:360)
    at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:516)
    at org.eclipse.core.internal.resources.Project.build(Project.java:94)
    at org.eclipse.ui.actions.BuildAction.invokeOperation(BuildAction.java:221)
    at org.eclipse.ui.actions.WorkspaceAction.execute(WorkspaceAction.java:162)
    at org.eclipse.ui.actions.WorkspaceAction$2.runInWorkspace(WorkspaceAction.java:483)
    at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38 )
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
    !SESSION 2010-12-22 09:48:27.766 -----------------------------------------------
    eclipse.buildId=M20100909-0800
    java.version=1.6.0_16
    java.vendor=Sun Microsystems Inc.
    BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
    Framework arguments:  -product org.eclipse.epp.package.jee.product
    Command-line arguments:  -data C:\Client_Flex4 -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.jee.product
    ================================================
    3. RESOLUTION/WORK AROUND
         - I was able to get this problem cleared by putting compiler option for Flex Application projects:  -keep-generated-actionscript
    4. SIDE NOTE
      I do not really see putting this compiler option as the solution and living with the mistery is making me fill a bit bad.

    Hi Faser,
    I just tried it on Vista with our latest FB Plugin build but
    I was unable to reproduce your issue with the following setup:
    - FB Plugin build installed by Administrator account user
    under her Documents folder
    - Administrator account user can launch, create Flex projects
    under her own workspace without any problems
    - Standard account user can launch the FB Plugin build (need
    Admin's password) and create Flex project (default location) under
    his own workspace
    If your setup is different, can you please log a bug at
    http://bugs.adobe.com/flex.
    Be sure to include what build you are using, whether it's
    reproducible, the detail of the setup, etc...
    thanks,
    Sharon

  • How do I input multiple string constants into VISA Write

    I am trying to put in multiple string commands into VISA Write to control a motor arm. However, when I use "concatenate strings" to link together my multiple string constants, only the first command is executed, and neglects the other commands below it. Should I be using something other then "concatenate strings" or do I need to use a delay so that the next command executes when the one before it is finished? Help.

    Concatenate strings should work or just use one string constant with multiple lines. The problem you're having could be that the instrument requires some sort of delay but without details on the instrument, only you or the vendor can answer that. Some instruments will have a queue and others won't. The other possiblity is that you need some kind of termination character between commands. This might be a carriage return for a serial instrument or the ; character for a GPIB one. Check the instrument manual or provide the make and model and maybe someone here has some experience with it.

  • Is multiple inheritence is possible in sap?

    can any one help me?
    is multiple inheritence possible in sap ?
    and is one class can extend multiplre interfaces??

    Hi,
            Multiple inheritance as a concept is not allowed in ABAP Objects. But the effect and behaviour that you get by multiple inheritance is acheviable in ABAP objects with the help of interfaces. As follows.
    An interface can inlcude more than one interface, that is an interface can extend more than one interface. Now if you have say interface1, interface2 and interface3.
    interface4 can be declared to include all three other interfaces. And you class can include this interface4 in its interfaces tab.
    Due to this your class gets the behviour(methods) that is defined in all ther interfaces. You can assign an object of this class to a reference of any one of these four interfaces. So one object can react to method calls on four different interfaces which is what you want to achevie in multiple inheritance.
    Regards,
    Sesh

  • Local class and switch statement -- compiler bug?

    Does anybody know why the following does not compile with "LocalClass cannot be resolved to a type" error in the case 1: block
    public class ProblemClass {
         public void localClassProblem() {
                   class LocalClass {
                        void doNothing() {};          
                   int i = 0; 
                   switch (i) {                    
                        case 1: {
                             LocalClass instance1 = new LocalClass();  //ERROR: unresolved type
                                            break;
    }while the following does (I only added case 2: where LocalClass type is not referenced within an embedded block)
    public class ProblemClass {
         public void localClassProblem() {
                   class LocalClass {
                        void doNothing() {};          
                   int i = 0; 
                   switch (i) {                    
                        case 1: {
                             LocalClass instance1 = new LocalClass();
                                            break;
                        case 2:
                             LocalClass instance2 = new LocalClass();
    }Is it a compiler bug? Thanks for clarifying this.
    --Michal                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    I'm using 1.5.0-b64
    --Michal                                                                                                                                                                                                                                   

  • Strange compiler bug in method overloading mechanism

    Hi,
    current javac compiler in version 1.4.2_10 and probably earlier versions seem to have a bug in the overloading mechanism of static methods in a certain case.
    I consider reporting this as a compiler bug but would like to have some feedback before.
    Would you consider this class correct? With 5+ years of java experience I'd consider it being correct:
    package test;
    public abstract class AbstractClass {
       public class RealizationClass extends AbstractClass {
          public void someMethod() {
             m(1); //Error: m(int,int) in test.AbstractClass cannot be applied to (int)
             m(1, 2);
       private static int m(int i) {
          return i+1;
       private static int m(int i, int j) {
          return i+j;
    }Interestingly the order of those two static method and their visibility affects the error (changing visibilty to public/protected makes javac accept the code).
    Eclipses compiler does not have this problem, it happily accepts the code above.
    What do you think?
    -Sebastian

    JLS 2.0 says on page 147: "The scope of a declaration of a member m declared in or inherited by a class type C is the entire body of C, including any nested type declarations."
    I read somewhere that in the case a nested or inner class accesses private fields of its enclosing type, the compiler generates "sythetic accessor methods" to allow access. Maybe there's something wrong with the generation of these generated methods...

  • Foreach syntax + generics, Possible compiler bug?

    I'm encountering an odd problem trying to use generics and the foreach (colon) syntax. The code in question:
    for (Iterator<String> it = col.getParameterNames().iterator(); it.hasNext();) {}
    for (String paramName : col.getParameterNames()) {}col is an instance of an inner class of the class whose method this code snippet is from, getParameterNames has the signature:
    public Set<String> getParameterNames();
    The first line, using the Iterator<String> explicitly, compiles fine. The second line, when present, raises the compiler error:
    found : java.lang.Object
    required: java.lang.String
    for (String paramName : col.getParameterNames()) {
    I cannot seem to reliably reproduce this situation in other (simpler) classes I write, but this one in particular seems to trigger it. Is it possible this is a compiler bug, or might there be something I'm doing incorrectly that I'm missing? Are my expectations about how the second line should work incorrect? It seems to in other circumstances...
    javac is 1.6.0_01. Any ideas?

    Here is a quick update, I'm more inclined to think of this as bad behavior now.
    This code compiles:
    public class Test {
    Vector<InnerTest> inners = new Vector<InnerTest>();
        public class InnerTest {        
           public Set<String> someSet() { return (new HashMap<String,String>()).keySet(); }
        public Test() {
            for (InnerTest it : inners) {
                for (String s : it.someSet()) {        
    }however, the following does not:
    public class Test {
    Vector<InnerTest> inners = new Vector<InnerTest>();
        public class InnerTest<P> {        
           public Set<String> someSet() { return (new HashMap<String,String>()).keySet(); }
        public Test() {
            for (InnerTest it : inners) {
                for (String s : it.someSet()) {        
    }Again, the problem might be with my expectations (I haven't gone through the specifications yet with this in mind), but I can't fathom how or why the unused parameter would make a difference in that method's tpye matching.

  • Xerox_mfp scanner not working in arch (compilation bug?)

    I have discovered that my xerox_mfp printer/scanner Xerox Workcentre 3119 is not working in archlinux. However, with the same libsane version, scanner is working in debian.
    I checked the two libraries libsane-xerox_mfp.so.1.0.22: they are different in size.
    I have copied the debian library in /usr/lib/sane and now the scanner is working.
    Compilation bug?
    Last edited by hifi25nl (2011-05-24 17:35:01)

    architecture: x86-64
    samsung scx-4200: xerox_mfp sane backend
    the same problem
    libsane-xerox_mfp.so.1.0.22 from debian libsane_1.0.22-6_amd64 package is working

  • Implementation of multiple inheritence

    hi
    i am goutam.how can we implement multiple inheritence in java.and how two super classes can be inherited in one sub class

    keep it to one thread, please!

  • SS9 CC5.6 compiler bug - algorithm count confused with struct member

    Found some code that fails to compile in CC 5.6
    CC: Sun C++ 5.6 2004/07/15
    #include <algorithm>
    using namespace std;
    struct A {
      int count;   
    struct B
      struct A *a;
    int main(int argc, char **argv)
      struct B *b = 0;
      // This line fails to build, any other operator is ok
      if ( b->a->count < 50 )
      return (1);
    }Fails with error :
    "c56_algorithm_bug.cpp", line 21: Error: Unexpected ")" -- Check for matching parenthesis.
    "c56_algorithm_bug.cpp", line 22: Error: "," expected instead of "{".
    "c56_algorithm_bug.cpp", line 22: Error: Illegal value for template parameter.
    "c56_algorithm_bug.cpp", line 22: Error: ")" expected instead of "{".
    4 Error(s) detected.The compiler is getting confused with the use of the count struct member vs the count algorithm. Changing the < to a > fixes the problem.
    Using CC5.3 works fine as well as all other compilers we use (gcc 3.4, mipspro 7.4, VC 7.1)
    Anyone seen this ?
    - mark

    This bug has been fixed in the C++ 5.6 compiler. I'm not sure if the fix is in the first patch which is about to be released. If not, the fix definitely will be in the next patch.
    The workaround is not to use
    using namespace std;That using-declaration is a pretty big hammer, and often results in conflicts with user code, compiler bugs aside.

  • Why  multiple inheritence is avoided in java.

    why multiple inheritence is avoided in java.
    r there any advantages in this???
    can u briefly explain with programming so that it will be clear.

    Here is one of several discussions of this topic to be found on the web:
    http://csis.pace.edu/~bergin/patterns/multipleinheritance.html

  • Interfaces to replace multiple inheritence

    Howdy,
    I have, conceptually, the following situation: I have a Ball abstract class. The Ball has several
    concrete methods. It also has an abstract method getAppearance (that would somehow return how a
    Ball is visualized). I have several "adjective" subclasses that I would like to build from it, for example:
    SpikyBall, GlowingBall, ColorBall, etc. I would like these classes to be concrete.
    Additionally, I would like to have a concrete class of any permutation of this list of adjectives, for example:
    SpikyColorBall, GlowingColorBall, SpikyGlowingColorBall. I want to accomplish this
    using as little code rewriting as possible, and, hopefully, none at all.
    Using certain other single letter languages that I won't name here, I used Multiple Inheritence. A
    SpikyColorBall would inherit from both SpikyBall and ColorBall, who both inherited from
    Ball. I was told I could accomplish this in Java using interfaces instead of multiple inheritence, which
    Java doesn't support. How is this accomplished? Could you give me (or forward me to) a good
    example? Again, the power I'm looking for is multiple inheritence's code-reusability.
    As a side note, why did Java choose to use interfaces instead of multiple inheritence?

    Courtesy of yawmark...
    composition_v_inheritance
    Bruce Eckel, author of Thinking In Java, has this to say about composition vs. inheritance:
    When deciding between inheritance and composition, ask if you need to upcast to the base type. If not, prefer composition (member objects) to inheritance. This can eliminate the perceived need for multiple base types. If you inherit, users will think they are supposed to upcast.
    Choose composition first when creating new classes from existing classes. You should only used inheritance if it is required by your design. If you use inheritance where composition will work, your designs will become needlessly complicated.
    Bill Venners: Composition versus Inheritance
    Use inheritance (of implementation) only when the class satisfies the following criteria:
    1) "Is a special kind of," not "is a role played by a";
    2) Never needs to transmute to be an object in some other class;
    3) Extends rather than overrides or nullifies superclass;
    4) Does not subclass what is merely a utility class (useful functionality you'd like to reuse); and
    5) Within PD: expresses special kinds of roles, transactions, or things.
    -- from Java Design: Building Better Apps and Applets (2nd Edition), by Peter Coad and Mark Mayfield

  • Is Java allow multiple inheritence?

    Hi,
    I am having class A and class B, and class A exteds Class B. All class in Java extends Object class by default,
    1. class B extends one class Object
    2. class A extends two classes class B and class Object.
    Now class A extending two classes is it correct?
    Kindly help me.

    RajivGuna wrote:
    Hi,
    I am having class A and class B, and class A exteds Class B. All class in Java extends Object class by default,
    1. class B extends one class Object
    2. class A extends two classes class B and class Object.
    Now class A extending two classes is it correct?
    Kindly help me.What you described isnt multiple-inheritence , more like multi-level inheritence .Java allows a maximum of one direct superclass for a class , and the situation you described doesnt violate that restriction.

  • Multiple inheritence occured in java?

    we know java doest support multiple inheritence
    we know the super class for all java classes is Object
    ex:
    class A
    class B extends A
    here A extending Object
    and B extending Object(by default ) and extendin A
    is multiple in heritence occured
    if u say its multilevel inheritence how will u prove that programatical?

    we know java doest support multiple inheritence
    we know the super class for all java classes is
    Object
    ex:
    class A
    class B extends A
    here A extending Object
    and B extending Object(by default ) and extendin A
    is multiple in heritence occuredno, multiple inheritance occurs when a type directly inherits from more than one other type
    if u say its multilevel inheritence how will u prove
    that programatical?huh ?

Maybe you are looking for