Obtaining parameter names through Reflection
I'm writing a code generator that creates wsdl files and javascript proxies of java objects through reflection. I've heard that if the java class is compiled in debug mode, there is a way to obtain the parameter names to methods, but I can't figure out how to get them. I don't see anything in the reflection API that would allow that. Is there some other API I need to use to get those values? WSDL files that list parameters as "arg0, arg1, arg2" are not real helpful to users.
Let us take this source:
public class a {
public void doit(int argc,String argv[] ) { }
}Let us compile it with the -g option. Then let's do strings a.class:
(I[Ljava/lang/String;)V
<init>
Code
LineNumberTable
LocalVariableTable
SourceFile
[Ljava/lang/String;
a.java
argc
argv
doit
java/lang/Object
thisSo the argument names really appear to be in the class file, but not forcibly available through reflection, but maybe through examining the LineNumberTable and LocalVariableTable parts of the class file.
Similar Messages
-
Obtaining Parameter Values through ReportDocument object
Post Author: realityenigma
CA Forum: .NET
Hello everyone. I am using Microsoft Visual Studio 2008 and C#. I am attempting to obtain the Parameter Values after they have been set via a CrystalReportViewer through the ReportDocument object. The reason is that I am writing a scheduler that allows users of our web application to schedule reports for X runs or X datetime span. At this point the application adds to an XML file that describes the newly scheduled report's information, etc. At this point, when the time critera etc. are met, a service reads the XML file and then runs the report with current data. The issue is I cannot seem to get the ParameterValues values, and serializing the document using a BinaryFormatter yields and error on the service side stating the that I need to load the report from a RAS. Am I going about this the wrong way? Can I get to the ParameterValues without the RAS serialization situation, or is that just it? All responses are appreciated.
Thanks,
Michael DavidsonLet us take this source:
public class a {
public void doit(int argc,String argv[] ) { }
}Let us compile it with the -g option. Then let's do strings a.class:
(I[Ljava/lang/String;)V
<init>
Code
LineNumberTable
LocalVariableTable
SourceFile
[Ljava/lang/String;
a.java
argc
argv
doit
java/lang/Object
thisSo the argument names really appear to be in the class file, but not forcibly available through reflection, but maybe through examining the LineNumberTable and LocalVariableTable parts of the class file. -
Ref Cursor - how to access through parameter name
Hi,
I'm using the below table and sample data. The below script named 'Script1' works well, my concern is values for the first and second parameters need to be used for the thrid and fourth one as well.
When I try with 'Script2' it gives "ORA-01008: not all variables bound ORA-06512: at line 17" error. I know Paramterized cursor can handle this effecively, since it is a dynamic SQL, I need to use from a parameter table, I don't have any control over the number of parameteters, parameter name, type and other things. So, I cannot go for parameterized cursor.
As of now, for my requirement, Script1 works fine, is there any way to make Script2 to work as well, I need to pass paramters by name, not by position, please give your suggestions, thank you.
CREATE TABLE T1
F1 NUMBER(5),
F2 VARCHAR2(100),
F3 DATE
Insert into T1
(F1, F2, F3)
Values
(1, 'One', TO_DATE('08/02/2012 07:43:34', 'MM/DD/YYYY HH24:MI:SS'));
Insert into T1
(F1, F2, F3)
Values
(2, 'Two', TO_DATE('08/02/2012 08:15:24', 'MM/DD/YYYY HH24:MI:SS'));
Insert into T1
(F1, F2, F3)
Values
(3, 'Three', TO_DATE('08/02/2012 08:16:34', 'MM/DD/YYYY HH24:MI:SS'));
COMMIT;
Script1:
declare
TYPE t_ref_cursor IS REF CURSOR;
v_cursor t_ref_cursor;
v_query_str varchar2(3000);
v_f1 number(5);
v_f2 varchar2(100);
v_f3 date;
begin
v_query_str := 'SELECT f1, f2, f3 from t1 where f1 = :p1 and f3 = to_date(:p2, ''DD-MON-YYYY hh24:mi:ss'') union ';
v_query_str := v_query_str || 'select 1, ''c1'', sysdate from dual where not exists (select 1 from t1 where f1 = :p3 and f3 = to_date(:p4, ''DD-MON-YYYY hh24:mi:ss''))';
--dbms_output.put_line(v_query_str);
open v_cursor for v_query_str using 1, '02-AUG-2012 07:43:34', 1, '02-AUG-2012 07:43:34';
loop
fetch v_cursor into v_f1, v_f2, v_f3;
exit when v_cursor%notfound;
dbms_output.put_line(v_f1 || ' ' || v_f2 || '' || v_f3);
end loop;
dbms_output.put_line('rowcount ' || v_cursor%rowcount);
close v_cursor;
end;
Script2:
declare
TYPE t_ref_cursor IS REF CURSOR;
v_cursor t_ref_cursor;
v_query_str varchar2(3000);
v_f1 number(5);
v_f2 varchar2(100);
v_f3 date;
begin
v_query_str := 'SELECT f1, f2, f3 from t1 where f1 = :p1 and f3 = to_date(:p2, ''DD-MON-YYYY hh24:mi:ss'') union ';
v_query_str := v_query_str || 'select 1, ''c1'', sysdate from dual where not exists (select 1 from t1 where f1 = :p1 and f3 = to_date(:p2, ''DD-MON-YYYY hh24:mi:ss''))';
--dbms_output.put_line(v_query_str);
open v_cursor for v_query_str using 1, '02-AUG-2012 07:43:34';
loop
fetch v_cursor into v_f1, v_f2, v_f3;
exit when v_cursor%notfound;
dbms_output.put_line(v_f1 || ' ' || v_f2 || '' || v_f3);
end loop;
dbms_output.put_line('rowcount ' || v_cursor%rowcount);
close v_cursor;
end;
/This link shall answer your Question. PL/SQL Dynamic SQL.
If it had been an Anonymous Block, your code would work through.
Please see demonstration below:
create or replace procedure emp_data (dep_id number, sal number, emp_id number)
is
l_cnt number;
begin
select count(*)
into l_cnt
from hr.employees
where department_id = dep_id
and salary >= sal
and employee_id > emp_id;
dbms_output.put_line('Count :: ' || l_cnt);
end;
declare
l_cnt number;
begin
execute immediate 'begin emp_data(:1, :2, :2); end;' using 20, 100;
end;
anonymous block completed
Count :: 2
--Trying the Similar example as in your OP.
--Execute the same Select statement as in emp_Data with Bind Variables;
declare
l_cnt number;
begin
--execute immediate 'begin emp_data(:1, :2, :2); end;' using 20, 100;
execute immediate 'select count(*)
from hr.employees
where department_id = :1
and salary >= :2
and employee_id > :2' into l_cnt using 20, 100;
dbms_output.put_line('Count :: ' || l_cnt);
end;
Results in error :- ORA-01008: not all variables bound -
Getting method parameter names
Hello everyone,
I need to get parameter names of class methods. I checked the API for java.lang.reflect.Method, I found that it gives the types but not the names.
The following should print parameter names but it displays nulls for parameter descriptors. Any idea why ?
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.IntrospectionException;
import java.beans.MethodDescriptor;
public class pd
public static void main( String[] args ) throws IntrospectionException
BeanInfo info = Introspector.getBeanInfo( javax.swing.JLabel.class,javax.swing.JComponent.class );
System.out.println("MethodDescriptors:");
for ( MethodDescriptor md : info.getMethodDescriptors() )
System.out.println( md.getName() );
System.out.println("ParameterDescriptors:"+md.getParameterDescriptors());
}Knowing the "true name" of the parameter gives one power over it?
I suppose one could want to create dynamically generated documentation on arbitrary compiled code, or create some user interface to analyze objects/classes at runtime and call methods directly on them through some generically generated input fields. Perhaps as some sort of learning tool.
In that case, it would be useful to know the parameter names when there's multiple, particularly of the same type. The names ideally would indicate their use... although you can't always assume that.
Not that I can offer much help if the reflection classes don't provide for it already. -
J2SE - Get Method Parameter Names
Hello Gurus,
I am trying to make a method in Java showing current running method's parameter name, the result will be some kind like below (showed in arrows):
FUNCTION1()::BEGIN
-TIME: 12-Jun-2013 05:39
FUNCTION1()::PARAMETERS
-PARAM01: val01 <!-------
-PARAM02: val02 <!-------
-PARAM03: val03 <!-------
FUNCTION1()::ERROR
-PATH: FUNCTION1()«FUNCTION2()«MAIN()
-MSG : '/ by zero'
FUNCTION1()::END
So I want to retrieve the parameter names and values automatically and dynamically using the function. So far, after googling, information that I get is by using spring framework:
private ParameterNameDiscoverer parameterNameDiscoverer;
Method m = ... <!------ what should I put here?
String[] names = parameterNameDiscoverer.getParameterNames(m).
In my idea, when we call a function, e.g: public String function1(String str, int i) {} and we put the code inside, we will get the function's parameter names which are "str" and "i", also with their current values.
Any help?Knowing the "true name" of the parameter gives one power over it?
I suppose one could want to create dynamically generated documentation on arbitrary compiled code, or create some user interface to analyze objects/classes at runtime and call methods directly on them through some generically generated input fields. Perhaps as some sort of learning tool.
In that case, it would be useful to know the parameter names when there's multiple, particularly of the same type. The names ideally would indicate their use... although you can't always assume that.
Not that I can offer much help if the reflection classes don't provide for it already. -
How do I obtain column names and types?
I am using Visual Studio C++ to connect and query an Oracle database using SQL commands. My code works, but I don't fully understand it because I'm new to Oracle and it is modified example code.
I need to obtain column names and types for a known table. The "Describe" SQL command fails when I call ->Execute, claiming this is an invalid SQL statement, although the same statement works when sent directly via sqlplus.
I need column names and types, but they don't have to come through Describe.Hi,
Desc isn't really a SQL command. Rather its a command specific to Oracle. Thats why it will work in SQLPlus and not anywhere else. If you want the column information for a table you can user either the user_tab_columns or all_tab_columns, depending on which schema the table is in. The query would look like:
select * from all_tab_columns where table_name = 'BONUS'
Sanjay -
Obtain server name in portal service
Hi all,
I've a portal service which must know the server name (https://xxx.yyy.com). In an AbstractPortalComponent I have no problem to get the name through the IPortalComponentRequest. But how to obtain it in a portal service which doesn't have such an object?
best regards,
Markusthanks, serlank, but that doesn't work in my environment (Tomcat 5.5.12).
The method event.getServletContext().getServletContextName() returns the Name of the web application which i can configure as <display-name> in web.xml. As i have the same web.xml for all my contexts, i can't set different names. -
Pass parameter name as table name
I tried to append a parameter name (area) to the name of the table through a stored procedure. As we're using CIS, the @area reference doesn't work -- instead we use ?. The SP is simple:
declare @sql nvarchar(2000)
set @sql = 'select 1,2,3 from table_'+@area+'where <condition 1>'
execute sp_execute @sql
Executing this SP shows up a long list of errors.
Any help is deeply appreciated.
Post the actual and complete procedure and not just the part you think is relevant.
Post at least some of the complete and actual error messages you have received.
Lastly I will assume that your code has been edited for posting. Assuming you did not add any additional errors during this editing, then perhaps you simply need to add a space between the table name and your where clause. In other words, change
from table_'+@area+'where <condition 1>'
to
from table_'+@area+' where <condition 1>'
And as always, it would help you and your readers to post the actual string that you are attempting to execute. Simple logic errors in assembling your string are difficult to diagnose when you don't actually "see" the executed statement. -
SUBMIT - donot know parameter name
Hi Gurus,
I am calling a report from another report. Inside report_2 i am using,
SUBMIT report_1
AND RETURN.
I am getting one more screen,with one parameter which can be filled dynamically.
I want to hard code this in my code itself just to make sure i get the output.
How do i do that? I am not able to find the name of the paramter that comes up on screen.
How do i pass the value.
I am using:
rspar_line-selname = 'INPUT'. // using input as i donot know the parameter name
rspar_line-kind = 'S'.
rspar_line-sign = 'I'.
rspar_line-option = 'EQ'.
rspar_line-low = 'ABC'. // 'ABC' is say, the hard coded value i want to pass
APPEND rspar_line TO rspar_tab.
Then i do,
SUBMIT report_1
WITH SELECTION-TABLE rspar_tab
AND RETURN.
How do i proceed?
In the function module, i found that the value goes into a feild symbol 'input'
name of parametr i cud not get
Thanks,
RashmiThank you gurus.
I made the changes accordingly.
but, there are 2 stages to get output from my 1st report.
When i execute report1, i enter some values(now i have hard-coded them in program)
then again, i get PRINT DIALOG BOX
Here i need to enter the put device name. and again exceute.
I am not able to automate this in my program. Could you suggest?
Through F1 help, i found the screen_field name to be 'SFPOUTPAR-DEST'
and i enter default output device 'PDEST'
where do i give this?
and also, after this, i need to do a 'Print Preview' and see if file is opening up.
Can i automate these actions?
Thanks a lot. The previous inputs did help me.
Regards,
Rashmi -
In miro what is po field parameter name
I don't know what is the parameter name in po field in miro, my problem is i have to check a business area of corresponding plant, i have been implement a badi 'zmrm_header_check', if i put hard coded po number then its work correctly , i have to put a po number dynamically to pick up plant number..
So please solve my problem.Hi,
As of my understanding, you are trying to get the PO Number from the MIRO into BADI. If so, you can get it through Parameter ID like
'GET PARAMETER ID '<ID>' FIELD <variable>.
For PO Number field 'BES'.
In general to know Parameter ID of any screen field, go to technical information from F1 help and know the Data element and Parameter ID will be assigned to that Data element.
If my understanding is wrong, can you please elaborate your query.
Regards,
Vijay -
Get current method through reflection. Is it possible?
Is it possible to get current method name (I mean method, which currently executes) through reflection.
it would seem i am not the one that has a problemas I said, get over it. I have no problem with you whatsoever, I merely pointed out that your solution was a massively heavyweight one that almost certainly wasn't necessary. if you really can't take this sort of opposition, that's your own look out. but don't go trying to start a flame war just because somebody disagreed with you on a couple of points
that's twice today you've posted something that actually wasn't pertinent to the original question, and rather than accept that, you insist on keeping dragging it up, re-defining terms and making passive-aggressive comments such as the one above. grow up
The End -
LRM-00101: unknown parameter name _optimizer_use_feedback
HI team,
I have got issue while starting the database using pfile, as the queries are getting slower in fetching the result, we have decided to add the parameter optimizeruse_feedback=false in the pfile and bring up the database. but the startup is throughing the error.
The below is the error
ORA-01078: failure in processing system parameters
LRM-00101: unknown parameter name optimizeruse_feedback
The following are the optimizer parameters in the pfile.
optimizer_secure_view_merging=FALSE
optimizer_features_enable=10.2.0.4
optimizeruse_feedback=false
the database version is 11.1.0.7.
Please let me know if this is bug. currently we are not able to bring up the databasesvenkata_sudheer wrote:
HI team,
I have got issue while starting the database using pfile, as the queries are getting slower in fetching the result, we have decided to add the parameter optimizeruse_feedback=false in the pfile and bring up the database. but the startup is throughing the error.
The below is the error
ORA-01078: failure in processing system parameters
LRM-00101: unknown parameter name optimizeruse_feedback
The following are the optimizer parameters in the pfile.
optimizer_secure_view_merging=FALSE
optimizer_features_enable=10.2.0.4
optimizeruse_feedback=false
the database version is 11.1.0.7.
Please let me know if this is bug. currently we are not able to bring up the databasesOnly Oracle support can decide if it is a bug.
IIRC, parameters that begin with underscore should only be used under direction from Oracle Support.
Was this change directed by Oracle Support? -
Specify Custom Parameter Names
Hi,
I could successfully publish and test dababase procedures as web services.
But WSDL is generated using "param0" and "param1" for parameter names.
Is there any way I can specify meaningful names for parameters?
When I invoke service, it always expects parameters as "param0", "param1"
I would like to specify "Name" for param0 and "Code" for param1 etc.,
Can any one let me know if it is possible?
Thanks,
NMJava introspection uses reflection and this information wasn't accessible in previous versions of the JVM...
-
I'm using jwsdp-2.0 and jdk1.4
my question is
How can i change method parameter names that generated on WSDL file ?
when I'm trying to use (-g) option with javac command i have the same result.The parameter names aren't included in the bytecode.
Therefor it is impossible to get them.
Not with reflection, not with other tools.
I'm afraid, but you'll have to scan the source. -
I have used reflection to read information about a class, but it does not provide the parameters names of the method arguments. I have read that I need JDI. Does anyone know of a good tutorial or sample code that will read the parameter names of methods and of other public variables in the class file?
ThanksI've seen others for some reason "needing" this kind of "requirement" too. And the answers being that the requirement is ill-conceived, which I agree with.
Maybe you are looking for
-
I need command to change the file name in vi please.
quick question i need command to change the file name in vi please. oldname = initprod12.ora new name = initprod2.ora
-
how do i get the movie sound to play through the TV speakers when watching a movie from Itunes, It is connected to my macbook pro but the sound only comes through my macbook pro. Thanks
-
Can anyone recommend a good book describing/teaching SQL or PL/SQL programming? Assume a new programmer.
-
Linker problem using version 12.4 on Linux
I am trying to use Solaris Studio 12.4 on Linux ( OpenSuse 13.2 ). I have installed the compiler and set up the PATH to its bin directory. When I compile/link a program I am receiving: "sun.link ../../../bin.v2/libs/vmd/test/test_after_array_elem.tes
-
Passing record id during onClick while also submitting the form
I'm displaying data in two different tables. All of the data is static except for a status field which is also the field that determines what table the data is displayed in. Inside of form tags I am using a cfoutput tag to loop through the records fo