Redian新闻
>
invoke a function dynamically in Java?
avatar
invoke a function dynamically in Java?# Java - 爪哇娇娃
w*s
1
转载。据说这篇是向骑桶人致敬。我很喜欢骑桶人。程婧波有一个网名叫冰狗,俺们就叫
她狗狗了。这篇我还没看……
avatar
o*l
2
Is there a way that we could invoke a function dynamically?
For example, at some point of the program, I need to call a function, but
the function name, input parameters need to be dynamic, which will be define
in a config file, loaded when the program start. The function always
return a integer.
the config file like this:




avatar
wh
3
贼长。我回头看。
想起来问你:你以前推荐的方方的小说是哪篇?你贴过链接的。

就叫
陷落
写作
所长

【在 w***s 的大作中提到】
: 转载。据说这篇是向骑桶人致敬。我很喜欢骑桶人。程婧波有一个网名叫冰狗,俺们就叫
: 她狗狗了。这篇我还没看……

avatar
g*g
4
You can either build on top of reflection APi to do this,
or spring api has something similar.

define

【在 o*****l 的大作中提到】
: Is there a way that we could invoke a function dynamically?
: For example, at some point of the program, I need to call a function, but
: the function name, input parameters need to be dynamic, which will be define
: in a config file, loaded when the program start. The function always
: return a integer.
: the config file like this:
:
:
:
:

avatar
M*N
5
写得很好啊,很喜欢。
谢谢分享。

就叫
陷落
写作
所长

【在 w***s 的大作中提到】
: 转载。据说这篇是向骑桶人致敬。我很喜欢骑桶人。程婧波有一个网名叫冰狗,俺们就叫
: 她狗狗了。这篇我还没看……

avatar
k*r
6
Or you can use a fixed function name but dynamic class name.
I think it's easier this way.

but
define

【在 o*****l 的大作中提到】
: Is there a way that we could invoke a function dynamically?
: For example, at some point of the program, I need to call a function, but
: the function name, input parameters need to be dynamic, which will be define
: in a config file, loaded when the program start. The function always
: return a integer.
: the config file like this:
:
:
:
:

avatar
l*i
7
太长了 我还没来得及读

【在 M****N 的大作中提到】
: 写得很好啊,很喜欢。
: 谢谢分享。
:
: 就叫
: 陷落
: 写作
: 所长

avatar
g*y
8
少写reflective的code, 多活20年。写的时候看上去很neat, 但是debug reflective的
code真的是nightmare, 哪怕是你自己写的。
感觉reflective就象花credit card, 用的时候很爽,还钱的时候很痛!
avatar
w*s
9
好像是叫 有爱无爱都铭心刻骨?

【在 wh 的大作中提到】
: 贼长。我回头看。
: 想起来问你:你以前推荐的方方的小说是哪篇?你贴过链接的。
:
: 就叫
: 陷落
: 写作
: 所长

avatar
T*g
10
if your methods are encapculated in specific class, java reflection will
meet your requirement.

define

【在 o*****l 的大作中提到】
: Is there a way that we could invoke a function dynamically?
: For example, at some point of the program, I need to call a function, but
: the function name, input parameters need to be dynamic, which will be define
: in a config file, loaded when the program start. The function always
: return a integer.
: the config file like this:
:
:
:
:

avatar
wh
11
多谢!你还能找到链接吗?我google前几个都不是。

【在 w***s 的大作中提到】
: 好像是叫 有爱无爱都铭心刻骨?
avatar
b*y
12
哈哈
写的时候是"i can handle every case"
debug的时候是"I can't even handle myself"

【在 g**********y 的大作中提到】
: 少写reflective的code, 多活20年。写的时候看上去很neat, 但是debug reflective的
: code真的是nightmare, 哪怕是你自己写的。
: 感觉reflective就象花credit card, 用的时候很爽,还钱的时候很痛!

avatar
A*o
14
我是先debug过别人的reflection代码,于是从此敬而远之。

【在 b******y 的大作中提到】
: 哈哈
: 写的时候是"i can handle every case"
: debug的时候是"I can't even handle myself"

avatar
r*l
16
这个比喻有点意思。
不过reflection没有那么可怕了。话说回来,如果reflection能
被其它东西实现,Java里面也不会有reflection了。

【在 g**********y 的大作中提到】
: 少写reflective的code, 多活20年。写的时候看上去很neat, 但是debug reflective的
: code真的是nightmare, 哪怕是你自己写的。
: 感觉reflective就象花credit card, 用的时候很爽,还钱的时候很痛!

avatar
c*n
17
我是新手啊
我觉得reflection 其实就是abstract,delegation 的concept 到extreme,
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。