Constructor in Package

Hi,
In a package after declaring a list of procedures and functions, we give the below statement as
BEGIN
     ProcFromItsOwnPackage;
END TestPack;
We call this as Constructor. Here, will it run when we call any Procedure or Function from the package
for the very first time.
Do we have any Destructor method here available similarly.

Do we have any Destructor method here available similarly.If you mean to initialize package state again you can do it with calling dbms_session.reset_package()
SQL> create or replace package pkg
as
g int;
function add return int;
end pkg;
Package created.
SQL> create or replace package body pkg
as
function add return int as begin g := g + 1; return g; end add;
begin
g := 0;
end pkg;
Package body created.
SQL> exec dbms_output.put_line(pkg.add)
1
PL/SQL procedure successfully completed.
SQL> exec dbms_output.put_line(pkg.add)
2
PL/SQL procedure successfully completed.
SQL> exec dbms_output.put_line(pkg.add)
3
PL/SQL procedure successfully completed.
SQL> exec dbms_session.reset_package()
PL/SQL procedure successfully completed.
SQL> exec dbms_output.enable() ---- must also be enabled again because of the call before
PL/SQL procedure successfully completed.
SQL> exec dbms_output.put_line(pkg.add)
1
PL/SQL procedure successfully completed.

Similar Messages

  • Record Type Constructors in Packages

    I am having trouble getting past this error. Here is an example of my code:
    create or replace
    PACKAGE MyPackage AS
      TYPE MyPerson IS RECORD ( "NAME"  VARCHAR2(255 CHAR) );
      FUNCTION GetPerson RETURN MyPerson;
    END MyPackage;
    create or replace
    PACKAGE BODY MyPackage AS
      FUNCTION GetPerson RETURN MyPerson
      AS
        John MyPerson := MyPerson('John');
      BEGIN
        RETURN John;
      END GetPerson;
    END MyPackage;After executing these separately, I receive the following errors when running the PACKAGE BODY statement:
    Error(6,10): PL/SQL: Item ignored
    Error(6,22): PLS-00222: no function with name 'MYPERSON' exists in this scope
    Error(8,5): PL/SQL: Statement ignored
    Error(8,12): PLS-00320: the declaration of the type of this expression is incomplete or malformedIs there any particular reason I cannot use a type defined in the PACKAGE header?
    select * from V$Version:
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    "CORE     11.2.0.3.0     Production"
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - ProductionEDIT: Formatting and v$version
    Edited by: 961346 on Sep 25, 2012 12:39 PM

    Hi,
    myperson is a record type and it is not an collection.
    Collections have constructors.
    Records not.
    Try like this:
    create or replace
    PACKAGE BODY MyPackage AS
    FUNCTION GetPerson RETURN MyPerson
    AS
       John MyPerson;
    BEGIN
      john.name := 'John';
       RETURN John;
    END GetPerson;
    END MyPackage;Regards,
    Peter
    Edited by: Peter vd Zwan on Sep 25, 2012 12:56 PM

  • Constructor of package protected class

    Why has class Test no constructor when trying to get the default constructor by reflection.
    class Test {
         public static void main(String[] args){
              try {
                   Class test=Test.class;
                   Constructor[] ctor= test.getConstructors();
                   System.out.println(ctor.length);
              } catch (Exception e) {
                   e.printStackTrace();
    }

    Returns:
    the array of Class objects representing all the
    the declared members of this classWrong citation:
    Returns an array containing Constructor objects reflecting all the public constructors of the class represented by this Class object. An array of length 0 is returned if the class has no public constructors, or if the class is an array class, or if the class reflects a primitive type or void.

  • How to access constructor that is not public from another package

    Hi,
    We have a class that has a constructor in package se.company.internal that looks like:
    DraHw(){
    Then from a HwTest class ( packge se.company.function.hw) we want to access this class but we cannot make the constructor public.
    Any ideas on how we can create an instance of DraHw when testing without making constructor public?
    br,
    //mike

    > we want
    However do you in fact actually need to?  And if you do that are you breaking the design of the other app?  Obviously there is in fact a way to create the class so perhaps you should study that first to insure that there is not some designed way to do what you want.
    > How would that 1:1 one class look like?
    I REALLY suggest that you look at the original design again.

  • How to create a new class

    Hi,
    I'm trying to create a new class called Questions, which has
    two properties (type and condition).
    The action script is saved in the folder myComponents under
    the project.
    When I compile the Main app, I get the following error
    message:
    "1172 Definition myComponents:Question could not be found."
    Why?
    How do you call a constructor for a new class, that is not an
    extension of an existing class?
    Regards
    /Acke
    //-----------Class----------//
    package myComponents
    // Import all classes in the mx.events package
    import mx.events.*;
    public class Question {
    // Public constructor.
    public var Question(){
    // Call the constructor in the superclass.
    //super();
    // Define properties and methods.
    // Define public vars.
    public var type:string;
    public var condition:string;
    //------Main----------//
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute"
    xmlns:MyComp="myComponents.*">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.events.CloseEvent;
    import myComponents.Question;
    etc, etc....

    quote:
    Originally posted by:
    MannenMytenLegenden
    Hi,
    I'm trying to create a new class called Questions, which has
    two properties (type and condition).
    The action script is saved in the folder myComponents under
    the project.
    When I compile the Main app, I get the following error
    message:
    "1172 Definition myComponents:Question could not be found."
    Why?
    How do you call a constructor for a new class, that is not an
    extension of an existing class?
    Regards
    /Acke
    //-----------Class----------//
    package myComponents
    // Import all classes in the mx.events package
    import mx.events.*;
    public class Question {
    // Public constructor.
    public var Question(){
    // Call the constructor in the superclass.
    //super();
    // Define properties and methods.
    // Define public vars.
    public var type:string;
    public var condition:string;
    //------Main----------//
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute"
    xmlns:MyComp="myComponents.*">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.events.CloseEvent;
    import myComponents.Question;
    etc, etc....
    Here is a test class I created a while back, although this
    one does extend Object it might help you out a bit with your
    constructor issue:
    package com.evilest
    import mx.controls.Alert;
    public class Testing_class extends Object
    private var message:String = new String();
    public function Testing_class(input:String) {
    this.message = input;
    public function showAlert():void {
    Alert.show(this.message, "sup");
    }

  • Inner classes in my interface - ok, no k, indifferent?

    I have an interface and a set of ComparatorS which are only used for objects which implement the interface. So I put the ComparatorS in the interface like so (not actual code because it is for my job):
    public interface Abc {
      //Class loader should only do this once so they are basically singleton constants
      public static final Comparator C_1 = new C1();
      public static final Comparator C_2 = new C2();
      //... there is one more
      public String getSomething();
      public String getSomethingElse();
      //First Comparator inner class
      public class C1 implements Comparator {
         private C1(){ }
         //implements appropriate methods checking for instanceof Abc in the compareTo method
        //Compares something (using getSomething())
      /* Second Comparator inner class */
      public class C2 implements Comparator {
        //same thing
        //Compares somethingElse (using getSomethingElse())
    } //End interfaceUsage:
    Set s = new TreeSet(Abc.C_1);
    s.add(abc1);Because the Comparator implementations were specific to objects which implement the interface I felt that was the best way to make that fact clear. If they were over in a separate package it would be confusing that these are for the one interface. If they were in the same package as Abc it wouldn't fit (IMO) because they are more utility type classes.
    So it was either that or make them a singleton in their own class files or something like this and I found myself liking this.
    Any comments on pros/cons of doing it this way?

    I'm confused as to why it would make sense to put the
    Comparators 'in' the interface but not in the package
    with the interface. You can't put them 'in' the
    interface without putting them in the package. In
    reality, nesting them in the interface just creates
    classes in the interface's package.My whole deal is that after talking it out I see that it is bad for reuse to have something which could be so generic residing in a particular interface (and therefore deduced soon after that in the same package as my interface). Which made me decide not to have the inner classes because it IS in the same package at that point. But I am saying that is bad. As I tried to state before, for the same reason I now think it is bad to have the classes in the interface (not much i.e. no reuse outside of the interface) then it is bad to have it in the same package as the interface (unelegant reuse outside of the package). Because if the getSomething() is getName() that could be used as a comparator for many different objects in different packages. I don't want to limit. This stance was a progression, once I decided not in the interface, I then also decided not in the same package.
    Java is strongly typed. If the class isn't an
    instance of the class you are casting to (in this
    case the interface) it doesn't matter if it has a
    method with the same signature. The cast will fail.Yes, of course, but like generics, you are not limited to just one type (Object is the type of the parameter). So I can either use instanceof before casting (not the best way) or I could have private overloads of the compareTo() method, a new one for every type I support and each supported type which has a getName() could come from a couple different packages. Not that generics does it the same way but on top of being about to declare hierachies that a genericized object can deal with you can also have comma delimitted other objects. They don't have to be related by package or hierarchy in generics. So I don't think it would be so bad for my Comparator to be (if it fit that these different types all had the same method needed by my Comparator).
    >>
    Here's anothe reason not to do that. Let's say that
    someone is using the interface. They need to compare
    it to something else, if the Comparators are right
    there with the interface, they will be likely to find
    them. If they are in some other package, they'd have
    to know where to go look for them.If that is the case, where I was worried about easy to find then I would go back to using inner classes with each Comparator as a constant. If I was worried about ease of finding where these ComparatorS are over code reuse across packages.
    I mean, I think if I am going to tie the ComparatorS so close to a particular Type then I am going to add it as an inner class whether my type was an interface or a class. At least that is what I am thinking now.
    >
    This is what I am talking about. So many Java
    developers treat packages like filing cabinets. I
    put things that do this here and things that do that
    there. But this is actually not very useful and it
    hamstrings your designs.
    Java doesn't have a friend class syntax like C++. So
    there's no way to say this class over here has access
    to this but no one else does. These kinds of
    relationships are very desireable. Some classes will
    need to access things in another class that shouldn't
    be public. You can do this cleanly if they ae in the
    same package but not otherwise.But I am not talking about taking an abstract class putting it in pack1 an a subclass in pack2. I am talking about putting a utility class that could eventially work on 50 classes in a place that is playingfield neutral and not in the original type it deals with today only. I am dealing with public accessor methods on my objects.
    >
    For example. Let's say you want to create a Factory
    (I'm using Factory in a loose way here not
    necessarily a GoF Pattern) for a public class. You
    don't want every class to have access to contructor
    because it creates the Object without initializing
    all the necessary atttributes. The factory is
    specially crafted to do this with protected info and
    access rights. If you put the class and the factory
    together it;s a snap. You create a package-protected
    constructor, some package-protected methods and/or
    fields and do it. No class outside the package will
    be able to do these dangerous operations. How do you
    do this if you have a factory package and a data
    object package?That is a whole nother situation I think. In that case it is obvious. I thought my situation was a little less obvious because of the utility nature of the classes (ComparatorS) that I was dealing with.

  • Problem with Subclassing

    I made a toolbar and subclassed it in another form but when i close the subclassed form and open it again it gives me error that it cannot find the source object.
    What is the proper way of subclassing and changing source module?
    Thanks

    unless there is at least one public or protected
    constructor in the Layer class definition you will not
    be able to subclass it. Since it is abstract and, I
    presume, is actually usable, then it is possible that
    all the constructors are package scoped so only other
    javax.microedition.lcdui.game classes may subclass
    it.
    i recommend scouring the class javadoc to make sure
    how it is to be used.
    dlgrassedlgrasse,
    Sun's javadoc documentation for the class (sadly not available online) says:
    -----8X----
    javax.microedition.lcdui.game
    Class Layer
    java.lang.Object
    |
    +-javax.microedition.lcdui.game.Layer
    Direct Known Subclasses:
    Sprite, TiledLayer
    public abstract class Layer
    extends Object
    A Layer is an abstract class representing a visual element of a game. Each Layer has position (in terms of the upper-left corner of its visual bounds), width, height, and can be made visible or invisible.
    Layer subclasses must implement a paint(Graphics) method so that they can be rendered.
    -----8X----
    Then follow a bunch of method descriptions etc.
    It might be possible that it is in fact not meant to be subclassed, but then why would they go into detail about how to subclass it?
    Also, the ready-made subclasses (Sprite, TiledLayer) are very specialized and thus not always useful, so it is more or less necessary to subclass from Layer.
    strange huh?

  • Issues converting scroll bar components from AS2 to AS3

    I am working on editing a document that has scroll bar components that I would like to convert from AS2 to AS3 since everytime I try to open the document it shows a WARNING and won't convert them and when I publish and look at the final document the scroll bar seems to act unusally since it is obviously still on AS2.
    Here are two of the scripts I finally was able to find within it. Should I fix it and how so? This first is for the "Creative Scroll Area" and the second is for the "Creative Scrollbar"
    package  {
              import flash.display.MovieClip;
              public class Creative Scroll Area extends MovieClip {
                        public function Creative Scroll Area() {
                                  // constructor code
    package  {
              import flash.display.MovieClip;
              public class Creative Scrollbar extends MovieClip {
                        public function Creative Scrollbar() {
                                  // constructor code

    Okay, well I know the code is making a scroll bar and a scroll area and under the "type" it says they are "compiled..." which is unusual since most of the other components I've worked with have been movie clips or bitmaps. Do I need to look up what AS3 components I need to replace the script from above? Because when I looked for that I couldn't specifically find what I needed or really understood if I was looking at the right information.
    Here is something I found when trying to "debug" it:
    WARNING: The component 'UIScrollBar' requires ActionScript 2.0, which is not supported in this version of Flash Professional.
    WARNING: The component 'Creative Scrollbar' requires ActionScript 2.0, which is not supported in this version of Flash Professional.
    WARNING: The component 'Creative Scroll Area' requires ActionScript 2.0, which is not supported in this version of Flash Professional.

  • HTTP Service XML Response?

    Hi,
    I have implemented an HTTP service to my getXML.php which produces XML output. I used Flash Builder Data Menu to do that, not write services by hand. It created a service packet, and also created an object type as return value( valueObjects). It converts responed XML file into that object type, and user can use that object to access data. However, I want to get XML file directly, I do not want that conversion. I looked at action script codes, and modify operation.resultType but it did not work. Any suggestiontions?
              _serviceControl = new HTTPMultiService("http://localhost/XMLprovider/");
             var operations:Array = new Array();
             var operation:Operation; 
             var argsArray:Array;      
             operation = new Operation(null, "getXML");
             operation.url = "getXML.php";
             operation.method = "GET";
             argsArray = new Array("s");
             operation.argumentNames = argsArray;        
             operation.serializationFilter = serializer0;
             operation.properties = new Object();
             operation.properties["xPath"] = "/";
          operation.resultType = valueObjects.SelectionXML;           
             operations.push(operation);
             _serviceControl.operationList = operations;

    You will need to modify the <Service Name> class.
    You can modify its constructor as:
    package services.srv
        import mx.rpc.http.Operation;
    public class Srv extends _Super_Srv
        public function Srv()
            var operation:Operation = _serviceControl.getOperation("getXML") as Operation;
            operation.serializationFilter = null;
            operation.resultFormat = "xml";       
    You can then get the XML from the result event as:
    protected function Operation1Result_resultHandler(event:ResultEvent):void
                    trace((event.result as XMLNode).toString());

  • Stopping my object [newb]

    I have an ball that moves across the screen and it works fine.
    Now I am trying to add code that will stop it when I click the mouse button.
    When I run the movie my clicks do nothing.
    Can someone look at my code and tell me where I am going wrong?
    Thank you.
    <code>
    package {
              import flash.display.MovieClip;
              import flash.events.Event;
              import flash.events.MouseEvent;
              public class Soccer extends MovieClip {
                        public function Soccer(){
                                  this.addEventListener(Event.ENTER_FRAME,update);
                                  this.addEventListener(MouseEvent.CLICK, clickHandler);
                        private function updatePosition():void {
                                  this.x++;
                                  this.y++
                        private function update(e:Event): void {
                                  this.updatePosition();
                        public function clickHandler(evt:MouseEvent): void {
                                  this.stop();
              }//close constructor
    }//close package
    </code>

    A couple of suggestions/tricks.
    1. Class constructor should have as little logic as possible. Eventually you will find that this is not only a coding style advice but something that has positive practical implications. In general the more specialized functions are, the more scalable solution you deal with.
    2. It does feel intuitive to use stop() methods to seize object movement. However, MovieClip documentation states that "Stops the playhead in the movie clip." Note that in your class you did not do anything move playhead.
    Adding ENTER_FRAME listener has nothing to do with the generic MovieClip playhead. ENTER_FRAME just makes code to execute before screen is refreshed.In other words, stop() does not remove ENTER_FRAME event listeners automatically.
    You can look at this from a different perspective. At this point it is clear that method stop() does not have enough functionality to accommodate your objectives. But it can be changed. Subclass can override any public API entities in AS3 (polymorphism).
    Class below demonstrates that. It kills two birds with one stone - preserves native MovieClip stop() method functionality and adds logic that implements objectives of your Soccer
    package
              import flash.display.MovieClip;
              import flash.events.Event;
              import flash.events.MouseEvent;
              public class Soccer extends MovieClip
                        public function Soccer()
                                  init();
                        private function init():void
                                  addEventListener(Event.ENTER_FRAME, update);
                                  addEventListener(MouseEvent.CLICK, clickHandler);
                        private function update(e:Event):void
                                  x++;
                                  y++;
                        public function clickHandler(e:MouseEvent):void
                                  stop();
                        override public function stop():void
                                  super.stop();
                                  removeEventListener(Event.ENTER_FRAME, update);

  • Mechanics of reference counters in GC?

    Hi all,
    I was thinking about Flash GC the other day and came up with a question about how reference counting would work in the following 4 class scenario (assume GuiMain is the movie's document class):
        package com.gui {    
    import flash.display.MovieClip;        
    public class GuiMain extends MovieClip {        
    private var button1Handle:Button1;        
    public function GuiMain() {            
    // constructor code            
    button1Handle = new Button1();            
    addChild(button1Handle);           
    killButton1();        
    public function killButton1(){            
    removeChild(button1Handle);            
    button1Handle = null;        
    package com.gui {    
    import fl.controls.Button;   
    import flash.display.*;        
    public class Button1 extends Sprite {        
    private var button2Handle:Button2;        
    private var tester:Test;        
    public function Button1() {            
    // constructor code           
    button2Handle = new Button2();            
    tester = new Test();        
    package com.gui {        
    public class Button2 {        
    public function Button2() {            
    // constructor code        
    package com.gui {    
    import flash.display.MovieClip;    
    import flash.events.Event;            
    public class Test extends MovieClip{        
    public function Test() {            
    // constructor code           
    addEventListener(Event.ENTER_FRAME, yellLoudly);        
    public function yellLoudly(e:Event){                        
    trace("AAAH!!!");        
    When the Button2 and Test instances are created in Button1, I would expect their reference counters to increment. The question is, do their reference counters decrement accordingly when the Button1 object that created them is removed from the display list and nulled out? I tested this code and the event listener in the Test class does seem to shut off, but that doesn't necessarily mean that it or the Button2 instance are eligible for GC. Even if they were, it might only be under Mark and Sweep, which is slower than reference count-based GC.
    One obvious solution would be to have the Button1 class remove listeners from/null out references it makes when it is time for it to be removed like so:
    package com.gui {    
    import fl.controls.Button;    
    import flash.display.*;        
    public class Button1 extends Sprite {        
    private var button2Handle:Button2;        
    private var tester:Test;        
    public function Button1() {            
    // constructor code            
    button2Handle = new Button2();            
    tester = new Test();        
    public function destroyRefs(){                  
    button2Handle = null;                  
    tester.removeEventListener(Event.ENTER_FRAME, tester.yellLoudly);                  
    tester = null;           
    but in a real program, where I may be working with multiple references to the same object from different classes (via passing in the original references in constructors) wouldn't setting the reference in one class to null cause the value of all other references to the same object to also become null? That would certainly be undesirable...
    The main question is as follows: when the only reference to Button1 is nulled out, do all the the objects it references have their reference counters decremented (either immediately or when the Button1 object is garbage collected)?
    Also, is there a way to view all instances of an object that exist in real time and/or their reference count values through the Flash debugger?  A detailed profiler like that would really help in figuring these questions out...
    thanks,
    CCJ

    to answer the last bit, flash builder premium has a good profiler and you could also try Monster Debugger - its free and i think it has a profiler

  • Hardcore Java Questions Thread

    Greetings,
    I am otherwise known as Robert Simmons jr. O'Reilly has recently published my first book entitled hardcore java. Since the motivation for some of the content came from questions asked on this forum, I decided to make a question an answer thread on this forum to deal with your questions on the book, its content and topics.
    You can find the book at O'Reilly:
    http://www.oreilly.com/catalog/hardcorejv/
    Or Amazon.com
    http://www.amazon.com/exec/obidos/tg/detail/-/0596005687/qid=1080130526/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/103-4213374-6043826?v=glance&s=books&n=507846
    It is also on sale in quite a few other places but I just mentioed two of the most popular.
    Feel free to ask your questions and I will knock them down as quick as I can.
    -- Robert Simmons Jr.

    I read the sample chapter about using final and,
    whilst I agree with you about using final beinggood
    coding practise, there are a few points I wouldmake:
    Example 2-2. Simple constants using final:
    public static class CircleToolsBetter {
    /** A value for PI. **/
    public final static double PI = 3.141;I think you should limit the scope of that variableby
    making it private.Why? What would be your motivation in hiding this
    value? At any rate, the example you are mentioning
    wasnt designed to demonstrate guarding access to
    constants. I talk about that a bit later in the
    chapter. There may be reasons for havign this private,
    I concede that. Just in this example I cant think of
    one. At any rate derived classes will probably need PI
    so protected would be a better option if you want to
    seal it off for some reason. I just think that you should always try to limit the scope of a variable as much as possible. I know that wasn't the point of that particular example, but I think it's good practise "in general".
    At any rate derived classes will probably need PI so
    protected would be a better option if you want to seal
    it off for some reason.Ah, but what about classes (it's public in the example), they could reference that variable and then if it changes ...
    In the section "Public Primitives and
    Substitution" you don't mention anywhere thatyou
    can get around the problem of having to recompile
    dependant classes by using static initializion and
    also by interning Strings. I think that would makea
    good addition to that section.Good feedback, Ill think about that for revision 2.
    There is some other material that didnt make that
    chapter as well. =) However, I do talk abotu
    initialization in detail in chapter one. You should
    check it out. =) Do I have to buy the book : )
    You say[i] "Most singleton classes shouldn't be
    declared as final. You never know what otherfeatures
    your class's user will dream up. However, since
    singleton classes need to be protected fromexternal
    instantiation, you can't make the constructorpublic.
    The solution to the problem is a protected
    constructor". I think you should add that thismeans you must put your singleton in a relevant
    package (i.e. Not in a package with classes that
    shouldn't be able to instantiate the singleton!)Of course you should always employ good package
    management. In fact package management might be in
    second edition as I do have quite a few notes on it.
    However, a singleton can only instantiate itself and
    that only once, so I dotn see why you think this is a
    concern. The goal of protected constructors is to
    prevent external instantiation of the class. Perhaps
    you were thinking of constructors with "package
    private" access (ie no public, private or protected
    keyword used) ?? Protected constructors can only be
    accessed bby the class and subclasses, whereas a
    "package private" constructor can be accessed by any
    class in the package.
    A protected constructor is accessible to the class itself, its subclasses, and classes in the same package.

  • Diamond problem

    how to solve diamond problem in java? can anyone explain with an example??

    tschodt wrote:
    dpxqb wrote:
    ... I "think" the real diamond problem happens when if you buy two libraries from different vendors. and then due to bad luck, you get a diamond name clashThese two vendor libraries will provide classes in two different package hierarchies.
    There is no name clash.I do not see how different package hierarchies would help?
    If that were true, there would really not be a problem. Rather, you can just type a little more (the fully qualified canonical names)? The diamond problem is special because canonical names cannot be used to show which interface's Foo class to use?
    package CompanyA;
    public interface InterA {
      public static class Foo {
        public Foo() { println("InterA::[constructor] Foo"); }
    package CompanyB;
    public interface InterB {
      public static class Foo {
        public Foo() { println("InterB::[constructor] Foo"); }
    public class Main {
      public static void main(String[] args) {
        AAA.Foo f = new AAA.Foo();  // error! <-- how can i use canonical names here?
        // reflective work-around
        Class[] cA = AAA.class.getInterfaces()[0].getClasses();
        cA[0].newInstance();
        Class[] cB = AAA.class.getInterfaces()[1].getClasses();
        cB[0].newInstance();
        public static class AAA implements CompanyA.InterA, CompanyB.InterB {
          public void x() { }
    }Other than the reflective work-around, I don't see how to tell Java which Foo class to use. Again, I really don't know if what I say is true, so please set me straight if I am making a mistake. thanks.

  • InvocationTargetException when using the reflection package (Constructor)

    Hi there!
    its my first post in here and not an easy one I suppose.
    I have got a JFrame class that has a inner class to handle button events (the inner class implements java.awt.event.ActionListener).
    I have got a file browser to lookup a particular class file (which has to be javax.swing.jframe) on my harddisk.
    Then I try to construct a constructor :) and want to display the class.
    It works with simple classes but the class with the inner class i mentioned above makes probelems in throwing a InvocationTargetException Error when calling the contructor.
    Here is the exact message:
    InvocationTargetException!java.lang.IllegalAccessError: tried to access class org.eml.adaptiveUI.demo.TransformationDemo_jButton1_actionAdapter from class org.eml.adaptiveUI.demo.twoButtons
    twoButtons is the class i try to open vie the reflection and class methods, ransformationDemo_jButton1_actionAdapter is the inner class. If i run the main method of the twoButtons class and call the constructor directly there are no problems.
    Does the VM not know about the inner class or something like that? If yes how to get all the needed classes and how to inform the VM about it.
    Thanks a lot!

    Hi
    yes I start the prog out of Borlands JBuilder and the loaded clas (via reflection) is also in my project so everything (classpath) should be fine.
    The problem is that "invocation target exception" is about access modifiers. Inner classes are not public so the vm thinks i am not allowed to call the constructor, which is wrong because the outer class calls the constructor not me myself.
    Perhaps this is even a java bug?
    thx again, Heiner

  • Why is the constructor of EnsTopic package private?How did you compile the sample?

    JmsSample.java:77: EnsTopic(java.lang.String) is not public in com.iplanet.ens.j
    Topic topic = new com.iplanet.ens.jms.EnsTopic(ensTopic);
    ^

    A work around is to change the offending statement to
    Topic topic = topicSess.createTopic(ensTopic);

Maybe you are looking for

  • Getting an error while copying pdf file into RMS enabled document library using copyTo() method

    In SharePoint 2010, I am trying to copy pdf file programmatically from a non-RMS protected document library into RMS protected library using copyTo() method. But I am getting an error while doing so. it gives error as mentioned below - This library d

  • Error in mapping of request message (IDoc)

    Hi! I am facing with the following mapping error. I try to map data element MT_Material to IDoc MATMAS.MATMAS02 com/sap/xi/tf/_MM_MT_Material_MATMAS02_</Trace> <Trace level="1" type="T">com.sap.aii.utilxi.misc.api.BaseRuntimeException: RuntimeExcepti

  • Getting rid of compound path "cut marks" in Illustrator

    Hi, I have created some icons in Illustrator using compound paths. I ended up having these faint, dark "cut out" lines (please see example). What am I doing wrong or what do I need to do to get rid of this? Thanks! Kathy

  • Can't see read my webpages anymore...

    New to the mac world. Mostly loving it, but I was surfing the internet tonight and I hit something on the mouse pad. I have no idea how it happened, but the entire screen for the web browser grew smaller. Now everything is so tiny I can barely read i

  • Inner table pointer

    Hi all      I define a structure(not build in database) in program and create a inner table with this structure.      now, i want to assign a pointer to the inner table and a pointer to a work area.How?      for example      data: begin of ty_test1 o