I need to find the replacement for the deprecated items in java. I found some description in javadoc about each and every deprecated items. But it's not sufficient.
To be more specific => I need to do a java program, which can read a java file and should replace the deprecated items used(if any) in that given java file with the appropriate replacement.
Is there any other source to find it?
OR
Is there any third party API's available to give the replacement for the deprecated itms?
OR
Is there any options available in eclipse to do this? -> I mean for example in the problems console of eclipse, we can able to find the warnings for the deprecated items used. Likewise, is there anything in eclipse which can show the replacement of the deprecated items in the project,
Please help me in this regard.
Thanks in advance,
Easwar
A #Deprecated API (method, class, whatever) is deprecated to notify you that a newer API exists that should be used instead of it. Exactly what the newer API is is not deterministic (i.e. is not something that can be inferred by eclipse or by analyzing the code). The only way to know what should be used instead of it is to read the documentation. If there is no documentation, there is no way of knowing apart from contacting someone who does know.
Related
Is there any tool that allows you to "query" (rather than simply search) the JDK documentation? For example:
Show me all deprecated methods.
Show me all subclasses of a particular class (rather than only the direct subclasses, which the documentation provides).
Show me all methods that return (say) a Thread.
Show me all instances of a given method name, regardless of signature.
What prompted this question is that I was muddling up two completely unrelated methods that I only use occasionally: Pattern.matches() and Matcher.matches(). And then I found that there is also PathMatcher.matches(), which also has a completely unrelated purpose. And that got me wondering how many other "matches()" methods there are in the JDK. And then I thought that there may be other useful queries that could also be run against the JDK documentation.
The only motivation for having such a tool is to help me improve my own knowledge of Java with information that is interesting or useful (to me at least), but is not otherwise easy to obtain. This question is similar, but I am looking for something more sophisticated than a simple search.
ETA: Marcel's suggestion below of using the Doclet API provides a great solution, without too much effort.
ETA2: Re determining deprecated methods, I've just found out that Oracle already address this in the JavaDoc API here
Could it be that you're approaching this from the wrong angle? Rather than parsing the docs, which is an already transformed representation of the source, why not parse source code or byte code of the JDK directly?
parsing byte code
parsing source code
hook into the Javadoc tool (i.e. let Javadoc parse the code for you) by using the Doclet API
Depending on your needs you might also want to take the really easy road and have your classpath scanned by the reflections library.
Reflections reflections = new Reflections("some.package");
Set<Method> voidMethods = reflections.getMethodsReturn(Thread.class);
That having said don't forget that any good IDE can dig up a lot of the info you seem to be looking for (e.g. searching for methods called matches).
since version 10 guava offers com.google.common.eventbus.EventBus - a generic pub-sub facility. It is not marked as GWT-compatible in the source. I wonder whether it's possible to plug some custom code pre-processing into gwt compiler to map this (partially annotation/reflection-based) API into javascript.
AFAIK there're some other custom extensions added into GWT java-to-js compiler, like com.google.gwt.i18n.client.ConstantsWithLookup and quite likely some others. I'd seen some experimental compiler extensions to add partial support for reflection/annotations, but not sure they're required in case we handle a specific set of annotations and simple class->methods->annotation listing is required (not a complete reflection API).
Maybe someone knows whether GWT-enabling this component is planned by guava dev team?
Thanks,
Anton
This is probably more appropriate for guava-discuss than for StackOverflow, but Guava team member here: no, we're not planning on it.
simply already working (GWT server+client compatible) with this one: http://www.gwtproject.org/javadoc/latest/com/google/gwt/event/shared/EventBus.html
and here (Tutorial): http://www.gwtproject.org/articles/mvp-architecture.html#events
(answered also here: https://stackoverflow.com/a/28082823/1915920)
Just start to learn Java, and always see some tutorials mentioning, "using the javaDoCs API to find...", what does "JavaDoCS API" stands for? Where to find it?
Javadocs are a way to write documents inside your code, that can be made into a little framed report dealio.
So for Java itself, you can get the Java 6 API at http://download.oracle.com/javase/6/docs/api/
if you are using say, Spring and someone says look at the JavaDocs API.. you would have to go google (or use something like Maven) to get the javadocs into your app.
Edit - Javadoc FAQ: http://java.sun.com/j2se/javadoc/faq/index.html
Javadocs are standard documentation pages generated from special comments inserted directly in the code.
You can find the whole thing for the standard API here: http://download.oracle.com/javase/6/docs/api/
Most IDES will also show you the API when you hit ctrl+space.
You will need the documentation or source files for non standard apis such as libraries / frameworks / etc.
I am using the AWTUtilities class in my application to create custom window shapes. As far as I know, there is no other way to do it. It is a requirement.
The javadoc generation gives me this error:
warning: com.sun.awt.AWTUtilities is Sun proprietary API and may be removed in a future release
What exactly does this mean? I can use it, but it may stop working with any release? Why put it in, then? More importantly, and the real question here, if Sun takes it out, will they likely replace it with another way to do the same thing? Is that what the warning is for?
I suppose I could just check for the presence of the AWTUtilities class before calling the code. But that's just obnoxious if I don't need to do it.
Does anyone have any experience with similar classes? Were they eventually accepted into the API and the warning removed or replaced with another method of doing the same thing? Do I need to be concerned about this?
FYI, I have read this:
How to distribute AWTUtilities
The Oracle documentation states:
Note: the com.sun.awt.AWTUtilities class is not part of an officially supported API and appears as an implementation detail. The API is only meant for limited use outside of the core platform. It may change drastically between update releases, and it may even be removed or be moved in some other packages or classes. The class should be used via Java Reflection. Supported and public API will appear in the next major JDK release.
JDK 7 has been a long time coming so it could be awhile. Whether you should use it is a risk management question that only your company can answer. If we are talking about an internal application where the deployed JRE can be guaranteed then you are not going to have a problem because you can guarantee a compatible JRE. If we are talking about deploying to external customers then you need to have a support plan if this provisional API ever changes.
A stable way to do this would be to create a Shell in SWT as per this snippet and then use the SWT_AWT bridge to get a Frame to use in your application:
java.awt.Frame frame = SWT_AWT.new_Frame(shell);
If you are just deploying to a single platform (like Windows) then tossing a single SWT jar plus the native library. If you are targeting multiple platforms then this becomes a pain.
So those are the two choice: deal with the AWTUtilities risk or use the SWT_AWT bridge.
EDIT:
Some time has passed and Java 7 is out. There is documentation on the officially supported way to accomplish this in the Java Tutorials. The section "How to Implement a Shaped Window" at the bottom gives an example. This of course assumes you can mandate Java 7
You don't need a new Frame object, you can only use
this.setShape(shape);
or your frame name like this
Frame1.setShape(shape);
a lot of AWT methods has been applied to java.awt.Frame
It is possible to access bits of MATLAB's internal java code to programmatically change MATLAB itself. For example, you can programmatically open a document in the editor using
editorServices = com.mathworks.mlservices.MLEditorServices;
editorServices.newDocument() %older versions of MATLAB seem to use new()
You can see the method signatures (but not what they do) using methodsview.
methodsview(com.mathworks.mlservices.MLEditorServices)
I have a few related questions about using these Java methods.
Firstly, is there any documentation on these things (either from the Mathworks or otherwise)?
Secondly, how do you find out what methods are available? The ones I've come across appear to be contained in JAR files in matlabroot\java\jar, but I'm not sure what the best way to inspect a JAR file is.
Thirdly, are there functions for inspecting the classes, other than methodsview?
Finally, are there any really useful methods that anyone has found?
There is no official documentation nor support for these classes. Moreover, these classes and internal methods represent internal implementation that may change without notice in any future Matlab release. This said, you can use my uiinspect and checkClass utilities to investigate the internal methods, properties and static fields. These utilities use Java reflection to do their job, something which is also done by the built-in methodsview function (I believe my utilities are far more powerful, though). In this respect, I believe we are not crossing the line of reverse-engineering which may violate Matlab's license.
If you are looking for documentation, then my UndocumentedMatlab.com website has plenty of relevant resources, and more is added on a regular basis so keep tuned.
I am also working on a book that will present a very detailed overview of all these internal classes, among other undocumented stuff - I hope to have publication news later this year.
I am an eclipse fan. If you use that as your IDE, the jar can be imported into one of your projects and you can inspect the methods in there.
To find out more about java objects, I use uiinspect.
The only place I know that is documenting the Matlab hidden Java stuff is Undocumented Matlab by Yair Altman. His site lists plenty of very useful tricks. Being able to use Java to format text in list boxes has come in very handy for me, for example.
EDIT
The man has spoken. Listen to him, since I don't think there's anyone outside MathWorks who knows more about Matlab's internal java code.
Undocumented Matlab is a great place to start looking.