new stuff

Aug. 14th, 2012 12:01 pm
juan_gandhi: (Default)
[personal profile] juan_gandhi
function New(name) { return java.lang.Class.forName(name).newInstance() }

function newList() { return New("java.util.LinkedList") }

Date: 2012-08-16 08:52 pm (UTC)
From: [identity profile] ivan-gandhi.livejournal.com
Wow, это то что надо!!! Спасибо!

Date: 2012-08-16 09:14 pm (UTC)
From: [identity profile] alamar.livejournal.com
Пожалуйста, коли не шутишь. Но вообще статические методы в джаваскрипте даже ценнее, чем в джаве: заимпортируй пару классов, и вся коробка инструментов под рукой.

Ещё мы сделали два тупых метода:
$F(объект, 'поле') для доставания значения приватного поля рефлекшоном
и $I(X) = java.lang.Integer.valueOf(X) (просто надобится постоянно)

Date: 2012-08-16 10:03 pm (UTC)
From: [identity profile] ivan-gandhi.livejournal.com
Вот-вот, это то что мне надо! А то я слышал про это чудо, но как-то не въезжал, пока сам не напоролся.

Date: 2012-08-23 08:08 pm (UTC)
From: [identity profile] ivan-gandhi.livejournal.com
Щас, $F где-то в открытом доступе есть? Могу и написать, конечно...

Date: 2012-08-23 09:03 pm (UTC)
From: [identity profile] alamar.livejournal.com
Там используются наши обёртки, но грубо говоря:
$F = function(obj, fieldName) {
var f = obj.getClass().getDeclaredField(fieldName);
f.setAccessible(true);
return f.get(obj);
}

Date: 2012-08-23 09:38 pm (UTC)
From: [identity profile] ivan-gandhi.livejournal.com
А, спасибо.

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

October 2025

S M T W T F S
    1 23 4
5 678 91011
12131415161718
19202122232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Oct. 9th, 2025 02:16 pm
Powered by Dreamwidth Studios