java


Dynamic binding can show protected methods?


parent class
package PPRO.Custom.Integration;
public class eInvoice_BSSFormat {
protected void run(String[] param){
}
}
other class
package PPRO.Custom.Integration;
public class eInvoice_Archon extends eInvoice_BSSFormat{
}
another one class
package com.birchstreet.smwc.scheduler.jobs;
public class eInvoice_Archon extends PPRO.Custom.Integration.eInvoice_Archon implements Job {
#Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
PPRO.Custom.Integration.eInvoice_Archon arc = new eInvoice_Archon();
arc.run(args);
}
eclipse show the problem is
The method run(String[]) from the type eInvoice_BSSFormat is not
visible
we can not changes the existing file only work in new file and we can not use this class object use
when we use like this problem solved
eInvoice_Archon arc = new eInvoice_Archon();
but we can not use like this only parent reference variable
how to solve this problem
From JLS 6.6.2. Details on protected Access
A protected member or constructor of an object may be accessed from outside the package in which it is declared only by code that is responsible for the implementation of that object.
Your protected void run(String[] param) method is protected so you can only access it within same package or from any class which implements you eInvoice_BSSFormat.
Use following:
package com.birchstreet.smwc.scheduler.jobs;
public class eInvoice_Archon extends PPRO.Custom.Integration.eInvoice_Archon implements Job {
#Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
//PPRO.Custom.Integration.eInvoice_Archon arc = new eInvoice_Archon();
this.run(args);
}
}
run() method is protected so you can only use it in a subclass in a different package
package A;
class Parent{
protected int x = 45;
}
package B;
import A.*;
class Child extends Parent{
public void access(){
x= 100; // works
}
public void method(){
Parent p =new Parent();
p.x = 150; // error
}
}

Related Links

Java String.split() sometimes giving blank strings
RSA keys transformation for Java - clarification needed?
Android: Why can't I create a handler in new thread
Errors running builder 'Java Builder' Negative time
FileInputStream converting some values to question mark
Do I need to close the connection after doing #isClosed method?
ClassCastException after executing Stored procedure in java
How to replace all 'x' on a string in Java to a number [duplicate]
IntelliJ NoClassDefFoundError for jar Dependencies in other Modules
Java regular expressions for Zip, telephone, email and date
Selenium (java) can't get text from nested element without printing it
Capitalize First letter [closed]
Converting json object to two arrays using java
Atomic get and increment functionality on a value in a file on a networked file system, in java
Creating weighted matrix with lettered edges
Firefox, websockets and odd behaviours

Categories

HOME
webpack
cookies
path-finding
view
iot
syntax
webstorm
leon
malloc
amazon-ecs
webpack-2
google-project-tango
ckeditor
alpha
yum
mouse
azure-storage-tables
spring-kafka
modelica
moonmail
orchardcms
caml
graphlab
ef-migrations
undefined
oracle-coherence
interop
samoa
nodatime
custom-wordpress-pages
autocad-plugin
wkwebview
microsoft-r
trading
xpages-ssjs
javacv
tdd
qhull
opentype
atlassian-crucible
libssl
tinymce-4
data-manipulation
repo
simplexml
jquery-bootgrid
neuroscience
serverside-rendering
nomethoderror
websphere-mq-fte
menuitem
fault
outlook-2013
smartcontracts
zip4j
prolog-setof
paxos
jlink
carrot
csound
tactic
diagnostics
azure-sdk
player
jwplayer7
connect-by
disque
yaws
ptrace
historian
hsv
tcpserver
t4mvc
jmeter-maven-plugin
ruby-2.2
fouc
purge
angular-leaflet-directive
appfabric-cache
mono-embedding
oberon
dundas
nsmutabledictionary
nstableviewcell
codeigniter-routing
rdl
jubula
mysql-error-1062
xceed-datagrid
rtmfp
cloud-connect
aqtime
dir
ruby-datamapper
jquery-mobile-dialog
seed
limejs
cassini-dev
factory-method
free-variable
distutils
anonymous-methods
typoscript2
dmoz
sublist
bitsharp
gil
quickdialog
dsn
django-tagging
w3wp.exe
gamequery
mozilla-prism
firefox-5
swing-app-framework
.net-1.0
paul-graham

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App