question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add functions to obtain Java classes to java.base

See original GitHub issue

As part of my continuing campaign to alleviate the need to use ceylon.interop.java for most programming tasks, I propose adding the following functions to java.base (in java.lang, I guess):

  • Class<out T> classForInstance<T>(T instance)
  • Class<out T> classForModel<T>(ClassOrInterface<T> model)
  • Class<out Anything> classForDeclaration(ClassOrInterfaceDeclaration declaration)
  • classForAnnotation() ???
  • ObjectArray<StackTraceElement> stackTrace(Throwable throwable)

This would alleviate the need to use ceylon.interop.java for anything except collection adaptors.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:23 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
jvasileffcommented, Apr 7, 2017

There would be Ceylon source code for a Ceylon module called java.lang which would include declarations for everything added to java.lang. All declarations would be native. Ceylon-docs for this module would be published to Herd.

Users wouldn’t actually import this module. From their perspective, these declarations would be made available by importing java.base, just as the java.lang declarations in Oracle’s Java-docs are made available by importing java.base.

0reactions
gavinkingcommented, Apr 7, 2017

Why can’t we use top-levels? Needing Type.

Well, I could have, but as was suggested here above, it’s weird that there would be toplevel functions in java.lang when Java doesn’t have toplevel functions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java add function to extended class [duplicate] - Stack Overflow
getmDataset() you are trying to access a static method of the class MainAdapter and getmDataset() is not static. Use as (new MainAdapter()).
Read more >
Java Programming Tutorial - 07 - Adding a Method to a Class
Get more lessons like this at http://www.MathTutorDVD.comLearn how to program in java with our online tutorial. We will cover variables, ...
Read more >
Java Class Methods - W3Schools
Access Methods With an Object · 1) We created a custom Main class with the class keyword. · 2) We created the fullThrottle()...
Read more >
Inheritance - Learning the Java Language
In the Java language, classes can be derived from other classes, thereby inheriting fields and methods from those classes.
Read more >
Functions - Learn Java - Free Interactive Java Tutorial
Non static methods in Java are used more than static methods. Those methods can only be run on objects and not on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found