How to refer to a protected class outside the enclosing package

Hi all,
At the page 357 of the book Java Language Specification(Second Edition), when saying about checking accessibility of Type and Method, they concern Let C be the class containing the method invovation T.m, if T is in a different package than C, and T is protected then T is accessible if and only if C is a subclass of T. I just wonder how to refer a protected type outside the package it declared.
For example,
package test;
public class test {
static protected class protectedTest {
public void foo() {..}
in another package
import test.*;
class subtest extends test.protectedTest {  <- error
Anyone can give me an example showing an invocation directly to foo() declared in class test.protectedTest ? The invocation should appear outside package test.
Thanks,
Ha Chau

The protected inner class would be accesible only within a class which extends test, where you could either use or extend it as in:
class subtest extends test {
    private static class sub2 extends protectedTest {
           }

Similar Messages

  • How to create an instance of a protected class outside the enclosing packag

    Hi all,
    I have a piece of code like this:
    package test;
    public class A {
    protected class B { }
    How to create an instance of B outside the package test ? Could you please give me an example ?
    Thanks
    Ha Chau

    Thank WirajR for your reply, but in your solution,
    you have to create an instance of B inside class A
    and pass it outside. I would like to know whetherwe
    can create an instance of class B outside thepackage
    test. That means I want the instance creation
    expression of B appears outside the package test.Can
    we do that?
    If you want to use a class this way then it shouldn't
    be marked protected. I can't see why you don't
    just declare it public if that's what it is.
    Wouldn't be much point to haveing a protected
    modifier if it had no effect, would there?I think there is use for it if you use an interface to filter out the parts you want to give public access to, and keep the part you want to keep protected, protected

  • How to use Landmark in a Class outside the Parsley Context

    Hi all,
    Is there anyway to get the Landmark metadata work without adding the annotated Class in the Parsley Context file?
    I mean, I have a Class such as:
    [Landmark(name="content.foo")]
    public class MyClass extends ManagedClass {
    [Enter(time="every")]
    public function enter():void
    LOG.info("content.foo:Enter");
    Problem:
    Enter method is never fired although ManagedClass( the super class ) has a <parsley:Configure /> tag ( and, of course, all injections happen ).
    Adding MyClass to the Parsley Context file makes everything work but is there anyway to make this Landmark work without doing that?
    Thanks.

    That's more of a Parsley question than C3 and AFAIK it's not feasable. The other way around is with i.e. the ProcessSuperclass object definition in Parsley. Check out Parsley's developer manual on that (chapter 3 should explain this)

  • [svn:fx-trunk] 5140: Removing [ExcludeClass] from classes outside the package.

    Revision: 5140
    Author: [email protected]
    Date: 2009-03-02 12:09:24 -0800 (Mon, 02 Mar 2009)
    Log Message:
    Removing [ExcludeClass] from classes outside the package.
    QE Notes: None.
    Doc Notes: None.
    tests: checkintests
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/layout/HorizontalLayout.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/layout/VerticalLayout.as

  • How do you call a java class from the main method in another class?

    Hi all,
    How do you call a java class from the main() method in another class? Assuming the two class are in the same package.
    Thanks
    SI
    Edited by: okun on May 16, 2010 8:40 PM
    Edited by: okun on May 16, 2010 8:41 PM
    Edited by: okun on May 16, 2010 8:47 PM

    georgemc wrote:
    To answer your impending question, either the method you're calling has to be static, or you need an instance of that other class to invoke it against. Prefer the latterAnd to your impending question after that: no, don't use the Singleton pattern.

  • How to convert the class in the one package to same class in the other pack

