Extended CAP Accessibility Example
To understand the extended CAP file accessibility, let’s consider a scenario as shown in the following figure:
Figure 8-1 Extended CAP Accessibiliy Example
The following table describes the package level access under different access conditions (1, 2, and 3):
Table 8-1 Package Level Access
Accessibility | package1 | package2 | package3 | package4 | package5 |
---|---|---|---|---|---|
|
N/A |
Yes (1) and (2) |
Yes (1) |
Yes (1) |
Yes (1), (2), and (3) |
|
Yes (1) and (2) |
N/A |
Yes (1) |
Yes (1) |
Yes (1), (2), and (3) |
|
Yes (1) and (2) |
Yes (1) and (2) |
N/A |
Yes (1) |
Yes (1), (2), and (3) |
|
Yes (1) and (2) |
Yes (1) and (2) |
Yes (1) |
N/A |
Yes (1), (2), and (3) |
|
Yes (1) and (2) |
No (1) |
No (1) and (3) |
Yes (1) and (3) |
N/A |
The following are the access conditions (1, 2, and 3) that are listed in the table:
- Exported packages in an extended CAP file - Packages in an extended CAP file can be marked as
public
orprivate
. Only thepublic
packages are accessible from packages in another CAP file. However, all packages are accessible within the same CAP file. -
Java access rules - Code access conforms to Java accessibility rules
(
private
,public
,package
,protected
, and so on). For example, inside theClass1
orClass2
methods, aClass3()
or aClass4()
constructor can be called (only if the constructors arepublic
) or other public methods fromClass3
andClass4
, even ifClass3
andClass4
are Java Card applets. - Java Card access rules for package containing an Applet - A public package containing a class extending the
javacard.framework.Applet
class does not export all itspublic
classes and interfaces. Only the interfaces extending thejavacard.framework.Shareable
interface or the classes implementing it are exported and visible from other packages. For example, code frompackage5
can access only theClass5
inpackage4
and cannot access content ofpackage3
because nothing is exported.