Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8450699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:02:29+00:00 2026-06-10T11:02:29+00:00

I did a experiment where i extended a java.lang package class and couldn’t access

  • 0

I did a experiment where i extended a java.lang package class and couldn’t access the package methods or field (methods or fields with no public or protected). Ok.

Then i put in my extension in a ‘java.lang’ on my source root and tried again and it compiled. So package access restriction is only cosmetic (you need to put it in the same place as the other classes, and thus the user will find it by importing java.lang) and they actually might as well be public, since there is no actual weaker level of access here? (protected at least assures that it’s a extension overriding).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:02:31+00:00Added an answer on June 10, 2026 at 11:02 am

    The concept of package exists in Java to provide an additional level of granularity in the accessibility of class members. Due to flexibility of the class loading mechanism in Java, their is nothing to restrain you to access package-level members and attributes of a class C when you declare your own classes in the same package as this class C.

    Some specifications enforce more restrictive access policies like OSGI. OSGI comes with the additional concept of bundle, absent from the Java language itself. Bundles are a set of classes packaged in a single jar. They declare in a manifest file which classes and which packages they export, which other bundles can access. Those packages and classes which are not exported are strictly not accessible from other bundles.

    What is more, you cannot access package-level methods and attributes of a class C of a bundle from another bundle, even though class C is exported. An OSGI class loader will not allow you to load a class from a package which is already “owned” by another bundle.

    If you are interested in these questions around accessibility and packaging, have a look at the Jigsaw project, which intends to redesign the modularity in Java and should come in next release of Java SE (Java SE 8, though I am not sure it has not been postponed).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My coworker did this experiment: public class DoubleDemo { public static void main(String[] args)
I just did a little experiment: public abstract class MyClass { private static int
I did an experiment: class A { public: A() {} A(const A& a) {
Basically I did the Cavendish experiment, and I have a damped sinusoidal wave plotted
As an experiment, I did this: letters=['a','b','c','d','e','f','g','h','i','j','k','l'] for i in letters: letters.remove(i) print letters
i did this code : from scitools.std import * npoints=10 vectorpoint=array(random.uniform(-1,1,[1,2])) experiment=array(random.uniform(-1,1,[npoints,2])) print(vectorpoint=,vectorpoint) print(experiment=,experiment)
I did an experiment today to see what I can do with <div> s.
I did some experiment with node earlier The following code outputs aaa to console,
I have a class like this: //Array of Structures class Unit { public: float
I'm just learn about memory dynamic, and did experiment, but still get stuck. already

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.