    How to convert the class in the one package to same class in the other package
    example:
    BeanDTO.java
    package cho3.hello.bean;
    public class BeanDTO {
    private String name;
    private int age;
    * @return
    public int getAge() {
         return age;
    * @return
    public String getName() {
         return name;
    * @param i
    public void setAge(int i) {
         age = i;
    * @param string
    public void setName(String string) {
         name = string;
    BeanDTO.java in other package
    package ch03.hello;
    public class BeanDTO {
    private String name;
    private int age;
    * @return
    public int getAge() {
         return age;
    * @return
    public String getName() {
         return name;
    * @param i
    public void setAge(int i) {
         age = i;
    * @param string
    public void setName(String string) {
         name = string;
    My converter lass lokks like
    public class BeanUtilTest {
         public static void main(String[] args) {
              try
                   ch03.hello.BeanDTO bean=new ch03.hello.BeanDTO();
              bean.setAge(10);
              bean.setName("mahesh");
              cho3.hello.bean.BeanDTO beanDto=new cho3.hello.bean.BeanDTO();
              ClassConverter classconv=new ClassConverter();
              //classconv.
              System.out.println("hi "+beanDto.getClass().toString());
              System.out.println("hi helli "+bean.toString()+" "+bean.getAge()+" "+bean.getName()+" "+bean.getClass());
              Object b=classconv.convert(beanDto.getClass(),(Object)bean);
              System.out.println(b.toString());
              beanDto= (cho3.hello.bean.BeanDTO)b;
              System.out.println(" "+beanDto.getAge()+" "+beanDto.getName() );
              }catch(Exception e)
                   e.printStackTrace();
    But its giving class cast exception. Please help on this..

    Do you mean "two different layers" as in separate JVMs or "two different layers" as in functional areas running within the same JVM.
    In either case, if the first class is actually semantically and functionally the same as the second (and they are always intended to be the same) then import and and use the first class in place of the second. That's beyond any question of how to get the data of the first into the second if and when you need to.
    Once you make the breakthrough and use one class instead of two I'd guess that almost solves your problem. But if you want to describe your architecture a little that would help others pin down want you're trying to do.

  • How can I buy subtitled movies from outside the US?

    how can I buy subtitled movies from outside the US?

    People here are users, you need to contact Apple Inc. by phone and see if you can resolve this problem.
    http://support.apple.com/kb/he57

  • HELP: signer info doesn't match info of other classes in the same package

    I have several jars which need to be signed. They contain several applications and packages which
    are split up based on which parts are needed by server vs client code. How do I get rid of this error?
    I'm signing all the jars using the keytool and jar signer in java 1.3.1. I generate a certificate file.
    My assumption is that each time I sign a different jar, the info is updated in the keystore and
    certificate file. What might I be doing wrong when signing multiple jars?
    (Yes, code from the same package may be in different jars. I don't have any controll of this,
    I'm not in charge of the build and distribution of the various packages).
    Exception in thread "main" java.lang.SecurityException: class
    "com.ibm.ucm.bootup.UCMSysMgtConstants"'s signer information does not match signer
    information of other classes in the same package
    at java.lang.ClassLoader.checkCerts(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at com.ibm.ucm.bootup.UCMServerUpdater.<init>(Unknown Source)
    at com.ibm.ucm.bootup.UCMServerUpdater.<init>(Unknown Source)
    at com.ibm.ucm.bootup.UCMAdminServerUpdater.<init>(Unknown Source)
    at com.ibm.ucm.bootup.UCMAdminServerUpdater.main(Unknown Source)

    Where you able to solve this issue? (I'm seeing the same problem.)
    Thanks,
    Stacy

  • Cannot acess classes in the same package.

    Hi
    I have "a.java" in c:/java/test directory. I have "b.java" file in the same directoty which creates a instance of "a" class. "a.java" compiled fine. But when compliling "b.java" i get error message
    cannot resolve symbol
    symbol : class a
    I have used "public" as acess modifier for both the classes. As per rule I can access the classes in the same package. But for some reason my program is not compiling. Can anyone tell me what the acutal problem is.
    Thanks in advance.

    Javapedia: Classpath
    Setting the class path (Windows)
    How Classes are Found
    java -cp .;<any other directories or jars> YourClassNameYou get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
    javac -classpath .;<any additional jar files or directories> YourClassName.javaYou get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.

  • Accessing other classes in the same package

    I have the following two classes in the same package. Why cant I access the myString vairable from Test2 like I try and do below?
    package test;
    class Test1 {
         public static String myString = "Hello world";
    package test;
    class Test2 {
         static void printMe(){
              System.out.println(Test1.myString);
         public static void main(String args[]) {
                   printMe();
    }

    Why when I take the "package test;" line of code away I can compile it normally?This depends on how you call the compiler and how you have set the class search path. Classes that are in a package are expected to be found from some place in the search path under a directory that has the same name as the package. The default class path consists of only the current directory, ".", so you can avoid all problems by compiling and running from the directory above "test" rather than "test" itself.

  • Signing 2 different classes in the same package differently.

    I have a class B in the default package.
    I have another class C which is kept in a jar file without any package information. I have signed this jar file in using one alias in my keystore.
    class B instantiates class C and passes its own reference to it.
    When I run class B, i get an error saying,
    Exception in thread "main" java.lang.SecurityException: class "C"'s signer information does not match signer information of other classes in the same package
    at java.lang.ClassLoader.checkCerts(ClassLoader.java:599)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:532)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
    at B.main(B.java:23)
    Does this mean, I cannot have 2 classes in the same package, signed differently?
    Thanks
    AahRiMaaN

    coupdegrace wrote:
    JoachimSauer wrote:
    Force1 wrote:
    Do the files get automatically compiled if they are in the same package ?No, but if the class you compile depends on another that's not yet been compiled (or for which the source is newer than the .class file), then it will be compiled as well.Like,say If i add a int parameter, amethod(int i),then I will get a error,isn't it ?It actually gives a error.
    Also it will compile automatically only for the first time and any changes made to any file will have to be compiled into latest .class files ?Yes.
    Did compile the files under the above constraints.
    So it is a smooth "run" for the first time,but not after editions to the either files.
    I would appreciate if experts give some feedback on this.
    Thank you.

  • Inheritance class in the system package

    Hi all, when I use a tool such as Java Decompiler to explore the classses in the system package(javax.microedition.lcdui provided with Nokia SDK_v1_1), I see that there are many non-documented methods in the class, e.g, getkeyPressedEvent() in the class TextBox. So I try to override these methods in the sub-classes that are declared in the same package. Compiling by J2SDK 1.4.1_03 is OK but running on the Nokia simulator 6310i, I take the error msg: "Cannot create class in the system package".
    What is wrong here? Does it means we can not modify the code of the super class in the system package?
    Please help me

    What is wrong here? Does it means we can not modify
    the code of the super class in the system package?Exactly.
    It would violate the license.

  • How to compile package which contain class outside the package

    I am writing a JDBC driver.
    I have the following package structure in the folder:
    MyDriver
        |_manager.jar
        |_com
               |_ jdbc
                       |_ HXDriver
                       |_ HXConnection
                       |_ HXResultSet
                       |_ HXStatementIn manager.jar, there is a remote object Interaface(Manager.java) which I need to use inside HXConnection.
    My question is how to compile(or/and how to set the classpath)so that I can compile the 4 classes inside jdbc package.
    I tried this:
    C:\MyDriver>javac -cp .;manager.jar com/hx/jdbc/*.java
    However, this does not work, compiler says it cannot find Manager
    Please help me.
    Cheers

    D:\380 Project\Driver>javac -cp .;manager.jar com\hx\jdbc\*.java
    com\hx\jdbc\HXConnection.java:21: cannot find symbol
    symbol  : class Manager
    location: class com.hx.jdbc.HXConnection
            private Manager manager;
                    ^
    com\hx\jdbc\HXStatement.java:18: cannot find symbol
    symbol  : class Manager
    location: class com.hx.jdbc.HXStatement
            private Manager manager;
                    ^
    com\hx\jdbc\HXStatement.java:20: cannot find symbol
    symbol  : class Manager
    location: class com.hx.jdbc.HXStatement
            public HXStatement(Manager manager){
                               ^
    com\hx\jdbc\HXConnection.java:41: cannot find symbol
    symbol  : class Manager
    location: class com.hx.jdbc.HXConnection
                            manager = (Manager)reg.lookup("manager");
                                       ^

  • How To Access a jar file present outside the war file through a jnlp

    Aoa
    I m new to this forum
    I m having problem with my jnlp file
    i want to know is there any way to access a jar file through jnlp.The problem is that my jnlp file is present in the war file
    and i want to know how to acess a jar file through this jnlp.The scenerio is as below
    I m using ear file on jboss.Its hirerchy is as
    -PAN-war.war
    -launch.jnlp
    -PAN-app-client.jar
    my jnlp file is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://localhost:8080/" href="PAN/launch.jnlp">
    <information>
    <title>PanEmirates</title>
    <vendor>M Fazal Ur Rehman</vendor>
    <description>PanEmirates</description>
    <description kind="short">PanEmirates</description>
    <homepage href=""/>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.5+"/>
    <jar href="PAN-app-client.jar" download="eager"/>
    <jar href="lib/javafxrt.jar" main="true" download="eager" />
    <jar href="lib/Filters.jar" download="eager"/>
    <jar href="lib/javafx-netbeans-fxuserlib.jar" download="eager"/>
    <jar href="lib/swing-layout-1.0.3.jar" download="eager"/>
    </resources>
    <application-desc main-class="net.java.javafx.FXShell">
    <argument>pan.Main</argument>
    </application-desc>
    </jnlp>
    when i run launch.jnlp file it says unable to download resource http://localhost:8080/PAN/PAN-app-client.jar
    how to access this jar file
    Any help or comment would be highly appreciated
    Regards
    M Fazal Ur Rehman

    Excellent question. I don't see any client-jar in your EAR file structure. So I am assuming you are writing a separate client application which will talk to the ejbs deployed as part of this EAR. You need to do the following:
    Write another EAR file with the following structure:
    ear:
    META-INF/application.xml
    util.jar
    client.jar
    client.jar should have a META-INF/MANIFEST.MF and that should contain Class-Path:util.jar and value for Main-Class attribute.
    Now deploy this new ear to your application server and execute it using Application Client Container that comes with your app server.
    If you don't want to write another EAR file, then bundle th client.jar in your original EAR file.
    Points to note are:
    you have to repackage util.jar again inside this ear file.
    For portability reason, you should use Class-Path manifest entry in client.jar. Refer to http://java.sun.com/j2ee/verified/packaging.html and J2EE platform spec section #8.2.
    Hope this helps,
    Sahoo

  • How to access a Matrix cell value outside the matrix in textbox?

    Hi
    I have created a matrix in SSRS. Columns are grouped by Channel Type. I want to access indicated cells value outside the matrix. 
    After Running the report the report shows
    How can I access cell values outside the matrix? Please help

    Hi Aladin92,
    According to your description, there is a matrix in the report, you want to reference the first value of total outside the matrix, right?
    In fact, Report item expressions can only refer to other report items within the same grouping scope or a containing grouping scope. Are the both textboxes in the same group. To workaround the issue, please refer to the following steps:
      1. Click and select the matrix, copy it and paste it in the report above the original matrix.
      2. Right-click handle of the first row in the upper matrix, click Insert Rows, then click Inside Group-Above.
      3. Right-click second cell of the first row, then click Expression.
      4. In the Expression text box, type the expression like below:
    ="A total of "& ReportItems!Textbox5.Value & "out of 258 BC CCRs have been evaluated"
      5. Set the text boxes and rows visibility to be hidden except for the text box with expression.
    The following screenshots are for your reference:
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    Wendy Fu
    TechNet Community Support

Maybe you are looking for

  • ALV report in Background Job

    Hi, We have an report in which we are using FM :- REUSE_ALV_LIST_DISPLAY. In forgroud the Report Header is getting displayed only Once. When we run the report in background, we are getting in spool in which there are "Page Break and Header" in every

  • Acsm files will not open in Adobe Digital Editions on iMac 10.7.2. I can still open them successfully on my Dell PC.

    Mid November I purchased an iMac Lion and downloaded Adobe Digital editions for Macs. The download went smoothly but I cannot get the ebooks from my library to open in Adobe Digital Editions. I still have my Dell PC and can (and unfortunately still h

  • Solution for File Vault Error.

    I just got off the phone from Apple Tech support (Holding for 20 minutes on a 10th attempt) I could not get past the log-in screen. "File Vault error needs to be repaired". This is what Brandon from Apple told me to do. 1)Restart Computer holding dow

  • How do I resolve "Installation failed to Initialize" message?

    I've used Adobe products for over 20 years. Now I'm truly stuck, and live chat hasn't been helpful at all (no responses to my questions, just instructions ignoring what I'm saying, which is basically that I tried all the suggestions/instructions alre

  • Issue with screenexit: SAPLXPRM:100

    Hi, I have activated the screen exit SAPLXPRM:100 and some function module exits for IP01 transaction.In the screen exit ,I have called the sub screen SAPLCV140 : 0204. In the transaction total 4 tabs are there, 4th one is the screen exit. My problem