Package scope visibility across 2 classloaders

Hi - I have 2 classes, examplepackage.ClassA and examplepackage.ClassB.
ClassA is being loaded by classloader1, and ClassB is being loaded by classloader2.
ClassB has instance variables defined with (default) pacakge scope, eg
String sString1 = "something";
String sString2 = "something else";
My problem is that if ClassA attempts to refer to the instance vars in ClassB directly, eg
classB.sString1 (where classB is an instance of ClassB loaded with classloader2), I get an IllegalAccessException.
Is this expected?
Thanks,
Kevin Hooke

yes Perhaps you could eloborate a bit? And a JLS reference would be nice. I looked and couldn't find anything.

Similar Messages

  • Package Scope - Constants

    I am trying to figure out the best way to implement a CONSTANTS class for my project. I have all of my files defined in a package. And I have included the class where I defined my package constants in that package. I have defined them like:
    static final int a = 1;
    So they have package level access (not public/private). And I can access them when a direct call:
    int b = consts.a;
    But, I am a little confused on the use of defining this way, using import, package scope, interfaces. Looking at the tutorial:
    http://java.sun.com/docs/books/tutorial/together/index.html
    I see that they have a constants class that is an interface which they also import into other classes when they want to use it AND they call it explicitly with the class name prefix. Running a little test, I see that without any of this, a class can access a variable defined without public/private definition and/or package and/or interface and/or imports. So, it doesn't seem like any of these are really necessary.
    Simple question: What is the best way to define and access constants in one place for a project?

    A question many of us ask but never really come up with a satisfactory answer.
    Firstly are they real constants? I.e. will they never change in the life of the program (if they might change then they should be in a config file).
    Next thing to bare in mind is how the java compiler works. Say I have class A
    class A
      public static final int A_NUMBER = 0;
    }which is use somewhere else
    class B
    void aMethod() {
    int something = A.A_NUMBER;
    }Now if I compile it all, it works fine. If I know go and change A_NUMBER to be another value and recompile class A only, then the reference to A.A_NUMBER will still be 0!! The compiler is actually copying the value accross.
    So, next question to ask. what is you build policy? Do you always recompile everything? If so then you should be alright with a load of static final values in an interface somewhere.
    Other things to bare in mind is were are constants used. If the constants are used in one class only then they should be defined in this class with a private modifier.
    I would normally suggest still using get methods to get hold of constants, just to make sure the senario with the compiler never happens.
    If you tell me what your constants are I can probably give you a better ideas as to what to do with them.
    One the whole, the only time you would want to put them all in one place was if you wanted to find them quickly for changing them. In which case you should have a config file instead.

  • Package scope

    Hi guys I need to know about package scopes.what is the difference
    between private and protected object and when do we say a method or an object is not accessible in in the second class if you have two classes

    For private objects declared in ClassA, only methods within ClassA can reference the object.
    If you have ClassA and ClassB within the same package e.g. PackageA:
    ClassA cannot see ClassB's private objects but ClassA can see ClassB's protected objects.
    Classes with the same package can see each others protected objects but they cannot see each the other's private objects.
    Classes in another package PackageB cannot see protected methods in PackageA. It can only see protected methods for classes in it's own package PackageB and public methods in PackageA.
    Hope this helps.
    JB

  • ODI Running Packages not visible in Operator

    Hi All,
    I have a set of packages running in ODI which show up their execution status in operator under status tab but they are not visible under all executions.
    Can anyone help me as why this happens?
    Thanks .....

    Hi,
    1. Goto OPERATOR
    2. Click onto the All Executions node
    3. On the right hand side you will find the following headings
    Status ,Session Number , Session Name , User, Physical Agent , Start , End , Return Code etc.
    4. Click onto the Start and choose ascending or descending based on your need
    Thanks,
    Sutirtha

  • Object COntent information for deleted packages still visible in content status

    Hi,
          I have a situation in our prod. SCCM site where deleted packages still have their object content information visible in Content status in SCCM. Has anyone faced the same issue?

    Hi,
    Check distmgr.log
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Package scope variable

    I created package variables in specification
    of the package.
    And all procedures and function can see these
    variables.
    The question is: What about transaction?
    If two users start using these variables,
    does it influence each other or every user
    will work in his own scope?
    Sorry for dummy question.
    Thanks Anatoly.

    Since Variables declared in the Package variables r global variables will be updated whenever accessed globally.Its not session dependant.
    Might be a problem when two users access it at the same time.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by avalko:
    I created package variables in specification
    of the package.
    And all procedures and function can see these
    variables.
    The question is: What about transaction?
    If two users start using these variables,
    does it influence each other or every user
    will work in his own scope?
    Sorry for dummy question.
    Thanks Anatoly.<HR></BLOCKQUOTE>
    null

  • Package scope and import statements

    Hi everubody,
    I'm studing a code: foo.java written by sb. else. In the code, I have:
    package com.dir1.dir2.dir3;
    import com.dir1.dir4.code1;
    import com.dir1.dir5.code2;
    The code: foo.java exists in the directory: com/dir1/dir2/dir3 as expected. However, in the import statements, there is NO dir4 and dir5 under com/dir1? Shouldn't the import statements be relative to the directory of package?
    Guess I'm missing a point here... Any help is greatly apprecited.

    When you import:
    import co.mycompany.my.MyClass
    then MyClass should reside in the directory:
    co/mycompany/my, right?Right. Somewhere in the classpath there would have to be that directory structure. Again, that could be an actual directory name, or a path name in a Jar.
    Then if the code: foo.java resides in the directory:
    com/dir2/dir3 with the:
    package com.dir1.dir2.dir3;
    How the compiler and JVM finds the code MyClass
    (which you imported in foo.java)?Thru the magic known as the classpath.

  • Public parts not visible across SCs

    Hello,
    in one product we have two software components: one for COMMON functionality and another for our SERVICE. In the COMMON SC we defined our exception classes and made them available as public parts. All steps until approval have been made and the new version of COMMON was imported for development for the SERVICE SC.
    Unfortunately, we are not able to reference the public part for the exception classes in the SC "SERVICE". Any idea why the public parts are not visible accross the software components?
    Regards,
    Volker

    Renjith,
    I had similar problem and its fixed now. What you need to do is..
    If you are adding an SC from Track A to Track B, then
    1. Choose track B in CMS
    2. Click on ¡§Landscape Configurator¡¨
    3. Add the SC of track A into ¡§Required Software Components¡¨
    4. In Track Data tab, select the SC in ¡§Software Components for Development¡¨ area.
    5. Click ¡§View/Edit XML content..¡¨
    6. Add the 2 lines in between ***
    **<used-compartment>vendorname_TrackA_1</used-compartment>**
    </dependencies>
    <build-variants>
    <build-variant name="default" required-for-activation="yes">
    <variant-mappings>
    <variant-mapping used-compartment="sap.com_SAP_JTECHS_1" used-variant-name="default"/>
    <variant-mapping used-compartment="sap.com_SAP-JEE_1" used-variant-name="default"/>
    <variant-mapping used-compartment="sap.com_SAP_BUILDT_1" used-variant-name="default"/>
    **<variant-mapping used-compartment=" vendorname_TrackA_1" used-variant-name="default"/>**
    </variant-mappings>
    </build-variant>
    </build-variants>
    7. Click on ¡§Back¡¨
    8. Save the track B.
    9. Click on ¡§Transport Studio¡¨
    10. Import each SC (there should be 4 listed. 3 from sap.com and 1 from track A) one at a time. First import sap.com¡¦s SCs.
    Thanks,
    Kiran

  • C# SSIS Script component - Save List String to Object package-scope variable and read it in Script Task

    before posting this i was searching this on internet but was not able to find info regarding my specific case:
    i have a DataFlow Task with "Error output" pointing from FlatFile to
    Script Component that does below (variable "ErrorMessageList" is listed under ReadWriteVariables property):
    List<string> lsErrors = new List<string>();
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    lsErrors.Add("test1");
    lsErrors.Add("test2");
        void PostExecute()
            base.PostExecute();
            Variables.ErrorMessageList = lsErrors;
    Then the DataFlow points to a ScriptComponent where this object variable is listed under ReadOnlyVariables property and does the below:
    public void Main()
    List<string> lsErrors = (List<string>)Dts.Variables["ErrorMessageList"].Value;
    and that is where i get exception-has-been-thrown-by-the-target-of-an-invocation
    What is wrong here?
    (i have mistakenly edited this first post before, so i tried to manually put it back to original version)

    i have missed the "override" keyword...
    public class ScriptMain : UserComponent
    public class UserComponent: ScriptComponent
    namespace Microsoft.SqlServer.Dts.Pipeline
    public class ScriptComponent
    // i should have seen this before
    public virtual void PostExecute();
    i believe i must have deleted the PostExecute method definition right after the ScriptComponent generated the script for me... and then when i've realized that i can't change ReadWriteVariables as a part of:
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    // --- can't change ReadWriteVariables here
    then i had to add the method back but forgot that the base method is virtual
    thanks for this hint, Russ!

  • Global Variables across sessions in PL/SQL package Specification

    Hi,
    Is there a way I can share a variable value across sessions that doesnot affect by Commit/rollback.
    The value would be set by one session and is visible across sessions, until it is set to another value by another/same session, and the new value is visible across.

    V$Session is not granted to the user executing this. So, had to go with the context. Finally could resolve with the following code.
    Run by DBA
    create or replace context ctx1 using USER_procowner.pkg_global accessed globally;
    grant execute on dbms_session to USER_procowner;
    Run by user_procowner
    create or replace package user_procowner.pkg_global AS
    procedure set_lock(in_val IN VARCHAR2);
    Function get_lock RETURN VARCHAR2;
    end pkg_global;
    create or replace package body user_procowner.pkg_global AS
    procedure set_lock(in_val IN VARCHAR2) IS
    begin
    dbms_session.set_context('ctx1','var1',in_val);
    end;
    Function get_lock RETURN VARCHAR2 IS
    begin
    return (Sys_context('ctx1','var1'));
    end;
    end pkg_global;
    grant execute on pkg_global to user_procuser;
    exec user_procowner.pkg_global.set_lock('Y')
    select user_procowner.pkg_global.get_lock Lock from dual;
    LOCK
    Y
    exec user_procowner.pkg_global.set_lock('N')
    select user_procowner.pkg_global.get_lock Lock from dual;
    LOCK
    N
    The current value of var1 is visible across sessions using user_procowner.pkg_global.get_lock.
    Thanks to all contributors.

  • Package visibility control

    Hello All,
    How can we limit the visibility of a package to a particular level?
    I've 3 package PackageA,PackageB,PackageC. Some classes in all packages have to communicate with some other classes in other packages.
    ie File1 in PackageA has to communicate with File2 in PackageB and file3 in PackageC. I would like to allow only PackageA as visible to outside.
    ie any classes in PackageB, and PackageC shouldn't be visible to import in outside classe (say file5 in PackageD).
    At present File2 in PackageB, file3 in PackageC are public in order to communicate with File1 in PackageA and hence it is visible to outside also.
    I would like to make only PackageA as visible to outside at the same time the necessary Files in PackageB and PackageC should able to communicate with PackageA classes.
    Thanks in advance.....
    Regards
    Sojan

    If PackageA contains the only publicly visible classes, then rather than having three packages, why not put all the classes in PackageA, and give those you don't want to have public visibility non-public (default) visibility?
    This makes PackageA adhere to one standard understanding of what a package should be: a collection of related classes that has minimal external dependencies, and exposes a cohesive external API.

  • Default visibility interface inheritance problem

    I have these constructs:
    package bar;
    public interface A {
    void Foo()
    package bar;
    public class B extends C implements A {
    void Foo() {
    This produces following compile error:
    Cannot reduce the visibility of the inherited method from A. The error does not occur if I make B::Foo() public.
    Why does the error occur?
    Thanks in advance,
    -Lev

    the default visability for interfaces are public for methods and public static final for variables. The
    default modifier for classes are packager-scope and variables are non-static, non-final by default.
    For this reason and others I prefer to state explicitly what modifiers I expect the methods and variables to have.... and believe me, you're not the only one ;-)
    lazyness is often leading to omitting modifiers, wiseness always recommends to be as explicit as possible.

  • What is the scope of implicit loop variables?

    Hi,
    I'm facing some strange error from the ABSL editor (syntax checker).
    In ABSL the loop variables are implicit and don't have to be declared in the head section of the script.
    My question now is simple: How is the scope/visibility of such loop variables specified ?
    There's a complete code snippet below.
    In line no.9, there's the first time use of implicit loop variable 'task_inst'.
    Because of type inference, it will be typed as MasterDataWanneBe/Tasks (which is my own BO type).
    In line no.20, I want to use the same variable name in a different loop, outside the parenthesis/scope of the first first use.
    Now the ABSL syntax checker complains about incompatible types (see code snippet)
    Thus the type inference should result in the, (lets say 'local') type Project/Task, which is the one I was querying for.
    To me it looks like, that loop variables implicitly get a global scope (hopefully bound to this ABSL file only).
    I would like to see the scope/visibility of loop variables restricted to the parenthesis.
    In other words only inside the loop.
    Hint
    I heard (from little sparrows), that local variable scoping is not possible because of underlying
    generated ABAP code. If so, than it would be helpful to print warnings, in case of types are compatible
    but used in different scopes. Think about the unintended side effects.
    import ABSL;
    import AP.ProjectManagement.Global;
    var query_tasks;
    var query_tasks_param;
    var query_tasks_result;
    foreach (empl_inst in this.Employees) {
         foreach (task_inst in empl_inst.Tasks) {
             //   ^^^^^^^^^  first time use
              task_inst.Delete();
    // ===========================================================================
    query_tasks = Project.Task.QueryByResponsibleEmployee;
    query_tasks_param = query_tasks.CreateSelectionParams();
    query_tasks_result = query_tasks.Execute(query_tasks_param);
    foreach (task_inst in query_tasks_result) {
          // ^^^^^^^^^ Error: 4
          // The foreach loop variable is already inferred to an incompatible type:
          // Node(MasterDataWanneBe/Tasks). Expected Node(Project/Task)

    Yes, variable declarations in ByD Scripting Language indeed have (snippet) global visibility. In the FP 3.0 release the variables can be declared anywhere in the snippet (not only in the beginning, as with FP 2.6), however still not within code blocks, i.e. within curly braces ({}). Therefore variable name shadowing is still not supported and because of the global visibility of variables they cannot be reused for a different type, later in the same snippet. This is because of the statically typed nature of ByD Script, despite the type inference convenience.
    Kind regards,
    Andreas Mueller

  • Multiple OLE DB connection managers to the same database instance in a SSIS package

    Hi,
    While migrating DTS package to SSIS package, I came across one which had multiple OLE DB connection managers all connecting to the same Oracle schema in the same instance.
    There are that many execute SQL task corresponding to each of these connection managers.
    Each of  these SQL task call different Oracle stored procedures and executes them in the same schema in the same instance.
    My question is, is there any particular reason or advantage in having multiple connection managers?
    Can't we have one single connection manager and use the same in all of these SQL tasks?
    Does multiple connection managers provide any added advantage like parallelism or something?
    In this particular case, there are no actual workflows, rather each of these SQL tasks are stand alones. But there are other packages which has SQL tasks in workflow but still each of them calling separate connection managers all calling the same schema
    in the same instance.
    Thanks for your time.
    Cordially, Biju George

    Well like I said, each of  these SQL task calls "different" Oracle stored procedures even though executes them in the same schema in the same instance. I tried a sample testing by creating two separate packages, one with only one single
    OLE DB connection referred in all of the SQL tasks and in the other one with mutiple OLE DB connections to the same schema in the same instance each of which is referred in each of the SQL task in one to one mapping.
    Now the first one created one session in Oracle but the later created as many sessions as there where OLE DB connection managers. The first one took longer to complete than the second one since second one created independent sessions and executed those procedures
    sort of parallely.
    I guess that can be called an advantage of creating multiple connection managers to the same schema in the same instance.
    Cordially, Biju George

  • Video Files Recorded on SD Card Used in Canon AVCHD Camcorder Not Visible Under Mountain Lion

    Hello:
    Mountain Lion seems to treat the storage media (an SD card) used to record video in my Canon AVCHD camcorder differently than Mac OS X 10.7, 10.6 and 10.5.
    When the card is inserted into the built in-card reader, it mounts as one would expect; however, a folder named "Private" appears and nothing seeems to be inside of it. If I use a machine running 10.7, 10.6, or 10.5, I'm able to drill down the fodler structure to the MTS files.
    Anyone know of a way to tell 10.8 to see the data structure as 10.7 would?
    I'm guessing that 10.8 wants me to use iMovie or Final Cut Pro X to access the video; however, the files need to remain as they are (i.e. mts files) and used in Adobe Premiere Pro and Adobe After Effects.
    This one is kind of obscure, I know.
    Thank you for any input.
    -Warren

    Let's see...
    Sounds like you're running into an expected issue if you make an alias to removeable media.  The same thing would happen if you made the alias to a folder on a DVD-R disc or CD-R.  If you eject the original, you disable the alias.
    If you copy the entire SD card volume to your drive, the PRIVATE package should copy across.  Then, as a folder on your hard drive rather than a volume on removeable media, you could make an alias to the STREAM package for quicker access later.
    I'm pretty sure that Handbrake, like Prmeiere Pro, can see the MTS files directly.  That is, it's not dependant on the other folders in the PRIVATE directory sturcture.  As such, you could copy the contents of the STREAM package to another folder on your drive.  Just be mindful of the default MTS file names if you're using more than one SD card (you don't want to accidentally copy 00001.MTS from one card over 00001.MTS from another card).
    As long as Handbrake sees MTS directly, you could even rename the MTS files after you've copied them.
    On a side note, I almost always archive my SD cards with the data structure intact.  More often than not, that file structure is important to corretly access the video stored within that structure.  If something unexpected happens while working with the MTS files, it is good to have the original file structure to go back to.  Although, SD cards are getting to be so low cost that sometimes I just label the SD card and store it for archiving.
    -Warren

Maybe you are looking for

  • Itunes 11.1 installation problem

    I have been having this problem with installing itunes 11.1 that halfway through the installation, the status starts saying 'rolling back action' and it said that the installation was not complete and to try again later. it did not give me any error

  • Is it possible for Express to broadcast signal in hotel room to iPad?

    Hello: I would like to know if it is possible to configure an Airport Express so that it is connected to an ethernet port in a hotel room and have the express broadcast a wireless signal to my iPad? This will be my configuration: 1. One airport expre

  • How to create table in smart form

    hi all, i want to create table in to main window of smartform. i am trying it but it gives me line type error. plz give me  detailed procedure for creating table in smartforms. thanks in advance. regds. Vinod

  • HT1386 Help syncing a iPhone 3GS so I can upgrade to a iPhone 4S

    I have a iPhone 3GS that I am about to upgrade to a iPhone 4S. I am still using version 4.0.1 since I am always skittish about changing anything. The most important things that I need saved are my Contacts, Calendars, and Notes. I upgraded to a newer

  • Can't get rid of white app icons

    Hey guys. Just today the icons on some of my apps have gone white on my iPod Touch (4th gen iOS 4.2.1). It's not the same shade of white that you get when downloading apps. I have tried rebooting my ipod and resyncing it with iTunes, but these soluti