[fpc-pascal] Java equivalent of Pascal's class reference functionality

Maciej Izak hnb.code at gmail.com
Thu Jun 9 01:46:54 CEST 2016


2016-06-09 1:17 GMT+02:00 Graeme Geldenhuys <mailinglists at geldenhuys.co.uk>:

> Does Java have an equivalent feature of a Object Pascal language's Class
> Reference.
>

+/- yes, it is called Class and you need no-arg constructor for that:

https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html

public void executeVisitor(TVisited pData, Class<TVisitor> pVisClass)
{
    TVisitor lVisitor = null;
    try {
        lVisitor := pVisClass.newInstance();  // <<-- Important Part
    } catch (InstantiationException e) {
        LOG.error("HINT: probably missing no-arg constructor for Entry: " +
pVisClass.getName());
        throw e;
    }

  ...
}

-- 
Best regards,
Maciej Izak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160609/168e6c51/attachment.html>


More information about the fpc-pascal mailing list