Possible strange bug with parallel loops in LV2010

I have a specific code which does not execute correctly in parallel, but making almost any small change to the code causes it to work.  Even more bizarre, I can change it so that it sometimes works correctly, and somtimes doesn't. Interested?  Read on...
I have a relatively simple VI (to compute 2D Wavelet Denoising on planes of a 3D array) with the following block diagram (debugging not allowed):
The parallel loop is set to 8 automatically-partitioned instances, and I've tested this on 2-core and 8-core machines.  When the #cores wired into the loop is not one, several of the iterations do not compute (for example 4 out of 24).  I can check this by putting a break in the VI called inside the loop and counting how many times it is called.
I can do a number of things to make all iterations run:
- put an indicator inside the loop on the iteration number, or anything else (except the P node)
- wire the iteration number outside the loop to an indicator
- remove the case structure
- remove the loop in the other case (it's at the moment identical except for a call to a different VI which uses Discrete WT instead of Undecimated WT -- if I change the other case to match this one, the other case runs fine but this one still fails)
- change code outside the loop
- turn on debugging!
- change the loop setup to another number of instances other than 8
- change the loop setup to set the number of partitions
I can also do a number of things that do not solve the problem:
- rewriting the loop from scratch
- copying the loop from the other case
- saving for LV2009 (in which everything runs as expected) and then reloading (and presumably recompiling) in 2010
Stranger still, if I replace the called VI with a dummy VI (which simply adds one to the input 2D array so I can tell if it executes), then as long as the other wires are still wired in, it sometimes executes all iterations, and sometimes doesn't (roughly 50% split)!!!  Any other changes and it always works fine.
I've managed to replace as much as possible with dummy code and still keep the results the same (i.e. sometimes executing all iterations and sometimes not).
If you want to check it out (on a multicore machine with LV2010), run LoopTest.vi, and the results at the index shown should sometimes be 13 and sometimes 14. Changing #cores to 1 will always give a result of 14, changing WT to DWT always gives 14, even though the code inside both cases is identical!
Hope it's not just me, otherwise I'll be sure that LV hates me!
Attachments:
LoopTest.zip ‏355 KB

OK, here's a new version that exhibits the same behaviour, but is hopefully simpler to understand.
The expected result is to add one to the whole array, however sometimes not all of the parallel iterations are executed.  Run ParallelLoopTest.vi from the attached ZIP file on a multi-core machine to verify.  This screenshot shows that sometimes it works correctly, and sometimes not:
The code in the other case is identical (created by duplicating the case) but always works correctly.
Attachments:
ParallelLoopTest.zip ‏63 KB

Similar Messages

  • Strange bug with the java.io.File class

    Hi everibody!
    I'm writting a system to upload images with JSF and RichFaces. But when i try to delete the images files sometimes hapen some strange bug.
    first i'll post my method code here:
    public void deleteUploadedFile(ActionEvent event) throws Throwable {
            UIComponent link = event.getComponent();
            UIParameter param = (UIParameter) link.findComponent("fileId");
            TheFile file = this.uploadedFiles.get((Integer) param.getValue());
            try {
                File f = new File(file.getPath(), file.getName());
                if ((f.exists()) && (f.canRead()) && (f.canWrite())) {
                    if(f.delete()){
                        for(int i=0; i<file.getThumbs().size(); i++){
                            File t1 = new File(file.getPath(), file.getThumbs().get(i).getThumbName());
                            t1.delete();
                        setDeleted(true);
                    else{
                        setDeleteLog("Arquivo não pode ser excluido");
                        setDeleted(false);
                } else {
                    setDeleteLog("Erro ao tentar excluir o arquivo");
                    setDeleted(false);
                this.finalize();
            } catch (Exception ex) {
                setDeleteLog("Deu erro: " + ex);
            } finally {
                if (this.deleted) {
                    if (this.uploadedFiles.remove(file)) {
                        setDeleteLog("Conseguiu remover");
                    } else {
                        setDeleteLog("Deu erro");
        }Well, when the method run the f.delete() line, sometimes, something strange hapen. With is, the file data is deleted as expected, but the file it self is not deleted. And even when i run the line this.finalize the JVM still using the file, with don't allows me to try to delete it untill my tomcat stop (with kill the application that was using the file). And this don't hapen every time that i try to delete one file.
    And worse, once it hapen every next time that i try to delete one file hapen the same bug.
    My question is...what could it be, and what can i do to solve this?!

    About this is not a possible cause. Because before i upload a file I verify if the file already exists and even after i change the file name:
    //this method change the file name and eliminate all the special characters, and also attach the current day of month,
    //month, year, minute and second to the file name
    public String generateFileName(String fileName){
            Locale l = new Locale("pt","BR");
            Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(TimeZone.getTimeZone("GMT-3").getID()), l);
            int ext = fileName.lastIndexOf('.');
            String name = fileName.replace(fileName.substring(ext), "");
            String newName = RemoverAcentos.remover(name).toLowerCase()+cal.get(cal.DAY_OF_MONTH)+cal.get(cal.MONTH)
                    +cal.get(cal.YEAR)+cal.get(cal.MINUTE)+cal.get(cal.SECOND)+fileName.substring(ext);
            return newName;
        }the upload method
    String fileName = generateFileName(item.getFileName());
            try {
                File uploadFile = new File(filepath, fileName);
                if (!uploadFile.exists()) {

  • Very strange bug with compareTo: returning incorrect results

    Hello everyone! I have used the method compareTo many times to maintain my database project's entries. However recently I have discovered a bug, in which:
    a and b both being Storage type objects:
    private static class Storage {
    object data
    int nextData //an array stores the Storage objects
    int previousData //this uses an integer to locate previous in array
    Problem:
    ((Comparable)(a.data)).compareTo((Comparable)(b.data)) returns a 3, when a.data is clearly 5, and b.data is clearly 20.
    This is very strange, as the compareTo should return a -1 instead of a positive number. Is this a known bug with the compareTo method? I have been using it reliably for many programs but this is the first time it ever occurs to me.

    Problem:
    ((Comparable)(a.data)).compareTo((Comparable)(b.data))
    returns a 3, when a.data is clearly 5, and b.data is
    clearly 20.
    This is very strange, as the compareTo should return a
    -1 instead of a positive number. Is this a known bug
    with the compareTo method? I have been using it
    reliably for many programs but this is the first time
    it ever occurs to me.Not really... comparing Strings "5" to "20"
    is really the same as comparing "5" to "2"
    being the first character of the string, difference
    being, surprise, surprise = 3.
    If you want the Strings to be comparable that way you should left-fill them with spaces or zeros.
    Or, better still, override compareTo and make your Storage implement Comparable instead of all that casting of the data objects.

  • Strange bug with CC panel and OS X Spaces

    I seem to have a strange bug where the CC panel opens each time I switch spaces in OS X (click on the GIF animation below).  Anyone else have this problem?

    Hi Lee ,
    This has been already notified to the engineering team.
    http://forums.adobe.com/message/5421355#5421355
    Thanks,
    Manish

  • Possible iPhone bug with custom recurring day schedule?  Need help.

    In Microsoft Outlook I have a 64 day schedule that is set up as single all day recurring events each day. Each day of the 64 day schedule recurrs every 64 days. Day 1 recurrs every 64 days, day 2 recurrs every 64 days, etc., etc.
    When I synced this to an iPhone, each day had an incorrect custom recurring day set at every 18 days. This, of course threw off the whole schedule. After doing some testing, I found out that a custom recurr of 45 days worked, a custom recurr of 46 days told the iPhone it recurred every 1 day. 47 day recurr did the same thing. 48 day recurr told the iPhone it recurred every 2 days, 49 day recurr became 3 days, 50 became 4 days, 51 became 5 days...64 became 18 days.
    Is this indeed a bug with iPhone or is there something I can do for a single 1 day event recurr every 64 days? And, why is there no custom setting when setting up an event on the iPhone?

    ICKIER wrote:
    Is this too complicated for a reply?!
    Apparently, no one has a solution for you. It may be a bona fide bug. You can let Apple know about that:
    http://www.apple.com/feedback/iphone.html.

  • Very strange bug with my Apple Wired Keyboard

    I have a very strange issue with my Apple Keyboard.
    Sometimes my Apple Keyboard stopped working at my MacBook Pro Retina 15 inch late 2013. I doesn't give any input at all in all the usb ports. The strange thing is when I connect the Apple Keyboard extension cable it worked again and I can disconnect the extension cable and plug it back in with only the cable from the keyboard itself and it works as well. This happened every 2 to 3 months to me. It only happens when my MacBook is in sleep mode and I wake it up.
    Can somebody please help me. What when I lose the Apple Extension cable?

    Yes, a USB extension cable with a male and female end will work.
    example: Amazon.com: Belkin USB Extension Cable (10-Feet): Electronics

  • Very strange bug with AIR and native process (Windows 7, EXE)

    Hello to everyone!
    The situation is:
    I've made an AIR Application, inside of that is running a native process - EXE file.
    I'm using Flash CC as IDE and tried to use compile that as EXE with AIR 2.6 and 3.6 - results are same.
    So I've insert inside a checking if Native Process is supported or not and the Native process is supported all the time.
    When I've just installed the application and run it - the very first attempt is good - everything is working as a must: internal EXE is called by my Application with necessary parameters as many time as I'm need.
    However if I'll close the App and then will run it again - internal EXE is not starting at all, doesn't depends on number of attempts to re-start of the App.
    So only way is to uninstall, install it back and then you'll be one more session of successful internal EXE-requests, till the next re-start of the App.
    That's it.
    I've tried to "google it" but unsuccessful. Probably the bug is very rare.
    Help me please?
    Update: at compilation with Flash CC IDE it's working all the time with no any issues.
    Update-2: when I'm running installator-EXE, there is going a notification "Same version is installed, etc." and then selected "Run Now" - there is also working with no problems.

    Well, I've found the solution and answer by myself and here is it please:
    In case with same situation as above you need to add just one line in your AS3-code
    nativeProcessStartupInfo.workingDirectory = File.applicationDirectory;
    And you will be happy so much

  • Strange bug with Full Outer Join

    Hi guys,
    can you please confirm this behaviour on 11gR2? It used to work fine on 10gR1.
    Small test case:
    create table TEST_OBJECT_METADATA
      project_name  VARCHAR2(30 CHAR) not null,
      object_id     NUMBER not null
    create table TEST_OBJECT_INFO
      object_id          NUMBER not null,
      object_type        VARCHAR2(30) not null
    create table TEST_SUPPORTED_OBJECTS
      object_type    VARCHAR2(30 CHAR) not null,
      enabled        NUMBER(1));
    INSERT INTO TEST_OBJECT_METADATA VALUES ('NEW',1);
    INSERT INTO TEST_OBJECT_INFO VALUES (1, 'TABLE');
    INSERT INTO TEST_SUPPORTED_OBJECTS VALUES ('TABLE',1);
    COMMIT;When I execute the following query:
    WITH old_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'OLD'),
    new_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'NEW')
    SELECT src.object_type,
               t.enabled
      FROM (SELECT nvl(o.object_type, n.object_type) object_type
              FROM old_project o
              FULL OUTER JOIN new_project n
                ON o.object_id = n.object_id) src,
           test_supported_objects t
    WHERE src.object_type = t.object_type(+);I get the following output:
    OBJECT_TYPE     ENABLED
    TABLE             So, the outer join to test_supported_objects does not match.
    But if I force the FULL OUTER JOIN to run first using rownum:
    WITH old_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'OLD'),
    new_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'NEW')
    SELECT src.object_type,
               t.enabled
      FROM (SELECT nvl(o.object_type, n.object_type) object_type,
                           rownum
              FROM old_project o
              FULL OUTER JOIN new_project n
                ON o.object_id = n.object_id) src,
           test_supported_objects t
    WHERE src.object_type = t.object_type(+);I get the expected output:
    OBJECT_TYPE     ENABLED
    TABLE             1 Thanks in advance.

    Without mixing works fine:
    WITH old_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'OLD'),
    new_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'NEW')
    SELECT src.object_type,
           t.enabled
      FROM (SELECT nvl(o.object_type, n.object_type) object_type
              FROM old_project o,
                   new_project n   
              where  o.object_id = n.object_id(+)
              UNION
              SELECT nvl(o.object_type, n.object_type) object_type
              FROM old_project o,
                   new_project n   
              where  o.object_id(+) = n.object_id) src,
           test_supported_objects t
    WHERE src.object_type = t.object_type(+);but there shouldn't be any restrictions on mixing them, right?

  • Strange bug with Microsoft LaserMouse 8000.

    I have Microsoft Wireless LaserMouse 8000, Microsoft IntelliPoint 6.2.2 and Apple OSX Leopard 10.5.4.
    On IntelliPoint setup side buttons to Back/Forward. All working fine first 30 mins. Then buttons changing significance by themselves to "commandoptiond" (Open/Close Dock). After next 30 mins it comeback to Back/Forward! But no changes on IntelliPoint at all.
    How can I solve this bug?

    the only problem I can think of is that it's a Microsoft product. but seriously if you haven't already check you're using the latest version of the driver

  • V. 2.2.1.00.04  Possible minor bug with breadcrumbs

    Hello,
    I have 'ORA-06502: PL/SQL: numeric or value error: character string buffer too small' error in Breadcrumbs section of Page Definition page when total length of breadcrumb string is more than 84 chars

    Edward,
    Thanks, this seems to work okay in 3.0. You can check it on apex.oracle.com, if you like.
    Scott

  • Parallel loops & improved efficiency

    I am developing an application that monitors & controls test chambers, and have quite a lot of VIs. I read amongst these pages that it is generally bad practice to have parallel loops in a VI, and one of my VIs has many - because the FP has six XY charts that constantly need updating.
    The code required to update each graph is considerable because there are four variables to plot and each variable uses a buffer, which potentially can be very large to incorporate a long history.
    I am a relatively new LabView programmer so do not know all the little tricks that are probably out there - but am gradually catching on, i.e. control refs, dynamic loading etc..
    I'm conscious that I'll be using too much memory/resources as it will have to run simultaneously with other VIs, and ideally want to make the code as efficient as possible.
    My questions/dilemmas are these:
    1. I've been trying to make the code to update a graph into a subVI so that it can be called six times as opposed to my current method of having identical code for each graph. I've semi-succeeded in that I have made a subVI that uses control refs to change certain properties (like x-axis scale) but still require the paralled loops so that the code executes correctly. What are the implications of having say, 8 parallel while loops in one VI? (I am using the Wait function) It seems to me that I need them to get different tasks to operate at the same time. (This is because the loop for each graph is inside a case statement that determines if the chamber is running or not - if not then the graph code does not execute)
    Once there is one while loop, anything outside that loop will not continue to execute until the loop has finished!
    2. To create the buffer I'm using a subVI from an example in LabView (6.02) found in Fundamentals/Graph & Chart/Chart/XY Chart.vi. The subVI is called XY Chart Buffer. The VI is reentrant and allows control of the number of elements allowed in the array. I want to have a large history so the user can see upto 24hrs worth of readings, that is as many as 17280 elements. Can LabView cope with buffers this big if there are many instances of the buffer running at the same time for different variables? Is the size of RAM directly responsible for how big the buffers can be?
    If anyone can offer any suggestions or advice i'd be very grateful. Attached is the VI i have talked about with code for only two graphs - one with a subVI using references and one with the code not inside a subVI.
    Dan
    Attachments:
    chambers.zip ‏197 KB

    The major concerns with parallel loops are just the added processing, sharing data between parallel loops, and synchronization. Race conditions are often a concern when setting the value or properties of variables in multiple parallel loops. Most of these issues can be avoided by careful programming and use of the synchronization tools such as Queues and notifiers from the Advanced menu. The processing problem of having several parallel loops is of course minimized by having sufficient delays in the loops. In 6.1 it can be minimized more by using the new event structure to eliminate the need for polling front panel controls.
    Maintaining a very large buffer of data is pricipally an issue of usable RAM, but may also cause speed and/or graphics issues
    when graphs need to be redrawn. Beware of the fact that LabVIEW often needs to replicate data behind the scenes, so you will often end up using more memory than you thought you would. Also, consider the efficiency of how you are storing your data. Remember that contiguous blocks of memory are usually required for arrays, and therefore very large arrays are more difficult to allocate. You might consider using some amount of file I/O to periodically store data and then retrieve it as necessary.

  • No difference between using a local variable and a notifier in timed parallel loops?

    The example code "Pass Data With Notifiers.vi" that came with LV 7.1 illustrates using notifiers with parallel loops.  Just looking at two of the loops, the one that generates the sine wave and the one for "User 1", you can change the timing of the two loops and you can change the condition of the "Ignore Previous" status on the "Wait on Notification".  I have a special case of this to consider, where I'm wondering if there's any reason not to use a local variable instead of the notifier:
    Set the delay on the generator portion (which contains the Send Notification) to something very short, say 5 ms.  Set the delay on the User 1 (which contains the Wait on Notification) to something relatively longer, say 200 ms.  Set the Wait on Notification to False.  Now you have a situation where the User 1 loop action is contingent only upon the loop delay time, since each time the loop timer runs the loop there will always be a value in the notifier.  In this case it seems to behave just like the case where you update a local variable in the fast loop and read it in the slow one.
    Is my understanding correct?  Would there be a performance difference between the two methods?  What do you prefer in this situation and why?
    Thanks,
    Hosehead

    Hi H.,
    I think your idea is to write to a Global Variable in the data-producer VI, and read it in the data-consumer VI(?)
    One reason this might be less efficient than using Notifiers is if you want to graph every new value in the "consumer" - or make sure the value read in the consumer has changed at least once since the last loop.
    > since each time the [consumer] loop timer runs the loop there will always be a value in the notifier...
    > Would there be a performance difference between the two methods? 
    If you don't use the Notification "event" to synchronize the producer and consumer, then to be sure the consumer gets a new vaue, you've made the producer loop faster - every 5 ms - a waste of cpu-cycles.  More often the situation is reversed, that is, there's a consumer that needs to see every single new value, and (without events) the consumer must loop faster than the producer (to catch every new value) - this is called polling and it wastes cpu-cycles.
    Just about anytime one's tempted to make a loop execute "fast" to check on some value (or to make sure there's a fresh value,) there's an opportunity to improve performance through synchronization with events (including notifiers, queues, occurrances, semaphores, and rendezvous')
    tbd
    Message Edited by tbd on 07-09-2006 03:51 AM
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)

  • Strange bug on linux

    Hi,
    I get strange bug with forms builder - when i try to choose something from combo box on property palette option doesn' t change. For example when I click 'Yes' on some option it still views 'No'.
    I really don't know whats wrong, I don't get any error on console.
    I run on Sabayon (gentoo) with openmotif- 2.1.30-r14
    Any idea?
    Thx, kamillo

    Hmm I think you misunderstood my post.
    This is not a problem with code, database or smth but with builder as a software. It doesn't work correctly because i can't change any option in property palette.
    And I really don't get what you mean writing
    reconnect?
    ctrl+shift+K?
    bug?kamillo

  • Strange behavior with "insertTextAsContent"

    Hi,
    I've got a strange behavior with this loop :
    for (j = 0; j < myParagraph.characters.length-1; j++) {
         var myCharacter = myParagraph.characters[j];
         if (myCharacter.appliedFont.fontStyleName == "Regular") {
              alert(myCharacter.contents);
              myXmlElement.insertTextAsContent(myCharacter.contents, XMLElementPosition.ELEMENT_END);
    I loop through every characters of a paragraph, test if they are "regular", "italic", "bold"..., and store them in different xmlElement. Everything is fine except that every double characters (in french : homme, cette, elle, ville...) output in my xmlElement as one only character (home, cete, ele, vile...). I try with "aaaaaazzzzzzeeeeeerrrrrtttttyyyyy" and it give me, the same way, "azerty" ?!
    The "alert" line output the correct full sentences character by character ("h", "o", "m", "m", "e"...).
    If you have any idea to explain, you are more than welcome
    Thanks
    ** edit : don't know if it's important but I'm using CS6 **

    Hi
    Have you seen this in the object model viewer?
    XMLElement.insertTextAsContent (using:varies, position: XMLElementPosition ): Text
    Adobe InDesign CC (8.0) Object Model
    Inserts the specified text as content before, in, or after the XML element.
    using: Data Type: varies
    The text to be inserted. Can accept: String or SpecialCharacters enumerator.
    position: Data Type: XMLElementPosition
    The position at which to insert the text. Note that text inserted before or after the element does not become part of the content of the element. Instead, it becomes content of the parent of the element.
    Don't ask me why it works when there is no doubled character
    So i tried the following and it worked. I hope this will solve your problem.
    function main() {
         if (app.documents.length != 0) {
            var myDoc = app.activeDocument;
            var myParagraph = myDoc.textFrames[0].paragraphs[0];
            var myXmlElement  = myDoc.xmlElements[0];
            for (j = 0; j < myParagraph.characters.length-1; j++) {
                var myCharacter = myParagraph.characters[j];
                if (myCharacter.appliedFont.fontStyleName == "Regular") {
                    alert(myCharacter.contents);
                    myXmlElement.contents += myCharacter.contents;
                    alert(">" + myXmlElement.contents+ "<");
                }     // if
            }     //for
        }     // if
    }   // main()
    Kind regards
    Dani (from Switzerland)

  • Possible bug with AlphaComposite.Src?

    While this is possibly a bug, it's more likely a misunderstanding on my part which is why I want to post it here first for comment.
    I have a BufferedImage (type BufferedImage.TYPE_INT_ARGB) with some graphics drawn in it that I want to clear out with a transparent white background (argb=0x00ffffff). That is, I want to replace every pixel in the image with a color of (new Color(255,255,255,0)). FWIW the reason for this is that after clearing and then drawing some new stuff onto the BufferedImage, it will be written out as a 32-bit PNG with a "canvas" color that will render as transparent on Mozilla and opaque white on MSIE (which ignores the 32-bit PNG alpha channel).
    In order to clear the BufferedImage (img), I tried the following:
    // img is a BufferedImage with stuff drawn in it
    g2 = (Graphics2D)img.getGraphics();  
    g2.setComposite(AlphaComposite.Src);
    g2.setPaint(new Color(255,255,255,0));
    g2.fillRect(0,0,w,h);  // w=image width, h=image height
    g2.setPaintMode();
    (draw stuff)The javadocs on AlphaComposite.SRC indicate that the destination pixels should be replaced by the source pixels, so I'd expect the image to be filled with color 0x00ffffff after the fillRect operation. However, I've found that the preexisting contents of img remain unchanged.
    What leads me to suspect that this may be a bug is that if I change the setPaint line to
    g2.setPaint(new Color(255,255,255,1));the contents of img are cleared out. Why should an increase in alpha of only 1/256 make such a difference? The javadocs say that AlphaComposite.SRC should ignore the destination image altogether.
    I'd like it if someone could either 1) explain to me why this is the correct behavior or 2) verify that this could be a bug.
    Thanks
    Ryan Olson

    Ok, I've isolated the bug, I think. It has to do with setting the RenderingHints for a BufferedImage's Graphics2D context, strangely enough. The following test case illustrates the problem:
    import java.awt.image.BufferedImage;
    import java.awt.*;
    public class AlphaCompositeSrcTest {
        private static final Color TRANSPARENT_COLOR = new Color(255,127,255,0);
        /** Creates a new instance of AlphaCompositeSrcTest */
        public AlphaCompositeSrcTest() {
            BufferedImage canvas = new BufferedImage(100,100,BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D)canvas.getGraphics();
            // turning on anti-aliasing here doesn't seem to matter
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            for (int i=0; i<10; i++) {
                drawOnImage(canvas);
            System.out.println("All done");
        private void drawOnImage(BufferedImage canvas) {
            Graphics2D g2 = (Graphics2D)canvas.getGraphics();
            // the following line will cause an assertion failure at [1] if not commented out
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // [1]
            g2.setComposite(AlphaComposite.Src);
            g2.setPaint(TRANSPARENT_COLOR);
            g2.fillRect(0,0,100,100);
            // entire image should now be the transparent color
            assert canvas.getRGB(50, 50) == TRANSPARENT_COLOR.getRGB(); // [2] <-- fails if [1] is present
            g2.setPaintMode();
            g2.setPaint(Color.BLUE);
            g2.fillRect(10, 10, 80, 80);
            // should now be an opaque blue square in center of image with edges still
            // in transparent color
            assert canvas.getRGB(5, 5) == TRANSPARENT_COLOR.getRGB();
            assert canvas.getRGB(50, 50) == Color.BLUE.getRGB();
        public static void main(String[] args) {
            new AlphaCompositeSrcTest();
    }

Maybe you are looking for