mardi 26 février 2019

How to Get Names of Methods and Parameters from inside .C File in Java?

I have a question about this topic. I want to get names of methods and parameters. I used Reflection API. If the class which I need to get names of methods is a Java Class, It works but I have a C file. I couldn't do that how to reach this C file and get names of methods and parametres.

package odev1;
import java.io.*;
import java.lang.reflect.Method;

public class Odev1 {


public static void main(String[] args) throws FileNotFoundException, ClassNotFoundException, IOException {

    try {


        Class cls = Odev1.class ;


        for (Method m : cls.getDeclaredMethods()) {
            m.getName();
            m.getReturnType();
            m.getParameterCount();
            System.out.println(" Name of Method : " + m.getName() + " \n"
                    + " Return Type of Method : " + m.getReturnType() + " \n"
                    + " Count of Parametres : " + m.getParameterCount());
        }

    } catch (Exception ex) {
        ex.printStackTrace();
    }
  }
}

This is the C file that will be read on parameters and methods.

#include "stdio.h" 
#include "stdlib.h" 

void DiziYazdir(int *p,int uzunluk)
{   
int i=0;  
for(;i<uzunluk;i++) 
printf("%d ",p[i]); 
} 

int DiziTopla(int *p,int uzunluk)
{ 
int i=0;  int toplam=0;  
for(;i<uzunluk;i++) 
toplam += p[i];  
return toplam; 
}

int main()
{ 
int x,y;  
printf("x:");  
scanf("%d",&x);  
printf("y:");  
scanf("%d",&y);  
int sonuc = x + y;  
printf("Sonuc:%d\n\n",sonuc);  
int *dizi = malloc(3*sizeof(int));  
dizi[0]=x;  
dizi[1]=y;  
dizi[2]=sonuc;  
DiziYazdir(dizi,3);  
printf("\n\nToplam Deger:%d",DiziTopla(dizi,3));  
free(dizi);  
return 0; 
}

How can I get names of methods and parameters in the C file ?





Aucun commentaire:

Enregistrer un commentaire