Search Results

Search found 60 results on 3 pages for 'javadocs'.

Page 1/3 | 1 2 3  | Next Page >

  • Self-documenting code vs Javadocs?

    - by Andiaz
    Recently I've been working on refactoring parts of the code base I'm currently dealing with - not only to understand it better myself, but also to make it easier for others who are working on the code. I tend to lean on the side of thinking that self-documenting code is nice. I just think it's cleaner and if the code speaks for itself, well... That's great. On the other hand we have documentation such as javadocs. I like this as well, but there's a certain risk that comments here gets outdated (as well as comments in general of course). However, if they are up-to-date they can be extremely useful of say, understanding a complex algorithm. What are the best practices for this? Where do you draw the line between self-documenting code and javadocs?

    Read the article

  • Java EE 7 Status Update - November 2012

    - by arungupta
    Here is a quick status update on different components that are targeted to be included in the Java EE 7 Platform: Java EE 7 Platform (JSR 342) - Early Draft 2 (list, project, javadocs ?) Java Persistence API 2.1 (JSR 338) - Early Draft 2 (list, project, javadocs ?) Java API for RESTful Web Services 2.0 (JSR 339) - Public Review (list, project, javadocs) Servlets 3.1 (JSR 340) - Early Draft (list, project, javadocs ?) Expression Language 3.0 (JSR 341) - Public Review (list, project, javadocs ?) Java Message Service 2.0 (JSR 343) - Early Draft (list, project, javadocs) JavaServer Faces 2.2 (JSR 344) - Early Draft (list, project, javadocs ?) Enterprise JavaBeans 3.2 (JSR 345) - Early Draft (list, project, javadocs ?) Context & Dependency Injection 1.1 (JSR 346) - Early Draft (list, project, javadocs) Bean Validation 1.1 (JSR 349) - Public Review (list, project, javadocs ?) JCACHE Java Temporary Caching API (JSR 107) - Early Draft (list, project, javadocs) Batch Applications for the Java Platform (JSR 352) - Early Draft (list, project, javadocs) Java API for JSON Processing (JSR 353) - Early Draft (list, project, javadocs) Java API for WebSocket (JSR 356) - Early Draft (list, project, javadocs) As evident, all the components have released at least an Early Draft specification. Some have released second Early Draft and some even have a Public Review in different stages. Several implementations are already integrated in GlassFish 4. Promoted Builds. Which ones are you tracking or contributing ? Make sure to file an issue so that your usecase and needs are addressed. Download GlassFish 4. Promoted Build and provide feedback.  

    Read the article

  • How to generate android styled javadocs ?

    - by Kaillash
    Hi, Is it possible to generate android styled javadocs for my android project (like http://developer.android.com/reference/java/lang/String.html, instead of http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html) Is it something regarding using of some custom doclet instead of standard doclet? If yes, then which one I have to use?

    Read the article

  • How do I include Implementation and Usage Documentation in one file

    - by Angelo.Hannes
    There are two types of documentation. One type, the Implementation Documentation, contains information about specific implementation of a construct (eg. Class, Method, etc.). It is targeted to the future me, maintainer, debugger and so on. And there is Usage Documentation, containing information how to use a provided api. It does not contain information about specific implementation and is targeted to users of the api. How do I include both of them in one file? (Or do I include both of them in one file? And if not, what type belongs into the source file?) Are there special techniques, using java-doc and/or best practices?

    Read the article

  • How to document experimental or incomplete APIs like @deprecated?

    - by Michael Levy
    Is there a good term that is similar but different than "deprecate" to mean that a method or API is in the code base but should not be used because its implementation is not complete or will likely change? (Yeah, I know, those methods shouldn't be public, yada yada yada. I didn't create my situation, I'm just trying to make the best of it.) What do people suggest? Experimental, Incomplete, something else? If I'm building javadoc documentation for this API that is still in flux, should I use the @deprecated tag or is there a better convention? To me @deprecated implies that this API is old and a newer preferred mechanism is available. In my situation, there is no alternative, but some of the methods in the API are not finished and so should not be used. At this point I cannot make them private, but I'd like to put clear warnings in the docs.

    Read the article

  • Deprecated vs. Denigrated in JavaDoc?

    - by jschoen
    In the JavaDoc for X509Certificate getSubjectDN() it states: Denigrated, replaced by getSubjectX500Principal(). I am used to seeing Deprecated in the for methods that should not be used any longer, but not Denigrated. I found a bug report about this particular case where it was closed with comment: This isn't a bug. "Deprecated" is meant to be used only in serious cases. When we are using a method that is Deprecated, the general suggested action is to stop using the method. So what is the suggested action when a method is marked as Denigrated?

    Read the article

  • How can I view javadocs that have been added to a maven repository?

    - by Coderer
    I know I can use maven to pull the javadocs for an artifact (if they've been added), which should come through as a JAR (right?), which I can then unpack and browse. My problem is, I'm trying to figure out which of a series of artifacts have the particular package I'm hunting for. I could download a half-dozen javadoc packages, unpack all of them, then open the index files one at a time, but that sounds like it would be pretty unpleasant. There must be a better way! I noticed that Nexus supports javadoc artifact browsing, but apparently only in the Pro version (which we do not have, and are unlikely to get any time soon). I'd prefer a GUI solution, though I'd settle for a command line answer, provided it's something along the lines of showmethedocs groupId:artifactId [version].

    Read the article

  • Extending AutoVue Through the API

    - by GrahamOracle
    The AutoVue API (previously called the “VueBean” API) is a great way to extend AutoVue Client/Server Deployment – specifically the client component – beyond the out-of-the-box capabilities and into new use-cases. In addition to having a solid grasp of J2SE programming, make sure to leverage the following resources if you’re developing or interested in developing customizations/extensions to AutoVue Client/Server Deployment: Programmer’s Guide: Before all else, read through the AutoVue API Programmer’s Guide to get an understanding of the architecture of the API. The Programmer’s Guide is included with the installation of AutoVue, and is posted on the Oracle Technology Network (OTN) website for the recent versions of AutoVue: http://www.oracle.com/technetwork/documentation/autovue-091442.html Javadocs: The AutoVue API Javadocs document the many packages, classes, and methods available to you. The Javadocs are included in the product installation under the \docs\JavaDocs\VueBean folder (easiest starting point is through the file index.html). Integrations Forum: If you have development questions that aren’t answered through the documentation, feel free to register and post in the public AutoVue Integrations Forum. For more information refer to the following blog post from October 2010: https://blogs.oracle.com/enterprisevisualization/entry/exciting_news_autovue_integrat Code Samples: Although the Oracle Support team’s scope of Support for API/customization topics is to answer questions regarding information already provided in the documentation (i.e. not to design or develop custom solutions), there are cases where Support comes across interesting samples or code snippets that may benefit various customers. In those cases, our Support team posts the samples into the Oracle knowledge base, and tracks them through a single reference note. The link to the KM Note depends on how you currently access the My Oracle Support portal: Flash interface: https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&doctype=REFERENCE&id=1325990.1 (New) HTML interface: https://supporthtml.oracle.com/epmos/faces/ui/km/SearchDocDisplay.jspx?type=DOCUMENT&id=1325990.1 Happy coding!

    Read the article

  • In maven2, how do I assemble bits and pieces of different modules to create final distributions?

    - by Carcassi
    I have four maven project: client api jar web service war ui jar web interface war The service war will need to be packaged to include the client api jar, together with javadocs (so that each version is distributed with a matching client and documentation). The web interface war will need the ui jar and all the dependencies (webstart/applet deployment). So I need a 5th project that does all the packaging. How to do this with ant or a script is perfectly clear to me, but not in maven. I tried the following: having the javadocs included as part of the war packaging: this requires the execution of the javadocs goal in project 1 before execution of package in project 2. Haven't found a way to bind plugins/goals across different projects. Using the assembly plugin in project2 had the same problem. create a fifth project and use the assembly plugin. Still the same problems as before, with the problem that since I need different pieces from each sub-project I do not understand how this can be done using the assembly. Is this too hard to do in maven, and should I just give up? Or I am looking at it wrong, in which case, how should I be looking at it? Thanks! Upon further reflection, here is a partial answer: Each project should build all its artifacts. This is done by having the plugins configured to run as per the prepare-resources and package phases. So, in my case, I prepare all that needs to be generated (jar, javadocs, xsd documentation, ...) as different artifacts so that a single "package" goal execution creates all. So, it's not "how project 2 forces project 1 to run different goals", but it's "make project 1 create all of its artifact as part as the normal lifecycle). This seems to simplify things.

    Read the article

  • Jersey 2 Integrated in GlassFish 4

    - by arungupta
    JAX-RS 2.0 has released Early Draft 3 and Jersey 2 (the implementation of JAX-RS 2.0) released Milestone 5. Jakub reported that this milestone is now integrated in GlassFish 4 builds. The first integration has basic functionality working and leaves EJB, CDI, and Validation for the coming months. TOTD #182 explains how to get started with creating a simple Maven-based application, deploying on GlassFish 4, and using the newly introduced Client API to test the REST endpoint. GlassFish 4 contains Jersey 2 as the JAX-RS implementation. If you want to use Jersey 1.1 functionality, then Martin's blog provide more details on that. All JAX-RS 1.x functionality will be supported using standard APIs anyway. This workaround is only required if Jersey 1.x functionality needs to be accessed. Here are some pointers to follow JAX-RS 2 Specification Early Draft 3 Latest status on specification (jax-rs-spec.java.net) Latest JAX-RS 2.0 Javadocs Latest status on Jersey 2 (jersey.java.net) Latest Jersey API Javadocs Latest GlassFish 4.0 Promoted Build Follow @gf_jersey Provide feedback on Jersey 2 to [email protected] and JAX-RS specification to [email protected].

    Read the article

  • Adopt-a-JSR for Java EE 7 - Getting Started

    - by arungupta
    Adopt-a-JSR is an initiative started by JUG leaders to encourage JUG members to get involved in a JSR, in order to increase grass roots participation. This allows JUG members to provide early feedback to specifications before they are finalized in the JCP. The standards in turn become more complete and developer-friendly after getting feedback from a wide variety of audience. adoptajsr.org provide more details about the logistics and benefits for you and your JUG. A similar activity was conducted for OpenJDK as well. Markus Eisele also provide a great introduction to the program (in German). Java EE 7 (JSR 342) is scheduled to go final in Q2 2013. There are several new JSRs that are getting included in the platform (e.g. WebSocket, JSON, and Batch), a few existing ones are getting an overhaul (e.g. JAX-RS 2 and JMS 2), and several other getting minor updates (e.g. JPA 2.1 and Servlets 3.1). Each Java EE 7 JSR can leverage your expertise and would love your JUG to adopt a JSR. What does it mean to adopt a JSR ? Your JUG is going to identify a particular JSR, or multiple JSRs, that is of interest to the JUG members. This is mostly done by polling/discussing on your local JUG members list. Your JUG will download and review the specification(s) and javadocs for clarity and completeness. The complete set of Java EE 7 specifications, their download links, and EG archives are listed here. glassfish.org/adoptajsr provide specific areas where different specification leads are looking for feedback. Your JUG can then think of a sample application that can be built using the chosen specification(s). An existing use case (from work or a personal hobby project) may be chosen to be implemented instead. This is where your creativity and uniqueness comes into play. Most of the implementations are already integrated in GlassFish 4 and others will be integrated soon. You can also explore integration of multiple technologies and provide feedback on the simplicity and ease-of-use of the programming model. Especially look for integration with existing Java EE technologies and see if you find any discrepancies. Report any missing features that may be included in future release of the specification. The most important part is to provide feedback by filing bugs on the corresponding spec or RI project. Any thing that is not clear either in the spec or implementation should be filed as a bug. This is what will ensure that specification and implementation leads are getting the required feedback and improving the quality of the final deliverable of the JSR. How do I get started ? A simple way to get started can be achieved by following S.M.A.R.T. as explained below. Specific Identify who all will be involved ? What would you like to accomplish ? For example, even though building a sample app will provide real-world validity of the API but because of time constraints you may identify that reviewing the specification and javadocs only can be accomplished. Establish a time frame by which the activities need to be complete. Measurable Define a success for metrics. For example, this could be the number of bugs filed. Remember, quality of bugs is more important that quantity of bugs. Define your end goal, for example, reviewing 4 chapters of the specification or completing the sample application. Create a dashboard that will highlight your JUG's contribution to this effort. Attainable Make sure JUG members understand the time commitment required for providing feedback. This can vary based upon the level of involvement (any is good!) and the number of specifications picked. adoptajsr.org defines different categories of involvement. Once again, any level of involvement is good. Just reviewing a chapter, a section, or javadocs for your usecase is helpful. Relevant Pick JSRs that JUG members are willing and able to work. If the JUG members are not interested then they might loose motivation half-way through. The "able" part is tricky as you can always stretch yourself and learn a new skill ;-) Time-bound Define a time table of activities with clearly defined tasks. A tentative time table may look like: Dec 25: Discuss and agree upon the specifications with JUG Jan 1: Start Adopt-a-JSR for Java EE 7 Jan 15: Initial spec reading complete. Keep thinking through the application that will be implemented. Jan 22: Early design of the sample application is ready Jan 29: JUG members agree upon the application Next 4 weeks: Implement the application Of course, you'll need to alter this based upon your commitment. Maintaining an activity dashboard will help you monitor and track the progress. Make sure to keep filing bugs through out the process! 12 JUGs from around the world (SouJava, Campinas JUG, Chennai JUG, London Java Community, BeJUG, Morocco JUG, Peru JUG, Indonesia JUG, Congo JUG, Silicon Valley JUG, Madrid JUG, and Houston JUG) have already adopted one of the Java EE 7 JSRs. I'm already helping some JUGs bootstrap and would love to help your JUG too. What are you waiting for ?

    Read the article

  • How to ignore/prevent javadoc folder from validation during Eclipse Build?

    - by h2g2java
    In my war is a huge javadoc folder. There is no point in validating it since javadocs are produced by Sun(Oracle) javadoc utility. I have forgotten how I did it the last time. I need to tell Eclipse build not to validate that particular folder. Reasons why I need it: 1. the html produced by Sun javadoc generation utility does not meet the requirement that Eclipse uses - there is a bug report in Eclipse but Eclipse responds that Sun javadoc generator non-compliance is not their fault and that Eclipse intends to stick to their strict compliance. Which results in lots of html errors listed in the problems tab. 2. the javadoc folder is a remote link and high activity on that link is using up my cpu resource, and because it is a link to a remote location, that cpu high activity is sustained for long time until it finishes scanning the whole 35MB javadocs. Thanks - need help.

    Read the article

  • Java EE 7 Launch Replay

    - by arungupta
    Java EE 7 was released final on Jun 12, 2013. A complete replay of Strategy and Technical Keynote can be seen below: All the Technical Breakout sessions are now available on GlassFishVideos@YouTube and can be viewed in the following playlist: Ready to try out Java EE 7 ? Download Binaries Java EE 7 SDK GlassFish Server Open Source Edition 4.0 Tools NetBeans 7.3.1 Eclipse Kepler Maven Coordinates Docs Java EE 7 Whitepaper Java EE 7 Tutorial (html pdf) First Cup Sample Application Java EE 7 Hands-on Lab Javadocs (online download) Specifications All-in-one GlassFish Documentation Bundle Do you feel enabled and empowered to start building Java EE 7 applications ? Just download Java EE 7 SDK that contains GlassFish Server Open Source Edition 4.0, tutorial, samples, documentation and much more. Enjoy!

    Read the article

  • JAX-RS 2.0 Early Draft - Third Edition Available

    - by arungupta
    JAX-RS 2.0 Early Draft Third Edition is now available. This updated draft include new samples explaining the features and clarifications in content-negotiation, discovery of providers, client-side API, filters and entity interceptors and several other sections. Provide feedback to users@jax-rs-spec. Jersey 2.0, the Reference Implementation of JAX-RS 2.0, released their fourth milestone a few days ago as well. Several features have already been implemented there. Note, this is an early development preview and several parts of the API and implementation are still evolving. Feel like trying it out? Simply go to Maven Central (of course none of this is production quality at this point). The latest JAX-RS Javadocs and Jersey 2.0 API docs are good starting points to explore. And provide them feedback at [email protected] or @gf_jersey.

    Read the article

  • Jersey 2 in GlassFish 4 - First Java EE 7 Implementation Now Integrated (TOTD #182)

    - by arungupta
    The JAX-RS 2.0 specification released their Early Draft 3 recently. One of my earlier blogs explained as the features were first introduced in the very first draft of the JAX-RS 2.0 specification. Last week was another milestone when the first Java EE 7 specification implementation was added to GlassFish 4 builds. Jakub blogged about Jersey 2 integration in GlassFish 4 builds. Most of the basic functionality is working but EJB, CDI, and Validation are still a TBD. Here is a simple Tip Of The Day (TOTD) sample to get you started with using that functionality. Create a Java EE 6-style Maven project mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo.archetypes -DarchetypeArtifactId=webapp-javaee6 -DgroupId=example -DartifactId=jersey2-helloworld -DarchetypeVersion=1.5 -DinteractiveMode=false Note, this is still a Java EE 6 archetype, at least for now. Open the project in NetBeans IDE as it makes it much easier to edit/add the files. Add the following <respositories> <repositories> <repository> <id>snapshot-repository.java.net</id> <name>Java.net Snapshot Repository for Maven</name> <url>https://maven.java.net/content/repositories/snapshots/</url> <layout>default</layout> </repository></repositories> Add the following <dependency>s <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.10</version> <scope>test</scope></dependency><dependency> <groupId>javax.ws.rs</groupId> <artifactId>javax.ws.rs-api</artifactId> <version>2.0-m09</version> <scope>test</scope></dependency><dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> <version>2.0-m05</version> <scope>test</scope></dependency> The complete list of Maven coordinates for Jersey2 are available here. An up-to-date status of Jersey 2 can always be obtained from here. Here is a simple resource class: @Path("movies")public class MoviesResource { @GET @Path("list") public List<Movie> getMovies() { List<Movie> movies = new ArrayList<Movie>(); movies.add(new Movie("Million Dollar Baby", "Hillary Swank")); movies.add(new Movie("Toy Story", "Buzz Light Year")); movies.add(new Movie("Hunger Games", "Jennifer Lawrence")); return movies; }} This resource publishes a list of movies and is accessible at "movies/list" path with HTTP GET. The project is using the standard JAX-RS APIs. Of course, you need the trivial "Movie" and the "Application" class as well. They are available in the downloadable project anyway. Build the project mvn package And deploy to GlassFish 4.0 promoted build 43 (download, unzip, and start as "bin/asadmin start-domain") as asadmin deploy --force=true target/jersey2-helloworld.war Add a simple test case by right-clicking on the MoviesResource class, select "Tools", "Create Tests", and take defaults. Replace the function "testGetMovies" to @Testpublic void testGetMovies() { System.out.println("getMovies"); Client client = ClientFactory.newClient(); List<Movie> movieList = client.target("http://localhost:8080/jersey2-helloworld/webresources/movies/list") .request() .get(new GenericType<List<Movie>>() {}); assertEquals(3, movieList.size());} This test uses the newly defined JAX-RS 2 client APIs to access the RESTful resource. Run the test by giving the command "mvn test" and see the output as ------------------------------------------------------- T E S T S-------------------------------------------------------Running example.MoviesResourceTestgetMoviesTests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.561 secResults :Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 GlassFish 4 contains Jersey 2 as the JAX-RS implementation. If you want to use Jersey 1.1 functionality, then Martin's blog provide more details on that. All JAX-RS 1.x functionality will be supported using standard APIs anyway. This workaround is only required if Jersey 1.x functionality needs to be accessed. The complete source code explained in this project can be downloaded from here. Here are some pointers to follow JAX-RS 2 Specification Early Draft 3 Latest status on specification (jax-rs-spec.java.net) Latest JAX-RS 2.0 Javadocs Latest status on Jersey (Reference Implementation of JAX-RS 2 - jersey.java.net) Latest Jersey API Javadocs Latest GlassFish 4.0 Promoted Build Follow @gf_jersey Provide feedback on Jersey 2 to [email protected] and JAX-RS specification to [email protected].

    Read the article

  • Is writing comments inside methods not a good practice?

    - by Srini Kandula
    A friend told me that writing comments inside methods is not good. He said that we should have comments only for the method definitions(javadocs) but not inside the method body. It seems he read in a book that having comments inside the code means there is a problem in the code. I don't quite understand his reasoning. I think writing comments inside the method body is good and it helps other developers to understand it better and faster. Please provide your comments.

    Read the article

  • Type Conversion in JPA 2.1

    - by delabassee
    The Java Persistence 2.1 specification (JSR 338) adds support for various new features such as schema generation, stored procedure invocation, use of entity graphs in queries and find operations, unsynchronized persistence contexts, injection into entity listener classes, etc. JPA 2.1 also add support for Type Conversion methods, sometime called Type Converter. This new facility let developers specify methods to convert between the entity attribute representation and the database representation for attributes of basic types. For additional details on Type Conversion, you can check the JSR 338 Specification and its corresponding JPA 2.1 Javadocs. In addition, you can also check those 2 articles. The first article ('How to implement a Type Converter') gives a short overview on Type Conversion while the second article ('How to use a JPA Type Converter to encrypt your data') implements a simple use-case (encrypting data) to illustrate Type Conversion. Mission critical applications would probably rely on transparent database encryption facilities provided by the database but that's not the point here, this use-case is easy enough to illustrate JPA 2.1 Type Conversion.

    Read the article

  • Java EE 7 support in NetBeans 7.3.1

    - by arungupta
    NetBeans IDE provide tools, templates, and samples for building Java EE 7 applications. NetBeans 7.3.1 specifically added support for the features mentioned below: Support for creating Java EE 7 projects using Maven and Ant Develop, Deploy, and Debug using GlassFish 4 Bundled Java EE 7 javadocs CDI is enabled by default for new Java EE 7 projects (CDI 1.1) Create database scripts from Entity Classes (JPA 2.1) Java Persistence Query Language (JPQL) testing tool (JPA 2.1) RESTful Java client creation using JAX-RS 2.0 Client APIs (JAX-RS 2.0) New templates for JAX-RS 2 Filter and Interceptor (JAX-RS 2.0) New templates for WebSocket endpoints (WebSocket 1.0) JMS messages are sent using JMS 2 simplified API (JMS 2.0) Pass-through attributes are supported during Facelet page editing (JSF 2.2) Resource Library Contracts(JSF 2.2) @FlowScoped beans from editor and wizards (JSF 2.2) Support for EL 3.0 syntax in editor (EL 3.0) JSON APIs can be used with code completion (JSON 1.0) A comprehensive list of features added in this release is available in NetBeans 7.3.1 New and Noteworthy. Watch the screencast below to get a quick overview of the features and capabilities: Download Netbeans 7.3.1 and start playing with Java EE 7!

    Read the article

  • Jersey 2.0 Milestone 2 Now Available

    - by arungupta
    Jersey 2.0 milestone 2 is now available. It builds upon the first milestone and adds several new features such as server-side asynchronous processing, server-side content negotiation, improved JAX-RS parameter injection, and several others. The REST endpoints can be published on Java SE HTTP Server, Grizzly 2 HTTP container, and some basic Servlet-based deployments. It also provides HTTPURLConnection-based client API implementation. Read about these and more about what's new in Marek's detailed post. Of course this is also the future reference implementation for JAX-RS 2.0. Feel like trying it out? Simply go to Maven Central (of course none of this is production quality at this point). The latest JAX-RS Javadocs and Jersey 2.0 API docs are good starting points to explore. And provide them feedback at [email protected].

    Read the article

  • Java ReentrantReadWriteLocks - how to safely acquire write lock?

    - by Andrzej Doyle
    I am using in my code at the moment a ReentrantReadWriteLock to synchronize access over a tree-like structure. This structure is large, and read by many threads at once with occasional modifications to small parts of it - so it seems to fit the read-write idiom well. I understand that with this particular class, one cannot elevate a read lock to a write lock, so as per the Javadocs one must release the read lock before obtaining the write lock. I've used this pattern successfully in non-reentrant contexts before. What I'm finding however is that I cannot reliably acquire the write lock without blocking forever. Since the read lock is reentrant and I am actually using it as such, the simple code lock.getReadLock().unlock(); lock.getWriteLock().lock() can block if I have acquired the readlock reentrantly. Each call to unlock just reduces the hold count, and the lock is only actually released when the hold count hits zero. EDIT to clarify this, as I don't think I explained it too well initially - I am aware that there is no built-in lock escalation in this class, and that I have to simply release the read lock and obtain the write lock. My problem is/was that regardless of what other threads are doing, calling getReadLock().unlock() may not actually release this thread's hold on the lock if it acquired it reentrantly, in which case the call to getWriteLock().lock() will block forever as this thread still has a hold on the read lock and thus blocks itself. For example, this code snippet will never reach the println statement, even when run singlethreaded with no other threads accessing the lock: final ReadWriteLock lock = new ReentrantReadWriteLock(); lock.getReadLock().lock(); // In real code we would go call other methods that end up calling back and // thus locking again lock.getReadLock().lock(); // Now we do some stuff and realise we need to write so try to escalate the // lock as per the Javadocs and the above description lock.getReadLock().unlock(); // Does not actually release the lock lock.getWriteLock().lock(); // Blocks as some thread (this one!) holds read lock System.out.println("Will never get here"); So I ask, is there a nice idiom to handle this situation? Specifically, when a thread that holds a read lock (possibly reentrantly) discovers that it needs to do some writing, and thus wants to "suspend" its own read lock in order to pick up the write lock (blocking as required on other threads to release their holds on the read lock), and then "pick up" its hold on the read lock in the same state afterwards? Since this ReadWriteLock implementation was specifically designed to be reentrant, surely there is some sensible way to elevate a read lock to a write lock when the locks may be acquired reentrantly? This is the critical part that means the naive approach does not work.

    Read the article

  • How do I add the Java Api Documentation to Eclipse?

    - by Kurru
    Hi I have downloaded Java API documentation from http://www.oracle.com/technetwork/java/javase/downloads/index.html#docs and have supposedly attached it to Eclipse using the Window-Preferences-Java-Installed JREs-Edit-"Select rt.jar"-Javadoc Location AND the location has been accepted and "Validates" just fine. However, for the life of me, I can't get Eclipse to show the Javadocs in the tooltip whene I hover over an item (for example in the declaration of an ArrayList). I have also restarted Eclipse in attempts to get it to work what am I doing wrong? Thank you

    Read the article

1 2 3  | Next Page >