How to get generic type parameter from static method of extended generic class?

82
June 26, 2021, at 5:50 PM

I have such code:

public class GenClass<T> 
{
    public static void m() 
    {
        //I need to know here, what is T ?
    }
}
class Test
{
    class Cl1 extends GenClass<Integer>{}
    class Cl2 extends GenClass<MyClass>{}
    class Cl3 extends GenClass<Cl3>{}
    public static void main(String[] args) 
    {
        Cl1.m();
        Cl2.m();
        Cl3.m();
    }
}

How can I know inside method m, what is T?

PS: I'm very new to java (my language is C#). I've found such construction as a solution of similar problem:

return (Class) ((ParameterizedType) /*getClass()*/GenClass.class
    .getGenericSuperclass()).getActualTypeArguments()[0];

But it was about instance method, so as I can't call getClass() from static method, I've tried to replace it by GenClass.class, but looks like .class eveluates statically, so it probably have not any info about T.

READ ALSO
ON DUPLICATE KEY UPDATE non-index columns

ON DUPLICATE KEY UPDATE non-index columns

I have a code that is updating a few mySQL tables with the data that is coming from a Sybase databaseThe table structures are exactly the same

67
How can I override MTablePagination component in Material- Table reactJS

How can I override MTablePagination component in Material- Table reactJS

I am stuck in my assignment, I have more than one million rows and want to display them in material-table reactjsHow do I get data from back-end only for rows on one page and then get next set of rows on next page click?

56
Javascript: Sends two arrays of base64 encoded images to php via xhr

Javascript: Sends two arrays of base64 encoded images to php via xhr

Hello everyone I'm here againI'm trying to write a code that's able to resize all images before they're uploaded to the server

39
Div inside of another Div avoid click

Div inside of another Div avoid click

Hello my friends so this is my question i have two divs, one of them is inside of the other one like this schema below

14