Forget what I said. I confused the "signature" field in the Type class with
the attribute "Signature". No code in BCEL will need to be changed. Unless
you want to add a a generator for generic type signatures. So I got things
working like this basically:
FieldGen fg;
fg.addAttribute(new org.apache.bcel.classfile.Signature(
cp.addUtf8("Signature"), 2,
cp.addUtf8(typeToVMSignature
<http://code.botcompany.de:8081/tb/show-snippet.php?id=1035321>(type)),
cp.getConstantPool()));
It really helps to talk about problems in a forum, lol.
My Java-based scripting language is coming along very nicely now.
Have a nice day
Stefan
On Sun, 1 May 2022 at 00:35, Stefan Reich <
[email protected]> wrote:
> OK I think I figured it out. There is setSignature in
> org.apache.bcel.generic.Type which I need to call with my generic field
> signature (since direct representations of generic types are actually not
> built into BCEL yet).
>
> Not a problem, what's unfortunate is just that setSignature is
> package-protected so I'd have to patch BCEL to call it.
>
> The field signature itself is protected so I could set it directly in a
> subclass of ObjectType.
>
> However, there is a note that say this practice will be made impossible in
> the future. So, in conclusion, I am proposing to change that note (in
> org/apache/bcel/generic/Type.java):
>
> /**
> * @deprecated (since 6.0) will be made private; do not access directly, use
> getter/setter
> */
> @Deprecated
> protected String signature; // signature for the type TODO should be private
>
>
> and/or making the setSignature method in the same class public.
>
> Greetings,
> Stefan
>
>
>
> On Sat, 30 Apr 2022 at 17:42, Stefan Reich <
> [email protected]> wrote:
>
>> Hi, the title basically says it... I'm trying to create a field with a
>> parameterized type (e.g. List<String>), but I can't find a subclass of Type
>> representing a parameterized type that I could pass to the FieldGen
>> constructor.
>>
>> Thanks,
>> Stefan
>>
>> --
>> == Gaz.AI ==
>>
>
>
> --
> == Gaz.AI ==
>
--
== Gaz.AI ==