Lint Tool to detect unused public methods?
I'm looking for a java lint tool that will point out <b>public</b> methods that
are unused within my codebase. All of the tools I've reviewed to date
have only detected unused private methods. Does such a tool exist?
If so, can you point me in the right direction?
I don't think such a tool can exist, because the tool wouldn't know whether your writing an API or an end user application.
Also, in any program you might end up with public methods that do nothing, but need to be there to complete an interface implementation.
Presumably, the goal with finding the unused public methods is to remove them and to improve performance somehow. I don't think this is a worthwhile exercise as the compiler does a pretty good job of this optimisation already.
Similar Messages
-
Identifying Unused public Methods in an Application
Is there any other open source that identifes the unused public methods? I have come across many open source that identifies and removes the unused public methods. But, I need only to identify and report it. If anyone knew about any of the open source package that does it, please let me know.
Hi Epesh,
I have found an Open Source Package named PMD from SourceForge that identifies the Unused Private methods,Unused Formal parameters and Reports them.
So if u know any Open Source Package which identifies the Unused Public Methods and reports them,please let me Know.
thanks & regards
Arun -
I have evaluated the following products.
Quest (Dell) MessageStats
Enow
StealthAudit
StealthAudit looked to be the best as they also group like mailboxes with like permissions for Office 365 migrations, but this was by far the most expensive.
We are looking to clean up our environment to eventually migrate to Office 365. Any advice on a product that would report on unused Mailboxes, unused Distribution Groups, and unused Public Folders that would be great.
dHi,
In your case, you can use the following cmdlet to determine unused mailboxes. If a mailbox has never logged on, the Lastlogontime is empty.
Get-Mailbox|Get-MailboxStatistics |fl DisplayName,Lastlogontime
Use the cmdlet below to get publicfolder's last access time.
Get-PublicFolderStatistics |fl name,LastAccessTime
Get all distribution lists used over last 30 days.
Get-MessageTrackingLog -EventId Expand -ResultSize Unlimited |Sort-Object RelatedRecipientAddress | Group-Object RelatedRecipientAddress |Sort-Object Name | Select-Object @{label=”PrimarySmtpAddress”;expression={$_.Name}}, Count
Hope this can be helpful to you.
Best regards,
Amy Wang
TechNet Community Support -
Error when calling a Webservice's public method in Forms10g
Hi,
I'm getting the following error when calling a webservice's public method, i'm using Forms10g 10.1.2.3
java.rmi.RemoteException; nested exception is: HTTP transport error javax.xml.soap.SOAPException
java.security.PrivilegedActionException javax.xml.soap.SOAPException
Message send failed javax.net.ssl.SSLException SSL handshake failed X509CertChI have added the Jar containing the client proxy in both Classpaths(system variable and default.env), the jar has been made with jdk 1.4
I also have tested the client proxy from jDeveloper and it's working there, but in Forms i'm getting this error.
I guess my problem might be that i'm calling a webservice that is secured since the url starts with https
what should i do to fix this ??
Regards
CarlosI understand, so i have a doubt, why the webservice works on jDeveloper ??Not just JDeveloper even soapUI and Neatbeans have a way of working without a client certificate installed.
I do not know how they achieve it. I know that they work without a client DC.
Cheers,
PS: See this http://stackoverflow.com/questions/8887434/webservices-ssl-https, it offers a clue.
The java programs run unhindered when one-way authentication is being used. These products ship with a digital certificate that is in the path of most popular CAs.
Corollary, if the Web Server is configured for mutual authentication then you need to install and configure the client certificate in the tools.
Edited by: Prabodh on Dec 5, 2012 8:36 PM -
JDeveloper 11g not detecting unused variables
I just switched to JDeveloper 11g. It appears not to be detecting unused variables in Java code. The 10g version would detect these. I verified that the unused syntax color was set up to be obvious (bright red in my case). Example:
public int getXXX ()
int abc = 2;
return XXX;
10g would highlight abc as unused, 11g is not.
I am using JDeveloper 11.1.1.0.1
I am using Java 1.6.0_11 for both running JDeveloper and for compiling my code.
Any suggestions? Is this a known limitation?Hi,
for a quick test I only had a newer internal build by hand and here the sample code works. So if this was an issue in the current build then it is fixed
Frank -
Error while calling a super class public method in the subclass constructor
Hi ,
I have code like this:
CLASS gacl_applog DEFINITION ABSTRACT.
PUBLIC SECTION.
METHODS:
create_new_a
IMPORTING pf_obj TYPE balobj_d
pf_subobj TYPE balsubobj
pf_extnumber TYPE string
EXPORTING pfx_log_hndl TYPE balloghndl
EXCEPTIONS error
ENDCLASS.
CLASS gacl_applog IMPLEMENTATION.
METHOD create_new_a.
DATA: ls_log TYPE bal_s_log.
Header aufsetzen
MOVE pf_extnumber TO ls_log-extnumber.
ls_log-object = pf_obj.
ls_log-subobject = pf_subobj.
ls_log-aluser = sy-uname.
ls_log-alprog = sy-repid.
ls_log-aldate = sy-datum.
ls_log-altime = sy-uzeit.
ls_log-aldate_del = ls_log-aldate + 1.
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log = ls_log
IMPORTING
e_log_handle = pfx_log_hndl
EXCEPTIONS
OTHERS = 1.
IF ( sy-subrc NE 0 ).
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
RAISING error.
ENDIF.
ENDMETHOD.
CLASS gcl_applog_temp DEFINITION INHERITING FROM gacl_applog.
PUBLIC SECTION.
DATA: log_hndl TYPE balloghndl READ-ONLY
, t_log_hndl TYPE bal_t_logh READ-ONLY
METHODS: constructor
IMPORTING pf_obj TYPE balobj_d
pf_subobj TYPE balsubobj
pf_extnumber TYPE string
EXCEPTIONS error
, msg_add REDEFINITION
, display REDEFINITION
ENDCLASS.
CLASS gcl_applog_temp IMPLEMENTATION.
METHOD constructor.
CALL METHOD create_new_a
EXPORTING pf_obj = pf_obj
pf_subobj = pf_subobj
pf_extnumber = pf_extnumber
IMPORTING pfx_log_hndl = log_hndl.
IF ( sy-subrc NE 0 ).
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
RAISING error.
ENDIF.
ENDMETHOD.
A public method of Super class has been called from the constructor of the sub class. we are getting the syntax error :
' In the constructor method, you can only access instance attributes, instance methods, or "ME" after calling the constructor of the superclass '
Can you please suggest how to change the code with out affecting the functioanlity.
Thank you ,
Lakshmi.Hi,
Call that method by instance of Subclass. OR
SUPER-->method.
Read very useful document
Constructors
Constructors are special methods that cannot be called using CALL METHOD. Instead, they are called automatically by the system to set the starting state of a new object or class. There are two types of constructors - instance constructors and static constructors. Constructors are methods with a predefined name. To use them, you must declare them explicitly in the class.
The instance constructor of a class is the predefined instance method CONSTRUCTOR. You declare it in the public section as follows:
METHODS CONSTRUCTOR
IMPORTING.. [VALUE(]<ii>[)] TYPE type [OPTIONAL]..
EXCEPTIONS.. <ei>.
and implement it in the implementation section like any other method. The system calls the instance constructor once for each instance of the class, directly after the object has been created in the CREATE OBJECT statement. You can pass the input parameters of the instance constructor and handle its exceptions using the EXPORTING and EXCEPTIONS additions in the CREATE OBJECT statement.
The static constructor of a class is the predefined static method CLASS_CONSTRUCTOR. You declare it in the public section as follows:
CLASS-METHODS CLASS_CONSTRUCTOR.
and implement it in the implementation section like any other method. The static constructor has no parameters. The system calls the static constructor once for each class, before the class is accessed for the first time. The static constructor cannot therefore access the components of its own class.
Pls. reward if useful.... -
Error while accessing a public method of applet from javascript.
Hi,
I am getting "Object doesn't support this property or method" error
when accessing a public method of applet from javascript in IE 6 using
document.applets[0].myMethod();
The same is working in IE 7.
Thanks in advance.
Regards,
PhanikanthI don't know why it happens, but this works for me in both versions:
<applet ..... name="MyApplet">
</applet>and in javascript use
document.MyApplet.myMethod() -
Calling Public Method in OOP.
Hello All,
How to call a Public method in one using the object of the other class.
The second class doesn't inherit the first class.
Thanx and Regards,
SampathKumar.Got the solution.
-
Accessing a private variable from a public method of the same class
can anyone please tell me how to access a private variable, declared in a private method from a public method of the same class?
here is the code, i'm trying to get the variable int[][][] grids.
public static int[][] generateS(boolean[][] constraints)
private static int[][][] sudokuGrids()
int[][][] grids; // array of arrays!
grids = new int[][][]
{Are you sure that you want to have everything static here? You're possibly throwing away all the object-oriented goodness that java has to offer.
Anyway, it seems to me that you can't get to that variable because it is buried within a method -- think scoping rules. I think that if you want to get at that variable your program design may be under the weather and may benefit from a significant refactoring in an OOP-manner.
If you need more specific help, then ask away, but give us more information please about what you are trying to accomplish here and how you want to do this. Good luck.
Pete
Edited by: petes1234 on Nov 16, 2007 7:51 PM -
Accessing a public method from javascript in an applet!!!
Hi!!
I'm have an applet (named say applet.class) in an html page that has a public method like this....
public void doShowFrame()
Frame frame = new frame();
frame.setVisible (true);
What I want to do is to call that method with javascript, I've tried to do it like this...
function show(){
applet.doShowFrame();
But when i press the button that launch the java scipt the browser says
'applet' is unidentified...
What's wrong, what can I do??http://www.google.com/search?q=applet+javascript+communication&sourceid=opera&num=0&ie=utf-8&oe=utf-8
how hard was that? seriously. -
Problem with local class, static private attribute and public method
Hello SDN,
Consider the following situation:
1) I have defined a LOCAL class airplane.
2) This class has a private static attribute "type table of ref to" airplane (array of airplanes)
3) A public method should return the private static table attribute
Problems:
a) The table cannot be given as an EXPORTING parameter in the method because TYPE TABLE OF... is not supported and I get syntax errors. I also cannot define a dictionary table type because it is a local class.
b) The table cannot be given as a TABLES parameter in the method because TABLES is not supported in the OO context.
c) The table cannot be given as an EXPORTING parameter in the method defined as LIKE myStaticAttribute because my method is PUBLIC and my attribute is PRIVATE. ABAP syntax requires that all PUBLIC statements are defined before PRIVATE ones, therefore it cannot find the attribute to reference to with LIKE.
I see only 2 solutions:
a) Never ever use local classes and always use global classes so that I might define a dictionary table type of my class which I can then use in my class.
b) Make the attribute public, but this goes against OO principles, and isn't really an option.
Am I missing anything here, or is this simply overlooked so far?Hello Niels
Since your class is local and, thus, only know to the "surrounding" application is does not really make sense to make it public to any other application.
However, if you require to store instances of your local classes in internal tables simply use the most generic reference type possible, i.e. <b>OBJECT</b>.
The following sample report shows how to do that. Furthermore, I believe it also shows that there are <u><b>no </b></u>serious inconsistency in the ABAP language.
*& Report ZUS_SDN_LOCAL_CLASS
REPORT zus_sdn_local_class.
" NOTE: SWF_UTL_OBJECT_TAB is a table type having reference type OBJECT
* CLASS lcl_airplane DEFINITION
CLASS lcl_airplane DEFINITION.
PUBLIC SECTION.
DATA: md_counter(3) TYPE n.
METHODS: constructor,
get_instances
RETURNING
value(rt_instances) TYPE swf_utl_object_tab.
PRIVATE SECTION.
CLASS-DATA: mt_instances TYPE swf_utl_object_tab.
ENDCLASS. "lcl_airplane DEFINITION
* CLASS lcl_airplane IMPLEMENTATION
CLASS lcl_airplane IMPLEMENTATION.
METHOD constructor.
APPEND me TO mt_instances.
DESCRIBE TABLE mt_instances.
md_counter = syst-tfill.
ENDMETHOD. "constructor
METHOD get_instances.
rt_instances = mt_instances.
ENDMETHOD. "get_instance
ENDCLASS. "lcl_airplane IMPLEMENTATION
DATA:
gt_instances TYPE swf_utl_object_tab,
go_object TYPE REF TO object,
go_airplane TYPE REF TO lcl_airplane.
START-OF-SELECTION.
" Create a few airplane instance
DO 5 TIMES.
CREATE OBJECT go_airplane.
ENDDO.
gt_instances = go_airplane->get_instances( ).
CLEAR: go_airplane.
LOOP AT gt_instances INTO go_object.
go_airplane ?= go_object.
WRITE: / 'Airplane =', go_airplane->md_counter.
ENDLOOP.
END-OF-SELECTION.
Regards
Uwe<u></u> -
Including External LVOOP Public Methods in Executable
Hello,
I have an application which on the top level must 'talk' to several different instruments; a LabJack UE9 (USB) , a Newport Motion Controller (USB-Serial), etc. When I wrote the drivers for these instruments in LV, I used the LVOOP functionality and created individual Classes with public methods for each of the different devices I need to communicate with. Sounds logical to me, anyway.
In my top-level application, I call the public methods (and must include local instances of the LVOOP classes) for those independant instrument-specific classes. In the development mode, everything works peachy. However, when I go to build the application executable (build), I get some weird behavior;
Firstly, with the default setting in 'Additional Exclusions' in the Build Properties of 'Remove as much as possible', I get errors when the builder gets to my independent classes. I get the message:
"An error occurred while building the following file:
C:\Documents and Settings\Wes Ramm\My Documents\Projects\RDT\LabJack\Class\Common Methods\Get DO Line State.vi
The VI became broken after disconnecting type definitions. Open the Build Specification and choose a different option on the Additional Exclusions page."
Ok, it seems that the class object is not linking, but I can get around that by selecting the second option in 'Additional Exclusions' ; 'Remove unreferenced project library members'. BUT, when the build is done, I get a couple of subdirectories with vi's named for all the different class methods for each independent that I am calling. There is no front panel or block diagram for the vis, so it looks like they are correctly 'included' in the build, but it seems cumbersome to include these subdirectories.
I even tried to 'add' the independant classes to the project by 'Add Folder', but got the same behavior.
The classes that I made are not a part of the top level VI, and the top Leve VI is not a member of any of the classes, so this I think is the crux of the matter. However, I am instantiating only the public methods, and the problems only pop up when I try to build the executable.
Am I missing something? Is there a more elegant way to do this? Any advise / tutorials / knowledgebase articles you can point me to?
The tree for the directory structure for my build looks like this (for reference)
\\Application Directory\
Executable
\Config
\ Class One.lvclass (first external class that I am calling in my top-level vi)
\ Method 1
\ Method 2
\ Method 3
\ etc
\ Class Two.lvclass
\Method 1
\Method 2
\Method 3
\ etc
Thanks,
Wes Ramm
Wes Ramm, Cyth UK
CLD, CPLIHello Wes Ramm,
It's better late than never! Hence I'm going to address some of the issues that you've brought up.
1) Which version of LabVIEW are you using? LabVIEW 8.5 has fixed a lot of issues that occured between the Application Builder and LV Classes. If you were using LV 8.2, I would suggest changing to LV 8.5 or at least LV 8.2.1
2) Apart from setting "Do not disconnect type definitions or remove unreferenced members" in the Additional Exclusions page, I would suggest also checking the box against "Enable Debugging" on the Advanced Page.
The following forum post has discussed many of the problems that have come up when building an executable which uses LVOOP classes. Hope this helps. -
iphone 4 after install the iOS 6 wi-fi networks are not detecting on public spot but working on home network.What is the reason for this/ any settings?
Is the firmware in the router up to date?
See here for the latest for v2.2: http://homesupport.cisco.com/en-us/support/routers/WRT54G
Note: All these ideas are a bit lame since you say that some iPhone 5s are connecting OK and they running the same iOS level 6.1 and, i think, have the same Broadcom WiFi chip BCM4334.
All devices are running iOS 6.1 right not 6.0.1, or 6.0.2?
You might want to try your iPad mini on some other WiFi networks to see how it fares there. -
Why only public methods in interfaces?
Howdy all,
I'm wondering if someone can shed some light on why Java doesn't allow interfaces to declare non-public methods.
Ideally, I'd like to do something like this:
public Interface Foo {
protected void setFooProperty(int);
public int getFooProperty();
public Interface Goo {
protected void makeGooey(boolean);
public boolean isGooey();
public class A implements Foo
public class B implements Goo
public class C implements Foo, GooI don't see any technical reason why interfaces must be restricted to declaring public methods only, but it seems too arbitrary to have been done without reason. Any ideas?I don't think that is a good idea to put non-public methods in public interfaces. But I beleive that's a good idea to have protected (or friendly) interfaces to be used only in package scope. It could help a lot some projets defining a second level of data exposure of an object so that developers of that package could have more information that others users from outside the package have that are interesting to develop better algorithm that work with that data. In this way, we can defien thre levels of that access: The lower is the package user, that can see the minimum that's possible, above him we have the package developer that don't work directly with the data, but needs some deep access to it to do cool stuff, and finally we have the guy that is doing the object that deals directly with the data (and encapsulate it).
In this way we can decouple a little the data from the algorithms that work on it, put between them an interface that standarize the access to the data in an intermediate level.
Hope you are able to understand what I wrote (my english isn't so good!).
RGB -
Limiting access to public methods
Hi!
I'm just curious if there's a way to do this.
You see, I have a package that is supposed to read an xml file, and through public methods give out data from that file.
Now, in order to do this, I implement a SAXHandler. But the SAXHandler needs to have public methods like startElement, etc.
Now let's say I'm one of those anally retentive information-hiding people. I really wouldn't want those public methods to be available to ust anyone who uses my class. And I can't make them protected, because the interface says they can't be, and anyway - there's no simple way to put the SAXParser in my package
While this example is specific, the problem seems a general one.
What do you do when: an interface calls for public methods, but you don't want just anyone to get to those public methods. (the only one you want to allow is the one that made you implement the interface in the first place).
Any hints? Thanks!
/Zthanks for the hint's everyone! Your thoughts were along the lines of my own. Hiding the implementing class inside another class is probably my best bet.
I doubt I'll do it though - I guess I'm just not that anal... yet...;-)
I guess what I was thinking was that maybe there was some way around the necessity of wrapping the implementor, because that just seems ugly in a lot of cases and Java been so good at getting rid of ugly since Tiger IMHO.
Maybe you are looking for
-
HP 1012 printer with Windows 7 64-bit
Looking for HP 1012 printer driver for Windows 7? You, like me, tried to install the HP 1012 printer onto a computer that ran Windows 7, but to no avail. You need to go to Start --> Devices and Printers --> Add a printer --> Add a local printer -->
-
I can no longer enter "new events"
I can no longer enter "new events" in my iCal on my Mac (O/S 10.6.7) . I can only enter a new event on my iPhone Calendar and then sync to my iCal on my home computer, which is a Mac Pro. It used to work fine.
-
I received the following error message when I tried to open a CS3 Indesign document that I had worked on last week. The document has some images in it and uses a lot of different script types. i cannot add data "unknown document" I am working on an I
-
Hi, I am trying to execute Runtime.getRuntime().exec() command on click of a button. It works fine, but the problem is that i get a command window when the command is executed. Is there any way to make the command window not to appear?
-
Change existing stock items from Non-Batch to Batch Management Method
Hi, Any prerequisites before changing the existing stock items from Non-Batch to Batch Management method which have On hand stock qty? Please advise. Thanks & Regards, Priscilla