Questions tagged [class-visibility]

In certain object-oriented programming languages, such as Java, class visibility determines the level of visibility or of accessibility of a class. For methods' or attributes' visibility, or for a more general tag on access modifiers, you might want to use the tag [access-modifiers].

In certain object-oriented programming languages, such as Java, class visibility determines the level of visibility or of accessibility of a class.

Generally the access modifiers used are: public, private or protected.

A question connected with the visibility of a class in an object-oriented programming language should use this tag.

For methods or attributes visibility, or for a more general tag on access modifiers, you might want to use the tag .

99 questions
1
vote
1 answer

PHP restrict calling of public methods

I'm working on a library that has quite a few classes that are all pulled together by a central class. This central class has to call certain methods on the other classes for set-up/configuration purposes. These methods have to be public so that the…
dawsonc623
  • 1,841
  • 2
  • 16
  • 26
1
vote
3 answers

Different behaviour of Class literal and Class.forName for package local classes

Only for example lets consider the class ClassFileAssembler from the sun.reflect package. This class is a package local class: class ClassFileAssembler implements sun.reflect.ClassFileConstants {... So we can not use even its name…
Andremoniy
  • 34,031
  • 20
  • 135
  • 241
1
vote
2 answers

Disable use of AsyncTask, using custom AsyncTask

I have the following implementation of AsyncTask, allowing multiple AsyncTasks to run concurrently: public abstract class MyAsyncTask extends AsyncTask { public AsyncTask
nhaarman
  • 98,571
  • 55
  • 246
  • 278
0
votes
1 answer

kotlin, how to keep the class constructor internal (but class is visible in outside)

In a android lib, having a public class in java which has default package level constructors public class UserInformationException extends Exception { private static final String ERROR_MESSAGE = "User information wrong!!"; …
lannyf
  • 9,865
  • 12
  • 70
  • 152
0
votes
0 answers

C# extended class doesn't expose methods on different project

I'm scratching my head on a problem that seems easy...I've published a NuGet package on my private server. This contains the SqlDb class: public class SqlDb { public void SetConnectionString(string connectionString) { // CODE …
0
votes
1 answer

Avoid Access to Constructor of nested Class

here a rougth code example to my problem: class FooMaster { private static FooChildBase GetFooChild(int number) { switch(number) { case 1: return new FooChild1(); case 2: …
Max N
  • 61
  • 6
0
votes
1 answer

Hack Rust Visibility and Privacy

I tried to use a struct from an external crate which does not use the pub key. I guess the best fix will be to open a PR but my curiosity get triggered here. In C++ it is pretty easy. We can do: #define private public #include <...> // import public…
tirz
  • 2,041
  • 1
  • 22
  • 37
0
votes
0 answers

How to properly organize interfaces and implementations in Java modular project?

I am looking for a way to properly organize interfaces and implementations in Java 11 modular project. Considering the simplest case: there is an interface and its multiple implementations. The intention is to expose only this interface and its…
diziaq
  • 6,881
  • 16
  • 54
  • 96
0
votes
2 answers

How can I protect a class property from extending classes in PHP?

Is it possible to do something like this: class foo { private $private = 'A'; } class bar extends foo { echo $this->private; } bar returns null... I'd really like it if the variable $private wasn't accessible by the child classes, but I'm…
James Thompson
  • 1,027
  • 6
  • 16
0
votes
1 answer

Laravel, can't acces to object data

I have this output at print_r($mailable): Illuminate\Mail\SendQueuedMailable Object ( [mailable:protected] => App\Mail\Expired Object ( [user:protected] => App\User Object ( …
pmiranda
  • 7,602
  • 14
  • 72
  • 155
0
votes
1 answer

How can I solve LI_LAZY_INIT_UPDATE_STATIC?

I'm trying to initialize a MethodHandle for a non-public method in an upstream library. private static Method OF_METHOD; static Method ofMethod() { if (OF_METHOD == null) { try { OF_METHOD =…
Jin Kwon
  • 20,295
  • 14
  • 115
  • 184
0
votes
1 answer

How to isolate the war classloading in wildfly 10. Getting a visibility issue for org.apache.cxf.enpoint.Client class

I am trying to deploy a war which has a JAX-WS client for SOAP services in Wildfly 10.1.0.Final. When I am trying to get the port for the webservice the delegate interface in javax.xml.ws.Service automatically going to apache cxf implementation of…
0
votes
1 answer

Restrict method visibility when passing instance to user procedure in C#

I am trying to define a class where "I" have access to all public methods but when I pass an instance off to a user-supplied function, they can only access a subset of the public methods. Something along these lines: // usercl.cs class UserClass { …
0
votes
2 answers

Can't access attributes in python

When I run this code, I get an error "AttributeError: 'NoneType' object has no attribute 'test'" class BaseClass: def __new__(self, number): self.test = 1 class InheritedClass(BaseClass): pass instance =…
Kona98
  • 139
  • 2
  • 9
0
votes
2 answers

Effective Java Item 13 and TDD

I just googled "Joshua Bloch TDD"... not much came up, which is a huge shame because I'd really like to know what he's got to say on the matter. Item 13 (I'm looking at the 2nd edition) is entitled "Minimize the accessibility of classes and…
mike rodent
  • 14,126
  • 11
  • 103
  • 157