Any way to run the processor before the compiler throws an error?

Hi,
I want to generate code for an annotation @OverrideAll that would implement all the interface I methods with some default body.:
Example
interface I {
  void method();
@OverrideAll
class A implements I {
}would have to generate code like this:
class A_gen implements I {
  public void method() {
class A extends A_gen {}However, I have the problem that the original source file does NOT compile because the interface I is not implemented, and as such, the annotation processor never runs. My question is:
Is there any way I could force the annotation processor to run before the compiler shows the error? Or at least some way to supress this error message and give a chance to the annotation processor to run?
TIA,
Gabriel

belingueres wrote:
Hi,
Thanks for answering so soon.
I would prefer not to name the generated class in the original source code. As an alternative I thought to rather generate a subclass, but then there is the instantiation problem (can´t do it without creating a factory method in class A and making it abstract, and indeed again need to name the generated class):
@OverrideAll
abstract class A implements I {
public static A create() {
return new A_gen();
// generated class
class A_gen extends A {
public void method() {
}so it seems I reached a dead end here.
It would really help if (using the superclass generation as originally posted) I could change in the processor the superclass of class A to be A_gen, but it would require AST rewritting and I guess it is not a good option (if at all possible.)Belingueres,There are two ways to do what you want. You can either generate a superclass of A, or a subclass of A.
If you generate a superclass, you need to specify the generated superclass's name in the extends clause of A. But you said "I would prefer not to name the generated class in the original source code", but give no reasons then go off exploring the second alternative.
If you generate a subclass of A, then you need a way for the rest of the code to instantiate As without really knowing about the subclass, so you do in fact need a factory method in A which actually returns A_gens.
I suggest you revisit your preference for not naming the generated class, and work out why you have that preference, and whether it is actually a sound engineering constraint, an aesthetic nicety (maybe in terms of not wanting the implemention strategy to be brought to the surface) or something emotional.
You can do what you want with annotation processing, but you must choose between naming the generated superclass in the extends, or having an factory method that names the subclass.
A related issue is that if you generate the superclass, the annotation processor can pick up the name of the class to be generated from the "extends" clause, and you therefore don't need to specify it any other way, whereas if you generate a subclass, the annotation processor cannot infer the name of the subclass that is being instantiated from the factory method (unless you use non standard APIs in your annotation processor), which means you need to explicitly name it as an attribute of the annotation.
I have a preference for generating a superclass because that imposes less restrictions on whatever else you do with the class, and less of the code generation implementation details leak up into the class's signature.
Also note when generating a superclass, if you want to extend something other than Object, then you need to specify that as an annotation value, usually as a Class<?>.
Bruce

Similar Messages

  • Is there any way to run the Symbian Anna applicati...

    hello 
    i have nokia 500 belle refresh i want to run the app's that run only on symbian anna like astroller and stellarium mobile though all are astro apps but i want them on my this device ie on symbian belle refresh 
    pls tell me the way to run these app on this phone as it have all the hardware requirments like GPS and Gryroscope,Magnetometer etc 
    pls tell any possible way to downgrade nokia 500 to anna or just freshly installed symbian anna OS in it 
    i am ready to do anything for these star gazing app also suggest some star gazing app that can run on this mobile using agumented reality 
    actualy all want to run astroller or star chart like apps

    What version are you trying to run
    V4 works fine with Belle Refresh
    http://store.ovi.com/content/51773?clickSource=search&pos=2
    if you are having problems then try contacting the publisher
    www.heliotropesoftware.com 
    [email protected]

  • Is there any way to run the datasocket server from the vi

    I want to run the datasocket server from the LabVIEW program and is there any command to do this. Because, I built one application vi and this vi is link with another vi using datasocket.So every time before i run the program, i need to run the data socket server. So if i forget to run the datasocket server, I need to restart my vi. So what I want to do is I want to run the data socket server, when i open this VI. So that I do not forget. Thanks.
    Saw.

    In the examples\comm folder there is a file called datasktxwin.llb In that library open e.g. DS 3D Graph Writer...launch it and you will see that it launches the data socket server. Take a look at the code and you'll find a VI that launches the server; "Launch DS server if Local URL.vi".
    If you know the path to the server executable you can always launch it using the System Exec.vi from the communication palette too. The typical command line would then be:
    C:\Program Files\National Instruments\DataSocket\cwdss.exe
    MTO

  • Any way to run the airport ex. admin utility on OSX 10.3.9?

    Does anybody know a way to install the admin utility on OSX 10.3.9? All I want to do is confiugre the AEBS. I can live without the printer and disk sharing.
    I see there are some third party scripts for talking SNMP to the Airport. Are any of the third party apps a reasonable alternative?
    Thanks,
    Bill
    mac mini   Mac OS X (10.3.9)  

    I found this suggestion:
    As an option, here's a workaround...
    - Download the AirPort Base Station Update 2007-001 file from: http://www.apple.com/support/downloads/airportbasestationupdate2007001formac.htm l
    - Double-click AirPortBaseStationUpdate2007001.dmg to mount and display it's contents.
    - From the AirPortUtilityUpdate window, right-click on "AirPortBaseStationUpdate2007001.mpkg."
    - Select "Show Package Contents" from the pop-up menu.
    - In the "AirPortBaseStationUpdate2007001.mpkg window, double-click on the "Contents" folder to open it.
    - In the "Contents" window, double-click on the "Packages" folder to open it.
    - Right-click on "AirPortUtility.pkg."
    - Select "Show Package Contents" from the pop-up menu.
    - In the "AirPortUtility.pkg window, double-click on the "Contents" folder to open it.
    - Double-click on "Archive.pax.gz." This will create a new folder on your Desktop, named "Applications." The AirPort Utility will be inside this new folder. You can copy or move it to your Applications folder.
    However, I just wind up with a file called archive.pax on my desktop. Stuffit expander says it doesn't know how to open it.
    mac mini   Mac OS X (10.3.9)  

  • Why the compiler throws this error?

    Hello there,
    Can someone be kind enough as to tell me how to avoid the following error in this snippet of code? It works fine but obviously I could be doing something better :)
    Error:
    SampleCode.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    Process completed.Code:
    public class RunMyWorkerGet extends SwingWorker<DefaultTableModel, DefaultTableModel>{
         String queryString;
         String urlString;
         JTable queryTable;
         DefaultTableModel model;
         ResultSet rs;
         //constructor
         public RunMyWorkerGet(String queryString, String urlString, JTable queryTable){
              this.queryString = queryString;
              this.urlString = urlString;
              this.queryTable = queryTable;
         }//constructor
         //doInBackground
         @Override
         protected DefaultTableModel doInBackground() throws Exception {
              model = resultSetToTableModel();
              return model;
         }//doInBackground
         //retrieveResults
         public DefaultTableModel resultSetToTableModel(){
              try{                                     
                   Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                   Connection con = DriverManager.getConnection(urlString);
                   Statement stmt;
                   stmt = con.createStatement();
                   rs = stmt.executeQuery(queryString);
                   ResultSetMetaData metaData = rs.getMetaData();
                   int numberOfColumns = metaData.getColumnCount();
                   Vector columnNames = new Vector();
                   for (int column=0; column<numberOfColumns; column++){
                        columnNames.addElement(metaData.getColumnLabel(column+1));
                   Vector rows = new Vector();
                   while (rs.next()){
                        Vector newRow = new Vector();
                        for (int i=1; i<=numberOfColumns; i++){
                             newRow.addElement(rs.getObject(i));
                        rows.addElement(newRow);
                   model = new DefaultTableModel(rows, columnNames);
                   con.close();                                   
              }//try5
              catch(ClassNotFoundException em){//catch5
                   em.printStackTrace();
                   JOptionPane.showMessageDialog(null,em.toString());
              }//catch5
              catch(SQLException em){//catch5
                   em.printStackTrace();
                   JOptionPane.showMessageDialog(null,em.toString());
              }//catch5
              return model;
         }//getResults
         //done
         @Override
         protected void done(){
              try{
                   model = get();
              }catch(Exception e){}               
              queryTable.setModel(model);
              queryTable.repaint();          
         }//done
    }//runMyWorkerGetI appreciate any hinds,
    Chris

    Chris,
    I'll attempt to paraphrase the exception message
    TestArrayLists.java:1060: warning: [unchecked] unchecked call to addElement(E) as a member of the raw type java.util.Vector
                                            columnNames.addElement(metaData.getColumnLabel(column+1));
                                                                  ^in the hope that I can explain the problem a bit more meaningfully.
    You are adding an element to the "raw" (ungenericised) Vector called columnNames. The compiler is unable to type-check the assignement... ie: The compiler is unable to ensure that the subtype-of-Object returned by metaData.getColumnLabel(column+1) (which is a String, isn't it?) is suitable for inclusion in the columnNames Vector, simply because you haven't specificied what type subtype-of-Object's columnNames holds... so it could hold all subtypes-of-Object... so, for all the compiler knows, columnNames could contain a variety of types (called a "dirty collection")... so the compiler is warning you that it can't do its job completely and properly.
    To fix this... change the declaration of columnNames (presuming that getColumnLabel returns a String) to:
      Vector<String> columnNames = new Vector<String>();This says: columnNames is a Vector of String's (ie this collection can contain only instances of the String class) ... so if you attempted to add a StringBuffer (for instance) to columnNames the compiler would detect your mistake and produce an error at compile-time... therebye avoiding runtime classcast exceptions when you retrieve a StringBuffer (for instance) from your collection and erroneously cast it to String... making your software far more robust.
    Is that any clearer?
    Cheers. Keith.
    Edited by: corlettk on 13/12/2008 09:54 ~~ That's better.

  • Does SQL Developer have any way to run the SQL*PLUS COPY FROM command?

    set arraysize 100;
    set copycommit 100;
    COPY FROM SCOTT/TIGER@OtherDBinstance -
    CREATE COMPANY -
    USING SELECT * from COMPANY;

    Thanks. I have been using the create table ABC as select * from ABC@otherdb but this often runs into temp segment issues for very large tables. The SQL*PLUS version allows me to have the copy commit save after each xxxxx lines and this seems to be able to handle any size table. Can copy commit be used from SQL Developer?

  • Just downloaded the new OS for IPhone. Despise the appearance. It has jacked with the way I like things in some unacceptable ways. Is there any way to keep the OS, but return to the old appearance? Important to know BEFORE I download OS for computer.

    Just downloaded the new OS for IPhone. Despise the appearance. It has jacked with the way I like things in some unacceptable ways. Is there any way to keep the OS, but return to the old appearance? Important to know BEFORE I download OS for computer.

    I know I am responding to my own thread, but I an SOOOO disgusted with Apple right now.
    The new iOS 7 was the lead story on CNN today... and it wasn't positive. Easy to see why, it's a graphics disaster. It is ugly, difficult to read, doesn't interface aesthetically with the iPhone 4S, and gives everyone in America vertigo. Either fix the appearance, or find some way to allow us to roll back to our previous iOS. Do so quickly, or this life-long Apple customer [circa 1978] will be moving on. If this represents shades of what is coming with OS Maverick, I am petrified. Further, I am a GM of a chain of newspapers and websites in the Austin, Texas area. I will be ripping out a scathing editorial. The notion that we can't roll back from something millions of us hate is despicable. I'm giving you one week. Be sure I am not alone.

  • Hi. I just got the iPhone 6, plugged into itunes and made the mistake of putting an OLD back up on my new phone resulting in losing all contacts after 2013. They are not saved on the cloud. Is there any way to go back to before I screwed up?

    Hi. I just got the iPhone 6, plugged into itunes and made the mistake of putting an OLD back up on my new phone resulting in losing all contacts after 2013. They are not saved on the cloud. Is there any way to go back to before I screwed up?

    If you have performed a sync with the device since you restored this old backup, then don't bother looking for another backup. iTunes writes over the last backup each time you sync. If you were handling contacts in iCloud, you would find them by logging into iCloud. Or you can check settings and iCloud and see if the button it on for Contacts. Otherwise it might have been on the computer, if you had a program that syncs with iTunes and handles contacts, depending on the computer system you use. If Windows, it would be Windows Contacts or Outlook. If a Mac, there is a Mac Address book as well.

  • I am not able to access ANSI character ALT 0165 Symbols font (infinity symbol) in Illustrator in CS (Windows 8.1) but I can access it in Illustrator 10 running on Windows XP. Any way to download the complete symbol character set under symbols to Illustrat

    I need to use the infinity symbol in Illustrator but it is not available in Illustrator in CS5 running on Windows 8.1. It is available in Illustrator 10 running on Windows XP. Is there any way to access the INFINITY character under fonts in Illustrator in CS5 (Windows 8.1)?

    Thank you for your suggestion. But I do not know how to access UNICODE. How do I download Unicode fonts?
    Also I have a problem working copying illustrations from Illustrator launched from CS5. The illustration does not copy correctly into FrameMaker 10 with Windows 8.1. However, the illustration copies correctly if I use Illustrator 10 in my computer with Windows XP. How do I solve this?
    When I called Adobe I was just told that they do not support CS5.

  • My old computer that ran on Mavericks was stolen and my new computer runs on Yosemite. I don't like the new iMovie (10) on the Yosemite version. Is there any way to get the old version (9) back?

    My old computer that ran on Mavericks was stolen and my new computer runs on Yosemite. I don't like the new iMovie (10) on the Yosemite version. Is there any way to get the old version (9) back?

    I read his question the way I answered it.
    If that is wrong then he can clarify his question.

  • Is there any way to limit the number of Threads running in Application(JVM)

    Hello all,
    is there any way to limit the number of Threads running in Application(JVM)?
    how to ensure that only 100 Threads are running in an Application?
    Thanks
    Mohamed Javeed

    You should definitely use a thread pool for this. You can specify maximum number of threads that can be run. Be note that the thread pool will only limit the number of threads that are submitted to it. So donot call "Thread"s start() method to start thread on your own. Submit it to the pool. To know more, study about executor service and thread pool creation. Actually it will not be more than 20 line code for a class and you might need maximum of 2 such classes, one for threadPool and other one for rejection handler (if you want).
    Just choose the queue used carefully, you just have to pass it as a parameter to the pool.
    You should use "Bounded" queue for limiting threads, but also be careful in using queues like SynchronizedQueue as the queue will execute immediately the threads submitted to it if maximum number of threads have not been running. Otherwise it will reject it and you should use rejection handler. So if your pool has a synchronized queue of size 100, if you submit 101th thread, it will be rejected and is not executed.
    If you want some kind of waiting mechanism, use something like LinkedBlockingQueue. What this will do is even if you want 100 threads, you can specify the queue's size to be 1000, so that you can submit 1000 threads, only 100 will run at a time and the remaining will wait in the queue. They will be executed when each thread already executing will complete. Rejection occurs only when the queue oveflows.

  • I lost my iphone but the battery has died. Is there any way to see the last known location of my phone before it shut down?

    I lost my iphone but the battery has died. Is there any way to see the last known location of my phone before it shut down?

    No

  • Is there any way to get the height/width of an image before importing it in the indesign document.

    Hi All,
    I need to obtain an image's attributes such as dimensions (height, width in pixels) without placing image in indesign document.
    I have full path of the image (say abc.jpg is stored at c:\my pic\abc.jpg).
    I have obtained the IDFile for this image, tried getting size using GetFileSize() which correctly return size in bytes.
    Is there any way to get the height/width of image without importing it in the indesign document.
    Please, give me some hints. I have spent quite a lot time digging in CHM. I have searched in FileUtils, IDFile API's but found no method which serves this purpose.
    At this point I am clueless where to search next.
    Any help will be appriciated.
    Just a point to mention, I am able to get image height and width for an image in indesign doc though Its not my requirement.
    Thnx,
    D.

    You might be able to examine the contents of the PlaceGun after calling kImportAndLoadPlaceGunCmdBoss without actually placing the image in a document. Not sure, but would be worth looking at.
    Otherwise you will probably have to write platform specific code, ideally with a generic platform-independant wrapper (see SDKSamples/paneltreeview/PlatformFileSystemIterator).
    For the Mac, look at CGImageGetWidth() etc., not sure what the best option is for windows.
    Perhaps Quicktime could provide you with a platform independant solution.

  • When I updated to ios5, I lost all of my calendar entries. Is there any way to retrieve the information?

    When I updated my iPad to ios5, I lost all my calendar entries. Is ther any way to retrieve the information? This was before iCloud was up and running.

    try and restore you ipad maybe that would work

  • Is there any  way to Mask the Name when  a select statement is issued?

    Dear all,
    Is there any way to mask the name .. i mean if User issue a select statement in a customer table the real name should come like ' ABCXXXDEFXXCFXX'... Which is not the actual name?
    e.g if Name: CHIEV SONG MEE
    If user issue a statment select * from customers;
    The Result Should come something Like this:
    Name
    CHXXV SXNG MXX
    Thank You

    user3029023 wrote:
    but it seems there is no option in oracle it self which can be used as there they are saying to get a data masking software which we can't due to some internal issues....I would not say that. How one implements masking depends entirely on the requirements that need to be met.
    For example, schema A owns all the tables. Schema B can be created as a "trusted" schema - in other words, schema A trusts schema B and allows it full access (with grants) to its tables. Schema B implements data masking as views. For each table in A, a view exists in B that implements the required masking. B can now grant select access on these views to user C. User C will see the same data object names in B as it would have if it used A - only, by using the B data objects it uses masked data objects and not the original source data objects.
    Another example - schema Dev is to have all the data objects of schema Prod, but masked where needed. One can use CTAS (Create Table As Select) to create the required tables in Dev with masked values where relevant. This Dev schema can be "refreshed" on weekends by dropping all tables and getting a new fresh copy of production data and masking it - ready for the next week's development cycle.
    If the application use is for example APEX, then instead of coding SQL directly as reporting regions to display, a function is used instead. APEX supports reporting regions where it calls a function and this function provides the APEX run-time with the SQL to execute and contents to render. It is easy to use this approach to implement logic in functions that masked column data depending on who the APEX user is, the security/role attributes of the user, and so on.
    No there is not a single "+mask this column!+" feature in Oracle.. but that does not mean that such a feature is not supported and cannot be implemented. Oracle has a very comprehensive and rich set of tools - more so than most (if not all) other RDBMS products.
    It is up to the architect/designer/developer to use this toolkit in creating a system that meets the specific requirements at hand.

Maybe you are looking for

  • How to hide tables in answers

    Hi, Is it possible to hide tables from users in answers. I would like to restrict the view to enable users to only view certain fact and dimension tables. Can anyone help? Thanks

  • How to insert a hyperlink in mail content for workflow

    Experts, I want to insert a hyperlink in mail content when i use sendmail type step in workflow. How to do it? Thanks you very much!

  • Subvi access label of input wire

    Hi is there a way to access the name/label of an input wire connected to a vi (or an XControl for that matter)? as an example: I would like to have an vi that takes a double as input and returns a string with "The wire with the label %s has the value

  • Where is the serial number for my AirPort Extreme G?

    I have an older AirPort Extreme G. I am trying to register the device to my Apple Support profile. When I use the link from the support site, https://register.apple.com/cgi-bin/WebObjects/GlobaliReg.woa it says it is not a valid serial number. I am t

  • IPv6 dhcp

    I am testing IPv6 DHCP server in test lab with 3750 switch. Following is the details of the setup. Windows server 2008 r2 is configured as DHCP server. 3750 switch with ios 12.2(55)SE5 is used to connect DHCP server and client. DHCP server and client